diff --git a/projects/hip/CMakeLists.txt b/projects/hip/CMakeLists.txt index 818c75783e..edb8c2d238 100644 --- a/projects/hip/CMakeLists.txt +++ b/projects/hip/CMakeLists.txt @@ -217,9 +217,11 @@ if(HIP_PLATFORM STREQUAL "hcc") set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -L/opt/rocm/profiler/CXLActivityLogger/bin/x86_64 -lCXLActivityLogger") endif() add_library(hip_hcc SHARED ${SOURCE_FILES_RUNTIME}) - target_link_libraries(hip_hcc PRIVATE hc_am) add_library(hip_hcc_static STATIC ${SOURCE_FILES_RUNTIME}) - target_link_libraries(hip_hcc_static PRIVATE hc_am) + if(HIP_COMPILER STREQUAL "hcc") + target_link_libraries(hip_hcc PRIVATE hc_am) + target_link_libraries(hip_hcc_static PRIVATE hc_am) + endif() add_library(hip_device STATIC ${SOURCE_FILES_DEVICE}) string(REPLACE " " ";" HCC_CXX_FLAGS_LIST ${HCC_CXX_FLAGS}) diff --git a/projects/hip/hip-config.cmake.in b/projects/hip/hip-config.cmake.in index efcdf708bb..d5dc6803fc 100644 --- a/projects/hip/hip-config.cmake.in +++ b/projects/hip/hip-config.cmake.in @@ -48,7 +48,9 @@ set_and_check( hip_BIN_INSTALL_DIR "@PACKAGE_BIN_INSTALL_DIR@" ) set_and_check(hip_HIPCC_EXECUTABLE "${hip_BIN_INSTALL_DIR}/hipcc") set_and_check(hip_HIPCONFIG_EXECUTABLE "${hip_BIN_INSTALL_DIR}/hipconfig") -find_dependency(hcc) +if(HIP_COMPILER STREQUAL "hcc") + find_dependency(hcc) +endif() include( "${CMAKE_CURRENT_LIST_DIR}/hip-targets.cmake" ) set( hip_LIBRARIES hip::host hip::device) diff --git a/projects/hip/packaging/hip-targets-release.cmake b/projects/hip/packaging/hip-targets-release.cmake index ba0a5005f5..0ae7405cde 100644 --- a/projects/hip/packaging/hip-targets-release.cmake +++ b/projects/hip/packaging/hip-targets-release.cmake @@ -7,22 +7,36 @@ set(CMAKE_IMPORT_FILE_VERSION 1) # Import target "hip::hip_hcc_static" for configuration "Release" set_property(TARGET hip::hip_hcc_static APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE) +if(HIP_COMPILER STREQUAL "clang") +set_target_properties(hip::hip_hcc_static PROPERTIES + IMPORTED_LINK_INTERFACE_LANGUAGES_RELEASE "CXX" + IMPORTED_LOCATION_RELEASE "/opt/rocm/hip/lib/libhip_hcc_static.a" + ) +else() set_target_properties(hip::hip_hcc_static PROPERTIES IMPORTED_LINK_INTERFACE_LANGUAGES_RELEASE "CXX" IMPORTED_LINK_INTERFACE_LIBRARIES_RELEASE "hc_am" IMPORTED_LOCATION_RELEASE "/opt/rocm/hip/lib/libhip_hcc_static.a" ) +endif() list(APPEND _IMPORT_CHECK_TARGETS hip::hip_hcc_static ) list(APPEND _IMPORT_CHECK_FILES_FOR_hip::hip_hcc_static "/opt/rocm/hip/lib/libhip_hcc_static.a" ) # Import target "hip::hip_hcc" for configuration "Release" set_property(TARGET hip::hip_hcc APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE) +if(HIP_COMPILER STREQUAL "clang") +set_target_properties(hip::hip_hcc PROPERTIES + IMPORTED_LOCATION_RELEASE "/opt/rocm/hip/lib/libhip_hcc.so" + IMPORTED_SONAME_RELEASE "libhip_hcc.so" + ) +else() set_target_properties(hip::hip_hcc PROPERTIES IMPORTED_LINK_INTERFACE_LIBRARIES_RELEASE "hcc::hccrt;hcc::hc_am" IMPORTED_LOCATION_RELEASE "/opt/rocm/hip/lib/libhip_hcc.so" IMPORTED_SONAME_RELEASE "libhip_hcc.so" ) +endif() list(APPEND _IMPORT_CHECK_TARGETS hip::hip_hcc ) list(APPEND _IMPORT_CHECK_FILES_FOR_hip::hip_hcc "/opt/rocm/hip/lib/libhip_hcc.so" ) diff --git a/projects/hip/packaging/hip-targets.cmake b/projects/hip/packaging/hip-targets.cmake index 5aff2ca1ed..ec2fa716a6 100644 --- a/projects/hip/packaging/hip-targets.cmake +++ b/projects/hip/packaging/hip-targets.cmake @@ -75,9 +75,15 @@ set_target_properties(hip::host PROPERTIES # Create imported target hip::device add_library(hip::device INTERFACE IMPORTED) +if(HIP_COMPILER STREQUAL "clang") +set_target_properties(hip::device PROPERTIES + INTERFACE_LINK_LIBRARIES "hip::host;hip::hip_device" +) +else() set_target_properties(hip::device PROPERTIES INTERFACE_LINK_LIBRARIES "hip::host;hip::hip_device;hcc::hccrt;hcc::hc_am" ) +endif() if(CMAKE_VERSION VERSION_LESS 3.0.0) message(FATAL_ERROR "This file relies on consumers using CMake 3.0.0 or greater.")