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

rapids_test_install_relocatable EXCLUDE_FROM_ALL is now the default #388

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
2 changes: 1 addition & 1 deletion cmake-format-rapids-cmake.json
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@
"rapids_test_install_relocatable": {
"pargs": {
"nargs": "0",
"flags": ["EXCLUDE_FROM_ALL"]
"flags": ["INCLUDE_IN_ALL"]
},
"kwargs": {
"INSTALL_COMPONENT_SET": "1",
Expand Down
17 changes: 8 additions & 9 deletions rapids-cmake/test/install_relocatable.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ by `ctest` in parallel with GPU awareness.

rapids_test_install_relocatable(INSTALL_COMPONENT_SET <component>
DESTINATION <relative_path>
[EXCLUDE_FROM_ALL])
[INCLUDE_IN_ALL])

Will install all tests created by :cmake:command:`rapids_test_add` that are
part of the provided ``INSTALL_COMPONENT_SET``.
Expand All @@ -43,23 +43,22 @@ arguments provided to the tests are machine independent (no absolute paths).
Relative path from the `CMAKE_INSTALL_PREFIX` to install the infrastructure.
This needs to be the same directory as the test executables

``EXCLUDE_FROM_ALL``
State that these install rules shouldn't be part of the default install set, and
instead must be explicitly installed.

``INCLUDE_IN_ALL``
State that these install rules should be part of the default install set.
By default tests are not part of the default install set.

#]=======================================================================]
function(rapids_test_install_relocatable)
list(APPEND CMAKE_MESSAGE_CONTEXT "rapids.test.install_relocatable")

set(options EXCLUDE_FROM_ALL)
set(options INCLUDE_IN_ALL)
set(one_value INSTALL_COMPONENT_SET DESTINATION)
set(multi_value)
cmake_parse_arguments(_RAPIDS_TEST "${options}" "${one_value}" "${multi_value}" ${ARGN})

set(to_exclude)
if(_RAPIDS_TEST_EXCLUDE_FROM_ALL)
set(to_exclude EXCLUDE_FROM_ALL)
set(to_exclude EXCLUDE_FROM_ALL)
if(_RAPIDS_TEST_INCLUDE_IN_ALL)
set(to_exclude)
endif()

set(component ${_RAPIDS_TEST_INSTALL_COMPONENT_SET})
Expand Down
3 changes: 2 additions & 1 deletion testing/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ add_cmake_config_test(init-existing-specfile.cmake)
add_cmake_config_test(init-simple.cmake)

set(wrong_component_message "No install component set [wrong_component] can be found")
add_cmake_config_test(install_relocatable-labels.cmake)
add_cmake_build_test(install_relocatable-include-in-all.cmake)
add_cmake_build_test(install_relocatable-labels.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
52 changes: 52 additions & 0 deletions testing/test/install_relocatable-include-in-all.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#=============================================================================
# Copyright (c) 2022-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/init.cmake)
include(${rapids-cmake-dir}/test/add.cmake)
include(${rapids-cmake-dir}/test/install_relocatable.cmake)

enable_language(CUDA)
rapids_test_init()

rapids_test_add(NAME verify_ COMMAND ls GPUS 1 INSTALL_COMPONENT_SET testing)

rapids_test_install_relocatable(INSTALL_COMPONENT_SET testing
DESTINATION bin/testing
INCLUDE_IN_ALL)

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(exclude_from_all_string [===[if(CMAKE_INSTALL_COMPONENT STREQUAL "testing" OR NOT CMAKE_INSTALL_COMPONENT)]===])
string(FIND "${contents}" ${exclude_from_all_string} is_found)
if(is_found EQUAL -1)
message(FATAL_ERROR "`rapids_test_install_relocatable` failed to mark items as EXCLUDE_FROM_ALL")
endif()
]=])
add_custom_target(verify_install_rule ALL
COMMAND ${CMAKE_COMMAND} -P "${CMAKE_CURRENT_BINARY_DIR}/verify_cmake_install.cmake")

set(generated_testfile "${CMAKE_CURRENT_BINARY_DIR}/rapids-cmake/testing/CTestTestfile.cmake.to_install")
file(READ "${generated_testfile}" contents)

set(execute_process_match_string [===[execute_process(COMMAND ./generate_ctest_json OUTPUT_FILE "${CTEST_RESOURCE_SPEC_FILE}")]===])
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()
19 changes: 17 additions & 2 deletions testing/test/install_relocatable-simple.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,23 @@ rapids_test_init()
rapids_test_add(NAME verify_ COMMAND ls GPUS 1 INSTALL_COMPONENT_SET testing)

rapids_test_install_relocatable(INSTALL_COMPONENT_SET testing
DESTINATION bin/testing
EXCLUDE_FROM_ALL)
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(exclude_from_all_string [===[if(CMAKE_INSTALL_COMPONENT STREQUAL "testing")]===])
string(FIND "${contents}" ${exclude_from_all_string} is_found)
if(is_found EQUAL -1)
message(FATAL_ERROR "`rapids_test_install_relocatable` failed to mark items as EXCLUDE_FROM_ALL")
endif()
]=])
add_custom_target(verify_install_rule ALL
COMMAND ${CMAKE_COMMAND} -P "${CMAKE_CURRENT_BINARY_DIR}/verify_cmake_install.cmake")

set(generated_testfile "${CMAKE_CURRENT_BINARY_DIR}/rapids-cmake/testing/CTestTestfile.cmake.to_install")
file(READ "${generated_testfile}" contents)
Expand Down
3 changes: 1 addition & 2 deletions testing/test/install_relocatable-wrong-component.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,4 @@ rapids_test_init()
rapids_test_install_relocatable(INSTALL_COMPONENT_SET wrong_component
DESTINATION bin/testing)
rapids_test_install_relocatable(INSTALL_COMPONENT_SET another_wrong_component
DESTINATION bin/testing
EXCLUDE_FROM_ALL)
DESTINATION bin/testing)