CMake: Added logic to link openmp library given through OpenMP_libomp_LIBRARY cmake variable on linux.

Enabled command line option to link libiomp5.so or libomp.so or libgomp.so libraries using cmake.
Eg:- -DOpenMP_libomp_LIBRARY=<path to openmp library including library name>.
If we not set above variable, by default openmp library will be libomp.so for clang and libgomp.so for gcc compiler.

Change-Id: I5bffa10ff8351f5d10f0d543cbdf55aa16c84c90
This commit is contained in:
Chandrashekara K R
2024-05-16 17:59:04 +05:30
committed by Chandrashekara KR
parent 91bdf9a3eb
commit fa75ce725e
5 changed files with 32 additions and 6 deletions

View File

@@ -53,7 +53,11 @@ foreach(source ${testcpp_sources})
)
target_link_libraries(${exec_name} PRIVATE ${LDFLAGS} ${libblis_link})
if(THREADING_MODEL STREQUAL "openmp")
target_link_libraries(${exec_name} PRIVATE OpenMP::OpenMP_C)
if((NOT ${OpenMP_libomp_LIBRARY} STREQUAL "") AND (NOT WIN32))
target_link_libraries(${exec_name} PRIVATE ${OpenMP_libomp_LIBRARY})
else()
target_link_libraries(${exec_name} PRIVATE OpenMP::OpenMP_C)
endif()
endif()
set_target_properties(${exec_name} PROPERTIES CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
# Put all those targets under vendor-testcpp-targets folder name so that they appear all together in IDE.