From 368796cd67bf3db0d794a611b6e745a98ce5b7a9 Mon Sep 17 00:00:00 2001 From: Kyle Edwards Date: Tue, 6 Feb 2024 17:50:02 -0500 Subject: [PATCH 01/10] Error out if generate_ctest_json fails to build or run Fixes: https://github.com/rapidsai/rapids-cmake/issues/421 --- .../detail/generate_installed_CTestTestfile.cmake | 2 +- rapids-cmake/test/generate_resource_spec.cmake | 12 ++---------- 2 files changed, 3 insertions(+), 11 deletions(-) diff --git a/rapids-cmake/test/detail/generate_installed_CTestTestfile.cmake b/rapids-cmake/test/detail/generate_installed_CTestTestfile.cmake index 54a9a522..f3b6040a 100644 --- a/rapids-cmake/test/detail/generate_installed_CTestTestfile.cmake +++ b/rapids-cmake/test/detail/generate_installed_CTestTestfile.cmake @@ -234,7 +234,7 @@ set(test_file_content set(CTEST_SCRIPT_DIRECTORY \".\") set(CMAKE_INSTALL_PREFIX \"./${_RAPIDS_INSTALL_PREFIX}\") set(CTEST_RESOURCE_SPEC_FILE \"./${rapids_test_json_file_name}\") -execute_process(COMMAND ./${rapids_test_generate_exe_name} OUTPUT_FILE \"\${CTEST_RESOURCE_SPEC_FILE}\") +execute_process(COMMAND ./${rapids_test_generate_exe_name} OUTPUT_FILE \"\${CTEST_RESOURCE_SPEC_FILE}\" COMMAND_ERROR_IS_FATAL ANY) \n\n ") diff --git a/rapids-cmake/test/generate_resource_spec.cmake b/rapids-cmake/test/generate_resource_spec.cmake index e610fd4b..8fb4d9e6 100644 --- a/rapids-cmake/test/generate_resource_spec.cmake +++ b/rapids-cmake/test/generate_resource_spec.cmake @@ -81,17 +81,9 @@ function(rapids_test_generate_resource_spec DESTINATION filepath) execute_process(COMMAND "${compiler}" "${eval_file}" ${compile_options} ${link_options} -o "${eval_exe}" OUTPUT_VARIABLE compile_output - ERROR_VARIABLE compile_output) + ERROR_VARIABLE compile_output COMMAND_ERROR_IS_FATAL ANY) endif() - if(NOT EXISTS "${eval_exe}") - message(STATUS "rapids_test_generate_resource_spec failed to build detection executable, presuming no GPUs." - ) - message(STATUS "rapids_test_generate_resource_spec compile[${compiler} ${compile_options} ${link_options}] failure details are ${compile_output}" - ) - file(WRITE "${filepath}" "${gpu_json_contents}") - else() - execute_process(COMMAND ${eval_exe} OUTPUT_FILE "${filepath}") - endif() + execute_process(COMMAND ${eval_exe} OUTPUT_FILE "${filepath}" COMMAND_ERROR_IS_FATAL ANY) endfunction() From 494e4415539432b70815a542edbb78b92b03eaa6 Mon Sep 17 00:00:00 2001 From: Kyle Edwards Date: Tue, 6 Feb 2024 17:55:08 -0500 Subject: [PATCH 02/10] Update copyright --- rapids-cmake/test/detail/generate_installed_CTestTestfile.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rapids-cmake/test/detail/generate_installed_CTestTestfile.cmake b/rapids-cmake/test/detail/generate_installed_CTestTestfile.cmake index f3b6040a..e3a2b39a 100644 --- a/rapids-cmake/test/detail/generate_installed_CTestTestfile.cmake +++ b/rapids-cmake/test/detail/generate_installed_CTestTestfile.cmake @@ -1,5 +1,5 @@ #============================================================================= -# Copyright (c) 2023, NVIDIA CORPORATION. +# Copyright (c) 2023-2024, NVIDIA CORPORATION. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. From 307dfdcbd7004ae5dff13f49a62e1884414acbee Mon Sep 17 00:00:00 2001 From: Kyle Edwards Date: Tue, 6 Feb 2024 18:03:52 -0500 Subject: [PATCH 03/10] Allow for multiple CUDA include directories --- rapids-cmake/test/generate_resource_spec.cmake | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/rapids-cmake/test/generate_resource_spec.cmake b/rapids-cmake/test/generate_resource_spec.cmake index 8fb4d9e6..1916b4ab 100644 --- a/rapids-cmake/test/generate_resource_spec.cmake +++ b/rapids-cmake/test/generate_resource_spec.cmake @@ -71,7 +71,9 @@ function(rapids_test_generate_resource_spec DESTINATION filepath) file(MAKE_DIRECTORY "${PROJECT_BINARY_DIR}/rapids-cmake/") if(CUDAToolkit_FOUND) - set(compile_options "-I${CUDAToolkit_INCLUDE_DIRS}" "-DHAVE_CUDA") + set(cuda_include_options ${CUDATookit_INCLUDE_DIRS}) + list(TRANSFORM cuda_include_options PREPEND "-I") + set(compile_options ${cuda_include_options} "-DHAVE_CUDA") endif() set(link_options ${CUDA_cudart_LIBRARY} -lpthread -lrt -ldl) set(compiler "${CMAKE_CXX_COMPILER}") From 7965d4b640af010ef1caa632757c77183c8b2411 Mon Sep 17 00:00:00 2001 From: Kyle Edwards Date: Tue, 6 Feb 2024 18:45:29 -0500 Subject: [PATCH 04/10] Print compile output on failure --- rapids-cmake/test/generate_resource_spec.cmake | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/rapids-cmake/test/generate_resource_spec.cmake b/rapids-cmake/test/generate_resource_spec.cmake index 1916b4ab..c0e3a8d5 100644 --- a/rapids-cmake/test/generate_resource_spec.cmake +++ b/rapids-cmake/test/generate_resource_spec.cmake @@ -86,6 +86,11 @@ function(rapids_test_generate_resource_spec DESTINATION filepath) ERROR_VARIABLE compile_output COMMAND_ERROR_IS_FATAL ANY) endif() - execute_process(COMMAND ${eval_exe} OUTPUT_FILE "${filepath}" COMMAND_ERROR_IS_FATAL ANY) + if(NOT EXISTS "${eval_exe}") + string(REPLACE "\n" "\n " compile_output "${compile_output}") + message(FATAL_ERROR "rapids_test_generate_resource_spec failed to build detection executable.\nrapids_test_generate_resource_spec compile[${compiler} ${compile_options} ${link_options}] failure details are:\n ${compile_output}") + else() + execute_process(COMMAND ${eval_exe} OUTPUT_FILE "${filepath}" COMMAND_ERROR_IS_FATAL ANY) + endif() endfunction() From f993b914f5139a3ee4bb08c3ae4bb7370cffcd7f Mon Sep 17 00:00:00 2001 From: Kyle Edwards Date: Tue, 6 Feb 2024 18:47:35 -0500 Subject: [PATCH 05/10] Fix style --- rapids-cmake/test/generate_resource_spec.cmake | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/rapids-cmake/test/generate_resource_spec.cmake b/rapids-cmake/test/generate_resource_spec.cmake index c0e3a8d5..7bc0f7ac 100644 --- a/rapids-cmake/test/generate_resource_spec.cmake +++ b/rapids-cmake/test/generate_resource_spec.cmake @@ -88,7 +88,8 @@ function(rapids_test_generate_resource_spec DESTINATION filepath) if(NOT EXISTS "${eval_exe}") string(REPLACE "\n" "\n " compile_output "${compile_output}") - message(FATAL_ERROR "rapids_test_generate_resource_spec failed to build detection executable.\nrapids_test_generate_resource_spec compile[${compiler} ${compile_options} ${link_options}] failure details are:\n ${compile_output}") + message(FATAL_ERROR "rapids_test_generate_resource_spec failed to build detection executable.\nrapids_test_generate_resource_spec compile[${compiler} ${compile_options} ${link_options}] failure details are:\n ${compile_output}" + ) else() execute_process(COMMAND ${eval_exe} OUTPUT_FILE "${filepath}" COMMAND_ERROR_IS_FATAL ANY) endif() From c9b3906d294479f94499ddd53b01b913cfc26c47 Mon Sep 17 00:00:00 2001 From: Kyle Edwards Date: Tue, 6 Feb 2024 18:48:15 -0500 Subject: [PATCH 06/10] Remove extraneous else() --- rapids-cmake/test/generate_resource_spec.cmake | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/rapids-cmake/test/generate_resource_spec.cmake b/rapids-cmake/test/generate_resource_spec.cmake index 7bc0f7ac..03ba8468 100644 --- a/rapids-cmake/test/generate_resource_spec.cmake +++ b/rapids-cmake/test/generate_resource_spec.cmake @@ -90,8 +90,7 @@ function(rapids_test_generate_resource_spec DESTINATION filepath) string(REPLACE "\n" "\n " compile_output "${compile_output}") message(FATAL_ERROR "rapids_test_generate_resource_spec failed to build detection executable.\nrapids_test_generate_resource_spec compile[${compiler} ${compile_options} ${link_options}] failure details are:\n ${compile_output}" ) - else() - execute_process(COMMAND ${eval_exe} OUTPUT_FILE "${filepath}" COMMAND_ERROR_IS_FATAL ANY) endif() + execute_process(COMMAND ${eval_exe} OUTPUT_FILE "${filepath}" COMMAND_ERROR_IS_FATAL ANY) endfunction() From 1c8d5d905deda1b19104403a7c3b582f79e5aefd Mon Sep 17 00:00:00 2001 From: Kyle Edwards Date: Tue, 6 Feb 2024 18:51:58 -0500 Subject: [PATCH 07/10] Use RESULT_VARIABLE --- rapids-cmake/test/generate_resource_spec.cmake | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/rapids-cmake/test/generate_resource_spec.cmake b/rapids-cmake/test/generate_resource_spec.cmake index 03ba8468..b321af17 100644 --- a/rapids-cmake/test/generate_resource_spec.cmake +++ b/rapids-cmake/test/generate_resource_spec.cmake @@ -83,13 +83,13 @@ function(rapids_test_generate_resource_spec DESTINATION filepath) execute_process(COMMAND "${compiler}" "${eval_file}" ${compile_options} ${link_options} -o "${eval_exe}" OUTPUT_VARIABLE compile_output - ERROR_VARIABLE compile_output COMMAND_ERROR_IS_FATAL ANY) - endif() + ERROR_VARIABLE compile_output RESULT_VARIABLE result) - if(NOT EXISTS "${eval_exe}") - string(REPLACE "\n" "\n " compile_output "${compile_output}") - message(FATAL_ERROR "rapids_test_generate_resource_spec failed to build detection executable.\nrapids_test_generate_resource_spec compile[${compiler} ${compile_options} ${link_options}] failure details are:\n ${compile_output}" - ) + if(NOT result EQUAL 0) + string(REPLACE "\n" "\n " compile_output "${compile_output}") + message(FATAL_ERROR "rapids_test_generate_resource_spec failed to build detection executable.\nrapids_test_generate_resource_spec compile[${compiler} ${compile_options} ${link_options}] failure details are:\n ${compile_output}" + ) + endif() endif() execute_process(COMMAND ${eval_exe} OUTPUT_FILE "${filepath}" COMMAND_ERROR_IS_FATAL ANY) From 363ac82c984a6c4ddb09ca54eb89eaed58d531d4 Mon Sep 17 00:00:00 2001 From: Kyle Edwards Date: Tue, 6 Feb 2024 19:07:32 -0500 Subject: [PATCH 08/10] Fix typo --- rapids-cmake/test/generate_resource_spec.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rapids-cmake/test/generate_resource_spec.cmake b/rapids-cmake/test/generate_resource_spec.cmake index b321af17..02609412 100644 --- a/rapids-cmake/test/generate_resource_spec.cmake +++ b/rapids-cmake/test/generate_resource_spec.cmake @@ -71,7 +71,7 @@ function(rapids_test_generate_resource_spec DESTINATION filepath) file(MAKE_DIRECTORY "${PROJECT_BINARY_DIR}/rapids-cmake/") if(CUDAToolkit_FOUND) - set(cuda_include_options ${CUDATookit_INCLUDE_DIRS}) + set(cuda_include_options ${CUDAToolkit_INCLUDE_DIRS}) list(TRANSFORM cuda_include_options PREPEND "-I") set(compile_options ${cuda_include_options} "-DHAVE_CUDA") endif() From 83677254bdcc676d7cc6beb90231b01c7c96f4a2 Mon Sep 17 00:00:00 2001 From: Kyle Edwards Date: Tue, 6 Feb 2024 19:14:20 -0500 Subject: [PATCH 09/10] Fix tests --- testing/test/install_relocatable-complex/tests/CMakeLists.txt | 2 +- testing/test/install_relocatable-include-in-all.cmake | 2 +- testing/test/install_relocatable-simple.cmake | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/testing/test/install_relocatable-complex/tests/CMakeLists.txt b/testing/test/install_relocatable-complex/tests/CMakeLists.txt index 8ed76f13..5079b777 100644 --- a/testing/test/install_relocatable-complex/tests/CMakeLists.txt +++ b/testing/test/install_relocatable-complex/tests/CMakeLists.txt @@ -37,7 +37,7 @@ 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}")]===]) +set(execute_process_match_string [===[execute_process(COMMAND ./generate_ctest_json OUTPUT_FILE "${CTEST_RESOURCE_SPEC_FILE}" COMMAND_ERROR_IS_FATAL ANY)]===]) 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") diff --git a/testing/test/install_relocatable-include-in-all.cmake b/testing/test/install_relocatable-include-in-all.cmake index 06227a5e..ba9d36a4 100644 --- a/testing/test/install_relocatable-include-in-all.cmake +++ b/testing/test/install_relocatable-include-in-all.cmake @@ -50,7 +50,7 @@ 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}")]===]) +set(execute_process_match_string [===[execute_process(COMMAND ./generate_ctest_json OUTPUT_FILE "${CTEST_RESOURCE_SPEC_FILE}" COMMAND_ERROR_IS_FATAL ANY)]===]) 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") diff --git a/testing/test/install_relocatable-simple.cmake b/testing/test/install_relocatable-simple.cmake index 387ee13d..5432a2f2 100644 --- a/testing/test/install_relocatable-simple.cmake +++ b/testing/test/install_relocatable-simple.cmake @@ -47,7 +47,7 @@ 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}")]===]) +set(execute_process_match_string [===[execute_process(COMMAND ./generate_ctest_json OUTPUT_FILE "${CTEST_RESOURCE_SPEC_FILE}" COMMAND_ERROR_IS_FATAL ANY)]===]) 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") From 3dbb62694685c6fb5e664b414cb124ec044514d0 Mon Sep 17 00:00:00 2001 From: Kyle Edwards Date: Tue, 6 Feb 2024 19:22:43 -0500 Subject: [PATCH 10/10] Update copyright --- testing/test/install_relocatable-complex/tests/CMakeLists.txt | 2 +- testing/test/install_relocatable-include-in-all.cmake | 2 +- testing/test/install_relocatable-simple.cmake | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/testing/test/install_relocatable-complex/tests/CMakeLists.txt b/testing/test/install_relocatable-complex/tests/CMakeLists.txt index 5079b777..8611d559 100644 --- a/testing/test/install_relocatable-complex/tests/CMakeLists.txt +++ b/testing/test/install_relocatable-complex/tests/CMakeLists.txt @@ -1,5 +1,5 @@ #============================================================================= -# Copyright (c) 2023, NVIDIA CORPORATION. +# Copyright (c) 2023-2024, NVIDIA CORPORATION. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/testing/test/install_relocatable-include-in-all.cmake b/testing/test/install_relocatable-include-in-all.cmake index ba9d36a4..7a696a66 100644 --- a/testing/test/install_relocatable-include-in-all.cmake +++ b/testing/test/install_relocatable-include-in-all.cmake @@ -1,5 +1,5 @@ #============================================================================= -# Copyright (c) 2022-2023, NVIDIA CORPORATION. +# Copyright (c) 2022-2024, NVIDIA CORPORATION. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/testing/test/install_relocatable-simple.cmake b/testing/test/install_relocatable-simple.cmake index 5432a2f2..9330eadc 100644 --- a/testing/test/install_relocatable-simple.cmake +++ b/testing/test/install_relocatable-simple.cmake @@ -1,5 +1,5 @@ #============================================================================= -# Copyright (c) 2022-2023, NVIDIA CORPORATION. +# Copyright (c) 2022-2024, NVIDIA CORPORATION. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License.