2018-05-19 21:40:20 +02:00
|
|
|
project(mycryptopp)
|
|
|
|
|
2018-05-19 23:18:35 +02:00
|
|
|
add_library(cryptopp dummy.cpp)
|
2018-05-20 22:33:16 +02:00
|
|
|
# note: include directory is called vendor_cryptopp instead of cryptopp to avoid include clashes with system headers
|
2018-05-19 23:18:35 +02:00
|
|
|
target_include_directories(cryptopp SYSTEM INTERFACE ${CMAKE_CURRENT_SOURCE_DIR})
|
|
|
|
|
2018-07-09 04:58:52 +02:00
|
|
|
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
|
|
|
|
target_compile_definitions(cryptopp PUBLIC -DCRYPTOPP_DEBUG)
|
|
|
|
endif()
|
|
|
|
|
2018-05-20 23:15:18 +02:00
|
|
|
if(NOT DISABLE_OPENMP)
|
2018-05-21 17:09:37 +02:00
|
|
|
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.12.0")))
|
2018-05-21 00:00:25 +02:00
|
|
|
# Workaround because older cmake on apple doesn't support FindOpenMP
|
2018-05-21 17:09:37 +02:00
|
|
|
message(STATUS "Applying workaround for OSX OpenMP")
|
2018-09-24 07:22:47 +02:00
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Xclang -fopenmp")
|
2018-05-21 00:00:25 +02:00
|
|
|
target_link_libraries(cryptopp PRIVATE -lomp)
|
2018-09-26 09:21:21 +02:00
|
|
|
elseif(MSVC)
|
|
|
|
message(WARNING "MSVC does not support the OpenMP 4.0 standard used by Crypto++. Disabling OpenMP. This can cause degraded performance.")
|
2018-05-21 00:00:25 +02:00
|
|
|
else()
|
|
|
|
find_package(OpenMP)
|
2018-09-25 09:41:03 +02:00
|
|
|
if (NOT OpenMP_CXX_LIBRARIES)
|
|
|
|
# Older CMake didn't have OpenMP_CXX_LIBRARIES defined yet, but passed the library in OpenMP_CXX_FLAGS
|
2018-09-26 09:21:21 +02:00
|
|
|
message(STATUS "We are on an older CMake that does not set OpenMP_CXX_LIBRARIES. Setting it from OpenMP_CXX_FLAGS.")
|
2018-09-25 09:41:03 +02:00
|
|
|
set(OpenMP_CXX_LIBRARIES ${OpenMP_CXX_FLAGS})
|
|
|
|
endif()
|
2018-05-21 00:00:25 +02:00
|
|
|
if(OPENMP_FOUND)
|
2018-09-25 09:41:03 +02:00
|
|
|
message(STATUS "Using OpenMP flags: ${OpenMP_CXX_FLAGS}")
|
2018-09-24 07:22:47 +02:00
|
|
|
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})
|
2018-05-21 00:00:25 +02:00
|
|
|
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()
|
2018-05-21 09:27:49 +02:00
|
|
|
else(NOT DISABLE_OPENMP)
|
|
|
|
message(WARNING "OpenMP is disabled. This can cause degraded performance.")
|
2018-05-20 23:15:18 +02:00
|
|
|
endif(NOT DISABLE_OPENMP)
|
2018-05-19 23:18:35 +02:00
|
|
|
|
|
|
|
|
2018-05-19 20:22:51 +02:00
|
|
|
set(BUILD_TESTING OFF)
|
2018-05-19 21:40:20 +02:00
|
|
|
set(BUILD_DOCUMENTATION OFF)
|
|
|
|
set(BUILD_SHARED OFF)
|
|
|
|
set(BUILD_STATIC ON)
|
2018-05-20 22:33:16 +02:00
|
|
|
add_subdirectory(vendor_cryptopp EXCLUDE_FROM_ALL)
|
2018-05-19 21:40:20 +02:00
|
|
|
|
|
|
|
target_link_libraries(cryptopp PRIVATE cryptopp-static)
|