-
-
Notifications
You must be signed in to change notification settings - Fork 119
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Modernize CMake #1524
Modernize CMake #1524
Conversation
ae581dd
to
757a5b9
Compare
I am now a great fan of "Fact_content" (or any higher level facade like https://github.com/TheLartians/CPM.cmake).
(with flag to allow to use the installed deps) |
Since CGAL is now header only, it is a good idea to simplify DGtal installation! If we replace |
I am not a great expert on configuration tools. Everything that makes the life of future developers/users easier is good for me. |
In DGtal, boost is already header only (only libs have been considered in DGtalTools but not true anymore I guess). It could also be "fetched" at cmake step but my only concern would be the size of the working copy (minor issue, though...). Maybe the "make install" step is also something that could introduce bugs.. |
FetchContent uses An alternative that from my experience works great is to have a With this approach, DGtal won't be changed, it will still expect The |
I think boost-graph can enjoy being linked (reduces compile time). |
In any case, this modernization is about removing global commands for target specific commands. Remove upper case, and modernize |
Additional things that should be in the Fetch_content stuff:
|
I've just tried a first Fetch_content with Catch2... |
- Avoid global `include_directories`, `link_libraries` etc. Use instead the `target_` commands. - Create DGtal library in the top directory, allowing to be targeted in the other CMake files. - Use lower case for CMake commands, i.e. `SET` to `set` etc. - Remove naming the condition in `else`, `endif`, and `endforeach`: `if(x), else(x), endif(x)` - Add function `DGtal_add_test(test_file)` to avoid repetition when configuring tests. It accepts a dummy optional parameter, for example `ONLY_ADD_EXECUTABLE` that will create the executable, link to DGtal, but avoid the `add_test` command. Used mainly when benchmarking is ON.
No need to prepend CMAKE_INSTALL_PREFIX
Instead of `INSTALL_X_DIR`. Where X is one of LIB, BIN, INCLUDE, DATA. `INSTALL_X_DIR` will be set based on the RELATIVE ones. This allow to have access to the relative paths to make DGtal re-allocatable. Also allow to change the docs with INSTALL_DOC_DIR_RELATIVE This also solves the existing problem where the docs installation folder does not change when changing `CMAKE_INSTALL_PREFIX` after the first configuration (because it was a CACHE variable)
Use find_dependency (find_package) for all enabled dependencies. This forces consumers of DGtal to provide `FOO_DIR` where FOO is a DGtal dependency. To ease this transition the option HINTS is provided with the current value of `FOO_DIR` computed when building DGtal. This will ease the transition in development environments, for example along DGtalTools. If DGtal is deployed, i.e. re-allocated, the HINTS are meaningless, but hopefully harmless, they just won't help in this case.
Use target_compile_definitions instead.
Provide HINTS to DGtalConfig.cmake. This allow third-parties (i.e DGtalTools) to not having to provide FOO_DIR, where FOO is a DGtal dependency, to their project, but to reuse the FOO_DIR provided in DGtal. This option should be disabled for deployment or any other re-allocation situation.
…s.cmake To avoid using add_definitions, we need DGtal target to exists. So these options are moved to a CMake file included after DGtal target is created.
Also fix OPENMP to OpenMP
In the build tree into: `PROJECT_BINARY_DIR/Modules` In install tree into `DGTAL_CMAKE_DIR_INSTALL/Modules` Also change find_dependency to find_package for the FindFoo.cmake packages. It seems that find_dependency prioritizes Config files and ignore Find modules.
@dcoeurjo I will rebase on top of master instead of:
Are you working on something on this branch? The head of this branch will be invalidated |
please go ahead, I'll resest my working copy if I need. |
No need to have two `add_library` commands based on `BUILD_SHARED_LIBS`. `SHARED` will be added automatically if `BUILD_SHARED_LIBS` is `ON` and `STATIC` if `OFF`.
2753977
to
309b81b
Compare
Can this branch be merged ? @phcerdan anything that is still WIP here? |
I think yes.
Sounds good! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Excellent, I just have a minor question.
Ok SoQT and COin3D can be removed.. I'll do it |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Changelog entry?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All good... thx
include_directories
,link_libraries
etc. Useinstead the
target_
commands.the other CMake files.
SET
toset
etc.else
,endif
, andendforeach
:if(x), else(x), endif(x)
DGtal_add_test(test_file)
to avoid repetition whenconfiguring tests. It accepts a dummy optional parameter, for example
ONLY_ADD_EXECUTABLE
that will create the executable, link to DGtal,but avoid the
add_test
command. Used mainly when benchmarking is ON.Checklist
cmake
mode (otherwise, Travis C.I. will fail).