From a087f7dc8abb1dc706e12cc51f8a89e63d7bbe03 Mon Sep 17 00:00:00 2001 From: Sebastian Messmer Date: Sun, 20 May 2018 14:15:18 -0700 Subject: [PATCH] Enforce OpenMP build by default, but allow disabling it with a cmake flag --- CMakeLists.txt | 1 + vendor/cryptopp/CMakeLists.txt | 17 +++++++++-------- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index fce1ad0c..e6445124 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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) diff --git a/vendor/cryptopp/CMakeLists.txt b/vendor/cryptopp/CMakeLists.txt index e4ba4835..07038838 100644 --- a/vendor/cryptopp/CMakeLists.txt +++ b/vendor/cryptopp/CMakeLists.txt @@ -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") - 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) +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) +endif(NOT DISABLE_OPENMP) set(BUILD_TESTING OFF)