From e5e6d3f1bdee818b3fcbb6e6a7b10eec1dcab759 Mon Sep 17 00:00:00 2001 From: Kyle Knoepfel Date: Fri, 12 Jan 2024 10:00:22 -0600 Subject: [PATCH] Adjust CMAKE_PREFIX_PATH environment variable for COMPILE_ONLY tests. Makes it possible to run COMPILE_ONLY tests without users needing to adjust the CMAKE_PREFIX_PATH environment variable in their own environments. --- Modules/CetTest.cmake | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/Modules/CetTest.cmake b/Modules/CetTest.cmake index d506e1bd..31ac23f1 100644 --- a/Modules/CetTest.cmake +++ b/Modules/CetTest.cmake @@ -687,6 +687,19 @@ test ${test} must be defined already to be specified as a fixture for ${CET_TARG ENVIRONMENT_MODIFICATION "${CET_TEST_ENV_MODIFICATION}") endif() endif() + if (CET_COMPILE_ONLY) + _transitive_binary_directories(${CETMODULES_CURRENT_PROJECT_NAME}) + list(JOIN TRANSITIVE_BINARY_DIRS ":" DIRS_FOR_PREFIX_PATH) + set(TEST_CMAKE_PREFIX_PATH "CMAKE_PREFIX_PATH=path_list_prepend:${DIRS_FOR_PREFIX_PATH}") + get_test_property(${target} ENVIRONMENT_MODIFICATION CET_TEST_ENV_TMP) + if (CET_TEST_ENV_TMP) + set_tests_properties(${target} PROPERTIES + ENVIRONMENT_MODIFICATION "${TEST_CMAKE_PREFIX_PATH};${CET_TEST_ENV_TMP}") + else() + set_tests_properties(${target} PROPERTIES + ENVIRONMENT_MODIFICATION "${TEST_CMAKE_PREFIX_PATH}") + endif() + endif() if (CET_REF) get_test_property(${target} REQUIRED_FILES REQUIRED_FILES_TMP) if (REQUIRED_FILES_TMP) @@ -1087,3 +1100,15 @@ function(_update_defined_test_groups) FORCE ) endfunction() + +function(_transitive_binary_directories PKG) + set(TRANSITIVE_BINARY_DIRS_TMP ${${PKG}_BINARY_DIR}) + foreach(DEP IN LISTS CETMODULES_FIND_DEPS_PNAMES_PROJECT_${PKG}) + if (${DEP}_IN_TREE) + _transitive_binary_directories(${DEP}) + list(APPEND TRANSITIVE_BINARY_DIRS_TMP ${TRANSITIVE_BINARY_DIRS}) + endif() + endforeach() + list(REMOVE_DUPLICATES TRANSITIVE_BINARY_DIRS_TMP) + set(TRANSITIVE_BINARY_DIRS ${TRANSITIVE_BINARY_DIRS_TMP} PARENT_SCOPE) +endfunction()