Enforce OpenMP build by default, but allow disabling it with a cmake flag

This commit is contained in:
Sebastian Messmer 2018-05-20 14:15:18 -07:00
parent 72f123e38e
commit a087f7dc8a
2 changed files with 10 additions and 8 deletions

View File

@ -17,6 +17,7 @@ require_clang_version(3.7)
# Default value is not to build test cases
option(BUILD_TESTING "build test cases" OFF)
option(CRYFS_UPDATE_CHECKS "let cryfs check for updates and security vulnerabilities" ON)
option(DISABLE_OPENMP "allow building without OpenMP libraries. This will cause performance degradations." OFF)
# Default value is to build in release mode
if(NOT CMAKE_BUILD_TYPE)

View File

@ -4,14 +4,15 @@ add_library(cryptopp dummy.cpp)
# note: include directory is called vendor_cryptopp instead of cryptopp to avoid include clashes with system headers
target_include_directories(cryptopp SYSTEM INTERFACE ${CMAKE_CURRENT_SOURCE_DIR})
find_package(OpenMP)
if(OPENMP_FOUND)
message(STATUS "Building crypto++ with OpenMP")
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(WARNING "Did not find OpenMP. Performance might be degraded.")
endif(OPENMP_FOUND)
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(NOT DISABLE_OPENMP)
set(BUILD_TESTING OFF)