diff --git a/recipes/aws-sdk-cpp/all/conandata.yml b/recipes/aws-sdk-cpp/all/conandata.yml index f47475c47e0b8..5e5940d87df8e 100644 --- a/recipes/aws-sdk-cpp/all/conandata.yml +++ b/recipes/aws-sdk-cpp/all/conandata.yml @@ -9,6 +9,8 @@ patches: "1.9.100": - base_path: source_subfolder patch_file: patches/1.9.100-0001-disable-sort-links.patch + - base_path: source_subfolder + patch_file: patches/1.9.100-0002-aws-plugin-conf.patch "1.8.130": - base_path: source_subfolder patch_file: patches/1.8.130-0001-disable-sort-links.patch @@ -18,3 +20,5 @@ patches: patch_file: patches/1.8.130-0003-disable-cmake-install-rpath-use-link-path.patch - base_path: source_subfolder patch_file: patches/1.8.130-0004-improve-pulseaudio-detection.patch + - base_path: source_subfolder + patch_file: patches/1.8.130-0005-aws-plugin-conf.patch diff --git a/recipes/aws-sdk-cpp/all/conanfile.py b/recipes/aws-sdk-cpp/all/conanfile.py index 9211a0abaf631..0b1b06622971d 100644 --- a/recipes/aws-sdk-cpp/all/conanfile.py +++ b/recipes/aws-sdk-cpp/all/conanfile.py @@ -1,7 +1,9 @@ +import os + +from conan.tools.files import rename from conan.tools.microsoft import msvc_runtime_flag -from conans import ConanFile, CMake, tools +from conans import CMake, ConanFile, tools from conans.errors import ConanInvalidConfiguration -import os required_conan_version = ">=1.43.0" @@ -421,6 +423,29 @@ def build(self): cmake = self._configure_cmake() cmake.build() + @property + def _res_folder(self): + return "res" + + def _create_project_cmake_module(self): + # package files needed to build other components (e.g. aws-cdi-sdk) with this SDK + for file in [ + "cmake/compiler_settings.cmake", + "cmake/initialize_project_version.cmake", + "cmake/utilities.cmake", + "cmake/sdk_plugin_conf.cmake", + "toolchains/cmakeProjectConfig.cmake", + "toolchains/pkg-config.pc.in", + "aws-cpp-sdk-core/include/aws/core/VersionConfig.h" + ]: + self.copy(file, src=self._source_subfolder, dst=self._res_folder) + tools.replace_in_file(os.path.join(self.package_folder, self._res_folder, file), "CMAKE_CURRENT_SOURCE_DIR", "AWS_NATIVE_SDK_ROOT", strict=False) + + # avoid getting error from hook + with tools.chdir(os.path.join(self.package_folder, self._res_folder)): + rename(self, os.path.join("toolchains", "cmakeProjectConfig.cmake"), os.path.join("toolchains", "cmakeProjectConf.cmake")) + tools.replace_in_file(os.path.join("cmake", "utilities.cmake"), "cmakeProjectConfig.cmake", "cmakeProjectConf.cmake") + def package(self): self.copy("LICENSE", dst="licenses", src=self._source_subfolder) cmake = self._configure_cmake() @@ -432,6 +457,8 @@ def package(self): tools.rmdir(os.path.join(self.package_folder, "lib", "cmake")) tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig")) + self._create_project_cmake_module() + def package_info(self): self.cpp_info.set_property("cmake_file_name", "AWSSDK") @@ -507,3 +534,9 @@ def package_info(self): self.cpp_info.names["cmake_find_package_multi"] = "AWS" self.cpp_info.components["core"].names["cmake_find_package"] = "aws-sdk-cpp-core" self.cpp_info.components["core"].names["cmake_find_package_multi"] = "aws-sdk-cpp-core" + + self.cpp_info.components["plugin_scripts"].requires = ["core"] + self.cpp_info.components["plugin_scripts"].builddirs.extend([ + os.path.join(self._res_folder, "cmake"), + os.path.join(self._res_folder, "toolchains")]) + self.cpp_info.components["plugin_scripts"].build_modules.append(os.path.join(self._res_folder, "cmake", "sdk_plugin_conf.cmake")) diff --git a/recipes/aws-sdk-cpp/all/patches/1.8.130-0005-aws-plugin-conf.patch b/recipes/aws-sdk-cpp/all/patches/1.8.130-0005-aws-plugin-conf.patch new file mode 100644 index 0000000000000..b3eccfe69cc45 --- /dev/null +++ b/recipes/aws-sdk-cpp/all/patches/1.8.130-0005-aws-plugin-conf.patch @@ -0,0 +1,44 @@ +commit 1179cb040d6b9292d30eb7d444298cd286f9f574 +Author: dvirtz +Date: Tue Nov 16 21:38:45 2021 +0200 + + add a file to configure SDK plugins + +diff --git a/cmake/sdk_plugin_conf.cmake b/cmake/sdk_plugin_conf.cmake +new file mode 100644 +index 0000000000..474ead75bd +--- /dev/null ++++ b/cmake/sdk_plugin_conf.cmake +@@ -0,0 +1,32 @@ ++get_filename_component(AWS_NATIVE_SDK_ROOT ${CMAKE_CURRENT_LIST_DIR} DIRECTORY) ++set(SIMPLE_INSTALL TRUE) ++ ++if (CMAKE_INSTALL_BINDIR) ++ set(BINARY_DIRECTORY "${CMAKE_INSTALL_BINDIR}") ++endif() ++ ++if (CMAKE_INSTALL_LIBDIR) ++ set(LIBRARY_DIRECTORY "${CMAKE_INSTALL_LIBDIR}") ++endif() ++ ++if (CMAKE_INSTALL_INCLUDEDIR) ++ set(INCLUDE_DIRECTORY "${CMAKE_INSTALL_INCLUDEDIR}") ++endif() ++ ++if(BUILD_SHARED_LIBS) ++ set(ARCHIVE_DIRECTORY "${BINARY_DIRECTORY}") ++else() ++ set(ARCHIVE_DIRECTORY "${LIBRARY_DIRECTORY}") ++endif() ++ ++if(DEFINED CMAKE_CXX_STANDARD) ++ set(STANDARD_DEFAULT ${CMAKE_CXX_STANDARD}) ++else() ++ set(STANDARD_DEFAULT "11") ++endif() ++set(CPP_STANDARD ${STANDARD_DEFAULT} CACHE STRING "Flag to upgrade the C++ standard used. The default is 11. The minimum is 11.") ++ ++include(CMakePackageConfigHelpers) ++include(initialize_project_version) ++include(utilities) ++include(compiler_settings) diff --git a/recipes/aws-sdk-cpp/all/patches/1.9.100-0002-aws-plugin-conf.patch b/recipes/aws-sdk-cpp/all/patches/1.9.100-0002-aws-plugin-conf.patch new file mode 100644 index 0000000000000..b3eccfe69cc45 --- /dev/null +++ b/recipes/aws-sdk-cpp/all/patches/1.9.100-0002-aws-plugin-conf.patch @@ -0,0 +1,44 @@ +commit 1179cb040d6b9292d30eb7d444298cd286f9f574 +Author: dvirtz +Date: Tue Nov 16 21:38:45 2021 +0200 + + add a file to configure SDK plugins + +diff --git a/cmake/sdk_plugin_conf.cmake b/cmake/sdk_plugin_conf.cmake +new file mode 100644 +index 0000000000..474ead75bd +--- /dev/null ++++ b/cmake/sdk_plugin_conf.cmake +@@ -0,0 +1,32 @@ ++get_filename_component(AWS_NATIVE_SDK_ROOT ${CMAKE_CURRENT_LIST_DIR} DIRECTORY) ++set(SIMPLE_INSTALL TRUE) ++ ++if (CMAKE_INSTALL_BINDIR) ++ set(BINARY_DIRECTORY "${CMAKE_INSTALL_BINDIR}") ++endif() ++ ++if (CMAKE_INSTALL_LIBDIR) ++ set(LIBRARY_DIRECTORY "${CMAKE_INSTALL_LIBDIR}") ++endif() ++ ++if (CMAKE_INSTALL_INCLUDEDIR) ++ set(INCLUDE_DIRECTORY "${CMAKE_INSTALL_INCLUDEDIR}") ++endif() ++ ++if(BUILD_SHARED_LIBS) ++ set(ARCHIVE_DIRECTORY "${BINARY_DIRECTORY}") ++else() ++ set(ARCHIVE_DIRECTORY "${LIBRARY_DIRECTORY}") ++endif() ++ ++if(DEFINED CMAKE_CXX_STANDARD) ++ set(STANDARD_DEFAULT ${CMAKE_CXX_STANDARD}) ++else() ++ set(STANDARD_DEFAULT "11") ++endif() ++set(CPP_STANDARD ${STANDARD_DEFAULT} CACHE STRING "Flag to upgrade the C++ standard used. The default is 11. The minimum is 11.") ++ ++include(CMakePackageConfigHelpers) ++include(initialize_project_version) ++include(utilities) ++include(compiler_settings) diff --git a/recipes/aws-sdk-cpp/all/test_package/CMakeLists.txt b/recipes/aws-sdk-cpp/all/test_package/CMakeLists.txt index 16884ee56e91b..efb9a3d957583 100644 --- a/recipes/aws-sdk-cpp/all/test_package/CMakeLists.txt +++ b/recipes/aws-sdk-cpp/all/test_package/CMakeLists.txt @@ -6,6 +6,8 @@ conan_basic_setup(TARGETS) find_package(AWSSDK REQUIRED CONFIG) +add_subdirectory(aws-sdk-cpp-plugin) + add_executable(${PROJECT_NAME} test_package.cpp) -target_link_libraries(${PROJECT_NAME} AWS::aws-sdk-cpp-s3) +target_link_libraries(${PROJECT_NAME} aws-sdk-cpp-plugin) set_target_properties(${PROJECT_NAME} PROPERTIES CXX_STANDARD 11) diff --git a/recipes/aws-sdk-cpp/all/test_package/aws-sdk-cpp-plugin/AwsSdkCppPlugin.cpp b/recipes/aws-sdk-cpp/all/test_package/aws-sdk-cpp-plugin/AwsSdkCppPlugin.cpp new file mode 100644 index 0000000000000..6171e1633708e --- /dev/null +++ b/recipes/aws-sdk-cpp/all/test_package/aws-sdk-cpp-plugin/AwsSdkCppPlugin.cpp @@ -0,0 +1,16 @@ +#include "AwsSdkCppPlugin.h" +#include +#include +#include +#include + +AwsSdkCppPlugin::AwsSdkCppPlugin() { + using namespace Aws; + using namespace Auth; + using namespace Client; + using namespace S3; + ClientConfiguration config; + auto client = MakeShared("S3Client", + MakeShared("S3Client"), config, + AWSAuthV4Signer::PayloadSigningPolicy::Never /*signPayloads*/, true /*useVirtualAddressing*/, US_EAST_1_REGIONAL_ENDPOINT_OPTION::LEGACY); +} diff --git a/recipes/aws-sdk-cpp/all/test_package/aws-sdk-cpp-plugin/AwsSdkCppPlugin.h b/recipes/aws-sdk-cpp/all/test_package/aws-sdk-cpp-plugin/AwsSdkCppPlugin.h new file mode 100644 index 0000000000000..e05192e725523 --- /dev/null +++ b/recipes/aws-sdk-cpp/all/test_package/aws-sdk-cpp-plugin/AwsSdkCppPlugin.h @@ -0,0 +1,7 @@ +#include + +class AWS_SDK_CPP_PLUGIN_EXPORT AwsSdkCppPlugin +{ +public: + AwsSdkCppPlugin(); +}; diff --git a/recipes/aws-sdk-cpp/all/test_package/aws-sdk-cpp-plugin/CMakeLists.txt b/recipes/aws-sdk-cpp/all/test_package/aws-sdk-cpp-plugin/CMakeLists.txt new file mode 100644 index 0000000000000..dddf745d2e408 --- /dev/null +++ b/recipes/aws-sdk-cpp/all/test_package/aws-sdk-cpp-plugin/CMakeLists.txt @@ -0,0 +1,15 @@ +cmake_minimum_required(VERSION 3.1) + +add_project(aws-sdk-cpp-plugin "C++ AWS SDK plugin" AWS::aws-sdk-cpp-s3) + +add_library(${PROJECT_NAME} AwsSdkCppPlugin.cpp) + +include(GenerateExportHeader) +generate_export_header(${PROJECT_NAME} BASE_NAME aws_sdk_cpp_plugin) +target_include_directories(${PROJECT_NAME} PUBLIC $ $) +target_link_libraries(${PROJECT_NAME} PUBLIC ${PROJECT_LIBS}) +set_target_properties(${PROJECT_NAME} PROPERTIES CXX_STANDARD 11) + +setup_install() + +do_packaging() diff --git a/recipes/aws-sdk-cpp/all/test_package/test_package.cpp b/recipes/aws-sdk-cpp/all/test_package/test_package.cpp index 295a0fe6c0954..f66fb046b91dc 100644 --- a/recipes/aws-sdk-cpp/all/test_package/test_package.cpp +++ b/recipes/aws-sdk-cpp/all/test_package/test_package.cpp @@ -1,23 +1,13 @@ -#include #include #include -#include -#include -#include -#include +#include int main() { using namespace Aws; - using namespace Auth; - using namespace Client; - using namespace S3; SDKOptions options; InitAPI(options); - ClientConfiguration config; - auto client = MakeShared("S3Client", - MakeShared("S3Client"), config, - AWSAuthV4Signer::PayloadSigningPolicy::Never /*signPayloads*/, true /*useVirtualAddressing*/, US_EAST_1_REGIONAL_ENDPOINT_OPTION::LEGACY); + AwsSdkCppPlugin Plugin; ShutdownAPI(options); return 0; }