Mercurial > hg > orthanc-object-storage
annotate Aws/CMakeLists.txt @ 29:46621cb1bb48
fix build on ubuntu 16.04
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Tue, 08 Sep 2020 10:36:12 +0200 |
parents | 318c1442d9bd |
children | 8a7a5defd5d0 |
rev | line source |
---|---|
1 | 1 cmake_minimum_required(VERSION 2.8) |
2 | |
3 option(BUILD_SHARED_LIBS "Build shared libraries" ON) | |
4 | |
5 project(OrthancAwsS3Storage) | |
6 | |
2 | 7 set(PLUGIN_VERSION "mainline") |
1 | 8 |
9 include(CheckIncludeFileCXX) | |
10 | |
11 set(ORTHANC_FRAMEWORK_SOURCE "hg" CACHE STRING "orthanc source") | |
15 | 12 set(ORTHANC_FRAMEWORK_VERSION "1.7.3" CACHE STRING "orthanc framework version") |
26
471eaf5c5d39
USE_VCPKG_PACKAGES to avoid using vcpkg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
22
diff
changeset
|
13 set(USE_VCPKG_PACKAGES ON CACHE BOOL "Use vcpkg to link against crypto++ and AWS SDK") |
28 | 14 set(STATIC_AWS_CLIENT ON CACHE BOOL "Statically link against AWS client library (only if USE_VCPKG_PACKAGES=OFF)") |
1 | 15 set(ALLOW_DOWNLOADS ON) |
16 | |
17 # Download and setup the Orthanc framework | |
18 include(${CMAKE_SOURCE_DIR}/../Common/Resources/DownloadOrthancFramework.cmake) | |
19 | |
15 | 20 include(${ORTHANC_FRAMEWORK_ROOT}/../Resources/CMake/OrthancFrameworkParameters.cmake) |
1 | 21 |
22 set(ENABLE_GOOGLE_TEST ON) | |
23 set(ORTHANC_FRAMEWORK_PLUGIN ON) | |
22
319d41a22de4
more lightweight use of Orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
24 set(ENABLE_MODULE_IMAGES OFF) |
319d41a22de4
more lightweight use of Orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
25 set(ENABLE_MODULE_JOBS OFF) |
319d41a22de4
more lightweight use of Orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
18
diff
changeset
|
26 set(ENABLE_MODULE_DICOM OFF) |
1 | 27 |
15 | 28 include(${ORTHANC_FRAMEWORK_ROOT}/../Resources/CMake/OrthancFrameworkConfiguration.cmake) |
18
44de9edf2443
fix compilation to avoid exposing internal symbols which caused a crash at Orthanc startup
Alain Mazy
parents:
15
diff
changeset
|
29 include(${ORTHANC_FRAMEWORK_ROOT}/../../OrthancServer/Plugins/Samples/Common/OrthancPluginsExports.cmake) |
1 | 30 |
31 | |
32 add_definitions( | |
33 -DHAS_ORTHANC_EXCEPTION=1 | |
15 | 34 -DORTHANC_ENABLE_LOGGING=1 |
1 | 35 -DAWS_STORAGE_PLUGIN=1 |
36 ) | |
37 add_definitions(-DPLUGIN_VERSION="${PLUGIN_VERSION}") | |
38 | |
39 include_directories( | |
15 | 40 ${ORTHANC_FRAMEWORK_ROOT} |
41 ${ORTHANC_FRAMEWORK_ROOT}/../../OrthancServer/Plugins/Include | |
42 ${ORTHANC_FRAMEWORK_ROOT}/../../OrthancServer/Plugins/Samples/Common | |
1 | 43 ) |
44 | |
45 | |
26
471eaf5c5d39
USE_VCPKG_PACKAGES to avoid using vcpkg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
22
diff
changeset
|
46 if (USE_VCPKG_PACKAGES) |
471eaf5c5d39
USE_VCPKG_PACKAGES to avoid using vcpkg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
22
diff
changeset
|
47 find_package(cryptopp CONFIG REQUIRED) |
471eaf5c5d39
USE_VCPKG_PACKAGES to avoid using vcpkg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
22
diff
changeset
|
48 find_package(AWSSDK REQUIRED COMPONENTS s3) |
471eaf5c5d39
USE_VCPKG_PACKAGES to avoid using vcpkg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
22
diff
changeset
|
49 include_directories(${WASTORAGE_INCLUDE_DIR}) |
471eaf5c5d39
USE_VCPKG_PACKAGES to avoid using vcpkg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
22
diff
changeset
|
50 set(CRYPTOPP_LIBRARIES cryptopp-static) |
471eaf5c5d39
USE_VCPKG_PACKAGES to avoid using vcpkg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
22
diff
changeset
|
51 else() |
471eaf5c5d39
USE_VCPKG_PACKAGES to avoid using vcpkg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
22
diff
changeset
|
52 ## |
471eaf5c5d39
USE_VCPKG_PACKAGES to avoid using vcpkg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
22
diff
changeset
|
53 ## Inclusion of system-wide crypto++ |
471eaf5c5d39
USE_VCPKG_PACKAGES to avoid using vcpkg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
22
diff
changeset
|
54 ## |
471eaf5c5d39
USE_VCPKG_PACKAGES to avoid using vcpkg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
22
diff
changeset
|
55 check_include_file_cxx(cryptopp/cryptlib.h HAVE_CRYPTOPP_H) |
471eaf5c5d39
USE_VCPKG_PACKAGES to avoid using vcpkg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
22
diff
changeset
|
56 if (NOT HAVE_CRYPTOPP_H) |
471eaf5c5d39
USE_VCPKG_PACKAGES to avoid using vcpkg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
22
diff
changeset
|
57 message(FATAL_ERROR "Please install the libcrypto++-dev package") |
471eaf5c5d39
USE_VCPKG_PACKAGES to avoid using vcpkg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
22
diff
changeset
|
58 endif() |
471eaf5c5d39
USE_VCPKG_PACKAGES to avoid using vcpkg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
22
diff
changeset
|
59 |
471eaf5c5d39
USE_VCPKG_PACKAGES to avoid using vcpkg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
22
diff
changeset
|
60 include(CheckCXXSymbolExists) |
471eaf5c5d39
USE_VCPKG_PACKAGES to avoid using vcpkg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
22
diff
changeset
|
61 set(CMAKE_REQUIRED_LIBRARIES cryptopp) |
471eaf5c5d39
USE_VCPKG_PACKAGES to avoid using vcpkg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
22
diff
changeset
|
62 check_cxx_symbol_exists("CryptoPP::SHA1::InitState" cryptopp/sha.h HAVE_LIBCRYPTOPP) |
471eaf5c5d39
USE_VCPKG_PACKAGES to avoid using vcpkg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
22
diff
changeset
|
63 if (NOT HAVE_LIBCRYPTOPP) |
471eaf5c5d39
USE_VCPKG_PACKAGES to avoid using vcpkg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
22
diff
changeset
|
64 message(FATAL_ERROR "Unable to find the cryptopp library") |
471eaf5c5d39
USE_VCPKG_PACKAGES to avoid using vcpkg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
22
diff
changeset
|
65 endif() |
471eaf5c5d39
USE_VCPKG_PACKAGES to avoid using vcpkg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
22
diff
changeset
|
66 |
471eaf5c5d39
USE_VCPKG_PACKAGES to avoid using vcpkg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
22
diff
changeset
|
67 set(CRYPTOPP_LIBRARIES cryptopp) |
1 | 68 |
26
471eaf5c5d39
USE_VCPKG_PACKAGES to avoid using vcpkg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
22
diff
changeset
|
69 ## |
471eaf5c5d39
USE_VCPKG_PACKAGES to avoid using vcpkg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
22
diff
changeset
|
70 ## Building the C++ SDK for Amazon AWS |
471eaf5c5d39
USE_VCPKG_PACKAGES to avoid using vcpkg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
22
diff
changeset
|
71 ## WARNING: This is *not* compatible with Ninja (yet) |
471eaf5c5d39
USE_VCPKG_PACKAGES to avoid using vcpkg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
22
diff
changeset
|
72 ## |
28 | 73 if (STATIC_AWS_CLIENT) |
74 set(Flags -DBUILD_SHARED_LIBS=OFF) # Create static library | |
75 else() | |
76 set(Flags -DBUILD_SHARED_LIBS=ON) | |
77 endif() | |
78 | |
26
471eaf5c5d39
USE_VCPKG_PACKAGES to avoid using vcpkg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
22
diff
changeset
|
79 include(ExternalProject) |
471eaf5c5d39
USE_VCPKG_PACKAGES to avoid using vcpkg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
22
diff
changeset
|
80 externalproject_add(AwsSdkCpp |
471eaf5c5d39
USE_VCPKG_PACKAGES to avoid using vcpkg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
22
diff
changeset
|
81 GIT_REPOSITORY https://github.com/aws/aws-sdk-cpp |
471eaf5c5d39
USE_VCPKG_PACKAGES to avoid using vcpkg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
22
diff
changeset
|
82 GIT_TAG 1.8.42 |
471eaf5c5d39
USE_VCPKG_PACKAGES to avoid using vcpkg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
22
diff
changeset
|
83 |
471eaf5c5d39
USE_VCPKG_PACKAGES to avoid using vcpkg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
22
diff
changeset
|
84 CMAKE_ARGS |
471eaf5c5d39
USE_VCPKG_PACKAGES to avoid using vcpkg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
22
diff
changeset
|
85 -DBUILD_ONLY=s3 #-DBUILD_ONLY=s3;transfer |
471eaf5c5d39
USE_VCPKG_PACKAGES to avoid using vcpkg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
22
diff
changeset
|
86 -DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE} |
471eaf5c5d39
USE_VCPKG_PACKAGES to avoid using vcpkg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
22
diff
changeset
|
87 -DENABLE_TESTING=OFF |
28 | 88 ${Flags} |
26
471eaf5c5d39
USE_VCPKG_PACKAGES to avoid using vcpkg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
22
diff
changeset
|
89 |
471eaf5c5d39
USE_VCPKG_PACKAGES to avoid using vcpkg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
22
diff
changeset
|
90 UPDATE_COMMAND "" # Don't run "cmake" on AWS each time "make/ninja" is run |
471eaf5c5d39
USE_VCPKG_PACKAGES to avoid using vcpkg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
22
diff
changeset
|
91 INSTALL_COMMAND "" # No install |
471eaf5c5d39
USE_VCPKG_PACKAGES to avoid using vcpkg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
22
diff
changeset
|
92 ) |
471eaf5c5d39
USE_VCPKG_PACKAGES to avoid using vcpkg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
22
diff
changeset
|
93 |
471eaf5c5d39
USE_VCPKG_PACKAGES to avoid using vcpkg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
22
diff
changeset
|
94 ExternalProject_Get_Property(AwsSdkCpp SOURCE_DIR) |
471eaf5c5d39
USE_VCPKG_PACKAGES to avoid using vcpkg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
22
diff
changeset
|
95 include_directories( |
471eaf5c5d39
USE_VCPKG_PACKAGES to avoid using vcpkg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
22
diff
changeset
|
96 ${SOURCE_DIR}/aws-cpp-sdk-core/include/ |
471eaf5c5d39
USE_VCPKG_PACKAGES to avoid using vcpkg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
22
diff
changeset
|
97 ${SOURCE_DIR}/aws-cpp-sdk-s3/include/ |
471eaf5c5d39
USE_VCPKG_PACKAGES to avoid using vcpkg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
22
diff
changeset
|
98 ) |
471eaf5c5d39
USE_VCPKG_PACKAGES to avoid using vcpkg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
22
diff
changeset
|
99 |
471eaf5c5d39
USE_VCPKG_PACKAGES to avoid using vcpkg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
22
diff
changeset
|
100 ExternalProject_Get_Property(AwsSdkCpp BINARY_DIR) |
28 | 101 if (STATIC_AWS_CLIENT) |
102 set(AWSSDK_LINK_LIBRARIES | |
103 ${BINARY_DIR}/aws-cpp-sdk-s3/libaws-cpp-sdk-s3.a | |
104 ${BINARY_DIR}/aws-cpp-sdk-core/libaws-cpp-sdk-core.a | |
105 ${BINARY_DIR}/.deps/install/lib/libaws-c-event-stream.a | |
106 ${BINARY_DIR}/.deps/install/lib/libaws-checksums.a | |
107 ${BINARY_DIR}/.deps/install/lib/libaws-c-common.a | |
108 curl | |
109 crypto | |
110 ) | |
29
46621cb1bb48
fix build on ubuntu 16.04
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
28
diff
changeset
|
111 if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU") |
46621cb1bb48
fix build on ubuntu 16.04
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
28
diff
changeset
|
112 list(APPEND AWSSDK_LINK_LIBRARIES |
46621cb1bb48
fix build on ubuntu 16.04
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
28
diff
changeset
|
113 gcc # for "undefined reference to `__cpu_model'" on Ubuntu 16.04 |
46621cb1bb48
fix build on ubuntu 16.04
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
28
diff
changeset
|
114 ) |
46621cb1bb48
fix build on ubuntu 16.04
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
28
diff
changeset
|
115 endif() |
28 | 116 else() |
117 set(AWSSDK_LINK_LIBRARIES | |
118 ${BINARY_DIR}/aws-cpp-sdk-core/libaws-cpp-sdk-core.so | |
119 ${BINARY_DIR}/aws-cpp-sdk-s3/libaws-cpp-sdk-s3.so | |
120 ) | |
121 endif() | |
26
471eaf5c5d39
USE_VCPKG_PACKAGES to avoid using vcpkg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
22
diff
changeset
|
122 endif() |
471eaf5c5d39
USE_VCPKG_PACKAGES to avoid using vcpkg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
22
diff
changeset
|
123 |
1 | 124 |
125 set(COMMON_SOURCES | |
126 ${CMAKE_SOURCE_DIR}/../Common/IStoragePlugin.h | |
15 | 127 ${CMAKE_SOURCE_DIR}/../Common/BaseStoragePlugin.h |
128 ${CMAKE_SOURCE_DIR}/../Common/BaseStoragePlugin.cpp | |
1 | 129 ${CMAKE_SOURCE_DIR}/../Common/EncryptionHelpers.cpp |
130 ${CMAKE_SOURCE_DIR}/../Common/EncryptionHelpers.h | |
131 ${CMAKE_SOURCE_DIR}/../Common/EncryptionConfigurator.cpp | |
132 ${CMAKE_SOURCE_DIR}/../Common/EncryptionConfigurator.h | |
15 | 133 ${ORTHANC_FRAMEWORK_ROOT}/../../OrthancServer/Plugins/Samples/Common/OrthancPluginCppWrapper.cpp |
1 | 134 |
135 ${ORTHANC_CORE_SOURCES} | |
136 ) | |
137 | |
138 add_library(OrthancAwsS3Storage SHARED | |
139 AwsS3StoragePlugin.cpp | |
140 AwsS3StoragePlugin.h | |
141 ${CMAKE_SOURCE_DIR}/../Common/StoragePlugin.cpp | |
142 | |
143 ${COMMON_SOURCES} | |
26
471eaf5c5d39
USE_VCPKG_PACKAGES to avoid using vcpkg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
22
diff
changeset
|
144 ) |
1 | 145 |
146 set_target_properties(OrthancAwsS3Storage PROPERTIES | |
147 VERSION ${PLUGIN_VERSION} | |
148 SOVERSION ${PLUGIN_VERSION} | |
149 ) | |
150 | |
151 target_link_libraries(OrthancAwsS3Storage | |
152 PRIVATE | |
26
471eaf5c5d39
USE_VCPKG_PACKAGES to avoid using vcpkg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
22
diff
changeset
|
153 ${CRYPTOPP_LIBRARIES} |
1 | 154 ${AWSSDK_LINK_LIBRARIES} |
155 ) | |
156 | |
157 | |
158 | |
159 add_executable(UnitTests | |
160 ${GOOGLE_TEST_SOURCES} | |
161 ${COMMON_SOURCES} | |
162 | |
163 ${CMAKE_SOURCE_DIR}/../UnitTestsSources/EncryptionTests.cpp | |
164 ${CMAKE_SOURCE_DIR}/../UnitTestsSources/UnitTestsMain.cpp | |
165 ) | |
166 | |
167 target_link_libraries(UnitTests | |
168 PRIVATE | |
169 ${GOOGLE_TEST_LIBRARIES} | |
26
471eaf5c5d39
USE_VCPKG_PACKAGES to avoid using vcpkg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
22
diff
changeset
|
170 ${CRYPTOPP_LIBRARIES} |
1 | 171 ${AWSSDK_LINK_LIBRARIES} |
172 ) | |
26
471eaf5c5d39
USE_VCPKG_PACKAGES to avoid using vcpkg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
22
diff
changeset
|
173 |
471eaf5c5d39
USE_VCPKG_PACKAGES to avoid using vcpkg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
22
diff
changeset
|
174 |
471eaf5c5d39
USE_VCPKG_PACKAGES to avoid using vcpkg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
22
diff
changeset
|
175 if (NOT USE_VCPKG_PACKAGES) |
471eaf5c5d39
USE_VCPKG_PACKAGES to avoid using vcpkg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
22
diff
changeset
|
176 add_dependencies(OrthancAwsS3Storage AwsSdkCpp) |
471eaf5c5d39
USE_VCPKG_PACKAGES to avoid using vcpkg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
22
diff
changeset
|
177 add_dependencies(UnitTests AwsSdkCpp) |
471eaf5c5d39
USE_VCPKG_PACKAGES to avoid using vcpkg
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
22
diff
changeset
|
178 endif() |