SWDEV-366831 - Use actual install path rather than using backward compatibility path

hip-config if invoked from backward compatibility path was providing package prefix directory as /opt/rocm-ver/hip.
Usage of backward compatibility path will result in error, since #warning messages are changed to #error
The change will provide the actual install path /opt/rocm-ver as package prefix directory

Change-Id: I4ac54a5ed9de01d5f40f456f20b76b60237b7d9e
This commit is contained in:
Ranjith Ramakrishnan
2023-02-23 09:49:05 -08:00
parent 705c56ed31
commit 9a7b2d0a88
+17 -15
View File
@@ -90,6 +90,21 @@ endif()
set(HIP_COMPILER "@HIP_COMPILER@")
set(HIP_RUNTIME "@HIP_RUNTIME@")
# NOTE: If hip-config is invoked from /opt/rocm-ver/hip/lib/cmake/hip/
# then PACKAGE_PREFIX_DIR will resolve to /opt/rocm-ver/hip, which is for backward compatibility
# The following will ensure PACKAGE_PREFIX_DIR will resolves to /opt/rocm-ver
# First find the real path to hip-config file with symlinks resolved
# Real Path : /opt/rocm-ver/lib/cmake/hip/hip-config.cmake
# Then go up 4 levels to get PACKAGE_PREFIX_DIR
# PACKAGE_PREFIX_DIR : /opt/rocm-ver
# TODO:once file reorg backward compatibility is turned off this can be removed.
if(IS_SYMLINK ${CMAKE_CURRENT_LIST_FILE})
get_filename_component(CONFIG_FILE_PATH "${CMAKE_CURRENT_LIST_FILE}" REALPATH)
get_filename_component(PACKAGE_PREFIX_DIR "${CONFIG_FILE_PATH}/../../../../" ABSOLUTE)
endif()
# end of TODO
set(HIP_PACKAGE_PREFIX_DIR ${PACKAGE_PREFIX_DIR})
set_and_check( hip_INCLUDE_DIR "@PACKAGE_INCLUDE_INSTALL_DIR@" )
set_and_check( hip_INCLUDE_DIRS "${hip_INCLUDE_DIR}" )
set_and_check( hip_LIB_INSTALL_DIR "@PACKAGE_LIB_INSTALL_DIR@" )
@@ -120,15 +135,7 @@ else()
# set a default path for ROCM_PATH
if(NOT DEFINED ROCM_PATH)
# 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
# Get the ROCM PATH in 2 steps as get_filename_component appears to process /../ textually
# first find the real path to hip-config file which doesn't have symbolic links
# Real Path : /opt/rocm-ver/lib/cmake/hip/hip-config.cmake
# then go up 4 levels get to /opt/rocm-ver
get_filename_component(CONFIG_PATH "${CMAKE_CURRENT_LIST_FILE}" REALPATH)
get_filename_component(ROCM_PATH "${CONFIG_PATH}/../../../../" ABSOLUTE)
set(ROCM_PATH ${PACKAGE_PREFIX_DIR})
endif()
endif()
@@ -169,12 +176,7 @@ if(NOT WIN32)
find_dependency(Threads)
endif()
# Find the real path to hip-config file with symlinks resolved
# Real Path : /opt/rocm-ver/lib/cmake/hip/hip-config.cmake
# Go up 4 levels to get /opt/rocm-ver
get_filename_component(_DIR "${CMAKE_CURRENT_LIST_FILE}" REALPATH)
get_filename_component(_IMPORT_PREFIX "${_DIR}/../../../../" ABSOLUTE)
set(_IMPORT_PREFIX ${HIP_PACKAGE_PREFIX_DIR})
# Right now this is only supported for amd platforms
set_target_properties(hip::host PROPERTIES
INTERFACE_COMPILE_DEFINITIONS "__HIP_PLATFORM_HCC__=1;__HIP_PLATFORM_AMD__=1"