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

Correct install_relocatable issues found by libcudf #423

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
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ function(set_tests_properties name)
set(prop_value "${_RAPIDS_TEST_${prop}}")
find_and_convert_paths_from_var_list(prop_value)
string(APPEND test_prop_content
"set_tests_properties([=[${name}]=] PROPERTIES ${prop} ${prop_value})\n")
"set_tests_properties([=[${name}]=] PROPERTIES ${prop} \"${prop_value}\")\n")
endif()
endforeach()

Expand Down Expand Up @@ -210,7 +210,7 @@ endfunction()
#
# Find all the cmake_install.cmake files in the install directory and parse them for install rules
function(determine_install_location_of_all_targets)
file(GLOB_RECURSE install_rule_files "${_RAPIDS_BUILD_DIR}/cmake_install.cmake")
file(GLOB_RECURSE install_rule_files "${_RAPIDS_PROJECT_DIR}/cmake_install.cmake")
vyasr marked this conversation as resolved.
Show resolved Hide resolved
foreach(file IN LISTS install_rule_files)
file(STRINGS "${file}" contents REGEX "INSTALL DESTINATION")
foreach(line IN LISTS contents)
Expand Down
6 changes: 5 additions & 1 deletion rapids-cmake/test/install_relocatable.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ the install directory.
State that these install rules should be part of the default install set.
By default tests are not part of the default install set.

.. note::
rapids_test_install_relocatable behavior is undefined when used with
multi-config generators such as "Visual Studio" and "Ninja Multi-Config"

#]=======================================================================]
function(rapids_test_install_relocatable)
list(APPEND CMAKE_MESSAGE_CONTEXT "rapids.test.install_relocatable")
Expand Down Expand Up @@ -80,7 +84,7 @@ function(rapids_test_install_relocatable)
set(_RAPIDS_TEST_DESTINATION \"${_RAPIDS_TEST_DESTINATION}\")
set(_RAPIDS_INSTALL_PREFIX \"${from_install_prefix}\")
set(_RAPIDS_BUILD_DIR \"${CMAKE_CURRENT_BINARY_DIR}\")
set(_RAPIDS_PROJECT_DIR \"${PROJECT_BINARY_DIR}\")
set(_RAPIDS_PROJECT_DIR \"${CMAKE_BINARY_DIR}\")
set(_RAPIDS_INSTALL_COMPONENT_SET \"${_RAPIDS_TEST_INSTALL_COMPONENT_SET}\")
set(_RAPIDS_TARGETS_INSTALLED \"${targets_to_install}\")
set(_RAPIDS_TESTS_TO_RUN \"${tests_to_run}\")
Expand Down
1 change: 1 addition & 0 deletions testing/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ 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_build_test(install_relocatable-simple.cmake)
add_cmake_build_test(install_relocatable-complex)
add_cmake_config_test(install_relocatable-wrong-component.cmake SHOULD_FAIL "${wrong_component_message}")

add_cmake_ctest_test(add-impossible-allocation SHOULD_FAIL "Insufficient resources for test")
Expand Down
25 changes: 25 additions & 0 deletions testing/test/install_relocatable-complex/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#=============================================================================
# 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.
#=============================================================================
cmake_minimum_required(VERSION 3.20)
set(CMAKE_CONFIGURATION_TYPES Debug)
project(rapids-test-project LANGUAGES CUDA)

include(${rapids-cmake-dir}/rapids-test.cmake)

add_library(preload SHARED usage.cu)
robertmaynard marked this conversation as resolved.
Show resolved Hide resolved
add_subdirectory(tests)

install(TARGETS preload DESTINATION lib)
61 changes: 61 additions & 0 deletions testing/test/install_relocatable-complex/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
#=============================================================================
# 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}/rapids-test.cmake)

enable_testing()
rapids_test_init()

rapids_test_add(NAME verify_ COMMAND ls GPUS 1 INSTALL_COMPONENT_SET testing)
set_tests_properties(
verify_
PROPERTIES
ENVIRONMENT
"STREAM_MODE=new_mode;LD_PRELOAD=$<TARGET_FILE:preload>"
)

rapids_test_install_relocatable(INSTALL_COMPONENT_SET testing
DESTINATION bin/testing
INCLUDE_IN_ALL)

file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/verify_installed_CTestTestfile.cmake"
"set(installed_test_file \"${CMAKE_CURRENT_BINARY_DIR}/install/bin/testing/CTestTestfile.cmake\")")
file(APPEND "${CMAKE_CURRENT_BINARY_DIR}/verify_installed_CTestTestfile.cmake"
[==[

file(READ "${installed_test_file}" 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()

set(properties_match_strings [===[PROPERTIES ENVIRONMENT "STREAM_MODE]===]
[===[LD_PRELOAD=${CMAKE_INSTALL_PREFIX}/lib/libpreload]===])
foreach(to_match IN LISTS properties_match_strings)
string(FIND "${contents}" ${to_match} is_found)
if(is_found EQUAL -1)
message(FATAL_ERROR "${contents}\nFailed to generate a proper set of test properties")
endif()
endforeach()
]==])

add_custom_target(install_testing_component ALL
COMMAND ${CMAKE_COMMAND} --install "${CMAKE_BINARY_DIR}" --prefix install/ --config Debug
COMMAND ${CMAKE_COMMAND} -P "${CMAKE_CURRENT_BINARY_DIR}/verify_installed_CTestTestfile.cmake"
)

add_dependencies(install_testing_component preload)
Empty file.