From 733d918cdcc1a0d69a8f053e08550489f74a4e88 Mon Sep 17 00:00:00 2001 From: Ioannis Assiouras Date: Thu, 22 Aug 2024 20:06:19 +0100 Subject: [PATCH] SWDEV-476915 - Set the CMAKE_PREFIX_PATH in hip-lang-config.cmake hip-lang package is part of the toolchain and shouldn't have to rely on the user's settings for CMAKE_PREFIX_PATH in order to find lower level dependencies. This commit also sets the CMAKE_SIZEOF_VOID_P variable before searching for hsa and comgr dependencies. This is a workaround to force cmake to include lib64 directories in the search. Change-Id: Ie7d10bd4078929275659aae10ec270816d4a30f5 [ROCm/hip commit: a885727cce91b34479dc4da03632566ce489b395] --- projects/hip/hip-lang-config.cmake.in | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/projects/hip/hip-lang-config.cmake.in b/projects/hip/hip-lang-config.cmake.in index 0c31ef70c5..10a49b39ef 100644 --- a/projects/hip/hip-lang-config.cmake.in +++ b/projects/hip/hip-lang-config.cmake.in @@ -60,6 +60,23 @@ endif() set(HIP_COMPILER "@HIP_COMPILER@") set(HIP_RUNTIME "@HIP_RUNTIME@") +if (NOT @BUILD_SHARED_LIBS@) + list(APPEND CMAKE_PREFIX_PATH "${PACKAGE_PREFIX_DIR}" "${PACKAGE_PREFIX_DIR}/lib/llvm") + + # Setting CMAKE_SIZEOF_VOID_P is a workaround to force cmake + # include searching in lib64 directories for dependencies. + set(CMAKE_SIZEOF_VOID_P_OLD ${CMAKE_SIZEOF_VOID_P}) + set(CMAKE_SIZEOF_VOID_P 8) + + find_dependency(hsa-runtime64) + find_dependency(amd_comgr) + + # Restore the original CMAKE_PREFIX_PATH and CMAKE_SIZEOF_VOID_P + # to avoid leaking the settings back to the project. + set(CMAKE_SIZEOF_VOID_P ${CMAKE_SIZEOF_VOID_P_OLD}) + list(REMOVE_AT CMAKE_PREFIX_PATH -2 -1) +endif() + include( "${CMAKE_CURRENT_LIST_DIR}/hip-lang-targets.cmake" ) # Find the hip-lang config file path with symlinks resolved