diff --git a/CMakeLists.txt b/CMakeLists.txt index 7d37fb112f0..e5e2e40c676 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -17,21 +17,16 @@ if (LEGACY_BUILD) project("aws-cpp-sdk-all" VERSION "${PROJECT_VERSION}" LANGUAGES CXX) include(legacy_main) else () - message(STATUS "Building with 1.10 CMake scripts.") + message(STATUS "Building with new CMake scripts.") string(CONCAT DESCRIPTION_STRING "The AWS SDK for C++ provides a modern C++ (standard version C++11 or later) " "interface for Amazon Web Services (AWS).") - if (NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) - message(STATUS "Setting build type to 'RelWithDebInfo' as none was specified.") - set(CMAKE_BUILD_TYPE "RelWithDebInfo" CACHE - STRING "Choose the type of build." FORCE) - # cmake-gui helper - set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" "MinSizeRel" "RelWithDebInfo") - endif () - list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake") - include(sdk_versioning) - obtain_project_version(SDK_PROJECT_VERSION) + + find_package(Git QUIET) # Adding development helper tools as git_hash built when available. + + include(project_version) + obtain_project_version(SDK_PROJECT_VERSION aws-cpp-sdk_GIT_HASH) project("aws-cpp-sdk" LANGUAGES CXX @@ -39,18 +34,40 @@ else () DESCRIPTION ${DESCRIPTION_STRING} HOMEPAGE_URL "https://docs.aws.amazon.com/sdk-for-cpp" ) + + # Setting C++ minimum requirements set(CMAKE_CXX_STANDARD 11) set(CMAKE_CXX_EXTENSIONS OFF) set(CMAKE_CXX_STANDARD_REQUIRED ON) message(STATUS "Building ${PROJECT_NAME} ${CMAKE_PROJECT_VERSION}") + # Setting version header for library + configure_file( + VersionConfig.h.in + src/aws-cpp-sdk-core/include/aws/core/VersionConfig.h + @ONLY + ) - message(WARNING "Anything below this warning is a TODO not yet implemented.") + # Validating config type and setting default if needed + get_property(is_multi_conf_build GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) + if (NOT is_multi_conf_build) + set(allowed_build_types Debug Release RelWithDebInfo MinSizeRel) + # cmake-gui helper + set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "${allowed_build_types}") + if (NOT CMAKE_BUILD_TYPE) + message(STATUS "Setting build type to 'RelWithDebInfo' as none was specified.") + set(CMAKE_BUILD_TYPE "RelWithDebInfo" CACHE STRING "Choose the type of build." FORCE) + elseif (NOT CMAKE_BUILD_TYPE IN_LIST allowed_build_types) + message(FATAL_ERROR "Unknown build type: ${CMAKE_BUILD_TYPE}") + endif () + endif () + option(BUILD_TESTS "If enabled, the SDK will include tests in the build" OFF) + message(WARNING "Anything below this warning is a TODO not yet implemented.") message(STATUS "Detecting toolchain and external dependencies.") - message(STATUS "Prepare CRT dependency.") message(STATUS "Setting up core library.") + message(STATUS "Prepare CRT dependency.") message(STATUS "Building core library.") message(STATUS "Building core library tests.") message(STATUS "Add support for static analysis.") diff --git a/VERSION b/VERSION new file mode 100644 index 00000000000..ed21137ee19 --- /dev/null +++ b/VERSION @@ -0,0 +1 @@ +1.10.0 \ No newline at end of file diff --git a/VersionConfig.h.in b/VersionConfig.h.in new file mode 100644 index 00000000000..f19f27239c1 --- /dev/null +++ b/VersionConfig.h.in @@ -0,0 +1,18 @@ +/** + * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 + */ + +#define AWS_CPP_SDK_VERSION_STRING "@aws-cpp-sdk_VERSION_STRING@" +#define AWS_CPP_SDK_VERSION_MAJOR @aws-cpp-sdk_VERSION_MAJOR@ +#define AWS_CPP_SDK_VERSION_MINOR @aws-cpp-sdk_VERSION_MINOR@ +#define AWS_CPP_SDK_VERSION_PATCH @aws-cpp-sdk_VERSION_PATCH@ +#define AWS_CPP_SDK_GIT_HASH "@aws-cpp-sdk_GIT_HASH@" + +// DEPRECATED in 1.10: The follow defines are kept for backward compatibility +// Please prefer the use the new ones defined above +#define AWS_SDK_VERSION_STRING AWS_CPP_SDK_VERSION_STRING +#define AWS_SDK_VERSION_MAJOR AWS_CPP_SDK_VERSION_MAJOR +#define AWS_SDK_VERSION_MINOR AWS_CPP_SDK_VERSION_MINOR +#define AWS_SDK_VERSION_PATCH AWS_CPP_SDK_VERSION_PATCH + diff --git a/cmake/project_version.cmake b/cmake/project_version.cmake new file mode 100644 index 00000000000..37b49c39fb2 --- /dev/null +++ b/cmake/project_version.cmake @@ -0,0 +1,28 @@ +include_guard() + +function(obtain_project_version resultVarVersion resultVarGitHash) + if (GIT_FOUND) + execute_process( + COMMAND ${GIT_EXECUTABLE} --git-dir=${CMAKE_CURRENT_SOURCE_DIR}/.git describe --abbrev=0 --tags + OUTPUT_VARIABLE VERSION_STRING + OUTPUT_STRIP_TRAILING_WHITESPACE + ) + execute_process( + COMMAND ${GIT_EXECUTABLE} rev-parse HEAD + RESULT_VARIABLE git_result + OUTPUT_VARIABLE GIT_HASH + OUTPUT_STRIP_TRAILING_WHITESPACE + ) + if (NOT git_result) + set(${resultVarGitHash} ${GIT_HASH} PARENT_SCOPE) + message(STATUS "Building git hash: ${GIT_HASH}") + endif() + endif () + + if (NOT VERSION_STRING) # Non DEV build relays on VERSION file updated by release CI + file(READ "${CMAKE_CURRENT_SOURCE_DIR}/VERSION" VERSION_STRING) + endif () + + set(${resultVarVersion} ${VERSION_STRING} PARENT_SCOPE) + message(STATUS "SDK project version: ${VERSION_STRING}") +endfunction() \ No newline at end of file diff --git a/cmake/sdk_versioning.cmake b/cmake/sdk_versioning.cmake deleted file mode 100644 index eb9c3a3f405..00000000000 --- a/cmake/sdk_versioning.cmake +++ /dev/null @@ -1,20 +0,0 @@ -include_guard() - -function(obtain_project_version resultVar) - find_package(Git QUIET) - if (GIT_FOUND) - execute_process(COMMAND ${GIT_EXECUTABLE} --git-dir=${CMAKE_CURRENT_SOURCE_DIR}/.git describe --abbrev=0 --tags - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} - OUTPUT_VARIABLE VERSION_STRING - OUTPUT_STRIP_TRAILING_WHITESPACE) - endif () - - if (NOT VERSION_STRING) - # extract it from the existing generated header file - file(STRINGS "${CMAKE_CURRENT_SOURCE_DIR}/src/aws-cpp-sdk-core/include/aws/core/VersionConfig.h" __SDK_VERSION_LINE LIMIT_COUNT 1 REGEX "AWS_SDK_VERSION_STRING.*[0-9]+\\.[0-9]+\\.[0-9]+") - string(REGEX MATCH "([0-9]+\\.[0-9]+\\.[0-9]+)" VERSION_STRING "${__SDK_VERSION_LINE}") - endif () - - set(${resultVar} ${VERSION_STRING} PARENT_SCOPE) - message(STATUS "SDK project version: ${VERSION_STRING}") -endfunction(obtain_project_version) \ No newline at end of file diff --git a/src/aws-cpp-sdk-core/include/aws/core/Version.h b/src/aws-cpp-sdk-core/include/aws/core/Version.h index 71215ec6bd6..658bd65707f 100644 --- a/src/aws-cpp-sdk-core/include/aws/core/Version.h +++ b/src/aws-cpp-sdk-core/include/aws/core/Version.h @@ -15,5 +15,6 @@ namespace Version AWS_CORE_API unsigned GetVersionMinor(); AWS_CORE_API unsigned GetVersionPatch(); AWS_CORE_API const char* GetCompilerVersionString(); + AWS_CORE_API const char* GetGitHash(); } //namespace Version } //namespace Aws diff --git a/src/aws-cpp-sdk-core/include/aws/core/VersionConfig.h b/src/aws-cpp-sdk-core/include/aws/core/VersionConfig.h index edbaaf92101..9111959e032 100644 --- a/src/aws-cpp-sdk-core/include/aws/core/VersionConfig.h +++ b/src/aws-cpp-sdk-core/include/aws/core/VersionConfig.h @@ -3,7 +3,15 @@ * SPDX-License-Identifier: Apache-2.0. */ +// DEPRECATED: This file is used by legacy_build generators only + #define AWS_SDK_VERSION_STRING "1.9.227" #define AWS_SDK_VERSION_MAJOR 1 #define AWS_SDK_VERSION_MINOR 9 #define AWS_SDK_VERSION_PATCH 227 +// Forward compatible definitions +#define AWS_CPP_SDK_VERSION_STRING AWS_SDK_VERSION_STRING +#define AWS_CPP_SDK_VERSION_MAJOR AWS_SDK_VERSION_MAJOR +#define AWS_CPP_SDK_VERSION_MINOR AWS_SDK_VERSION_MINOR +#define AWS_CPP_SDK_VERSION_PATCH AWS_SDK_VERSION_PATCH +#define AWS_CPP_SDK_GIT_HASH "NoHashAvailableInLegacyBuild" diff --git a/src/aws-cpp-sdk-core/include/aws/core/VersionConfig.h.in b/src/aws-cpp-sdk-core/include/aws/core/VersionConfig.h.in index 6b698d0b417..16b3c073091 100644 --- a/src/aws-cpp-sdk-core/include/aws/core/VersionConfig.h.in +++ b/src/aws-cpp-sdk-core/include/aws/core/VersionConfig.h.in @@ -3,7 +3,15 @@ * SPDX-License-Identifier: Apache-2.0. */ +// DEPRECATED: This file is used by legacy_build generators only + #define AWS_SDK_VERSION_STRING "@AWSSDK_VERSION_STRING@" #define AWS_SDK_VERSION_MAJOR @AWSSDK_VERSION_MAJOR@ #define AWS_SDK_VERSION_MINOR @AWSSDK_VERSION_MINOR@ -#define AWS_SDK_VERSION_PATCH @AWSSDK_VERSION_PATCH@ \ No newline at end of file +#define AWS_SDK_VERSION_PATCH @AWSSDK_VERSION_PATCH@ +// Forward compatible definitions +#define AWS_CPP_SDK_VERSION_STRING AWS_SDK_VERSION_STRING +#define AWS_CPP_SDK_VERSION_MAJOR AWS_SDK_VERSION_MAJOR +#define AWS_CPP_SDK_VERSION_MINOR AWS_SDK_VERSION_MINOR +#define AWS_CPP_SDK_VERSION_PATCH AWS_SDK_VERSION_PATCH +#define AWS_CPP_SDK_GIT_HASH "NoHashAvailableInLegacyBuild" \ No newline at end of file diff --git a/src/aws-cpp-sdk-core/source/Version.cpp b/src/aws-cpp-sdk-core/source/Version.cpp index 35291906b77..6611771f2fa 100644 --- a/src/aws-cpp-sdk-core/source/Version.cpp +++ b/src/aws-cpp-sdk-core/source/Version.cpp @@ -12,22 +12,26 @@ namespace Version { const char* GetVersionString() { - return AWS_SDK_VERSION_STRING; + return AWS_CPP_SDK_VERSION_STRING; } unsigned GetVersionMajor() { - return AWS_SDK_VERSION_MAJOR; + return AWS_CPP_SDK_VERSION_MAJOR; } unsigned GetVersionMinor() { - return AWS_SDK_VERSION_MINOR; + return AWS_CPP_SDK_VERSION_MINOR; } unsigned GetVersionPatch() { - return AWS_SDK_VERSION_PATCH; + return AWS_CPP_SDK_VERSION_PATCH; + } + + const char* GetGitHash(){ + return AWS_CPP_SDK_GIT_HASH; }