Skip to content

Commit

Permalink
CMake: Add the AWS SDK submodule
Browse files Browse the repository at this point in the history
  • Loading branch information
alessandrogario authored and Smjert committed Aug 25, 2019
1 parent 179bddb commit 18f5643
Show file tree
Hide file tree
Showing 6 changed files with 101 additions and 2 deletions.
3 changes: 3 additions & 0 deletions .gitmodules
Expand Up @@ -103,3 +103,6 @@
[submodule "libraries/cmake/source/gflags/src"]
path = libraries/cmake/source/gflags/src
url = https://github.com/gflags/gflags
[submodule "libraries/cmake/source/aws-sdk-cpp/src"]
path = libraries/cmake/source/aws-sdk-cpp/src
url = https://github.com/aws/aws-sdk-cpp
2 changes: 1 addition & 1 deletion CMakeLists.txt
Expand Up @@ -62,7 +62,6 @@ function(importLibraries)

set(library_descriptor_list
"Linux,Darwin:augeas"
"Linux,Darwin,Windows:aws-sdk-cpp"
"Linux:berkeley-db"
"Linux,Darwin,Windows:boost"
"Linux,Darwin,Windows:bzip2"
Expand Down Expand Up @@ -100,6 +99,7 @@ function(importLibraries)
"Linux,Darwin,Windows:zlib"
"Linux,Darwin,Windows:zstd"
"Linux,Darwin,Windows:openssl"
"Linux,Darwin,Windows:aws-sdk-cpp"
)

foreach(python_module ${python_module_list})
Expand Down
2 changes: 1 addition & 1 deletion libraries/cmake/formula/modules/utils.cmake
Expand Up @@ -7,7 +7,7 @@
cmake_minimum_required(VERSION 3.13.3)
include(ExternalProject)

set(OSQUERY_FORMULA_INSTALL_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/build")
set(OSQUERY_FORMULA_INSTALL_DIRECTORY "${CMAKE_BINARY_DIR}/installed_formulas")

function(importFormula library_name)
message(STATUS "Importing formula: formula/${library_name}")
Expand Down
85 changes: 85 additions & 0 deletions libraries/cmake/source/aws-sdk-cpp/CMakeLists.txt
@@ -0,0 +1,85 @@
# Copyright (c) 2014-present, Facebook, Inc.
# All rights reserved.
#
# This source code is licensed in accordance with the terms specified in
# the LICENSE file found in the root directory of this source tree.

function(awsSdkCppMain)
# Set the AWS sdk parameters in cache
set(enabled_option_list
ZLIB_FOUND
OPENSSL_FOUND
STATIC_LINKING
NO_HTTP_CLIENT
MINIMIZE_SIZE
)

set(disabled_option_list
ENABLE_TESTING
AUTORUN_UNIT_TESTS
)

foreach(option_name ${enabled_option_list})
set("${option_name}" true CACHE BOOL "" FORCE)
endforeach()

foreach(option_name ${disabled_option_list})
set("${option_name}" false CACHE BOOL "" FORCE)
endforeach()

# Pass the required dependencies
get_target_property(zlib_include_directory thirdparty_zlib INTERFACE_INCLUDE_DIRECTORIES)

set(ZLIB_LIBRARY "$<TARGET_FILE:thirdparty_zlib>" CACHE STRING "" FORCE)
set(ZLIB_INCLUDE_DIR "${zlib_include_directory}" CACHE STRING "" FORCE)

get_target_property(libcrypto_library_path thirdparty_intermediate_libcrypto IMPORTED_LOCATION)
get_target_property(libssl_library_path thirdparty_intermediate_libssl IMPORTED_LOCATION)
get_target_property(openssl_include_directory thirdparty_intermediate_libssl INTERFACE_INCLUDE_DIRECTORIES)

set(OPENSSL_CRYPTO_LIBRARY "${libcrypto_library_path}" CACHE STRING "" FORCE)
set(OPENSSL_SSL_LIBRARY "${libssl_library_path}" CACHE STRING "" FORCE)
set(OPENSSL_INCLUDE_DIR "${openssl_include_directory}" CACHE STRING "" FORCE)

set(BUILD_ONLY "firehose;kinesis;sts;ec2" CACHE STRING "" FORCE)

# Actually include the AWS sdk folder
set(library_root "${CMAKE_CURRENT_SOURCE_DIR}/src")
add_subdirectory("${library_root}" "${CMAKE_CURRENT_BINARY_DIR}/submodule" EXCLUDE_FROM_ALL)

add_dependencies(aws-cpp-sdk-core
thirdparty_openssl
thirdparty_zlib
)

# Transfer at least some of the compilation flags we want
set(compile_options_target_list
global_settings
cxx_settings
thirdparty_source_module_warnings
)

foreach(library_name ${BUILD_ONLY})
foreach(compile_options_target ${compile_options_target_list})
get_target_property(flag_list
"${compile_options_target}"
INTERFACE_COMPILE_OPTIONS
)

target_compile_options("aws-cpp-sdk-${library_name}" PUBLIC
${flag_list}
)
endforeach()
endforeach()

# Generate the final interface target, adding the core library
add_library(thirdparty_aws-sdk-cpp INTERFACE)

foreach(library_name ${BUILD_ONLY} core)
target_link_libraries(thirdparty_aws-sdk-cpp INTERFACE
"aws-cpp-sdk-${library_name}"
)
endforeach()
endfunction()

awsSdkCppMain()
1 change: 1 addition & 0 deletions libraries/cmake/source/aws-sdk-cpp/src
Submodule src added at 59337e
10 changes: 10 additions & 0 deletions libraries/cmake/source/modules/Findaws-sdk-cpp.cmake
@@ -0,0 +1,10 @@
# Copyright (c) 2014-present, Facebook, Inc.
# All rights reserved.
#
# This source code is licensed in accordance with the terms specified in
# the LICENSE file found in the root directory of this source tree.

cmake_minimum_required(VERSION 3.13.3)
include("${CMAKE_CURRENT_LIST_DIR}/utils.cmake")

importSourceSubmodule("aws-sdk-cpp")

0 comments on commit 18f5643

Please sign in to comment.