changeset 28:318c1442d9bd

STATIC_AWS_CLIENT
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 07 Sep 2020 19:00:57 +0200
parents e1f52b851827
children 46621cb1bb48
files Aws/CMakeLists.txt
diffstat 1 files changed, 24 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/Aws/CMakeLists.txt	Mon Sep 07 17:16:38 2020 +0200
+++ b/Aws/CMakeLists.txt	Mon Sep 07 19:00:57 2020 +0200
@@ -11,6 +11,7 @@
 set(ORTHANC_FRAMEWORK_SOURCE "hg" CACHE STRING "orthanc source")
 set(ORTHANC_FRAMEWORK_VERSION "1.7.3" CACHE STRING "orthanc framework version")
 set(USE_VCPKG_PACKAGES ON CACHE BOOL "Use vcpkg to link against crypto++ and AWS SDK")
+set(STATIC_AWS_CLIENT ON CACHE BOOL "Statically link against AWS client library (only if USE_VCPKG_PACKAGES=OFF)")
 set(ALLOW_DOWNLOADS ON)
 
 # Download and setup the Orthanc framework
@@ -69,6 +70,12 @@
   ## Building the C++ SDK for Amazon AWS
   ## WARNING: This is *not* compatible with Ninja (yet)
   ##
+  if (STATIC_AWS_CLIENT)
+    set(Flags -DBUILD_SHARED_LIBS=OFF)  # Create static library
+  else()
+    set(Flags -DBUILD_SHARED_LIBS=ON)
+  endif()
+  
   include(ExternalProject)
   externalproject_add(AwsSdkCpp
     GIT_REPOSITORY https://github.com/aws/aws-sdk-cpp
@@ -78,6 +85,7 @@
     -DBUILD_ONLY=s3   #-DBUILD_ONLY=s3;transfer
     -DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE}
     -DENABLE_TESTING=OFF
+    ${Flags}
 
     UPDATE_COMMAND ""    # Don't run "cmake" on AWS each time "make/ninja" is run
     INSTALL_COMMAND ""   # No install
@@ -90,10 +98,22 @@
     )
 
   ExternalProject_Get_Property(AwsSdkCpp BINARY_DIR)
-  set(AWSSDK_LINK_LIBRARIES
-    ${BINARY_DIR}/aws-cpp-sdk-core/libaws-cpp-sdk-core.so
-    ${BINARY_DIR}/aws-cpp-sdk-s3/libaws-cpp-sdk-s3.so
-    )
+  if (STATIC_AWS_CLIENT)
+    set(AWSSDK_LINK_LIBRARIES
+      ${BINARY_DIR}/aws-cpp-sdk-s3/libaws-cpp-sdk-s3.a
+      ${BINARY_DIR}/aws-cpp-sdk-core/libaws-cpp-sdk-core.a
+      ${BINARY_DIR}/.deps/install/lib/libaws-c-event-stream.a
+      ${BINARY_DIR}/.deps/install/lib/libaws-checksums.a
+      ${BINARY_DIR}/.deps/install/lib/libaws-c-common.a
+      curl
+      crypto
+      )
+  else()
+    set(AWSSDK_LINK_LIBRARIES
+      ${BINARY_DIR}/aws-cpp-sdk-core/libaws-cpp-sdk-core.so
+      ${BINARY_DIR}/aws-cpp-sdk-s3/libaws-cpp-sdk-s3.so
+      )
+  endif()
 endif()