diff options
author | Brad King <brad.king@kitware.com> | 2023-09-25 15:40:17 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2023-09-25 20:06:36 (GMT) |
commit | 479450512253e904c077c5e77fc04bc916466930 (patch) | |
tree | e71acb97b10464323f5ed2d3222f46a65a53d21a /Modules | |
parent | 09d759dc7f2e47eef1d04d77aec6f1ed45274937 (diff) | |
download | CMake-479450512253e904c077c5e77fc04bc916466930.zip CMake-479450512253e904c077c5e77fc04bc916466930.tar.gz CMake-479450512253e904c077c5e77fc04bc916466930.tar.bz2 |
HIP: Do not require hip-lang package for NVIDIA platform
ROCm may not install the `hip-lang` cmake package on NVIDIA platforms.
Skip verifying its presence. We do not use it for NVIDIA platforms anyway.
Fixes: #25271
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/CMakeDetermineHIPCompiler.cmake | 94 |
1 files changed, 49 insertions, 45 deletions
diff --git a/Modules/CMakeDetermineHIPCompiler.cmake b/Modules/CMakeDetermineHIPCompiler.cmake index 28a4f1d..bc85dbb 100644 --- a/Modules/CMakeDetermineHIPCompiler.cmake +++ b/Modules/CMakeDetermineHIPCompiler.cmake @@ -164,57 +164,61 @@ if(NOT CMAKE_HIP_COMPILER_ROCM_ROOT) message(FATAL_ERROR "Failed to find ROCm root directory.") endif() -# Normally implicit link information is not detected until ABI detection, -# but we need to populate CMAKE_HIP_LIBRARY_ARCHITECTURE to find hip-lang. -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) +if(CMAKE_HIP_PLATFORM STREQUAL "amd") + # For this platform we need the hip-lang cmake package. + + # Normally implicit link information is not detected until ABI detection, + # but we need to populate CMAKE_HIP_LIBRARY_ARCHITECTURE to find hip-lang. + 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 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" - "${CMAKE_HIP_COMPILER_ROCM_ROOT}/lib64" - ) + "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) - list(APPEND _CMAKE_HIP_COMPILER_ROCM_LIB_DIRS "${CMAKE_HIP_COMPILER_ROCM_ROOT}/lib/${CMAKE_HIP_LIBRARY_ARCHITECTURE}") + message(CONFIGURE_LOG + "Parsed HIP library architecture from compiler id output: ${CMAKE_HIP_LIBRARY_ARCHITECTURE}\n") 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() + 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) - 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" + set(_CMAKE_HIP_COMPILER_ROCM_LIB_DIRS + "${CMAKE_HIP_COMPILER_ROCM_ROOT}/lib" + "${CMAKE_HIP_COMPILER_ROCM_ROOT}/lib64" ) + 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(CMAKE_HIP_COMPILER_ROCM_LIB MATCHES "/lib64$" AND NOT DEFINED CMAKE_SIZEOF_VOID_P) + # We have not yet determined the target ABI but we need 'find_package' to + # search lib64 directories to find hip-lang CMake package dependencies. + # This will be replaced by ABI detection later. + set(CMAKE_HIP_SIZEOF_DATA_PTR 8) endif() - unset(_CMAKE_HIP_COMPILER_ROCM_LIB_DIRS) -endif() -if(CMAKE_HIP_COMPILER_ROCM_LIB MATCHES "/lib64$" AND NOT DEFINED CMAKE_SIZEOF_VOID_P) - # We have not yet determined the target ABI but we need 'find_package' to - # search lib64 directories to find hip-lang CMake package dependencies. - # This will be replaced by ABI detection later. - set(CMAKE_HIP_SIZEOF_DATA_PTR 8) endif() if (NOT _CMAKE_TOOLCHAIN_LOCATION) |