From 6903b309e462ceb60a40ee0ba9bf5391d2ab7a4e Mon Sep 17 00:00:00 2001 From: Wayne Franz Date: Mon, 30 Dec 2024 15:18:42 -0500 Subject: [PATCH] Avoid evaluating CMake LINK_LANGUAGE generator expressions in CMake <3.18 Recently, we added CMake HIP Language support. That change introduced generator expressions that use the LINK_LANGUAGE keyword. This keyword is only supported in CMake 3.18+. The minimum CMake version we require is 3.16. As a result, if you built with CMake 3.16 - 3.18, you'd get a build failure. This change adds checks around all the spots where the LINK_LANGUAGE keyword is used to avoid this problem. It also adds a description of the CMake HIP Language support to the changelog (previously overlooked). --- CHANGELOG.md | 1 + benchmark/CMakeLists.txt | 8 +++++--- example/CMakeLists.txt | 8 +++++--- test/CMakeLists.txt | 8 +++++--- test/rocprim/CMakeLists.txt | 8 +++++--- 5 files changed, 21 insertions(+), 12 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0db0f029e..088cf0de1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -31,6 +31,7 @@ Full documentation for rocPRIM is available at [https://rocm.docs.amd.com/projec * Removed HIP-CPU support. HIP-CPU support was experimental and broken. * Changed the C++ version from 14 to 17. C++14 will be deprecated in the next major release. +* You can use CMake HIP language support with CMake 3.18 and later. To use HIP language support, run `cmake` with `-DUSE_HIPCXX=ON` instead of setting the `CXX` variable to the path to a HIP-aware compiler. ### Resolved issues diff --git a/benchmark/CMakeLists.txt b/benchmark/CMakeLists.txt index 64975916d..700c4bbb5 100644 --- a/benchmark/CMakeLists.txt +++ b/benchmark/CMakeLists.txt @@ -82,10 +82,12 @@ function(add_rocprim_benchmark BENCHMARK_SOURCE) benchmark::benchmark ) - target_link_libraries(${BENCHMARK_TARGET} - PRIVATE + if(USE_HIPCXX) + target_link_libraries(${BENCHMARK_TARGET} + PRIVATE $,hip::host,hip::device> - ) + ) + endif() target_compile_options(${BENCHMARK_TARGET} PRIVATE diff --git a/example/CMakeLists.txt b/example/CMakeLists.txt index b9edcae00..df3400283 100644 --- a/example/CMakeLists.txt +++ b/example/CMakeLists.txt @@ -33,10 +33,12 @@ function(add_rocprim_example EXAMPLE_SOURCE) PRIVATE rocprim ) - target_link_libraries(${EXAMPLE_TARGET} - PRIVATE + if(USE_HIPCXX) + target_link_libraries(${EXAMPLE_TARGET} + PRIVATE $,hip::host,hip::device> - ) + ) + endif() set_target_properties(${EXAMPLE_TARGET} PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/example" diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 31538a58d..d313be0c9 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -76,10 +76,12 @@ function(add_hip_test TEST_NAME TEST_SOURCES) PRIVATE rocprim ) - target_link_libraries(${TEST_TARGET} - PRIVATE + if(USE_HIPCXX) + target_link_libraries(${TEST_TARGET} + PRIVATE $,hip::host,hip::device> - ) + ) + endif() target_compile_options(${TEST_TARGET} PRIVATE diff --git a/test/rocprim/CMakeLists.txt b/test/rocprim/CMakeLists.txt index d31e8f9ce..990a9cdf3 100644 --- a/test/rocprim/CMakeLists.txt +++ b/test/rocprim/CMakeLists.txt @@ -55,10 +55,12 @@ function(add_rocprim_test_internal TEST_NAME TEST_SOURCES TEST_TARGET) GTest::Main ) - target_link_libraries(${TEST_TARGET} - PRIVATE + if(USE_HIPCXX) + target_link_libraries(${TEST_TARGET} + PRIVATE $,hip::host,hip::device> - ) + ) + endif() target_compile_options(${TEST_TARGET} PRIVATE