Conversation
|
How dependent are all these changes on each other? Each time I flip through this I get overwhelmed by the number of changes. I'm a bit worried that if we keep it as one larger PR it will never get merged. These changes may have more success if broken down into independent parts. |
|
Well the goal of this PR was to refactor and cleanup our CMake build system. There are two parts to this 1) pulling the dependencies, and 2) cleaning up how modules are defined, as well as tutorials/unit tests. It may be a lot of changes, but it's really confined to the CMake scripts (I avoided doing changes to the .cpp unless I had to). I'd rather not do "half-cleanup" for this. Better look at it as a rewrite of the whole CMake build system where everything is new. |
alecjacobson
left a comment
There was a problem hiding this comment.
Some initial comments. I think this will take a very long time to sift through everything.
CMakeLists.txt
Outdated
| endif() | ||
|
|
||
| # Check for gmp + mpfr and enable cork / cgal modules accordingly | ||
| set(LIBIGL_DEFAULT_CGAL_CORK ${LIBIGL_TOPLEVEL_PROJECT}) |
There was a problem hiding this comment.
Should this LIBIGL_DEFAULT_CGAL_CORK be something like LIBIGL_DEFAULT_GMP_MPFR ? so it's more clear what it's controlling?
(I'm also not sure what DEFAULT means here.)
There was a problem hiding this comment.
We don't have an option LIBIGL_DEFAULT_GMP_MPFR. Here LIBIGL_DEFAULT_CGAL_CORK controls the default value of the options for the CGAL and Cork modules. If GMP and MPFR are not available on the target machine, then I disable the CGAL/Cork modules by default, since CGAL/Cork depend on GMP+MPFR.
There was a problem hiding this comment.
Right, and I'm commenting that the name LIBIGL_DEFAULT_CGAL_CORK is confusing since it seems to primarily refer to the presence of gmp/mpfr.
There was a problem hiding this comment.
The value of LIBIGL_DEFAULT_CGAL_CORK is set based on the presence of gmp/mpfr, but what it is used for is to set the default option for the CGAL and Cork modules. But hey I'm happy to rename it if you prefer.
There was a problem hiding this comment.
One thing though: if libigl is not built as a subproject, LIBIGL_DEFAULT_CGAL_CORK will be OFF. Also on Windows, LIBIGL_DEFAULT_CGAL_CORK will always be ON by default for toplevel project. So if I rename the variable into LIBIGL_GMP_MPFR_AVAILABLE, this would be somewhat misleading (e.g. GMP/MPFR might be available, but because libigl is built as a subproject, it will be set to OFF).
There was a problem hiding this comment.
I see. Maybe it makes sense to have a variable that tracks whether GMP_MPFR has been found and then the existing variables for wether building the cork / cgal modules.
There was a problem hiding this comment.
a variable that tracks whether GMP_MPFR has been found
What would you use it for? To track whether GMP/MPFR have been found, I would test for the existence of the imported targets gmp::gmp and mpfr::mpfr. Using variables in CMake is kinda brittle so I like to keep it to the bare minimum. But if you want to amend this part of the script to your liking feel free to give it a shot, since I'm not sure what you have in mind.
There was a problem hiding this comment.
I don't think I can amend it because I don't understand it. What does LIBIGL_DEFAULT_CGAL_CORK mean? LIBIGL I can guess means this is one of our variables, DEFAULT means this is a flag On or Off for a default setting. CGAL_CORK why both? Is this variable the same as LIBIGL_DEFAULT_CGAL AND LIBIGL_DEFAULT_CORK?
There was a problem hiding this comment.
I mean it's just a variable name. The "correct" name should be:
LIBIGL_DEFAULT_VALUE_FOR_CMAKE_OPTION_CGAL_AND_CORK_MODULES_BASED_ON_WHETHER_GMP_AND_MPFR_ARE_AVAILABLE
Then I just use this variable twice to set the default value for the following CMake options:
- LIBIGL_COPYLEFT_WITH_CGAL
- LIBIGL_COPYLEFT_WITH_CORK
So really this should be invisible to the user. LIBIGL_DEFAULT_CGAL_CORK is just a "local variable", it's not a proper CMake option that the user has to concern themselves with. If the user provides their own value for LIBIGL_COPYLEFT_WITH_CGAL or LIBIGL_COPYLEFT_WITH_CORK, the user-provided option will take precedence.
| @@ -0,0 +1,76 @@ | |||
| # Try to find the GNU Multiple Precision Arithmetic Library (GMP) | |||
There was a problem hiding this comment.
Somehow from previous discussions with @jdumas I was under the impression that writing custom Find*.cmake was a no-no these days. This PR adds a lot of custom cmake. Is this really what's expected for a modern cmake build system? Or is it a special case because GMP/MPFR are a pain?
There was a problem hiding this comment.
GMP/MPFR are a pain yes. We are not building them from source since they do not use a CMake build system. So the only option is to install via a package manager on macOS/Linux, or download a pre-built dll on Windows (which this find_package() will find).
| @@ -0,0 +1,32 @@ | |||
| # 1. Define module | |||
There was a problem hiding this comment.
These cmake/igl/modules//.cmake files all look roughly the same. Perhaps this can be abstracted into a function rather than copy-pasting files with minor changes.
There was a problem hiding this comment.
I am wary of making everything into a function. This file still separates the different parts of defining a libigl module based on:
- Module name
- Include headers
- Target sources
- Target dependencies
- Unit test definitions
Imho abstracting away some of these steps would make it too much look like "cmake magic" (e.g. where does the include header definition come from?).
| if (ImGui::CollapsingHeader("Workspace", ImGuiTreeNodeFlags_DefaultOpen)) | ||
| { | ||
| float w = ImGui::GetContentRegionAvailWidth(); | ||
| float w = ImGui::GetContentRegionAvail().x; |
There was a problem hiding this comment.
candidate for independent PR
There was a problem hiding this comment.
I have added the IMGUI_DISABLE_OBSOLETE_FUNCTIONS define macro when updating our imgui dependency, which required updating the code accordingly. I could make a separate PR for this but I don't think it's worth the effort (adding IMGUI_DISABLE_OBSOLETE_FUNCTIONS to our current CMake would create conflict, and otherwise the change is not needed).
|
Alright I have renamed nonfree -> restricted + added details in comments, and updated the description in the ".sample" CMake file. Once this is merged I will update instructions on the website accordingly. |
|
I haven't got a chance to review the PR in its entirety but happy to help test as needed. |
Thanks! I just want to make sure this is not breaking existing Hunter integration. I don't have much experience packaging libraries with Hunter, and I'm not sure if you use the upstream repo or a clone for the Hunter package. If you have any insight please let me know. |
|
Hey, I'm interested in adding Conan support (#1634) and it seems this PR is almost done and awaits review? Thanks |
|
Yes I'm waiting for green light from @alecjacobson and @danielepanozzo, but not sure when it's gonna happen... |
|
Thanks I'll wait for @alecjacobson and @danielepanozzo to chime in! |
|
🎉 |
libigl introduced breaking changes in libigl/libigl#1805 This fixes the OSS-Fuzz set up.
libigl introduced breaking changes in libigl/libigl#1805 This fixes the OSS-Fuzz set up.
libigl introduced breaking changes in libigl/libigl#1805 This fixes the OSS-Fuzz set up.
Alright, here it is. As part of the efforts towards v3.0.0 described in #1696, this refactors libigl's CMake system to be more modern and maintainable. The new setup is inspired by Lagrange, e.g. how
include()+FetchContentis used to download and handle third-party dependencies.I wrote an upgrade guide > here <, which I will update with final information once we merge this PR.
Highlights
igl::open_glfw_imgui) that didn't bring much to the table, in favor of three root classes based on available licenses for each module.LibiglOptions.cmakesample file at the root of the project repository, which should make it easier to document/update available CMake options.CMakeLists.txt. This facilitates maintenance, as before eithertutorial/CMakeLists.txtandcmake/libigl.cmakecould serve as potential entry points.igl_copy_dll()function to copy GMP/MPFR dlls on Windows.Tested on macOS/Windows.Ok looks like I have some issues left to sort out on Windows, shouldn't be to bad.--> Looks like we're having compilations issues with Cork on Windows. Cork depends on gmpxx, which is a C++ wrapper around gmp types. The CGAL precompiled gmp libs only come with gmp itself. Thus supporting Cork with gmpxx on Windows would require integrating the mpir fork of gmp. Because this is a lot of work for little value, I vote that we drop support for the cork files altogether. After all we know that there are better alternatives nowadays.
TODO
OSXFixDylibReferences.cmakeis also not used, for the same reason as above (although I am on macOS, I dot not have a setup that needs it).