summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2023-06-01 13:54:44 (GMT)
committerKitware Robot <kwrobot@kitware.com>2023-06-01 13:54:52 (GMT)
commitea82b2c3b5a8ec25c2b8dac1a9c60f5cb455ace0 (patch)
tree99444a2ce97b78886b771a81d248d8acf6883f8f
parent64a4d1f1040f260a90f6551f1d4aad04c6ec34ec (diff)
parentbae57dc28179022ba0b654368efc451e36db6396 (diff)
downloadCMake-ea82b2c3b5a8ec25c2b8dac1a9c60f5cb455ace0.zip
CMake-ea82b2c3b5a8ec25c2b8dac1a9c60f5cb455ace0.tar.gz
CMake-ea82b2c3b5a8ec25c2b8dac1a9c60f5cb455ace0.tar.bz2
Merge topic 'hip-multiarch'
bae57dc281 HIP: Fix search for hip-lang CMake package on multiarch distros cc737ae829 Linux: Provide multiarch library directory regex earlier Acked-by: Kitware Robot <kwrobot@kitware.com> Merge-request: !8525
-rw-r--r--Modules/CMakeDetermineHIPCompiler.cmake50
-rw-r--r--Modules/CMakeHIPCompiler.cmake.in1
-rw-r--r--Modules/CMakeHIPInformation.cmake2
-rw-r--r--Modules/Platform/Linux-Initialize.cmake2
-rw-r--r--Modules/Platform/Linux.cmake3
5 files changed, 47 insertions, 11 deletions
diff --git a/Modules/CMakeDetermineHIPCompiler.cmake b/Modules/CMakeDetermineHIPCompiler.cmake
index 6294d04..5e54502 100644
--- a/Modules/CMakeDetermineHIPCompiler.cmake
+++ b/Modules/CMakeDetermineHIPCompiler.cmake
@@ -3,6 +3,7 @@
include(${CMAKE_ROOT}/Modules/CMakeDetermineCompiler.cmake)
include(${CMAKE_ROOT}/Modules/CMakeParseImplicitLinkInfo.cmake)
+include(${CMAKE_ROOT}/Modules/CMakeParseLibraryArchitecture.cmake)
if( NOT ( ("${CMAKE_GENERATOR}" MATCHES "Make") OR
("${CMAKE_GENERATOR}" MATCHES "Ninja") ) )
@@ -102,13 +103,48 @@ endif()
if(NOT CMAKE_HIP_COMPILER_ROCM_ROOT)
message(FATAL_ERROR "Failed to find ROCm root directory.")
endif()
-if(NOT EXISTS "${CMAKE_HIP_COMPILER_ROCM_ROOT}/lib/cmake/hip-lang/hip-lang-config.cmake")
- message(FATAL_ERROR
- "The ROCm root directory:\n"
- " ${CMAKE_HIP_COMPILER_ROCM_ROOT}\n"
- "does not contain the HIP runtime CMake package, expected at:\n"
- " ${CMAKE_HIP_COMPILER_ROCM_ROOT}/lib/cmake/hip-lang/hip-lang-config.cmake\n"
- )
+
+# Normally implicit link information is not detected until
+cmake_parse_implicit_link_info("${CMAKE_HIP_COMPILER_PRODUCED_OUTPUT}"
+ _CMAKE_HIP_COMPILER_ID_IMPLICIT_LIBS
+ _CMAKE_HIP_COMPILER_ID_IMPLICIT_DIRS
+ _CMAKE_HIP_COMPILER_ID_IMPLICIT_FWKS
+ _CMAKE_HIP_COMPILER_ID_IMPLICIT_LOG
+ "" LANGUAGE HIP)
+message(CONFIGURE_LOG
+ "Parsed HIP implicit link information from compiler id output:\n${_CMAKE_HIP_COMPILER_ID_IMPLICIT_LOG}\n\n")
+cmake_parse_library_architecture(HIP "${_CMAKE_HIP_COMPILER_ID_IMPLICIT_DIRS}" "" CMAKE_HIP_LIBRARY_ARCHITECTURE)
+if(CMAKE_HIP_LIBRARY_ARCHITECTURE)
+ message(CONFIGURE_LOG
+ "Parsed HIP library architecture from compiler id output: ${CMAKE_HIP_LIBRARY_ARCHITECTURE}\n")
+endif()
+unset(_CMAKE_HIP_COMPILER_ID_IMPLICIT_LIBS)
+unset(_CMAKE_HIP_COMPILER_ID_IMPLICIT_DIRS)
+unset(_CMAKE_HIP_COMPILER_ID_IMPLICIT_FWKS)
+unset(_CMAKE_HIP_COMPILER_ID_IMPLICIT_LOG)
+
+if(NOT CMAKE_HIP_COMPILER_ROCM_LIB)
+ set(_CMAKE_HIP_COMPILER_ROCM_LIB_DIRS "${CMAKE_HIP_COMPILER_ROCM_ROOT}/lib")
+ if(CMAKE_HIP_LIBRARY_ARCHITECTURE)
+ list(APPEND _CMAKE_HIP_COMPILER_ROCM_LIB_DIRS "${CMAKE_HIP_COMPILER_ROCM_ROOT}/lib/${CMAKE_HIP_LIBRARY_ARCHITECTURE}")
+ endif()
+ foreach(dir IN LISTS _CMAKE_HIP_COMPILER_ROCM_LIB_DIRS)
+ if(EXISTS "${dir}/cmake/hip-lang/hip-lang-config.cmake")
+ set(CMAKE_HIP_COMPILER_ROCM_LIB "${dir}")
+ break()
+ endif()
+ endforeach()
+ if(NOT CMAKE_HIP_COMPILER_ROCM_LIB)
+ list(TRANSFORM _CMAKE_HIP_COMPILER_ROCM_LIB_DIRS APPEND "/cmake/hip-lang/hip-lang-config.cmake")
+ string(REPLACE ";" "\n " _CMAKE_HIP_COMPILER_ROCM_LIB_DIRS "${_CMAKE_HIP_COMPILER_ROCM_LIB_DIRS}")
+ message(FATAL_ERROR
+ "The ROCm root directory:\n"
+ " ${CMAKE_HIP_COMPILER_ROCM_ROOT}\n"
+ "does not contain the HIP runtime CMake package, expected at one of:\n"
+ " ${_CMAKE_HIP_COMPILER_ROCM_LIB_DIRS}\n"
+ )
+ endif()
+ unset(_CMAKE_HIP_COMPILER_ROCM_LIB_DIRS)
endif()
if (NOT _CMAKE_TOOLCHAIN_LOCATION)
diff --git a/Modules/CMakeHIPCompiler.cmake.in b/Modules/CMakeHIPCompiler.cmake.in
index c94153b..0fa5bf0 100644
--- a/Modules/CMakeHIPCompiler.cmake.in
+++ b/Modules/CMakeHIPCompiler.cmake.in
@@ -18,6 +18,7 @@ set(CMAKE_HIP_SIMULATE_VERSION "@CMAKE_HIP_SIMULATE_VERSION@")
@SET_MSVC_HIP_ARCHITECTURE_ID@
@_SET_CMAKE_HIP_COMPILER_SYSROOT@
set(CMAKE_HIP_COMPILER_ROCM_ROOT "@CMAKE_HIP_COMPILER_ROCM_ROOT@")
+set(CMAKE_HIP_COMPILER_ROCM_LIB "@CMAKE_HIP_COMPILER_ROCM_LIB@")
set(CMAKE_HIP_COMPILER_ENV_VAR "HIPCXX")
diff --git a/Modules/CMakeHIPInformation.cmake b/Modules/CMakeHIPInformation.cmake
index 33f8697..41a98db 100644
--- a/Modules/CMakeHIPInformation.cmake
+++ b/Modules/CMakeHIPInformation.cmake
@@ -142,7 +142,7 @@ set(CMAKE_HIP_INFORMATION_LOADED 1)
# Load the file and find the relevant HIP runtime.
if(NOT DEFINED _CMAKE_HIP_DEVICE_RUNTIME_TARGET)
- set(hip-lang_DIR "${CMAKE_HIP_COMPILER_ROCM_ROOT}/lib/cmake/hip-lang")
+ set(hip-lang_DIR "${CMAKE_HIP_COMPILER_ROCM_LIB}/cmake/hip-lang")
find_package(hip-lang CONFIG QUIET NO_DEFAULT_PATH REQUIRED)
endif()
if(DEFINED _CMAKE_HIP_DEVICE_RUNTIME_TARGET)
diff --git a/Modules/Platform/Linux-Initialize.cmake b/Modules/Platform/Linux-Initialize.cmake
new file mode 100644
index 0000000..6d9cbae
--- /dev/null
+++ b/Modules/Platform/Linux-Initialize.cmake
@@ -0,0 +1,2 @@
+# Match multiarch library directory names.
+set(CMAKE_LIBRARY_ARCHITECTURE_REGEX "[a-z0-9_]+(-[a-z0-9_]+)?-linux-gnu[a-z0-9_]*")
diff --git a/Modules/Platform/Linux.cmake b/Modules/Platform/Linux.cmake
index 3dc3ca3..1f2d8e6 100644
--- a/Modules/Platform/Linux.cmake
+++ b/Modules/Platform/Linux.cmake
@@ -80,9 +80,6 @@ else()
endif()
endif()
-# Match multiarch library directory names.
-set(CMAKE_LIBRARY_ARCHITECTURE_REGEX "[a-z0-9_]+(-[a-z0-9_]+)?-linux-gnu[a-z0-9_]*")
-
include(Platform/UnixPaths)
# Debian has lib32 and lib64 paths only for compatibility so they should not be