comparison Aws/CMakeLists.txt @ 38:9c0dfd10d5d0

statically link against libcrypto++
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 20 Jan 2021 12:35:23 +0100
parents 8a7a5defd5d0
children 50d0be413c42
comparison
equal deleted inserted replaced
37:f55b2afdf53d 38:9c0dfd10d5d0
8 8
9 include(CheckIncludeFileCXX) 9 include(CheckIncludeFileCXX)
10 10
11 set(ORTHANC_FRAMEWORK_SOURCE "hg" CACHE STRING "orthanc source") 11 set(ORTHANC_FRAMEWORK_SOURCE "hg" CACHE STRING "orthanc source")
12 set(ORTHANC_FRAMEWORK_VERSION "1.8.2" CACHE STRING "orthanc framework version") 12 set(ORTHANC_FRAMEWORK_VERSION "1.8.2" CACHE STRING "orthanc framework version")
13 set(USE_VCPKG_PACKAGES ON CACHE BOOL "Use vcpkg to link against crypto++ and AWS SDK") 13 set(USE_VCPKG_PACKAGES ON CACHE BOOL "Use Microsoft vcpkg to link against crypto++ and AWS SDK")
14 set(STATIC_AWS_CLIENT ON CACHE BOOL "Statically link against AWS client library (only if USE_VCPKG_PACKAGES=OFF)") 14 set(STATIC_AWS_CLIENT ON CACHE BOOL "Statically link against AWS client library (only if USE_VCPKG_PACKAGES=OFF)")
15 set(ALLOW_DOWNLOADS ON) 15 set(USE_SYSTEM_CRYPTOPP ON CACHE BOOL "Use the system version of crypto++")
16 16
17 # Download and setup the Orthanc framework 17 # Download and setup the Orthanc framework
18 set(ALLOW_DOWNLOADS ON)
18 include(${CMAKE_SOURCE_DIR}/../Common/Resources/DownloadOrthancFramework.cmake) 19 include(${CMAKE_SOURCE_DIR}/../Common/Resources/DownloadOrthancFramework.cmake)
19 20
20 include(${ORTHANC_FRAMEWORK_ROOT}/../Resources/CMake/OrthancFrameworkParameters.cmake) 21 include(${ORTHANC_FRAMEWORK_ROOT}/../Resources/CMake/OrthancFrameworkParameters.cmake)
21 22
23 set(ENABLE_WEB_CLIENT ON) # Access options related to curl
22 set(ENABLE_GOOGLE_TEST ON) 24 set(ENABLE_GOOGLE_TEST ON)
23 set(ORTHANC_FRAMEWORK_PLUGIN ON) 25 set(ORTHANC_FRAMEWORK_PLUGIN ON)
24 set(ENABLE_MODULE_IMAGES OFF) 26 set(ENABLE_MODULE_IMAGES OFF)
25 set(ENABLE_MODULE_JOBS OFF) 27 set(ENABLE_MODULE_JOBS OFF)
26 set(ENABLE_MODULE_DICOM OFF) 28 set(ENABLE_MODULE_DICOM OFF)
41 ${ORTHANC_FRAMEWORK_ROOT}/../../OrthancServer/Plugins/Include 43 ${ORTHANC_FRAMEWORK_ROOT}/../../OrthancServer/Plugins/Include
42 ${ORTHANC_FRAMEWORK_ROOT}/../../OrthancServer/Plugins/Samples/Common 44 ${ORTHANC_FRAMEWORK_ROOT}/../../OrthancServer/Plugins/Samples/Common
43 ) 45 )
44 46
45 47
46 if (USE_VCPKG_PACKAGES) 48 if (NOT STATIC_BUILD AND USE_VCPKG_PACKAGES)
49 # Use vcpkg by Microsoft
47 find_package(cryptopp CONFIG REQUIRED) 50 find_package(cryptopp CONFIG REQUIRED)
48 find_package(AWSSDK REQUIRED COMPONENTS s3) 51 find_package(AWSSDK REQUIRED COMPONENTS s3)
49 include_directories(${WASTORAGE_INCLUDE_DIR}) 52 include_directories(${WASTORAGE_INCLUDE_DIR})
50 set(CRYPTOPP_LIBRARIES cryptopp-static) 53 set(CRYPTOPP_LIBRARIES cryptopp-static)
51 else() 54 else()
52 ## 55 include(${CMAKE_SOURCE_DIR}/../Common/CryptoPPConfiguration.cmake)
53 ## Inclusion of system-wide crypto++ 56
54 ##
55 check_include_file_cxx(cryptopp/cryptlib.h HAVE_CRYPTOPP_H)
56 if (NOT HAVE_CRYPTOPP_H)
57 message(FATAL_ERROR "Please install the libcrypto++-dev package")
58 endif()
59
60 include(CheckCXXSymbolExists)
61 set(CMAKE_REQUIRED_LIBRARIES cryptopp)
62 check_cxx_symbol_exists("CryptoPP::SHA1::InitState" cryptopp/sha.h HAVE_LIBCRYPTOPP)
63 if (NOT HAVE_LIBCRYPTOPP)
64 message(FATAL_ERROR "Unable to find the cryptopp library")
65 endif()
66
67 set(CRYPTOPP_LIBRARIES cryptopp)
68
69 ## 57 ##
70 ## Building the C++ SDK for Amazon AWS 58 ## Building the C++ SDK for Amazon AWS
71 ## WARNING: This is *not* compatible with Ninja (yet) 59 ## WARNING: This is *not* compatible with Ninja (yet)
72 ## 60 ##
73 if (STATIC_AWS_CLIENT) 61 if (STATIC_AWS_CLIENT)
74 set(Flags -DBUILD_SHARED_LIBS=OFF) # Create static library 62 set(Flags -DBUILD_SHARED_LIBS=OFF) # Create static library
75 else() 63 else()
76 set(Flags -DBUILD_SHARED_LIBS=ON) 64 set(Flags -DBUILD_SHARED_LIBS=ON)
77 endif() 65 endif()
78 66
79 include(ExternalProject) 67 include(ExternalProject)
80 externalproject_add(AwsSdkCpp 68 externalproject_add(AwsSdkCpp
81 GIT_REPOSITORY https://github.com/aws/aws-sdk-cpp 69 GIT_REPOSITORY https://github.com/aws/aws-sdk-cpp
82 GIT_TAG 1.8.42 70 GIT_TAG 1.8.127
83 71
84 CMAKE_ARGS 72 CMAKE_ARGS
85 -DBUILD_ONLY=s3 #-DBUILD_ONLY=s3;transfer 73 -DBUILD_ONLY=s3 #-DBUILD_ONLY=s3;transfer
86 -DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE} 74 -DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE}
87 -DENABLE_TESTING=OFF 75 -DENABLE_TESTING=OFF
131 ${CMAKE_SOURCE_DIR}/../Common/EncryptionConfigurator.cpp 119 ${CMAKE_SOURCE_DIR}/../Common/EncryptionConfigurator.cpp
132 ${CMAKE_SOURCE_DIR}/../Common/EncryptionConfigurator.h 120 ${CMAKE_SOURCE_DIR}/../Common/EncryptionConfigurator.h
133 ${ORTHANC_FRAMEWORK_ROOT}/../../OrthancServer/Plugins/Samples/Common/OrthancPluginCppWrapper.cpp 121 ${ORTHANC_FRAMEWORK_ROOT}/../../OrthancServer/Plugins/Samples/Common/OrthancPluginCppWrapper.cpp
134 122
135 ${ORTHANC_CORE_SOURCES} 123 ${ORTHANC_CORE_SOURCES}
124 ${CRYPTOPP_SOURCES}
136 ) 125 )
137 126
138 add_library(OrthancAwsS3Storage SHARED 127 add_library(OrthancAwsS3Storage SHARED
139 AwsS3StoragePlugin.cpp 128 AwsS3StoragePlugin.cpp
140 AwsS3StoragePlugin.h 129 AwsS3StoragePlugin.h
170 ${CRYPTOPP_LIBRARIES} 159 ${CRYPTOPP_LIBRARIES}
171 ${AWSSDK_LINK_LIBRARIES} 160 ${AWSSDK_LINK_LIBRARIES}
172 ) 161 )
173 162
174 163
175 if (NOT USE_VCPKG_PACKAGES) 164 if (STATIC_BUILD OR NOT USE_VCPKG_PACKAGES)
176 add_dependencies(OrthancAwsS3Storage AwsSdkCpp) 165 add_dependencies(OrthancAwsS3Storage AwsSdkCpp)
177 add_dependencies(UnitTests AwsSdkCpp) 166 add_dependencies(UnitTests AwsSdkCpp)
178 endif() 167 endif()