|
22 | 22 |
|
23 | 23 | cmake_minimum_required( VERSION 3.16.8 ) |
24 | 24 |
|
| 25 | +function( apply_omp_settings lib_target_ ) |
| 26 | + if (CMAKE_CXX_COMPILER_ID MATCHES "Clang" AND TARGET OpenMP::OpenMP_CXX) |
| 27 | + set_target_properties( ${lib_target_} PROPERTIES |
| 28 | + BUILD_RPATH "${HIP_CLANG_ROOT}/lib" |
| 29 | + ) |
| 30 | + set_target_properties( ${lib_target_} PROPERTIES |
| 31 | + INSTALL_RPATH "$ORIGIN/../llvm/lib" |
| 32 | + ) |
| 33 | + elseif(CMAKE_CXX_COMPILER_ID MATCHES "Clang" AND TARGET OpenMP::omp) |
| 34 | + set_target_properties( ${lib_target_} PROPERTIES |
| 35 | + BUILD_RPATH "${HIP_CLANG_ROOT}/${openmp_LIB_DIR}" |
| 36 | + ) |
| 37 | + set_target_properties( ${lib_target_} PROPERTIES |
| 38 | + INSTALL_RPATH "$ORIGIN/../llvm/${openmp_LIB_DIR}" |
| 39 | + ) |
| 40 | + endif() |
| 41 | +endfunction() |
| 42 | + |
25 | 43 | # This has to be initialized before the project() command appears |
26 | 44 | # Set the default of CMAKE_BUILD_TYPE to be release, unless user specifies with -D. MSVC_IDE does not use CMAKE_BUILD_TYPE |
27 | 45 | if( NOT DEFINED CMAKE_CONFIGURATION_TYPES AND NOT DEFINED CMAKE_BUILD_TYPE ) |
@@ -69,20 +87,21 @@ endif() |
69 | 87 | set(THREADS_PREFER_PTHREAD_FLAG ON) |
70 | 88 | find_package(Threads REQUIRED) |
71 | 89 |
|
72 | | -# if it fails to find OpenMP compile and link flags in strange configurations it can just use non-parallel reference computation |
73 | | -# if there is no omp.h to find the client compilation will fail and this should be obvious, used to be REQUIRED |
74 | | -find_package(OpenMP) |
75 | | - |
76 | | -if (TARGET OpenMP::OpenMP_CXX) |
77 | | - set( COMMON_LINK_LIBS "OpenMP::OpenMP_CXX") |
78 | | - get_filename_component(LIBOMP_PATH "${OpenMP_omp_LIBRARY}" PATH) |
79 | | - if (NOT WIN32) |
80 | | - list( APPEND COMMON_LINK_LIBS "-Wl,-rpath=${LIBOMP_PATH}") |
81 | | - endif() |
| 90 | +if (CMAKE_CXX_COMPILER_ID MATCHES "Clang") |
| 91 | + # Look for openmp config in ROCm install to populate openmp_LIB_DIR and openmp_LIB_INSTALL_DIR |
| 92 | + find_package(OpenMP CONFIG PATHS "${HIP_CLANG_ROOT}/lib/cmake") |
82 | 93 | endif() |
83 | 94 |
|
84 | | -if (WIN32) |
85 | | - list( APPEND COMMON_LINK_LIBS "libomp") |
| 95 | +if (CMAKE_CXX_COMPILER_ID MATCHES "Clang" AND TARGET OpenMP::omp) |
| 96 | + set( COMMON_LINK_LIBS "OpenMP::omp") |
| 97 | + message(STATUS "Found openmp-config.cmake at ${OpenMP_DIR}") |
| 98 | +else() |
| 99 | + # if it fails to find OpenMP compile and link flags in strange configurations it can just use non-parallel reference computation |
| 100 | + # if there is no omp.h to find the client compilation will fail and this should be obvious, used to be REQUIRED |
| 101 | + find_package(OpenMP) |
| 102 | + if (TARGET OpenMP::OpenMP_CXX) |
| 103 | + set( COMMON_LINK_LIBS "OpenMP::OpenMP_CXX") |
| 104 | + endif() |
86 | 105 | endif() |
87 | 106 |
|
88 | 107 | if (TARGET Threads::Threads) |
|
0 commit comments