Fix OpenMP for osx

This commit is contained in:
Sebastian Messmer 2018-05-20 15:00:25 -07:00
parent a087f7dc8a
commit 635a6c7bcd
2 changed files with 17 additions and 8 deletions

View File

@ -35,6 +35,7 @@ Requirements
- SSL development libraries (including development headers, e.g. libssl-dev) - SSL development libraries (including development headers, e.g. libssl-dev)
- libFUSE version >= 2.8.6 (including development headers), on Mac OS X instead install osxfuse from https://osxfuse.github.io/ - libFUSE version >= 2.8.6 (including development headers), on Mac OS X instead install osxfuse from https://osxfuse.github.io/
- Python >= 2.7 - Python >= 2.7
- OpenMP
You can use the following commands to install these requirements You can use the following commands to install these requirements
@ -45,7 +46,7 @@ You can use the following commands to install these requirements
sudo dnf install git gcc-c++ cmake make libcurl-devel boost-devel boost-static openssl-devel fuse-devel python sudo dnf install git gcc-c++ cmake make libcurl-devel boost-devel boost-static openssl-devel fuse-devel python
# Macintosh # Macintosh
brew install cmake boost openssl brew install cmake boost openssl libomp
Build & Install Build & Install
--------------- ---------------

View File

@ -5,13 +5,21 @@ add_library(cryptopp dummy.cpp)
target_include_directories(cryptopp SYSTEM INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}) target_include_directories(cryptopp SYSTEM INTERFACE ${CMAKE_CURRENT_SOURCE_DIR})
if(NOT DISABLE_OPENMP) if(NOT DISABLE_OPENMP)
find_package(OpenMP) if(APPLE AND (CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang" OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
if(OPENMP_FOUND) AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL "7.0"
set(CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}) AND ßCMAKE_VERSION VERSION_LESS "3.8.0")
target_link_libraries(cryptopp PRIVATE ${OpenMP_CXX_FLAGS}) # Workaround because older cmake on apple doesn't support FindOpenMP
else(OPENMP_FOUND) set(CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} "-Xclang -fopenmp")
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.") target_link_libraries(cryptopp PRIVATE -lomp)
endif(OPENMP_FOUND) else()
find_package(OpenMP)
if(OPENMP_FOUND)
set(CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS})
target_link_libraries(cryptopp PRIVATE ${OpenMP_CXX_FLAGS})
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)
endif()
endif(NOT DISABLE_OPENMP) endif(NOT DISABLE_OPENMP)