Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

install_relocatable only installs files that exist #392

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions rapids-cmake/test/install_relocatable.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -103,12 +103,16 @@ function(rapids_test_install_relocatable)

# We need to install the rapids-test gpu detector, and the json script we also need to write out /
# install the new CTestTestfile.cmake
install(PROGRAMS "${PROJECT_BINARY_DIR}/rapids-cmake/${rapids_test_generate_exe_name}"
COMPONENT ${_RAPIDS_TEST_INSTALL_COMPONENT_SET} DESTINATION ${_RAPIDS_TEST_DESTINATION}
${to_exclude})
install(FILES "${CMAKE_CURRENT_FUNCTION_LIST_DIR}/detail/run_gpu_test.cmake"
COMPONENT ${_RAPIDS_TEST_INSTALL_COMPONENT_SET} DESTINATION ${_RAPIDS_TEST_DESTINATION}
${to_exclude})
if(EXISTS "${PROJECT_BINARY_DIR}/rapids-cmake/${rapids_test_generate_exe_name}")
install(PROGRAMS "${PROJECT_BINARY_DIR}/rapids-cmake/${rapids_test_generate_exe_name}"
COMPONENT ${_RAPIDS_TEST_INSTALL_COMPONENT_SET} DESTINATION ${_RAPIDS_TEST_DESTINATION}
${to_exclude})
endif()
if(EXISTS "${CMAKE_CURRENT_FUNCTION_LIST_DIR}/detail/run_gpu_test.cmake")
install(FILES "${CMAKE_CURRENT_FUNCTION_LIST_DIR}/detail/run_gpu_test.cmake"
COMPONENT ${_RAPIDS_TEST_INSTALL_COMPONENT_SET} DESTINATION ${_RAPIDS_TEST_DESTINATION}
${to_exclude})
endif()
if(targets_to_install)
install(TARGETS ${targets_to_install} COMPONENT ${_RAPIDS_TEST_INSTALL_COMPONENT_SET}
DESTINATION ${_RAPIDS_TEST_DESTINATION} ${to_exclude})
Expand Down
1 change: 1 addition & 0 deletions testing/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ add_cmake_config_test(init-simple.cmake)
set(wrong_component_message "No install component set [wrong_component] can be found")
add_cmake_build_test(install_relocatable-include-in-all.cmake)
add_cmake_build_test(install_relocatable-labels.cmake)
add_cmake_build_test(install_relocatable-no-tests.cmake)
add_cmake_config_test(install_relocatable-simple.cmake)
add_cmake_config_test(install_relocatable-wrong-component.cmake SHOULD_FAIL "${wrong_component_message}")

Expand Down
40 changes: 40 additions & 0 deletions testing/test/install_relocatable-no-tests.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#=============================================================================
# Copyright (c) 2023, NVIDIA CORPORATION.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#=============================================================================
include(${rapids-cmake-dir}/test/add.cmake)
include(${rapids-cmake-dir}/test/install_relocatable.cmake)

enable_language(CUDA)
enable_testing()

rapids_test_add(NAME verify_ COMMAND ls GPUS 1 INSTALL_COMPONENT_SET testing)
rapids_test_install_relocatable(INSTALL_COMPONENT_SET testing
DESTINATION bin/testing)

file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/verify_cmake_install.cmake"
"set(install_rules_file \"${CMAKE_CURRENT_BINARY_DIR}/cmake_install.cmake\")")

file(APPEND "${CMAKE_CURRENT_BINARY_DIR}/verify_cmake_install.cmake"
[=[

file(READ "${install_rules_file}" contents)
set(bad_install_rule_match_string [===[rapids-cmake/generate_ctest_json")]===])
string(FIND "${contents}" ${bad_install_rule_match_string} is_found)
if(NOT is_found EQUAL -1)
message(FATAL_ERROR "`rapids_test_install_relocatable` trying to install files that don't exist")
endif()
]=])
add_custom_target(verify_install_files_valid ALL
COMMAND ${CMAKE_COMMAND} -P "${CMAKE_CURRENT_BINARY_DIR}/verify_cmake_install.cmake")