Skip to content

Commit 3516fff

Browse files
authored
Avoid linking both libgomp and libomp in mixed clang/gfortran builds
1 parent 8fc2c2d commit 3516fff

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

ctest/CMakeLists.txt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,10 @@ else()
4040
c_${float_char}blas1.c)
4141
endif()
4242
target_link_libraries(x${float_char}cblat1 ${OpenBLAS_LIBNAME})
43+
if (USE_OPENMP AND (${CMAKE_Fortran_COMPILER_ID} STREQUAL GNU) AND (${CMAKE_C_COMPILER_ID} STREQUAL Clang))
44+
string(REGEX REPLACE "-fopenmp" "" CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS}")
45+
target_link_libraries(x${float_char}cblat1 omp pthread)
46+
endif()
4347
if(${CMAKE_SYSTEM_NAME} MATCHES "Linux" OR ${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD" OR ${CMAKE_SYSTEM_NAME} MATCHES "QNX")
4448
target_link_libraries(x${float_char}cblat1 m)
4549
endif()
@@ -65,6 +69,10 @@ else()
6569
constant.c)
6670
endif()
6771
target_link_libraries(x${float_char}cblat2 ${OpenBLAS_LIBNAME})
72+
if (USE_OPENMP AND (${CMAKE_Fortran_COMPILER_ID} STREQUAL GNU) AND (${CMAKE_C_COMPILER_ID} STREQUAL Clang))
73+
string(REGEX REPLACE "-fopenmp" "" CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS}")
74+
target_link_libraries(x${float_char}cblat2 omp pthread)
75+
endif()
6876
if(${CMAKE_SYSTEM_NAME} MATCHES "Linux" OR ${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD" OR ${CMAKE_SYSTEM_NAME} MATCHES "QNX")
6977
target_link_libraries(x${float_char}cblat2 m)
7078
endif()
@@ -90,6 +98,10 @@ else()
9098
constant.c)
9199
endif()
92100
target_link_libraries(x${float_char}cblat3 ${OpenBLAS_LIBNAME})
101+
if (USE_OPENMP AND (${CMAKE_Fortran_COMPILER_ID} STREQUAL GNU) AND (${CMAKE_C_COMPILER_ID} STREQUAL Clang))
102+
string(REGEX REPLACE "-fopenmp" "" CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS}")
103+
target_link_libraries(x${float_char}cblat3 omp pthread)
104+
endif()
93105
if(${CMAKE_SYSTEM_NAME} MATCHES "Linux" OR ${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD" OR ${CMAKE_SYSTEM_NAME} MATCHES "QNX")
94106
target_link_libraries(x${float_char}cblat3 m)
95107
endif()

0 commit comments

Comments
 (0)