From 635a6c7bcd2553a8100e57a0d5e2a297d7bcf48b Mon Sep 17 00:00:00 2001 From: Sebastian Messmer Date: Sun, 20 May 2018 15:00:25 -0700 Subject: [PATCH] Fix OpenMP for osx --- README.md | 3 ++- vendor/cryptopp/CMakeLists.txt | 22 +++++++++++++++------- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 2dde4de1..e924b823 100644 --- a/README.md +++ b/README.md @@ -35,6 +35,7 @@ Requirements - 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/ - Python >= 2.7 + - OpenMP 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 # Macintosh - brew install cmake boost openssl + brew install cmake boost openssl libomp Build & Install --------------- diff --git a/vendor/cryptopp/CMakeLists.txt b/vendor/cryptopp/CMakeLists.txt index 07038838..15d2c1c2 100644 --- a/vendor/cryptopp/CMakeLists.txt +++ b/vendor/cryptopp/CMakeLists.txt @@ -5,13 +5,21 @@ add_library(cryptopp dummy.cpp) target_include_directories(cryptopp SYSTEM INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}) if(NOT DISABLE_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}) - 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) + if(APPLE AND (CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang" OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang") + AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL "7.0" + AND ßCMAKE_VERSION VERSION_LESS "3.8.0") + # Workaround because older cmake on apple doesn't support FindOpenMP + set(CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} "-Xclang -fopenmp") + target_link_libraries(cryptopp PRIVATE -lomp) + 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)