Draft: Simplify implementation of dune_create_dependency_tree
Summary
By using modern cmake functionality, the implementation of the dune cmake function dune_create_dependency_tree
can be simplified significantly. This makes it much easier to understand what is going on there.
TODO
-
Verify that the new implementation does "exactly" the same as the old implementation
Merge request reports
Activity
added buildsystem label
added 23 commits
-
4c02191d...10e76a88 - 21 commits from branch
master
- 5c5619c8 - Simplify implementation of dune_create_dependency_tree
- 17c3b51c - Add CMAKE_MODULE_PATH to project config files
-
4c02191d...10e76a88 - 21 commits from branch
See pipeline https://gitlab.dune-project.org/infrastructure/dune-nightly-test/-/pipelines/41100 for a system-test.
Edited by Simon Praetoriusadded 1 commit
- cd1c5b97 - Remove escape character for variables in dune-common-config.cmake.in
77 math(EXPR length "${length}-1") 78 if(start EQUAL -1) 79 list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake/modules ${_my_path}) 80 else() 81 if(start EQUAL ${length}) 82 list(APPEND CMAKE_MODULE_PATH ${_my_path}) 83 else() 84 if(_my_path) 85 list(INSERT CMAKE_MODULE_PATH ${start} ${_my_path}) 86 endif() 87 endif() 88 endif() 89 endif() 90 set(ALL_DEPENDENCIES ${NEW_ALL_DEPS}) 52 list(REVERSE ALL_DEPENDENCIES) 53 list(REMOVE_DUPLICATES ALL_DEPENDENCIES) 73 endif() 74 endforeach() 75 endif() 76 list(LENGTH CMAKE_MODULE_PATH length) 77 math(EXPR length "${length}-1") 78 if(start EQUAL -1) 79 list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake/modules ${_my_path}) 80 else() 81 if(start EQUAL ${length}) 82 list(APPEND CMAKE_MODULE_PATH ${_my_path}) 83 else() 84 if(_my_path) 85 list(INSERT CMAKE_MODULE_PATH ${start} ${_my_path}) 86 endif() 87 endif() 88 endif() - Comment on lines -78 to -88
If I understand this correctly, this logic forces that
${PROJECT_SOURCE_DIR}/cmake/modules
is always on theCMAKE_MODULE_PATH
(even though it seems to be a common pattern to write it explicitly in the rootCMakeLists.txt
of the module). The${ProjectName}_MODULE_PATH
variable seems to be hard coded to be${PROJECT_SOURCE_DIR}/cmake/modules
, so it does makes sense that this is path is forced to be on theCMAKE_MODULE_PATH
during configuration time. The extra logic seems to avoid path duplication and to include dependent module paths in a given order (I would argue that anyone depending in a given order of the module path has a bug in its code).In any case, this behavior doesn't seem to be included in this MR.
If this behavior is somehow guaranteed, one can think of removing the inclusion of those paths in the
duneproject
CMakeLists.txt and all downstream modules.Ok, this MR finally get me the idea of how to properly handle dependencies at the config file. See !1249 (merged)
mentioned in merge request !1248 (closed)
mentioned in merge request !848 (closed)
I will close this in favor of !1249 (merged) where most of the manual dependency handling is deprecated.