Fix wrong handling of OpenMP on osx

This commit is contained in:
Sebastian Messmer 2018-09-23 22:22:47 -07:00
parent 9102c06356
commit a10dd04dea

View File

@ -13,14 +13,14 @@ if(NOT DISABLE_OPENMP)
AND ((CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL "7.0") AND (CMAKE_VERSION VERSION_LESS "3.12.0")))
# Workaround because older cmake on apple doesn't support FindOpenMP
message(STATUS "Applying workaround for OSX OpenMP")
set(CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} "-Xclang -fopenmp")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Xclang -fopenmp")
target_link_libraries(cryptopp PRIVATE -lomp)
else()
message(STATUS "Using OpenMP")
find_package(OpenMP)
if(OPENMP_FOUND)
set(CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS})
target_link_libraries(cryptopp PRIVATE ${OpenMP_CXX_FLAGS})
message(STATUS "Using OpenMP library: ${OpenMP_CXX_LIBRARIES}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
target_link_libraries(cryptopp PRIVATE ${OpenMP_CXX_LIBRARIES})
else(OPENMP_FOUND)
message(FATAL_ERROR "Did not find OpenMP. Build with -DDISABLE_OPENMP=ON if you want to allow this and are willing to take the performance hit.")
endif(OPENMP_FOUND)