From 57146de728d4b6f3723f8bf55f8db960cab200ad Mon Sep 17 00:00:00 2001 From: Ranjith Ramakrishnan Date: Tue, 26 Jul 2022 16:04:00 -0700 Subject: [PATCH] SWDEV-346857 - Find ROCM_PATH based on config file path rather than hardcoding As per the requirements in SWDEV-287540, config files should not have hard coded /opt/rocm path Instead of setting ROCM_PATH to /opt/rocm, used hip-config file path to find the rocm path Validated by printing the CONFIG_PATH and is coming as/opt/rocm-ver/lib/cmake/hip/hip-config.cmake So need four level up,with file name in the path Change-Id: Iac01d3a0c0168138c777551165705ed56cf6c3b1 [ROCm/clr commit: f61a87ebb222beb55310a5da12b0e766e6b3afbe] --- projects/clr/hipamd/hip-config.cmake.in | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/projects/clr/hipamd/hip-config.cmake.in b/projects/clr/hipamd/hip-config.cmake.in index b860993d87..eb7c0c4b94 100755 --- a/projects/clr/hipamd/hip-config.cmake.in +++ b/projects/clr/hipamd/hip-config.cmake.in @@ -114,7 +114,13 @@ if(WIN32) else() # Linux - set a default path for ROCM_PATH if(NOT DEFINED ROCM_PATH) - set(ROCM_PATH /opt/rocm) + # TODO:once file reorg backward compatibility is turned off, + # ROCM_PATH can be set to PACKAGE_PREFIX_DIR. + # Time being find the ROCM_PATH based on hip-config file + # Following will provide the path with filename with symlinks resolved. + # Move four level up to get rocm path + file(REAL_PATH ${CMAKE_CURRENT_LIST_FILE} CONFIG_PATH) + get_filename_component(ROCM_PATH "${CONFIG_PATH}/../../../../" ABSOLUTE) endif() #If HIP is not installed under ROCm, need this to find HSA assuming HSA is under ROCm @@ -187,8 +193,7 @@ if(NOT WIN32) find_dependency(Threads) endif() -#get_filename_component cannot resolve the symlinks if called from /opt/rocm/lib/hip -#and do three level up again +# From hip config directory, do three level up get_filename_component(_DIR "${CMAKE_CURRENT_LIST_DIR}" REALPATH) get_filename_component(_IMPORT_PREFIX "${_DIR}/../../../" REALPATH)