Skip to content

Commit

Permalink
Support multi-config generators
Browse files Browse the repository at this point in the history
  • Loading branch information
robertmaynard committed Oct 7, 2024
1 parent f41a546 commit e54c559
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 7 deletions.
22 changes: 17 additions & 5 deletions rapids-cmake/test/detail/generate_installed_CTestTestfile.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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}")
Expand Down Expand Up @@ -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()

Expand Down Expand Up @@ -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()
Expand Down
14 changes: 12 additions & 2 deletions testing/test/install_relocatable-simple.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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_")
Expand All @@ -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)

0 comments on commit e54c559

Please sign in to comment.