From e54c5590fbb150e6aa745c618c9c406687a503c4 Mon Sep 17 00:00:00 2001 From: Robert Maynard Date: Mon, 7 Oct 2024 09:47:08 -0400 Subject: [PATCH] Support multi-config generators --- .../generate_installed_CTestTestfile.cmake | 22 ++++++++++++++----- testing/test/install_relocatable-simple.cmake | 14 ++++++++++-- 2 files changed, 29 insertions(+), 7 deletions(-) diff --git a/rapids-cmake/test/detail/generate_installed_CTestTestfile.cmake b/rapids-cmake/test/detail/generate_installed_CTestTestfile.cmake index 6e892c7d..c9f29b6a 100644 --- a/rapids-cmake/test/detail/generate_installed_CTestTestfile.cmake +++ b/rapids-cmake/test/detail/generate_installed_CTestTestfile.cmake @@ -48,8 +48,13 @@ function(convert_paths_to_install_dir prop_var) get_property(install_loc GLOBAL PROPERTY ${name}_install) if(install_loc) - get_property(build_loc GLOBAL PROPERTY ${name}_build) - string(REPLACE "${build_loc}" "${install_loc}/${name}" install_value "${possible_build_path}") + get_property(build_locs GLOBAL PROPERTY ${name}_build) + foreach(build_loc IN LISTS build_locs) + if(build_loc STREQUAL possible_build_path) + string(REPLACE "${build_loc}" "${install_loc}/${name}" install_value "${possible_build_path}") + break() + endif() + endforeach() else() string(REPLACE "${_RAPIDS_BUILD_DIR}" "\${CMAKE_INSTALL_PREFIX}" install_value "${possible_build_path}") @@ -99,8 +104,13 @@ function(add_test name command) else() get_property(install_loc GLOBAL PROPERTY ${name}_install) if(install_loc) - get_property(build_loc GLOBAL PROPERTY ${name}_build) - string(REPLACE "${build_loc}" "${install_loc}/${name}" command "${command}") + get_property(build_locs GLOBAL PROPERTY ${name}_build) + foreach(build_loc IN LISTS build_locs) + if(build_loc STREQUAL command) + string(REPLACE "${build_loc}" "${install_loc}/${name}" command "${command}") + break() + endif() + endforeach() endif() endif() @@ -203,7 +213,9 @@ function(extract_install_info) foreach(build_loc IN LISTS _RAPIDS_TEST_FILES) cmake_path(GET build_loc FILENAME name) set_property(GLOBAL PROPERTY ${name}_install ${_RAPIDS_TEST_DESTINATION}) - set_property(GLOBAL PROPERTY ${name}_build ${build_loc}) + + # For multi-config generators we will have multiple locations + set_property(GLOBAL APPEND PROPERTY ${name}_build ${build_loc}) endforeach() endif() endfunction() diff --git a/testing/test/install_relocatable-simple.cmake b/testing/test/install_relocatable-simple.cmake index 9330eadc..9c6237c7 100644 --- a/testing/test/install_relocatable-simple.cmake +++ b/testing/test/install_relocatable-simple.cmake @@ -21,7 +21,16 @@ enable_language(CUDA) enable_testing() rapids_test_init() -rapids_test_add(NAME verify_ COMMAND ls GPUS 1 INSTALL_COMPONENT_SET testing) +file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/main.cu" +[=[ +int main(int, char **) +{ + return 0; +} +]=]) +add_executable(test_verify ${CMAKE_CURRENT_BINARY_DIR}/main.cu) + +rapids_test_add(NAME verify_ COMMAND test_verify GPUS 1 INSTALL_COMPONENT_SET testing) rapids_test_install_relocatable(INSTALL_COMPONENT_SET testing DESTINATION bin/testing) @@ -52,7 +61,7 @@ string(FIND "${contents}" ${execute_process_match_string} is_found) if(is_found EQUAL -1) message(FATAL_ERROR "Failed to generate a `execute_process` with escaped CTEST_RESOURCE_SPEC_FILE") endif() -set(add_test_match_string [===[add_test([=[verify_]=] "cmake" -Dcommand_to_run=ls -Dcommand_args= -P=./run_gpu_test.cmake)]===]) +set(add_test_match_string [===[add_test([=[verify_]=] "cmake" -Dcommand_to_run=${CMAKE_INSTALL_PREFIX}/bin/testing/test_verify -Dcommand_args= -P=./run_gpu_test.cmake)]===]) string(FIND "${contents}" ${add_test_match_string} is_found) if(is_found EQUAL -1) message(FATAL_ERROR "Failed to generate an installed `add_test` for verify_") @@ -68,3 +77,4 @@ add_custom_target(install_testing_component ALL COMMAND ${CMAKE_COMMAND} --install "${CMAKE_CURRENT_BINARY_DIR}" --component testing --prefix install/ COMMAND ${CMAKE_COMMAND} -P "${CMAKE_CURRENT_BINARY_DIR}/verify_installed_CTestTestfile.cmake" ) +add_dependencies(install_testing_component test_verify)