-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This function accepts a path name and a project name (default is the current project name). For each transitive dependency of the specificied project name, the value of the corresponding path name is appended to an output variable.
- Loading branch information
Showing
2 changed files
with
92 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
#[================================================================[.rst: | ||
CetTransitivePaths | ||
------------------ | ||
Defines the function :commmand:`cet_transitive_paths`. | ||
#]================================================================] | ||
|
||
include_guard() | ||
|
||
#[================================================================[.rst: | ||
.. command:: cet_transitive_paths | ||
Get a list of path values for all transitive dependencies of the | ||
given project name. For a given path name, the dependency tree of | ||
the given project is searched according to the dependencies | ||
specified via ``find_package``. | ||
For example, if the path name ``"MY_PATH"`` is supplied, the | ||
function will traverse the dependency structure and collect all | ||
values of the path name ``"<project-or-dependency name>_MY_PATH"``. | ||
The result can be accessed via the variable | ||
``"TRANSITIVE_PATHS_WITH_MY_PATH"``. | ||
.. code-block:: cmake | ||
cet_transitive_paths(<path-name> [<project-variable localization options>] [IN_TREE] [PROJECT <project-name>]) | ||
Options | ||
^^^^^^^ | ||
``[PROJECT] <project-name>`` | ||
The top-level project from which the transitive dependency | ||
traversal occurs. (default | ||
:variable:`${CETMODULES_CURRENT_PROJECT_NAME} | ||
<CETMODULES_CURRENT_PROJECT_NAME>`). | ||
``IN_TREE`` | ||
Include paths only from projects that are included in the build tree. | ||
Non-option arguments | ||
^^^^^^^^^^^^^^^^^^^^ | ||
``[<path-name>]`` | ||
The name of the path that serves as the suffix for the top-level | ||
project and all transitive dependencies. The path name can be a | ||
Cetmodules project variable, in which case the options to | ||
:command:`cet_localize_pv` may also be provided. | ||
#]================================================================] | ||
|
||
function(cet_transitive_paths PATH) | ||
cmake_parse_arguments(PARSE_ARGV 1 CTP "IN_TREE;BINARY;SOURCE;TRY_BINARY" "PROJECT" "") | ||
cet_passthrough(FLAG APPEND CTP_BINARY clpv_args) | ||
cet_passthrough(FLAG APPEND CTP_SOURCE clpv_args) | ||
cet_passthrough(FLAG APPEND CTP_TRY_BINARY clpv_args) | ||
|
||
set(PKG ${CETMODULES_CURRENT_PROJECT_NAME}) | ||
if (CTP_PROJECT) | ||
set(PKG ${CTP_PROJECT}) | ||
endif() | ||
|
||
_cet_transitive_project_names(${PKG} PNAMES_RESULT CTP_IN_TREE) | ||
foreach(DEP IN LISTS PNAMES_RESULT) | ||
if (DEFINED CACHE{CETMODULES_${PATH}_PROPERTIES_PROJECT_${DEP}}) | ||
cet_localize_pv(${DEP} ${PATH} ${clpv_args}) | ||
endif() | ||
list(APPEND TRANSITIVE_PATHS_TMP ${${DEP}_${PATH}}) | ||
endforeach() | ||
set(TRANSITIVE_PATHS_WITH_${PATH} ${TRANSITIVE_PATHS_TMP} PARENT_SCOPE) | ||
|
||
endfunction() | ||
|
||
function(_cet_transitive_project_names PKG RESULT_LIST) | ||
set(RESULT_LIST_TMP ${${RESULT_LIST}}) | ||
foreach(DEP IN LISTS CETMODULES_FIND_DEPS_PNAMES_PROJECT_${PKG}) | ||
if (PKG STREQUAL DEP OR | ||
(ARGN STREQUAL "IN_TREE" AND NOT ${DEP}_IN_TREE)) | ||
continue() | ||
endif() | ||
if (NOT "${DEP}" IN_LIST RESULT_LIST_TMP) | ||
_cet_transitive_project_names("${DEP}" RESULT_LIST_TMP ${ARGN}) | ||
endif() | ||
endforeach() | ||
list(PREPEND RESULT_LIST_TMP ${PKG}) | ||
set(${RESULT_LIST} ${RESULT_LIST_TMP} PARENT_SCOPE) | ||
endfunction() |