Skip to content
Snippets Groups Projects

Draft: Simplify implementation of dune_create_dependency_tree

Closed Simon Praetorius requested to merge feature/cmake-dune-create-dependency-tree into master
2 unresolved threads

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
Edited by Simon Praetorius

Merge request reports

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
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 the CMAKE_MODULE_PATH (even though it seems to be a common pattern to write it explicitly in the root CMakeLists.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 the CMAKE_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)

    • Please register or sign in to reply
  • 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.

  • Please register or sign in to reply
    Loading