From 1160b67fa166cad5ac2e2393182ce3d9cffb37eb Mon Sep 17 00:00:00 2001 From: telendry Date: Sun, 11 Jan 2026 18:53:42 -0800 Subject: [PATCH 1/4] Packaging for RPM and DEB --- CMakeLists.txt | 7 + cmake/CPackComponents.cmake | 301 +++++++++++++++++ cmake/CPackConfig.cmake | 154 +++++++++ cmake/ServiceGroupMapping.cmake | 350 +++++++++++++++++++ cmake/deb-scripts/postinst | 14 + cmake/deb-scripts/postrm | 14 + cmake/rpm-scripts/post.sh | 10 + cmake/rpm-scripts/postun.sh | 10 + cmake/utilities.cmake | 33 +- docs/PACKAGING.md | 504 ++++++++++++++++++++++++++++ scripts/build-packages.sh | 170 ++++++++++ src/aws-cpp-sdk-core/CMakeLists.txt | 24 +- 12 files changed, 1587 insertions(+), 4 deletions(-) create mode 100644 cmake/CPackComponents.cmake create mode 100644 cmake/CPackConfig.cmake create mode 100644 cmake/ServiceGroupMapping.cmake create mode 100755 cmake/deb-scripts/postinst create mode 100755 cmake/deb-scripts/postrm create mode 100755 cmake/rpm-scripts/post.sh create mode 100755 cmake/rpm-scripts/postun.sh create mode 100644 docs/PACKAGING.md create mode 100755 scripts/build-packages.sh diff --git a/CMakeLists.txt b/CMakeLists.txt index 4fc116b70b3f..ebd94c3d4a8e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -73,6 +73,7 @@ if (LEGACY_BUILD) option(DISABLE_DNS_REQUIRED_TESTS "Disable unit tests that require DNS lookup to succeed, useful when using a http client that does not perform DNS lookup" OFF) option(AWS_APPSTORE_SAFE "Remove reference to private Apple APIs for AES GCM in Common Crypto. If set to OFF you application will get rejected from the apple app store." OFF) option(AWS_ENABLE_CORE_INTEGRATION_TEST "Enables the core integration tests to be built which contains dependencies on other clients for setup and tear down" OFF) + option(ENABLE_CPACK_PACKAGING "Enable CPack for DEB and RPM package generation (Linux only)" OFF) set(AWS_USER_AGENT_CUSTOMIZATION "" CACHE STRING "User agent extension") @@ -360,6 +361,12 @@ if (LEGACY_BUILD) else () ADD_CUSTOM_TARGET(uninstall-awssdk "${CMAKE_COMMAND}" -P "${AWS_NATIVE_SDK_ROOT}/cmake/make_uninstall.cmake") endif () + + # CPack packaging configuration (DEB and RPM packages) + if(ENABLE_CPACK_PACKAGING) + include(cmake/ServiceGroupMapping.cmake) + include(cmake/CPackConfig.cmake) + endif() else () # End of Legacy Build # -- Preamble -- message(STATUS "Building with new CMake scripts.") diff --git a/cmake/CPackComponents.cmake b/cmake/CPackComponents.cmake new file mode 100644 index 000000000000..3eb36da6ae04 --- /dev/null +++ b/cmake/CPackComponents.cmake @@ -0,0 +1,301 @@ +# CPack Component Definitions for AWS SDK C++ +# Defines component groups and components for packaging + +# Component groups represent logical groupings of AWS services +# Each group has two components: +# - {group}-runtime: Runtime libraries (.so or .a files) +# - {group}-devel: Development files (headers, CMake configs) + +# Core group (required) +cpack_add_component_group(core + DISPLAY_NAME "AWS SDK Core" + DESCRIPTION "Core SDK libraries including HTTP clients, authentication, and utilities (required)" + EXPANDED + BOLD_TITLE +) + +# Storage Services +cpack_add_component_group(storage + DISPLAY_NAME "Storage Services" + DESCRIPTION "S3, Glacier, EFS, FSx and related storage services" +) + +# Compute Services +cpack_add_component_group(compute + DISPLAY_NAME "Compute Services" + DESCRIPTION "EC2, Lambda, Batch and compute services" +) + +# Container Services +cpack_add_component_group(containers + DISPLAY_NAME "Container Services" + DESCRIPTION "ECS, EKS, ECR and container orchestration services" +) + +# Database Services +cpack_add_component_group(database + DISPLAY_NAME "Database Services" + DESCRIPTION "DynamoDB, RDS, Redshift, Neptune and database services" +) + +# Networking & Content Delivery +cpack_add_component_group(networking + DISPLAY_NAME "Networking Services" + DESCRIPTION "VPC, Route53, CloudFront, API Gateway and networking services" +) + +# Messaging & Streaming +cpack_add_component_group(messaging + DISPLAY_NAME "Messaging Services" + DESCRIPTION "SQS, SNS, Kinesis, EventBridge and messaging services" +) + +# AI & Machine Learning +cpack_add_component_group(aiml + DISPLAY_NAME "AI/ML Services" + DESCRIPTION "Bedrock, SageMaker, Rekognition, Comprehend and AI/ML services" +) + +# Analytics +cpack_add_component_group(analytics + DISPLAY_NAME "Analytics Services" + DESCRIPTION "Athena, EMR, Glue, QuickSight and analytics services" +) + +# Security & Identity +cpack_add_component_group(security + DISPLAY_NAME "Security Services" + DESCRIPTION "IAM, Cognito, KMS, Secrets Manager and security services" +) + +# Management & Governance +cpack_add_component_group(management + DISPLAY_NAME "Management Services" + DESCRIPTION "CloudFormation, CloudWatch, Config and management services" +) + +# Application Integration +cpack_add_component_group(appintegration + DISPLAY_NAME "Application Integration" + DESCRIPTION "AppConfig, AppSync, Step Functions and integration services" +) + +# Developer Tools +cpack_add_component_group(devtools + DISPLAY_NAME "Developer Tools" + DESCRIPTION "CodeCommit, CodeBuild, CodeDeploy, X-Ray and developer tools" +) + +# Media Services +cpack_add_component_group(media + DISPLAY_NAME "Media Services" + DESCRIPTION "MediaConvert, MediaLive, IVS and media services" +) + +# IoT Services +cpack_add_component_group(iot + DISPLAY_NAME "IoT Services" + DESCRIPTION "IoT Core, Greengrass and IoT services" +) + +# Business Applications +cpack_add_component_group(business + DISPLAY_NAME "Business Applications" + DESCRIPTION "WorkSpaces, Chime, Connect and business applications" +) + +# Migration & Transfer +cpack_add_component_group(migration + DISPLAY_NAME "Migration Services" + DESCRIPTION "DMS, DataSync, Transfer and migration services" +) + +# Cost Management +cpack_add_component_group(costmgmt + DISPLAY_NAME "Cost Management" + DESCRIPTION "Cost Explorer, Budgets and cost management services" +) + +# Miscellaneous Services +cpack_add_component_group(misc + DISPLAY_NAME "Miscellaneous Services" + DESCRIPTION "Other AWS services" +) + +# Define component for each group +# We use a macro to avoid repetition +macro(define_group_components GROUP_NAME DISPLAY_NAME IS_REQUIRED) + # Runtime component (libraries) + cpack_add_component(${GROUP_NAME}-runtime + DISPLAY_NAME "${DISPLAY_NAME} Runtime" + DESCRIPTION "${DISPLAY_NAME} runtime libraries" + GROUP ${GROUP_NAME} + REQUIRED ${IS_REQUIRED} + ) + + # Development component (headers + cmake configs) + cpack_add_component(${GROUP_NAME}-devel + DISPLAY_NAME "${DISPLAY_NAME} Development" + DESCRIPTION "${DISPLAY_NAME} headers and CMake configuration files" + GROUP ${GROUP_NAME} + DEPENDS ${GROUP_NAME}-runtime + ) + + # Static library component (for separate static builds) + cpack_add_component(${GROUP_NAME}-static + DISPLAY_NAME "${DISPLAY_NAME} Static" + DESCRIPTION "${DISPLAY_NAME} static libraries" + GROUP ${GROUP_NAME} + ) +endmacro() + +# Define components for all groups +define_group_components(core "Core" TRUE) +define_group_components(storage "Storage" FALSE) +define_group_components(compute "Compute" FALSE) +define_group_components(containers "Containers" FALSE) +define_group_components(database "Database" FALSE) +define_group_components(networking "Networking" FALSE) +define_group_components(messaging "Messaging" FALSE) +define_group_components(aiml "AI/ML" FALSE) +define_group_components(analytics "Analytics" FALSE) +define_group_components(security "Security" FALSE) +define_group_components(management "Management" FALSE) +define_group_components(appintegration "App Integration" FALSE) +define_group_components(devtools "Developer Tools" FALSE) +define_group_components(media "Media" FALSE) +define_group_components(iot "IoT" FALSE) +define_group_components(business "Business Apps" FALSE) +define_group_components(migration "Migration" FALSE) +define_group_components(costmgmt "Cost Management" FALSE) +define_group_components(misc "Miscellaneous" FALSE) + +# ============================================================================= +# RPM Package Configuration +# ============================================================================= + +# Macro to configure RPM package for a group +macro(configure_rpm_group GROUP_NAME) + # Runtime package + set(CPACK_RPM_${GROUP_NAME}-RUNTIME_PACKAGE_NAME "aws-sdk-cpp-${GROUP_NAME}") + set(CPACK_RPM_${GROUP_NAME}-RUNTIME_FILE_NAME "RPM-DEFAULT") + + # Development package + set(CPACK_RPM_${GROUP_NAME}-DEVEL_PACKAGE_NAME "aws-sdk-cpp-${GROUP_NAME}-devel") + set(CPACK_RPM_${GROUP_NAME}-DEVEL_FILE_NAME "RPM-DEFAULT") + + # Static package + set(CPACK_RPM_${GROUP_NAME}-STATIC_PACKAGE_NAME "aws-sdk-cpp-${GROUP_NAME}-static") + set(CPACK_RPM_${GROUP_NAME}-STATIC_FILE_NAME "RPM-DEFAULT") + + # Development package depends on runtime + set(CPACK_RPM_${GROUP_NAME}-DEVEL_PACKAGE_REQUIRES + "aws-sdk-cpp-${GROUP_NAME} = \${CPACK_PACKAGE_VERSION}") + + # Service groups depend on core (except core itself) + if(NOT GROUP_NAME STREQUAL "core") + set(CPACK_RPM_${GROUP_NAME}-RUNTIME_PACKAGE_REQUIRES + "aws-sdk-cpp-core = \${CPACK_PACKAGE_VERSION}") + set(CPACK_RPM_${GROUP_NAME}-DEVEL_PACKAGE_REQUIRES + "aws-sdk-cpp-${GROUP_NAME} = \${CPACK_PACKAGE_VERSION}, aws-sdk-cpp-core-devel = \${CPACK_PACKAGE_VERSION}") + endif() +endmacro() + +# Core package has system library dependencies +if(BUILD_SHARED_LIBS) + set(CPACK_RPM_CORE-RUNTIME_PACKAGE_REQUIRES "libcurl >= 7.58.0, openssl-libs >= 1.1.1, zlib >= 1.2.11") +endif() +set(CPACK_RPM_CORE-DEVEL_PACKAGE_REQUIRES + "aws-sdk-cpp-core = \${CPACK_PACKAGE_VERSION}, libcurl-devel >= 7.58.0, openssl-devel >= 1.1.1, zlib-devel >= 1.2.11, cmake >= 3.13") + +# Configure all groups for RPM +configure_rpm_group(core) +configure_rpm_group(storage) +configure_rpm_group(compute) +configure_rpm_group(containers) +configure_rpm_group(database) +configure_rpm_group(networking) +configure_rpm_group(messaging) +configure_rpm_group(aiml) +configure_rpm_group(analytics) +configure_rpm_group(security) +configure_rpm_group(management) +configure_rpm_group(appintegration) +configure_rpm_group(devtools) +configure_rpm_group(media) +configure_rpm_group(iot) +configure_rpm_group(business) +configure_rpm_group(migration) +configure_rpm_group(costmgmt) +configure_rpm_group(misc) + +# RPM post-install/uninstall scripts for shared libraries +if(BUILD_SHARED_LIBS AND EXISTS "${CMAKE_SOURCE_DIR}/cmake/rpm-scripts/post.sh") + set(CPACK_RPM_CORE-RUNTIME_POST_INSTALL_SCRIPT_FILE "${CMAKE_SOURCE_DIR}/cmake/rpm-scripts/post.sh") + set(CPACK_RPM_CORE-RUNTIME_POST_UNINSTALL_SCRIPT_FILE "${CMAKE_SOURCE_DIR}/cmake/rpm-scripts/postun.sh") +endif() + +# ============================================================================= +# DEB Package Configuration +# ============================================================================= + +# Macro to configure DEB package for a group +macro(configure_deb_group GROUP_NAME) + # Runtime package (follows lib* naming convention for Debian) + set(CPACK_DEBIAN_${GROUP_NAME}-RUNTIME_PACKAGE_NAME "libaws-sdk-cpp-${GROUP_NAME}") + set(CPACK_DEBIAN_${GROUP_NAME}-RUNTIME_FILE_NAME "DEB-DEFAULT") + + # Development package + set(CPACK_DEBIAN_${GROUP_NAME}-DEVEL_PACKAGE_NAME "libaws-sdk-cpp-${GROUP_NAME}-dev") + set(CPACK_DEBIAN_${GROUP_NAME}-DEVEL_FILE_NAME "DEB-DEFAULT") + + # Static package + set(CPACK_DEBIAN_${GROUP_NAME}-STATIC_PACKAGE_NAME "libaws-sdk-cpp-${GROUP_NAME}-static") + set(CPACK_DEBIAN_${GROUP_NAME}-STATIC_FILE_NAME "DEB-DEFAULT") + + # Development package depends on runtime + set(CPACK_DEBIAN_${GROUP_NAME}-DEVEL_PACKAGE_DEPENDS + "libaws-sdk-cpp-${GROUP_NAME} (= \${CPACK_PACKAGE_VERSION})") + + # Service groups depend on core (except core itself) + if(NOT GROUP_NAME STREQUAL "core") + set(CPACK_DEBIAN_${GROUP_NAME}-RUNTIME_PACKAGE_DEPENDS + "libaws-sdk-cpp-core (= \${CPACK_PACKAGE_VERSION})") + set(CPACK_DEBIAN_${GROUP_NAME}-DEVEL_PACKAGE_DEPENDS + "libaws-sdk-cpp-${GROUP_NAME} (= \${CPACK_PACKAGE_VERSION}), libaws-sdk-cpp-core-dev (= \${CPACK_PACKAGE_VERSION})") + endif() +endmacro() + +# Core package has system library dependencies +if(BUILD_SHARED_LIBS) + set(CPACK_DEBIAN_CORE-RUNTIME_PACKAGE_DEPENDS "libcurl4 (>= 7.58.0), libssl3 (>= 1.1.1) | libssl1.1 (>= 1.1.1), zlib1g (>= 1:1.2.11)") +endif() +set(CPACK_DEBIAN_CORE-DEVEL_PACKAGE_DEPENDS + "libaws-sdk-cpp-core (= \${CPACK_PACKAGE_VERSION}), libcurl4-openssl-dev (>= 7.58.0), libssl-dev (>= 1.1.1), zlib1g-dev (>= 1:1.2.11), cmake (>= 3.13)") + +# Configure all groups for DEB +configure_deb_group(core) +configure_deb_group(storage) +configure_deb_group(compute) +configure_deb_group(containers) +configure_deb_group(database) +configure_deb_group(networking) +configure_deb_group(messaging) +configure_deb_group(aiml) +configure_deb_group(analytics) +configure_deb_group(security) +configure_deb_group(management) +configure_deb_group(appintegration) +configure_deb_group(devtools) +configure_deb_group(media) +configure_deb_group(iot) +configure_deb_group(business) +configure_deb_group(migration) +configure_deb_group(costmgmt) +configure_deb_group(misc) + +# DEB post-install/remove scripts for shared libraries +if(BUILD_SHARED_LIBS AND EXISTS "${CMAKE_SOURCE_DIR}/cmake/deb-scripts/postinst") + set(CPACK_DEBIAN_CORE-RUNTIME_PACKAGE_CONTROL_EXTRA + "${CMAKE_SOURCE_DIR}/cmake/deb-scripts/postinst;${CMAKE_SOURCE_DIR}/cmake/deb-scripts/postrm") +endif() diff --git a/cmake/CPackConfig.cmake b/cmake/CPackConfig.cmake new file mode 100644 index 000000000000..a6fa4daff6b2 --- /dev/null +++ b/cmake/CPackConfig.cmake @@ -0,0 +1,154 @@ +# CPack Configuration for AWS SDK C++ +# Generates DEB and RPM packages for the AWS SDK + +# Only support Linux packaging for now +if(NOT CMAKE_SYSTEM_NAME STREQUAL "Linux") + message(STATUS "CPack packaging is currently only supported on Linux") + return() +endif() + +message(STATUS "Configuring CPack for DEB and RPM package generation") + +# ============================================================================= +# Version Information +# ============================================================================= + +# Read version from VERSION file +if(EXISTS "${CMAKE_SOURCE_DIR}/VERSION") + file(READ "${CMAKE_SOURCE_DIR}/VERSION" SDK_VERSION_STRING) + string(STRIP "${SDK_VERSION_STRING}" SDK_VERSION_STRING) + string(REPLACE "." ";" VERSION_LIST "${SDK_VERSION_STRING}") + list(LENGTH VERSION_LIST VERSION_LIST_LENGTH) + + if(VERSION_LIST_LENGTH GREATER_EQUAL 3) + list(GET VERSION_LIST 0 CPACK_PACKAGE_VERSION_MAJOR) + list(GET VERSION_LIST 1 CPACK_PACKAGE_VERSION_MINOR) + list(GET VERSION_LIST 2 CPACK_PACKAGE_VERSION_PATCH) + set(CPACK_PACKAGE_VERSION "${SDK_VERSION_STRING}") + message(STATUS "Package version: ${CPACK_PACKAGE_VERSION}") + else() + message(WARNING "VERSION file format is invalid, using default version 1.0.0") + set(CPACK_PACKAGE_VERSION "1.0.0") + set(CPACK_PACKAGE_VERSION_MAJOR "1") + set(CPACK_PACKAGE_VERSION_MINOR "0") + set(CPACK_PACKAGE_VERSION_PATCH "0") + endif() +else() + message(WARNING "VERSION file not found, using default version 1.0.0") + set(CPACK_PACKAGE_VERSION "1.0.0") + set(CPACK_PACKAGE_VERSION_MAJOR "1") + set(CPACK_PACKAGE_VERSION_MINOR "0") + set(CPACK_PACKAGE_VERSION_PATCH "0") +endif() + +# ============================================================================= +# Basic Package Information +# ============================================================================= + +set(CPACK_PACKAGE_NAME "aws-sdk-cpp") +set(CPACK_PACKAGE_VENDOR "Amazon Web Services") +set(CPACK_PACKAGE_CONTACT "AWS SDK Team ") +set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "AWS SDK for C++ - High performance C++ library for Amazon Web Services") +set(CPACK_PACKAGE_DESCRIPTION + "The AWS SDK for C++ provides a modern C++ interface for Amazon Web Services. +It provides high-level and low-level APIs for nearly all AWS features, minimizing dependencies and providing platform portability.") +set(CPACK_PACKAGE_HOMEPAGE_URL "https://github.com/aws/aws-sdk-cpp") + +# License and documentation files +if(EXISTS "${CMAKE_SOURCE_DIR}/LICENSE") + set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_SOURCE_DIR}/LICENSE") +endif() +if(EXISTS "${CMAKE_SOURCE_DIR}/README.md") + set(CPACK_RESOURCE_FILE_README "${CMAKE_SOURCE_DIR}/README.md") +endif() + +# ============================================================================= +# Generator Configuration +# ============================================================================= + +# Support both RPM and DEB generators +set(CPACK_GENERATOR "RPM;DEB") + +# Component-based packaging (creates separate packages for each component) +set(CPACK_COMPONENTS_GROUPING ONE_PER_GROUP) +set(CPACK_COMPONENT_INCLUDE_TOPLEVEL_DIRECTORY OFF) + +# Architecture detection +if(CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64|amd64|AMD64") + set(CPACK_PACKAGE_ARCHITECTURE "x86_64") +elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "aarch64|arm64|ARM64") + set(CPACK_PACKAGE_ARCHITECTURE "aarch64") +else() + set(CPACK_PACKAGE_ARCHITECTURE "${CMAKE_SYSTEM_PROCESSOR}") +endif() + +# ============================================================================= +# RPM-Specific Configuration +# ============================================================================= + +set(CPACK_RPM_COMPONENT_INSTALL ON) +set(CPACK_RPM_PACKAGE_LICENSE "Apache-2.0") +set(CPACK_RPM_PACKAGE_GROUP "Development/Libraries") +set(CPACK_RPM_PACKAGE_URL "${CPACK_PACKAGE_HOMEPAGE_URL}") +set(CPACK_RPM_PACKAGE_RELEASE "1") +set(CPACK_RPM_FILE_NAME "RPM-DEFAULT") +set(CPACK_RPM_PACKAGE_ARCHITECTURE "${CPACK_PACKAGE_ARCHITECTURE}") + +# Exclude standard system directories from RPM +set(CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION + "/usr" + "/usr/lib" + "/usr/lib64" + "/usr/lib64/cmake" + "/usr/lib/cmake" + "/usr/include" + "/usr/include/aws" + "/usr/include/smithy" + "/usr/share" + "/usr/bin" +) + +# Enable automatic dependency detection +set(CPACK_RPM_PACKAGE_AUTOREQ ON) +set(CPACK_RPM_PACKAGE_AUTOPROV ON) + +# ============================================================================= +# DEB-Specific Configuration +# ============================================================================= + +set(CPACK_DEB_COMPONENT_INSTALL ON) +set(CPACK_DEBIAN_PACKAGE_SECTION "devel") +set(CPACK_DEBIAN_PACKAGE_PRIORITY "optional") +set(CPACK_DEBIAN_FILE_NAME "DEB-DEFAULT") +set(CPACK_DEBIAN_PACKAGE_HOMEPAGE "${CPACK_PACKAGE_HOMEPAGE_URL}") +set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE "${CPACK_PACKAGE_ARCHITECTURE}") + +# Map x86_64 to amd64 for Debian +if(CPACK_PACKAGE_ARCHITECTURE STREQUAL "x86_64") + set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE "amd64") +endif() + +# Enable automatic dependency detection (requires dpkg-shlibdeps) +set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS ON) +set(CPACK_DEBIAN_PACKAGE_GENERATE_SHLIBS ON) + +# ============================================================================= +# Include Component Definitions +# ============================================================================= + +# This file defines all component groups and their dependencies +include(${CMAKE_CURRENT_LIST_DIR}/CPackComponents.cmake) + +# ============================================================================= +# Include CPack Module +# ============================================================================= + +# This must come last to process all the configuration +include(CPack) + +message(STATUS "CPack configuration complete") +message(STATUS " Generators: RPM, DEB") +message(STATUS " Package name: ${CPACK_PACKAGE_NAME}") +message(STATUS " Package version: ${CPACK_PACKAGE_VERSION}") +message(STATUS " Library type: ${BUILD_SHARED_LIBS}") +message(STATUS "To generate packages, run: cpack -G RPM or cpack -G DEB") diff --git a/cmake/ServiceGroupMapping.cmake b/cmake/ServiceGroupMapping.cmake new file mode 100644 index 000000000000..7b765f2207c1 --- /dev/null +++ b/cmake/ServiceGroupMapping.cmake @@ -0,0 +1,350 @@ +# Service Group Mapping for CPack Component-Based Packaging +# Maps individual AWS service libraries to logical package groups + +# Function: get_service_group_component +# Maps a service name to its package group component +# Args: +# SERVICE_NAME - The service library name (e.g., "aws-cpp-sdk-s3") +# OUTPUT_VAR - Variable name to store the result +# Returns: +# Sets OUTPUT_VAR to the group name (e.g., "storage") +function(get_service_group_component SERVICE_NAME OUTPUT_VAR) + # Core services (always required) + if(SERVICE_NAME MATCHES "^aws-cpp-sdk-(core|access-management|identity-management|queues|text-to-speech|transfer)$") + set(${OUTPUT_VAR} "core" PARENT_SCOPE) + return() + endif() + + # Storage services + if(SERVICE_NAME MATCHES "^aws-cpp-sdk-(s3|s3-crt|s3control|s3outposts|s3tables|s3vectors|s3-encryption)") + set(${OUTPUT_VAR} "storage" PARENT_SCOPE) + return() + endif() + if(SERVICE_NAME MATCHES "^aws-cpp-sdk-(glacier|backup|backup-gateway|backupsearch)") + set(${OUTPUT_VAR} "storage" PARENT_SCOPE) + return() + endif() + if(SERVICE_NAME MATCHES "^aws-cpp-sdk-(storagegateway|storage-gateway|fsx|elasticfilesystem)") + set(${OUTPUT_VAR} "storage" PARENT_SCOPE) + return() + endif() + + # Compute services + if(SERVICE_NAME MATCHES "^aws-cpp-sdk-(ec2|ec2-instance-connect)") + set(${OUTPUT_VAR} "compute" PARENT_SCOPE) + return() + endif() + if(SERVICE_NAME MATCHES "^aws-cpp-sdk-(lambda|batch|lightsail)") + set(${OUTPUT_VAR} "compute" PARENT_SCOPE) + return() + endif() + if(SERVICE_NAME MATCHES "^aws-cpp-sdk-(elasticbeanstalk|elastic-beanstalk)") + set(${OUTPUT_VAR} "compute" PARENT_SCOPE) + return() + endif() + + # Container services + if(SERVICE_NAME MATCHES "^aws-cpp-sdk-(ecs|eks|eks-auth)") + set(${OUTPUT_VAR} "containers" PARENT_SCOPE) + return() + endif() + if(SERVICE_NAME MATCHES "^aws-cpp-sdk-(ecr|ecr-public)") + set(${OUTPUT_VAR} "containers" PARENT_SCOPE) + return() + endif() + if(SERVICE_NAME MATCHES "^aws-cpp-sdk-(apprunner|app-runner)") + set(${OUTPUT_VAR} "containers" PARENT_SCOPE) + return() + endif() + + # Database services + if(SERVICE_NAME MATCHES "^aws-cpp-sdk-(dynamodb|dynamodbstreams)") + set(${OUTPUT_VAR} "database" PARENT_SCOPE) + return() + endif() + if(SERVICE_NAME MATCHES "^aws-cpp-sdk-(rds|rds-data)") + set(${OUTPUT_VAR} "database" PARENT_SCOPE) + return() + endif() + if(SERVICE_NAME MATCHES "^aws-cpp-sdk-(redshift|redshift-data|redshift-serverless)") + set(${OUTPUT_VAR} "database" PARENT_SCOPE) + return() + endif() + if(SERVICE_NAME MATCHES "^aws-cpp-sdk-(neptune|neptune-data|neptunegraph)") + set(${OUTPUT_VAR} "database" PARENT_SCOPE) + return() + endif() + if(SERVICE_NAME MATCHES "^aws-cpp-sdk-(docdb|docdb-elastic)") + set(${OUTPUT_VAR} "database" PARENT_SCOPE) + return() + endif() + if(SERVICE_NAME MATCHES "^aws-cpp-sdk-(timestream-query|timestream-write|timestream-influxdb)") + set(${OUTPUT_VAR} "database" PARENT_SCOPE) + return() + endif() + if(SERVICE_NAME MATCHES "^aws-cpp-sdk-(memorydb|elasticache|dsql)") + set(${OUTPUT_VAR} "database" PARENT_SCOPE) + return() + endif() + + # Networking & Content Delivery + if(SERVICE_NAME MATCHES "^aws-cpp-sdk-(vpc-lattice|route53|route53domains|route53resolver|route53profiles)") + set(${OUTPUT_VAR} "networking" PARENT_SCOPE) + return() + endif() + if(SERVICE_NAME MATCHES "^aws-cpp-sdk-(route53-recovery-cluster|route53-recovery-control-config|route53-recovery-readiness)") + set(${OUTPUT_VAR} "networking" PARENT_SCOPE) + return() + endif() + if(SERVICE_NAME MATCHES "^aws-cpp-sdk-(cloudfront|cloudfront-keyvaluestore)") + set(${OUTPUT_VAR} "networking" PARENT_SCOPE) + return() + endif() + if(SERVICE_NAME MATCHES "^aws-cpp-sdk-(elb|elasticloadbalancing|elasticloadbalancingv2)") + set(${OUTPUT_VAR} "networking" PARENT_SCOPE) + return() + endif() + if(SERVICE_NAME MATCHES "^aws-cpp-sdk-(apigateway|apigatewaymanagementapi|apigatewayv2)") + set(${OUTPUT_VAR} "networking" PARENT_SCOPE) + return() + endif() + if(SERVICE_NAME MATCHES "^aws-cpp-sdk-(directconnect|globalaccelerator)") + set(${OUTPUT_VAR} "networking" PARENT_SCOPE) + return() + endif() + + # Messaging & Streaming + if(SERVICE_NAME MATCHES "^aws-cpp-sdk-(sqs|sns)") + set(${OUTPUT_VAR} "messaging" PARENT_SCOPE) + return() + endif() + if(SERVICE_NAME MATCHES "^aws-cpp-sdk-(kinesis|kinesisanalytics|kinesisanalyticsv2)") + set(${OUTPUT_VAR} "messaging" PARENT_SCOPE) + return() + endif() + if(SERVICE_NAME MATCHES "^aws-cpp-sdk-(kinesisvideo|kinesis-video)") + set(${OUTPUT_VAR} "messaging" PARENT_SCOPE) + return() + endif() + if(SERVICE_NAME MATCHES "^aws-cpp-sdk-(eventbridge|events|mq)") + set(${OUTPUT_VAR} "messaging" PARENT_SCOPE) + return() + endif() + + # AI & Machine Learning + if(SERVICE_NAME MATCHES "^aws-cpp-sdk-(bedrock|bedrock-runtime|bedrock-agent|bedrock-agent-runtime)") + set(${OUTPUT_VAR} "aiml" PARENT_SCOPE) + return() + endif() + if(SERVICE_NAME MATCHES "^aws-cpp-sdk-(bedrock-agentcore|bedrock-agentcore-control|bedrock-data-automation|bedrock-data-automation-runtime)") + set(${OUTPUT_VAR} "aiml" PARENT_SCOPE) + return() + endif() + if(SERVICE_NAME MATCHES "^aws-cpp-sdk-(sagemaker|sagemaker-runtime|sagemaker-a2i-runtime|sagemaker-edge)") + set(${OUTPUT_VAR} "aiml" PARENT_SCOPE) + return() + endif() + if(SERVICE_NAME MATCHES "^aws-cpp-sdk-(sagemaker-featurestore-runtime|sagemaker-geospatial|sagemaker-metrics)") + set(${OUTPUT_VAR} "aiml" PARENT_SCOPE) + return() + endif() + if(SERVICE_NAME MATCHES "^aws-cpp-sdk-(rekognition|comprehend|comprehendmedical)") + set(${OUTPUT_VAR} "aiml" PARENT_SCOPE) + return() + endif() + if(SERVICE_NAME MATCHES "^aws-cpp-sdk-(textract|translate)") + set(${OUTPUT_VAR} "aiml" PARENT_SCOPE) + return() + endif() + if(SERVICE_NAME MATCHES "^aws-cpp-sdk-(transcribe|transcribestreaming)") + set(${OUTPUT_VAR} "aiml" PARENT_SCOPE) + return() + endif() + if(SERVICE_NAME MATCHES "^aws-cpp-sdk-(polly|lexv2-models|lexv2-runtime|lex-models|lex)") + set(${OUTPUT_VAR} "aiml" PARENT_SCOPE) + return() + endif() + + # Analytics + if(SERVICE_NAME MATCHES "^aws-cpp-sdk-(athena|emr|emr-containers|emr-serverless)") + set(${OUTPUT_VAR} "analytics" PARENT_SCOPE) + return() + endif() + if(SERVICE_NAME MATCHES "^aws-cpp-sdk-(glue|gluedatabrew|databrew)") + set(${OUTPUT_VAR} "analytics" PARENT_SCOPE) + return() + endif() + if(SERVICE_NAME MATCHES "^aws-cpp-sdk-(quicksight|opensearch|opensearchserverless)") + set(${OUTPUT_VAR} "analytics" PARENT_SCOPE) + return() + endif() + if(SERVICE_NAME MATCHES "^aws-cpp-sdk-(elasticsearch|es)") + set(${OUTPUT_VAR} "analytics" PARENT_SCOPE) + return() + endif() + if(SERVICE_NAME MATCHES "^aws-cpp-sdk-(datazone|cleanrooms|cleanroomsml|entityresolution)") + set(${OUTPUT_VAR} "analytics" PARENT_SCOPE) + return() + endif() + + # Security & Identity + if(SERVICE_NAME MATCHES "^aws-cpp-sdk-(iam|sts)") + set(${OUTPUT_VAR} "security" PARENT_SCOPE) + return() + endif() + if(SERVICE_NAME MATCHES "^aws-cpp-sdk-(cognito-identity|cognito-idp|cognito-sync)") + set(${OUTPUT_VAR} "security" PARENT_SCOPE) + return() + endif() + if(SERVICE_NAME MATCHES "^aws-cpp-sdk-(kms|secretsmanager|secrets-manager)") + set(${OUTPUT_VAR} "security" PARENT_SCOPE) + return() + endif() + if(SERVICE_NAME MATCHES "^aws-cpp-sdk-(acm|acm-pca)") + set(${OUTPUT_VAR} "security" PARENT_SCOPE) + return() + endif() + if(SERVICE_NAME MATCHES "^aws-cpp-sdk-(waf|waf-regional|wafv2)") + set(${OUTPUT_VAR} "security" PARENT_SCOPE) + return() + endif() + if(SERVICE_NAME MATCHES "^aws-cpp-sdk-(shield|guardduty)") + set(${OUTPUT_VAR} "security" PARENT_SCOPE) + return() + endif() + if(SERVICE_NAME MATCHES "^aws-cpp-sdk-(macie|macie2)") + set(${OUTPUT_VAR} "security" PARENT_SCOPE) + return() + endif() + if(SERVICE_NAME MATCHES "^aws-cpp-sdk-(inspector|inspector2|inspectorcan|inspector-scan)") + set(${OUTPUT_VAR} "security" PARENT_SCOPE) + return() + endif() + if(SERVICE_NAME MATCHES "^aws-cpp-sdk-(securityhub|security-lake|detective)") + set(${OUTPUT_VAR} "security" PARENT_SCOPE) + return() + endif() + if(SERVICE_NAME MATCHES "^aws-cpp-sdk-(verified-permissions|verifiedpermissions|accessanalyzer)") + set(${OUTPUT_VAR} "security" PARENT_SCOPE) + return() + endif() + if(SERVICE_NAME MATCHES "^aws-cpp-sdk-(rolesanywhere)") + set(${OUTPUT_VAR} "security" PARENT_SCOPE) + return() + endif() + + # Management & Governance + if(SERVICE_NAME MATCHES "^aws-cpp-sdk-(cloudformation|cloudtrail|cloudtrail-data)") + set(${OUTPUT_VAR} "management" PARENT_SCOPE) + return() + endif() + if(SERVICE_NAME MATCHES "^aws-cpp-sdk-(monitoring|logs|synthetics|cloudwatch)") + set(${OUTPUT_VAR} "management" PARENT_SCOPE) + return() + endif() + if(SERVICE_NAME MATCHES "^aws-cpp-sdk-(config|ssm|systems-manager)") + set(${OUTPUT_VAR} "management" PARENT_SCOPE) + return() + endif() + if(SERVICE_NAME MATCHES "^aws-cpp-sdk-(ssm-contacts|ssm-incidents|ssm-quicksetup|ssm-sap)") + set(${OUTPUT_VAR} "management" PARENT_SCOPE) + return() + endif() + if(SERVICE_NAME MATCHES "^aws-cpp-sdk-(organizations|servicecatalog|servicecatalog-appregistry)") + set(${OUTPUT_VAR} "management" PARENT_SCOPE) + return() + endif() + if(SERVICE_NAME MATCHES "^aws-cpp-sdk-(resource-groups|resource-explorer-2)") + set(${OUTPUT_VAR} "management" PARENT_SCOPE) + return() + endif() + if(SERVICE_NAME MATCHES "^aws-cpp-sdk-(application-autoscaling|autoscaling|autoscaling-plans)") + set(${OUTPUT_VAR} "management" PARENT_SCOPE) + return() + endif() + if(SERVICE_NAME MATCHES "^aws-cpp-sdk-(opsworks|opsworkscm)") + set(${OUTPUT_VAR} "management" PARENT_SCOPE) + return() + endif() + if(SERVICE_NAME MATCHES "^aws-cpp-sdk-(trustedadvisor|health|healthlake)") + set(${OUTPUT_VAR} "management" PARENT_SCOPE) + return() + endif() + if(SERVICE_NAME MATCHES "^aws-cpp-sdk-(servicequotas|support|supportapp)") + set(${OUTPUT_VAR} "management" PARENT_SCOPE) + return() + endif() + if(SERVICE_NAME MATCHES "^aws-cpp-sdk-(controltower|cloudcontrol)") + set(${OUTPUT_VAR} "management" PARENT_SCOPE) + return() + endif() + + # Application Integration + if(SERVICE_NAME MATCHES "^aws-cpp-sdk-(appconfig|appconfigdata)") + set(${OUTPUT_VAR} "appintegration" PARENT_SCOPE) + return() + endif() + if(SERVICE_NAME MATCHES "^aws-cpp-sdk-(appsync)") + set(${OUTPUT_VAR} "appintegration" PARENT_SCOPE) + return() + endif() + if(SERVICE_NAME MATCHES "^aws-cpp-sdk-(step-functions|sfn)") + set(${OUTPUT_VAR} "appintegration" PARENT_SCOPE) + return() + endif() + if(SERVICE_NAME MATCHES "^aws-cpp-sdk-(appflow|appintegrations)") + set(${OUTPUT_VAR} "appintegration" PARENT_SCOPE) + return() + endif() + if(SERVICE_NAME MATCHES "^aws-cpp-sdk-(scheduler|eventbridge)") + set(${OUTPUT_VAR} "appintegration" PARENT_SCOPE) + return() + endif() + + # Developer Tools + if(SERVICE_NAME MATCHES "^aws-cpp-sdk-(code|xray)") + set(${OUTPUT_VAR} "devtools" PARENT_SCOPE) + return() + endif() + if(SERVICE_NAME MATCHES "^aws-cpp-sdk-(cloud9)") + set(${OUTPUT_VAR} "devtools" PARENT_SCOPE) + return() + endif() + + # Media Services + if(SERVICE_NAME MATCHES "^aws-cpp-sdk-(media|ivs|elemental)") + set(${OUTPUT_VAR} "media" PARENT_SCOPE) + return() + endif() + + # IoT + if(SERVICE_NAME MATCHES "^aws-cpp-sdk-(iot|greengrass)") + set(${OUTPUT_VAR} "iot" PARENT_SCOPE) + return() + endif() + + # Business Applications + if(SERVICE_NAME MATCHES "^aws-cpp-sdk-(workspaces|workdocs|workmail|chime|connect|wisdom|voice-id)") + set(${OUTPUT_VAR} "business" PARENT_SCOPE) + return() + endif() + + # Migration & Transfer + if(SERVICE_NAME MATCHES "^aws-cpp-sdk-(dms|migration|datasync|snowball|discovery)") + set(${OUTPUT_VAR} "migration" PARENT_SCOPE) + return() + endif() + if(SERVICE_NAME MATCHES "^aws-cpp-sdk-(awstransfer)") + set(${OUTPUT_VAR} "migration" PARENT_SCOPE) + return() + endif() + + # Cost Management + if(SERVICE_NAME MATCHES "^aws-cpp-sdk-(ce|budgets|billing|bcm|pricing|savingsplans|marketplace|artifact)") + set(${OUTPUT_VAR} "costmgmt" PARENT_SCOPE) + return() + endif() + + # Miscellaneous - catch-all for services not in other groups + set(${OUTPUT_VAR} "misc" PARENT_SCOPE) +endfunction() diff --git a/cmake/deb-scripts/postinst b/cmake/deb-scripts/postinst new file mode 100755 index 000000000000..d64ce0bdc73b --- /dev/null +++ b/cmake/deb-scripts/postinst @@ -0,0 +1,14 @@ +#!/bin/sh +# DEB post-install script for AWS SDK C++ +# Updates the shared library cache after installation + +set -e + +# Only run ldconfig on configure +if [ "$1" = "configure" ]; then + if [ -x /sbin/ldconfig ]; then + ldconfig + fi +fi + +exit 0 diff --git a/cmake/deb-scripts/postrm b/cmake/deb-scripts/postrm new file mode 100755 index 000000000000..afe06427c85e --- /dev/null +++ b/cmake/deb-scripts/postrm @@ -0,0 +1,14 @@ +#!/bin/sh +# DEB post-remove script for AWS SDK C++ +# Updates the shared library cache after removal + +set -e + +# Run ldconfig on remove +if [ "$1" = "remove" ]; then + if [ -x /sbin/ldconfig ]; then + ldconfig + fi +fi + +exit 0 diff --git a/cmake/rpm-scripts/post.sh b/cmake/rpm-scripts/post.sh new file mode 100755 index 000000000000..f15c8af1fa40 --- /dev/null +++ b/cmake/rpm-scripts/post.sh @@ -0,0 +1,10 @@ +#!/bin/sh +# RPM post-install script for AWS SDK C++ +# Updates the shared library cache after installation + +# Run ldconfig to update the shared library cache +if [ -x /sbin/ldconfig ]; then + /sbin/ldconfig +fi + +exit 0 diff --git a/cmake/rpm-scripts/postun.sh b/cmake/rpm-scripts/postun.sh new file mode 100755 index 000000000000..7d9c9b664273 --- /dev/null +++ b/cmake/rpm-scripts/postun.sh @@ -0,0 +1,10 @@ +#!/bin/sh +# RPM post-uninstall script for AWS SDK C++ +# Updates the shared library cache after uninstallation + +# Run ldconfig to update the shared library cache +if [ -x /sbin/ldconfig ]; then + /sbin/ldconfig +fi + +exit 0 diff --git a/cmake/utilities.cmake b/cmake/utilities.cmake index 9b780021fe96..7ca3bf0e38bc 100644 --- a/cmake/utilities.cmake +++ b/cmake/utilities.cmake @@ -84,16 +84,33 @@ macro(setup_install) if(SIMPLE_INSTALL) configure_file("${AWS_NATIVE_SDK_ROOT}/toolchains/pkg-config.pc.in" "${PROJECT_NAME}.pc" @ONLY) + # Determine the component for this library based on service group mapping + if(COMMAND get_service_group_component) + get_service_group_component(${PROJECT_NAME} SERVICE_GROUP) + if(BUILD_SHARED_LIBS) + set(INSTALL_COMPONENT "${SERVICE_GROUP}-runtime") + else() + set(INSTALL_COMPONENT "${SERVICE_GROUP}-static") + endif() + else() + # Fallback if service group mapping not available + set(INSTALL_COMPONENT "Unspecified") + endif() + install( TARGETS ${PROJECT_NAME} EXPORT "${PROJECT_NAME}-targets" ARCHIVE DESTINATION ${ARCHIVE_DIRECTORY} + COMPONENT ${INSTALL_COMPONENT} LIBRARY DESTINATION ${LIBRARY_DIRECTORY} - RUNTIME DESTINATION ${BINARY_DIRECTORY} ) + COMPONENT ${INSTALL_COMPONENT} + RUNTIME DESTINATION ${BINARY_DIRECTORY} + COMPONENT ${INSTALL_COMPONENT} ) if (BUILD_SHARED_LIBS) install( FILES "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.pc" - DESTINATION ${LIBRARY_DIRECTORY}/pkgconfig) + DESTINATION ${LIBRARY_DIRECTORY}/pkgconfig + COMPONENT ${INSTALL_COMPONENT}) endif() else() if(PLATFORM_CUSTOM) @@ -132,10 +149,20 @@ macro(do_packaging) @ONLY) endif() + # Determine the development component for this library + if(COMMAND get_service_group_component) + get_service_group_component(${PROJECT_NAME} SERVICE_GROUP) + set(DEVEL_COMPONENT "${SERVICE_GROUP}-devel") + else() + # Fallback if service group mapping not available + set(DEVEL_COMPONENT "Devel") + endif() + set(ConfigPackageLocation "${LIBRARY_DIRECTORY}/cmake/${PROJECT_NAME}") install(EXPORT "${PROJECT_NAME}-targets" FILE "${PROJECT_NAME}-targets.cmake" DESTINATION ${ConfigPackageLocation} + COMPONENT ${DEVEL_COMPONENT} ) install( @@ -145,7 +172,7 @@ macro(do_packaging) DESTINATION ${ConfigPackageLocation} COMPONENT - Devel) + ${DEVEL_COMPONENT}) endif() if (MSVC AND BUILD_SHARED_LIBS) install (FILES $ DESTINATION ${CMAKE_INSTALL_BINDIR} OPTIONAL) diff --git a/docs/PACKAGING.md b/docs/PACKAGING.md new file mode 100644 index 000000000000..04fa8dcf682a --- /dev/null +++ b/docs/PACKAGING.md @@ -0,0 +1,504 @@ +# AWS SDK for C++ - Package Building Guide + +This document describes how to build and use DEB and RPM packages for the AWS SDK for C++. + +## Overview + +The AWS SDK for C++ provides CPack-based packaging support for generating DEB and RPM packages. The packages are organized into logical service groups, with separate binary (runtime) and development packages for each group. + +### Package Types + +1. **Runtime Packages**: Contain compiled libraries (.so or .a files) and pkg-config files +2. **Development Packages**: Contain header files and CMake configuration files + +### Package Formats + +- **RPM**: For Red Hat, Fedora, CentOS, Amazon Linux, and other RPM-based distributions +- **DEB**: For Debian, Ubuntu, and other DEB-based distributions + +## Service Groups + +The 418+ AWS services are organized into 19 logical groups to avoid creating hundreds of individual packages: + +| Group | Services Included | +|-------|-------------------| +| **core** | aws-cpp-sdk-core, access-management, identity-management, queues, text-to-speech, transfer | +| **storage** | S3, Glacier, EFS, FSx, Backup, Storage Gateway | +| **compute** | EC2, Lambda, Batch, Lightsail, Elastic Beanstalk | +| **containers** | ECS, EKS, ECR, App Runner | +| **database** | DynamoDB, RDS, Redshift, Neptune, DocumentDB, ElastiCache, MemoryDB | +| **networking** | VPC, Route53, CloudFront, ELB, API Gateway, Direct Connect | +| **messaging** | SQS, SNS, Kinesis, EventBridge, MQ | +| **aiml** | Bedrock, SageMaker, Rekognition, Comprehend, Textract, Transcribe, Polly, Lex | +| **analytics** | Athena, EMR, Glue, QuickSight, OpenSearch, Clean Rooms | +| **security** | IAM, STS, Cognito, KMS, Secrets Manager, WAF, GuardDuty, Macie, Inspector | +| **management** | CloudFormation, CloudWatch, Config, Systems Manager, Organizations | +| **appintegration** | AppConfig, AppSync, Step Functions, AppFlow, EventBridge Scheduler | +| **devtools** | CodeCommit, CodeBuild, CodeDeploy, CodePipeline, X-Ray, Cloud9 | +| **media** | MediaConvert, MediaLive, MediaPackage, IVS, Elemental | +| **iot** | IoT Core, IoT Analytics, IoT Events, Greengrass | +| **business** | WorkSpaces, WorkDocs, WorkMail, Chime, Connect | +| **migration** | DMS, DataSync, Transfer, Snow Family, Migration Hub | +| **costmgmt** | Cost Explorer, Budgets, Billing, Pricing, Savings Plans, Marketplace | +| **misc** | Other services not in above groups | + +## Package Naming + +### RPM Packages + +``` +Runtime: aws-sdk-cpp-{group}-{version}-{release}.{arch}.rpm +Development: aws-sdk-cpp-{group}-devel-{version}-{release}.{arch}.rpm +Static: aws-sdk-cpp-{group}-static-{version}-{release}.{arch}.rpm +``` + +Examples: +- `aws-sdk-cpp-core-1.11.725-1.x86_64.rpm` +- `aws-sdk-cpp-core-devel-1.11.725-1.x86_64.rpm` +- `aws-sdk-cpp-storage-1.11.725-1.x86_64.rpm` + +### DEB Packages + +``` +Runtime: libaws-sdk-cpp-{group}_{version}-{release}_{arch}.deb +Development: libaws-sdk-cpp-{group}-dev_{version}-{release}_{arch}.deb +Static: libaws-sdk-cpp-{group}-static_{version}-{release}_{arch}.deb +``` + +Examples: +- `libaws-sdk-cpp-core_1.11.725-1_amd64.deb` +- `libaws-sdk-cpp-core-dev_1.11.725-1_amd64.deb` +- `libaws-sdk-cpp-storage_1.11.725-1_amd64.deb` + +## Building Packages + +### Prerequisites + +**System Requirements:** +- Linux operating system +- CMake 3.13 or later +- GCC/Clang compiler +- rpmbuild (for RPM packages) +- dpkg-dev (for DEB packages) + +**System Dependencies:** +- libcurl development headers +- OpenSSL development headers +- zlib development headers + +**Install dependencies on different distributions:** + +```bash +# Amazon Linux / RHEL / CentOS / Fedora +sudo yum install cmake3 gcc-c++ libcurl-devel openssl-devel zlib-devel rpm-build + +# Debian / Ubuntu +sudo apt install cmake g++ libcurl4-openssl-dev libssl-dev zlib1g-dev dpkg-dev rpm +``` + +### Using the Build Script (Recommended) + +The easiest way to build packages is using the provided automation script: + +```bash +# Build shared libraries with default services (core, s3, ec2, dynamodb, lambda) +./scripts/build-packages.sh + +# Build all services as shared libraries +./scripts/build-packages.sh Release shared all + +# Build specific services as static libraries +./scripts/build-packages.sh Release static "s3;ec2;dynamodb" +``` + +**Script Parameters:** +1. `BUILD_TYPE`: Release, Debug, RelWithDebInfo, or MinSizeRel (default: Release) +2. `LIBRARY_TYPE`: shared or static (default: shared) +3. `BUILD_SERVICES`: Semicolon-separated service list or "all" (default: "core;s3;ec2;dynamodb;lambda") + +### Manual Build Process + +If you prefer to build packages manually: + +#### Step 1: Configure CMake + +```bash +mkdir build-packaging && cd build-packaging + +cmake .. \ + -DCMAKE_BUILD_TYPE=Release \ + -DBUILD_SHARED_LIBS=ON \ + -DBUILD_ONLY="s3;ec2;dynamodb;lambda" \ + -DSIMPLE_INSTALL=ON \ + -DENABLE_CPACK_PACKAGING=ON \ + -DCMAKE_INSTALL_PREFIX=/usr \ + -DCMAKE_INSTALL_LIBDIR=lib64 \ + -DUSE_OPENSSL=ON \ + -DFORCE_CURL=ON \ + -DENABLE_TESTING=OFF +``` + +**Important CMake Options:** +- `-DENABLE_CPACK_PACKAGING=ON` - **Required** to enable package generation +- `-DSIMPLE_INSTALL=ON` - **Required** for standard Linux filesystem layout +- `-DBUILD_SHARED_LIBS=ON` - Build shared libraries (OFF for static) +- `-DBUILD_ONLY="list"` - Build only specified services (omit to build all) +- `-DCMAKE_INSTALL_PREFIX=/usr` - Install location (standard is /usr) +- `-DCMAKE_INSTALL_LIBDIR=lib64` - Use lib64 on x86_64 systems + +#### Step 2: Build the SDK + +```bash +make -j$(nproc) +``` + +#### Step 3: Generate Packages + +```bash +# Generate both RPM and DEB packages +cpack -G "RPM;DEB" + +# Or generate individually +cpack -G RPM +cpack -G DEB +``` + +The packages will be created in the current build directory. + +## Installing Packages + +### RPM Installation + +**Using rpm command:** + +```bash +# Install core library (required) +sudo rpm -ivh aws-sdk-cpp-core-1.11.725-1.x86_64.rpm +sudo rpm -ivh aws-sdk-cpp-core-devel-1.11.725-1.x86_64.rpm + +# Install additional service groups +sudo rpm -ivh aws-sdk-cpp-storage-1.11.725-1.x86_64.rpm +sudo rpm -ivh aws-sdk-cpp-storage-devel-1.11.725-1.x86_64.rpm +``` + +**Using yum/dnf (handles dependencies automatically):** + +```bash +sudo yum install ./aws-sdk-cpp-core-*.rpm ./aws-sdk-cpp-storage-*.rpm +``` + +**Verify installation:** + +```bash +# List installed packages +rpm -qa | grep aws-sdk-cpp + +# Check package contents +rpm -ql aws-sdk-cpp-core +rpm -ql aws-sdk-cpp-core-devel + +# Check dependencies +rpm -qR aws-sdk-cpp-storage +``` + +### DEB Installation + +**Using dpkg command:** + +```bash +# Install core library (required) +sudo dpkg -i libaws-sdk-cpp-core_1.11.725-1_amd64.deb +sudo dpkg -i libaws-sdk-cpp-core-dev_1.11.725-1_amd64.deb + +# Install additional service groups +sudo dpkg -i libaws-sdk-cpp-storage_1.11.725-1_amd64.deb +sudo dpkg -i libaws-sdk-cpp-storage-dev_1.11.725-1_amd64.deb +``` + +**Using apt (handles dependencies automatically):** + +```bash +sudo apt install ./libaws-sdk-cpp-core_*.deb ./libaws-sdk-cpp-storage_*.deb +``` + +**Verify installation:** + +```bash +# List installed packages +dpkg -l | grep aws-sdk-cpp + +# Check package contents +dpkg -L libaws-sdk-cpp-core +dpkg -L libaws-sdk-cpp-core-dev + +# Check dependencies +dpkg-deb -I libaws-sdk-cpp-storage_*.deb +``` + +## Using the SDK from Packages + +### CMake Integration + +After installing the packages, you can use CMake's `find_package()` to locate the SDK: + +```cmake +cmake_minimum_required(VERSION 3.13) +project(MyAWSApp) + +# Find the AWS SDK packages +find_package(aws-cpp-sdk-core REQUIRED) +find_package(aws-cpp-sdk-s3 REQUIRED) + +# Create your executable +add_executable(myapp main.cpp) + +# Link against AWS SDK libraries +target_link_libraries(myapp + AWS::aws-cpp-sdk-core + AWS::aws-cpp-sdk-s3 +) +``` + +### Example Application + +```cpp +#include +#include +#include +#include + +int main() { + Aws::SDKOptions options; + Aws::InitAPI(options); + { + Aws::S3::S3Client s3_client; + auto outcome = s3_client.ListBuckets(); + + if (outcome.IsSuccess()) { + std::cout << "S3 Buckets:\n"; + for (const auto& bucket : outcome.GetResult().GetBuckets()) { + std::cout << " " << bucket.GetName() << std::endl; + } + } + } + Aws::ShutdownAPI(options); + return 0; +} +``` + +**Build the application:** + +```bash +mkdir build && cd build +cmake .. +make +./myapp +``` + +### pkg-config Integration + +For non-CMake projects, you can use pkg-config (shared libraries only): + +```bash +# Get compile flags +pkg-config --cflags aws-cpp-sdk-core aws-cpp-sdk-s3 + +# Get link flags +pkg-config --libs aws-cpp-sdk-core aws-cpp-sdk-s3 + +# Compile example +g++ myapp.cpp $(pkg-config --cflags --libs aws-cpp-sdk-core aws-cpp-sdk-s3) -o myapp +``` + +## Package Dependencies + +### Runtime Package Dependencies + +All service group runtime packages depend on: +- **aws-sdk-cpp-core** (or libaws-sdk-cpp-core) - Required +- **libcurl** >= 7.58.0 +- **openssl-libs** (or libssl) >= 1.1.1 +- **zlib** >= 1.2.11 + +### Development Package Dependencies + +All service group development packages depend on: +- Corresponding runtime package (same version) +- **aws-sdk-cpp-core-devel** (or libaws-sdk-cpp-core-dev) +- Development headers for: libcurl, OpenSSL, zlib +- **cmake** >= 3.13 + +## Uninstalling Packages + +### RPM Uninstallation + +```bash +# Remove specific packages +sudo rpm -e aws-sdk-cpp-storage-devel aws-sdk-cpp-storage + +# Remove all AWS SDK packages +sudo rpm -e $(rpm -qa | grep aws-sdk-cpp) +``` + +### DEB Uninstallation + +```bash +# Remove specific packages +sudo apt remove libaws-sdk-cpp-storage-dev libaws-sdk-cpp-storage + +# Remove all AWS SDK packages +sudo apt remove libaws-sdk-cpp-* +``` + +## Troubleshooting + +### Missing Dependencies + +If package installation fails due to missing dependencies: + +```bash +# RPM: Install dependencies first +sudo yum install libcurl openssl-libs zlib + +# DEB: Use apt to handle dependencies +sudo apt install -f +``` + +### CMake Can't Find Package + +Ensure the development package is installed: + +```bash +# Check if installed +rpm -q aws-sdk-cpp-core-devel # RPM +dpkg -l | grep libaws-sdk-cpp-core-dev # DEB + +# Verify CMake config files exist +ls /usr/lib64/cmake/aws-cpp-sdk-core/ # RPM (x86_64) +ls /usr/lib/cmake/aws-cpp-sdk-core/ # DEB +``` + +### Library Not Found at Runtime + +Update the library cache: + +```bash +sudo ldconfig +``` + +Or check your LD_LIBRARY_PATH: + +```bash +export LD_LIBRARY_PATH=/usr/lib64:$LD_LIBRARY_PATH +``` + +### Package Version Conflicts + +When upgrading, remove old packages first: + +```bash +# RPM +sudo rpm -e --nodeps aws-sdk-cpp-core # Remove without dependencies +sudo rpm -ivh aws-sdk-cpp-core-NEW.rpm # Install new version + +# DEB +sudo dpkg --purge libaws-sdk-cpp-core +sudo dpkg -i libaws-sdk-cpp-core_NEW.deb +``` + +## Advanced Topics + +### Building Static Library Packages + +```bash +cmake .. \ + -DCMAKE_BUILD_TYPE=Release \ + -DBUILD_SHARED_LIBS=OFF \ + -DENABLE_CPACK_PACKAGING=ON \ + -DSIMPLE_INSTALL=ON \ + -DCMAKE_INSTALL_PREFIX=/usr + +make -j$(nproc) +cpack -G "RPM;DEB" +``` + +Static packages are named with `-static` suffix: +- `aws-sdk-cpp-core-static-1.11.725-1.x86_64.rpm` +- `libaws-sdk-cpp-core-static_1.11.725-1_amd64.deb` + +### Cross-Architecture Builds + +The packaging system automatically detects the build architecture: +- x86_64 / amd64 (Intel/AMD 64-bit) +- aarch64 / arm64 (ARM 64-bit) + +### Creating Package Repositories + +**For RPM:** + +```bash +# Create repository directory +mkdir -p /path/to/repo + +# Copy packages +cp *.rpm /path/to/repo/ + +# Create repository metadata +createrepo_c /path/to/repo + +# Configure client +cat > /etc/yum.repos.d/aws-sdk-cpp.repo < Packages.gz + +# Configure client +cat >> /etc/apt/sources.list </dev/null || sysctl -n hw.ncpu 2>/dev/null || echo 4) +make -j"$NPROC" + +if [ $? -ne 0 ]; then + echo "Error: Build failed" + exit 1 +fi + +echo "" +echo "Generating packages..." +echo "========================================" + +# Generate RPM packages +echo "Generating RPM packages..." +cpack -G RPM + +if [ $? -ne 0 ]; then + echo "Warning: RPM package generation failed" +fi + +# Generate DEB packages +echo "Generating DEB packages..." +cpack -G DEB + +if [ $? -ne 0 ]; then + echo "Warning: DEB package generation failed" +fi + +echo "" +echo "Package validation..." +echo "========================================" + +# List generated packages +echo "Generated RPM packages:" +ls -lh *.rpm 2>/dev/null || echo "No RPM packages found" + +echo "" +echo "Generated DEB packages:" +ls -lh *.deb 2>/dev/null || echo "No DEB packages found" + +echo "" +echo "Validating package metadata..." + +# Validate RPM packages +for rpm in *.rpm 2>/dev/null; do + if [ -f "$rpm" ]; then + echo "" + echo "--- $rpm ---" + rpm -qp --info "$rpm" 2>/dev/null || true + echo "Dependencies:" + rpm -qp --requires "$rpm" 2>/dev/null || true + fi +done + +# Validate DEB packages +for deb in *.deb 2>/dev/null; do + if [ -f "$deb" ]; then + echo "" + echo "--- $deb ---" + dpkg-deb -I "$deb" 2>/dev/null || true + fi +done + +echo "" +echo "========================================" +echo "Package build complete!" +echo "========================================" +echo "Packages are located in: $BUILD_DIR" +echo "" +echo "To install RPM packages:" +echo " sudo rpm -ivh $BUILD_DIR/aws-sdk-cpp-core-*.rpm" +echo " sudo rpm -ivh $BUILD_DIR/aws-sdk-cpp-core-devel-*.rpm" +echo "" +echo "To install DEB packages:" +echo " sudo dpkg -i $BUILD_DIR/libaws-sdk-cpp-core_*.deb" +echo " sudo dpkg -i $BUILD_DIR/libaws-sdk-cpp-core-dev_*.deb" +echo "" +echo "Or use your package manager for automatic dependency resolution:" +echo " sudo yum install $BUILD_DIR/*.rpm" +echo " sudo apt install $BUILD_DIR/*.deb" +echo "" diff --git a/src/aws-cpp-sdk-core/CMakeLists.txt b/src/aws-cpp-sdk-core/CMakeLists.txt index abc6668d0cb0..0a85a367323e 100644 --- a/src/aws-cpp-sdk-core/CMakeLists.txt +++ b/src/aws-cpp-sdk-core/CMakeLists.txt @@ -668,12 +668,27 @@ set_compiler_flags(${PROJECT_NAME}) set_compiler_warnings(${PROJECT_NAME}) if(SIMPLE_INSTALL) + # Determine the component for this library based on service group mapping (CPack packaging support) + if(COMMAND get_service_group_component) + get_service_group_component(${PROJECT_NAME} SERVICE_GROUP) + if(BUILD_SHARED_LIBS) + set(INSTALL_COMPONENT "${SERVICE_GROUP}-runtime") + else() + set(INSTALL_COMPONENT "${SERVICE_GROUP}-static") + endif() + else() + set(INSTALL_COMPONENT "Unspecified") + endif() + install ( TARGETS ${PROJECT_NAME} EXPORT "${PROJECT_NAME}-targets" ARCHIVE DESTINATION ${ARCHIVE_DIRECTORY} + COMPONENT ${INSTALL_COMPONENT} LIBRARY DESTINATION ${LIBRARY_DIRECTORY} + COMPONENT ${INSTALL_COMPONENT} RUNTIME DESTINATION ${BINARY_DIRECTORY} + COMPONENT ${INSTALL_COMPONENT} ) else() if(PLATFORM_CUSTOM) @@ -695,10 +710,17 @@ if(SIMPLE_INSTALL) if(BUILD_SHARED_LIBS) install( FILES "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.pc" - DESTINATION ${LIBRARY_DIRECTORY}/pkgconfig) + DESTINATION ${LIBRARY_DIRECTORY}/pkgconfig + COMPONENT ${INSTALL_COMPONENT}) endif() endif() +# Set default component for header installations (CPack packaging support) +if(COMMAND get_service_group_component) + get_service_group_component(${PROJECT_NAME} SERVICE_GROUP) + set(CMAKE_INSTALL_DEFAULT_COMPONENT_NAME "${SERVICE_GROUP}-devel") +endif() + install (FILES ${AWS_HEADERS} DESTINATION ${INCLUDE_DIRECTORY}/aws/core) install (FILES ${AWS_AUTH_HEADERS} DESTINATION ${INCLUDE_DIRECTORY}/aws/core/auth) install (FILES ${AWS_AUTH_SIGNER_HEADERS} DESTINATION ${INCLUDE_DIRECTORY}/aws/core/auth/signer) From 4d1308dd0fb4862e12d5019a9c7532a24672b4a5 Mon Sep 17 00:00:00 2001 From: telendry Date: Sun, 11 Jan 2026 19:18:08 -0800 Subject: [PATCH 2/4] ToC and list of packaging related files --- docs/PACKAGING.md | 109 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 109 insertions(+) diff --git a/docs/PACKAGING.md b/docs/PACKAGING.md index 04fa8dcf682a..a162f994646d 100644 --- a/docs/PACKAGING.md +++ b/docs/PACKAGING.md @@ -16,6 +16,115 @@ The AWS SDK for C++ provides CPack-based packaging support for generating DEB an - **RPM**: For Red Hat, Fedora, CentOS, Amazon Linux, and other RPM-based distributions - **DEB**: For Debian, Ubuntu, and other DEB-based distributions +## Table of Contents + +- [Overview](#overview) + - [Package Types](#package-types) + - [Package Formats](#package-formats) +- [Packaging Configuration Files](#packaging-configuration-files) + - [Core CMake Configuration Files](#core-cmake-configuration-files) + - [Package Maintenance Scripts](#package-maintenance-scripts) + - [Build and Documentation Files](#build-and-documentation-files) + - [Modified Files](#modified-files) + - [File Structure](#file-structure) +- [Service Groups](#service-groups) +- [Package Naming](#package-naming) + - [RPM Packages](#rpm-packages) + - [DEB Packages](#deb-packages) +- [Building Packages](#building-packages) + - [Prerequisites](#prerequisites) + - [Using the Build Script (Recommended)](#using-the-build-script-recommended) + - [Manual Build Process](#manual-build-process) +- [Installing Packages](#installing-packages) + - [RPM Installation](#rpm-installation) + - [DEB Installation](#deb-installation) +- [Using the SDK from Packages](#using-the-sdk-from-packages) + - [CMake Integration](#cmake-integration) + - [Example Application](#example-application) + - [pkg-config Integration](#pkg-config-integration) +- [Package Dependencies](#package-dependencies) + - [Runtime Package Dependencies](#runtime-package-dependencies) + - [Development Package Dependencies](#development-package-dependencies) +- [Uninstalling Packages](#uninstalling-packages) + - [RPM Uninstallation](#rpm-uninstallation) + - [DEB Uninstallation](#deb-uninstallation) +- [Troubleshooting](#troubleshooting) + - [Missing Dependencies](#missing-dependencies) + - [CMake Can't Find Package](#cmake-cant-find-package) + - [Library Not Found at Runtime](#library-not-found-at-runtime) + - [Package Version Conflicts](#package-version-conflicts) +- [Advanced Topics](#advanced-topics) + - [Building Static Library Packages](#building-static-library-packages) + - [Cross-Architecture Builds](#cross-architecture-builds) + - [Creating Package Repositories](#creating-package-repositories) +- [Package Maintainer Information](#package-maintainer-information) + - [File Locations](#file-locations) + - [Modifying Service Groups](#modifying-service-groups) + - [Package Metadata](#package-metadata) +- [Support and Feedback](#support-and-feedback) + +## Packaging Configuration Files + +The CPack packaging system is implemented through the following configuration files: + +### Core CMake Configuration Files + +| File | Purpose | +|------|---------| +| `cmake/ServiceGroupMapping.cmake` | Maps individual AWS service libraries to logical package groups (core, storage, compute, etc.) | +| `cmake/CPackConfig.cmake` | Main CPack configuration - defines package metadata, generators (RPM/DEB), and global settings | +| `cmake/CPackComponents.cmake` | Defines package components, component groups, and inter-package dependencies for both RPM and DEB | + +### Package Maintenance Scripts + +| File | Purpose | +|------|---------| +| `cmake/rpm-scripts/post.sh` | RPM post-install script - runs `ldconfig` to update shared library cache | +| `cmake/rpm-scripts/postun.sh` | RPM post-uninstall script - runs `ldconfig` after package removal | +| `cmake/deb-scripts/postinst` | DEB post-install script - runs `ldconfig` on package configuration | +| `cmake/deb-scripts/postrm` | DEB post-remove script - runs `ldconfig` after package removal | + +### Build and Documentation Files + +| File | Purpose | +|------|---------| +| `scripts/build-packages.sh` | Automated build script for generating packages with configurable options | +| `docs/PACKAGING.md` | Comprehensive documentation for building, installing, and using packages | + +### Modified Files + +| File | Modifications | +|------|---------------| +| `CMakeLists.txt` | Added `ENABLE_CPACK_PACKAGING` option and CPack integration (lines 75, 362-366) | +| `cmake/utilities.cmake` | Modified `setup_install()` and `do_packaging()` macros to add COMPONENT support for CPack | +| `src/aws-cpp-sdk-core/CMakeLists.txt` | Added COMPONENT parameters to library and header installation commands for packaging | + +### File Structure + +``` +aws-sdk-cpp/ +├── cmake/ +│ ├── ServiceGroupMapping.cmake # NEW - Service to group mapping +│ ├── CPackConfig.cmake # NEW - Main CPack configuration +│ ├── CPackComponents.cmake # NEW - Component definitions +│ ├── utilities.cmake # MODIFIED - Added COMPONENT support +│ ├── rpm-scripts/ +│ │ ├── post.sh # NEW - RPM post-install +│ │ └── postun.sh # NEW - RPM post-uninstall +│ └── deb-scripts/ +│ ├── postinst # NEW - DEB post-install +│ └── postrm # NEW - DEB post-remove +├── scripts/ +│ └── build-packages.sh # NEW - Build automation script +├── docs/ +│ └── PACKAGING.md # NEW - Packaging documentation +├── src/aws-cpp-sdk-core/ +│ └── CMakeLists.txt # MODIFIED - Added COMPONENT support +└── CMakeLists.txt # MODIFIED - CPack integration + +Total: 9 new files, 3 modified files +``` + ## Service Groups The 418+ AWS services are organized into 19 logical groups to avoid creating hundreds of individual packages: From 9fd72b648aa7f87cb99d5803a6ef83e398447d58 Mon Sep 17 00:00:00 2001 From: James Hickman Date: Tue, 16 Jun 2026 10:22:24 -0700 Subject: [PATCH 3/4] Fix CPack packaging: per-component routing, deps, and CRT bundling `cpack -G RPM` previously produced packages named aws-sdk-cpp-Devel / -Development / -Runtime / -Unspecified with no inter-package Requires -- none of the per-component naming or dependency config in the macros took effect. Verified end-to-end: cpack now generates aws-sdk-cpp-{core, core-devel, crt, crt-devel} with correct Requires (system devel libs, cross-package version-pinned deps, AUTOREQ for shared libs). CPackComponents.cmake: - Uppercase component name on the LHS of CPACK_RPM/DEBIAN__* sets (CPack uppercases before lookup, so lowercase names were ignored) - Drop \${CPACK_PACKAGE_VERSION} backslash escape so CMake substitutes the version at configure time (CPack does not re-expand ${...} -- RPM uses %{...} for macros, not ${...}) - Force macro-arg dereference via "${GROUP_NAME}" in if() -- a bare GROUP_NAME inside macro() is a variable lookup, not a substitution, so the non-core branch was running for core too and overwriting the standalone CORE-DEVEL_PACKAGE_REQUIRES - Switch devel-package dep target between runtime and -static based on BUILD_SHARED_LIBS so static-only builds don't depend on a runtime package that was never produced - Drop hardcoded distro-specific runtime package names (libcurl vs curl, libssl3 vs libssl1.1); rely on AUTOREQ/SHLIBDEPS for runtime deps - include(CPackComponent) so cpack_add_component_group works -- this file runs before include(CPack) loads the helper - Route aws-crt-cpp's Runtime/Development install components to aws-sdk-cpp-crt[-devel] rpm/deb names and add the crt-devel cross-dep on core-devel CPackConfig.cmake: - CPACK_COMPONENTS_GROUPING IGNORE (was ONE_PER_GROUP, which collapsed runtime+devel into a single package and bypassed all per-component name/Requires variables) CMakeLists.txt: - Move include(ServiceGroupMapping.cmake) before add_sdks() so get_service_group_component is defined when each service's setup_install/do_packaging runs -- otherwise every install fell through to "Unspecified" - Default CMAKE_INSTALL_DEFAULT_COMPONENT_NAME to "Development" around add_subdirectory(crt/aws-crt-cpp) so the CRT submodules that install without an explicit COMPONENT (aws-c-http, aws-c-compression headers) merge into the crt-devel package instead of producing a stray rpm setup_cmake_find_module.cmake: - Tag installs with COMPONENT core-devel (was landing in Unspecified) - Exclude build-only files (CPackConfig.cmake, CPackComponents.cmake, ServiceGroupMapping.cmake, rpm-scripts/, deb-scripts/) from the bulk cmake/ directory install so they don't ship to consumers Co-Authored-By: Claude Opus 4.7 (1M context) --- CMakeLists.txt | 24 +++- cmake/CPackComponents.cmake | 175 ++++++++++++++++++++-------- cmake/CPackConfig.cmake | 7 +- cmake/setup_cmake_find_module.cmake | 23 +++- 4 files changed, 173 insertions(+), 56 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ebd94c3d4a8e..2989b2f1651e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -245,7 +245,18 @@ if (LEGACY_BUILD) set(BUILD_SHARED_LIBS OFF) endif () set(CRT_BUILD_SHARED_LIBS ${BUILD_SHARED_LIBS}) + # Some CRT submodule install() calls (e.g. aws-c-http, aws-c-compression + # headers) omit COMPONENT, which would otherwise hit CMake's "Unspecified" + # default and produce a stray rpm/deb. Default them to "Development" so + # they merge with the rest of the CRT devel artifacts. + if(ENABLE_CPACK_PACKAGING) + set(_PREV_DEFAULT_COMPONENT "${CMAKE_INSTALL_DEFAULT_COMPONENT_NAME}") + set(CMAKE_INSTALL_DEFAULT_COMPONENT_NAME "Development") + endif() add_subdirectory(crt/aws-crt-cpp) + if(ENABLE_CPACK_PACKAGING) + set(CMAKE_INSTALL_DEFAULT_COMPONENT_NAME "${_PREV_DEFAULT_COMPONENT}") + endif() set(BUILD_TESTING ${BUILD_TESTING_PREV}) if (ENABLE_OPENSSL_ENCRYPTION) set(BUILD_SHARED_LIBS ${BUILD_SHARED_LIBS_PREV}) @@ -344,6 +355,13 @@ if (LEGACY_BUILD) add_definitions("-DAWS_TEST_REGION=${AWS_TEST_REGION}") + # Load the service-to-group mapping BEFORE add_sdks() so each service's + # setup_install/do_packaging can route installs into per-group CPack + # components. Without this, every install falls through to "Unspecified". + if(ENABLE_CPACK_PACKAGING) + include(cmake/ServiceGroupMapping.cmake) + endif() + add_sdks() include(tests) @@ -362,9 +380,11 @@ if (LEGACY_BUILD) ADD_CUSTOM_TARGET(uninstall-awssdk "${CMAKE_COMMAND}" -P "${AWS_NATIVE_SDK_ROOT}/cmake/make_uninstall.cmake") endif () - # CPack packaging configuration (DEB and RPM packages) + # CPack packaging configuration (DEB and RPM packages). Must run after all + # install() calls and after add_sdks() so every component is registered + # before include(CPack) finalizes. ServiceGroupMapping is included earlier + # (before add_sdks) so the install rules themselves can use its mapping. if(ENABLE_CPACK_PACKAGING) - include(cmake/ServiceGroupMapping.cmake) include(cmake/CPackConfig.cmake) endif() else () # End of Legacy Build diff --git a/cmake/CPackComponents.cmake b/cmake/CPackComponents.cmake index 3eb36da6ae04..9f8e7c3a010b 100644 --- a/cmake/CPackComponents.cmake +++ b/cmake/CPackComponents.cmake @@ -1,6 +1,11 @@ # CPack Component Definitions for AWS SDK C++ # Defines component groups and components for packaging +# Provides cpack_add_component / cpack_add_component_group. CPackConfig.cmake +# includes this file before include(CPack), so we can't rely on CPack pulling +# the helper module in for us. +include(CPackComponent) + # Component groups represent logical groupings of AWS services # Each group has two components: # - {group}-runtime: Runtime libraries (.so or .a files) @@ -174,39 +179,61 @@ define_group_components(misc "Miscellaneous" FALSE) # RPM Package Configuration # ============================================================================= -# Macro to configure RPM package for a group +# A given build produces either shared (*-runtime) or static (*-static) library +# packages, not both -- setup_install routes installs to one or the other based +# on BUILD_SHARED_LIBS. The devel package and the inter-service dep chain must +# point at whichever variant actually exists. +if(BUILD_SHARED_LIBS) + set(_AWS_LIB_VARIANT_SUFFIX "") +else() + set(_AWS_LIB_VARIANT_SUFFIX "-static") +endif() + +# Macro to configure RPM package for a group. +# CPackRPM looks up per-component variables under the upper-cased component +# name (CPACK_RPM__*), so the LHS must be upper-case even +# though the component itself and the rpm package names are lower-case. macro(configure_rpm_group GROUP_NAME) + string(TOUPPER "${GROUP_NAME}" _GROUP_UPPER) + # Runtime package - set(CPACK_RPM_${GROUP_NAME}-RUNTIME_PACKAGE_NAME "aws-sdk-cpp-${GROUP_NAME}") - set(CPACK_RPM_${GROUP_NAME}-RUNTIME_FILE_NAME "RPM-DEFAULT") + set(CPACK_RPM_${_GROUP_UPPER}-RUNTIME_PACKAGE_NAME "aws-sdk-cpp-${GROUP_NAME}") + set(CPACK_RPM_${_GROUP_UPPER}-RUNTIME_FILE_NAME "RPM-DEFAULT") # Development package - set(CPACK_RPM_${GROUP_NAME}-DEVEL_PACKAGE_NAME "aws-sdk-cpp-${GROUP_NAME}-devel") - set(CPACK_RPM_${GROUP_NAME}-DEVEL_FILE_NAME "RPM-DEFAULT") + set(CPACK_RPM_${_GROUP_UPPER}-DEVEL_PACKAGE_NAME "aws-sdk-cpp-${GROUP_NAME}-devel") + set(CPACK_RPM_${_GROUP_UPPER}-DEVEL_FILE_NAME "RPM-DEFAULT") # Static package - set(CPACK_RPM_${GROUP_NAME}-STATIC_PACKAGE_NAME "aws-sdk-cpp-${GROUP_NAME}-static") - set(CPACK_RPM_${GROUP_NAME}-STATIC_FILE_NAME "RPM-DEFAULT") - - # Development package depends on runtime - set(CPACK_RPM_${GROUP_NAME}-DEVEL_PACKAGE_REQUIRES - "aws-sdk-cpp-${GROUP_NAME} = \${CPACK_PACKAGE_VERSION}") - - # Service groups depend on core (except core itself) - if(NOT GROUP_NAME STREQUAL "core") - set(CPACK_RPM_${GROUP_NAME}-RUNTIME_PACKAGE_REQUIRES - "aws-sdk-cpp-core = \${CPACK_PACKAGE_VERSION}") - set(CPACK_RPM_${GROUP_NAME}-DEVEL_PACKAGE_REQUIRES - "aws-sdk-cpp-${GROUP_NAME} = \${CPACK_PACKAGE_VERSION}, aws-sdk-cpp-core-devel = \${CPACK_PACKAGE_VERSION}") + set(CPACK_RPM_${_GROUP_UPPER}-STATIC_PACKAGE_NAME "aws-sdk-cpp-${GROUP_NAME}-static") + set(CPACK_RPM_${_GROUP_UPPER}-STATIC_FILE_NAME "RPM-DEFAULT") + + # Inter-package deps. Skip for core -- the standalone block below sets core's + # devel requires (with system devel libs) and would otherwise be overwritten. + # NB: this is a macro, so a bare `GROUP_NAME` in if() is a variable lookup, + # not a substitution; we must dereference via ${GROUP_NAME}. + if(NOT "${GROUP_NAME}" STREQUAL "core") + if(BUILD_SHARED_LIBS) + set(CPACK_RPM_${_GROUP_UPPER}-RUNTIME_PACKAGE_REQUIRES + "aws-sdk-cpp-core = ${CPACK_PACKAGE_VERSION}") + else() + set(CPACK_RPM_${_GROUP_UPPER}-STATIC_PACKAGE_REQUIRES + "aws-sdk-cpp-core-static = ${CPACK_PACKAGE_VERSION}") + endif() + set(CPACK_RPM_${_GROUP_UPPER}-DEVEL_PACKAGE_REQUIRES + "aws-sdk-cpp-${GROUP_NAME}${_AWS_LIB_VARIANT_SUFFIX} = ${CPACK_PACKAGE_VERSION}, aws-sdk-cpp-core-devel = ${CPACK_PACKAGE_VERSION}") endif() endmacro() -# Core package has system library dependencies -if(BUILD_SHARED_LIBS) - set(CPACK_RPM_CORE-RUNTIME_PACKAGE_REQUIRES "libcurl >= 7.58.0, openssl-libs >= 1.1.1, zlib >= 1.2.11") -endif() +# Runtime deps on system shared libraries are discovered automatically via +# CPACK_RPM_PACKAGE_AUTOREQ from the .so files. Hardcoding rpm package names +# (libcurl vs curl, openssl-libs vs libopenssl1_1, ...) breaks portability +# across Fedora/RHEL/openSUSE, so we leave runtime requires to autoreq. +# +# Devel deps cannot be auto-discovered; the names below target the +# Fedora/RHEL family which is the primary consumer of rpm packages. set(CPACK_RPM_CORE-DEVEL_PACKAGE_REQUIRES - "aws-sdk-cpp-core = \${CPACK_PACKAGE_VERSION}, libcurl-devel >= 7.58.0, openssl-devel >= 1.1.1, zlib-devel >= 1.2.11, cmake >= 3.13") + "aws-sdk-cpp-core${_AWS_LIB_VARIANT_SUFFIX} = ${CPACK_PACKAGE_VERSION}, libcurl-devel >= 7.58.0, openssl-devel >= 1.1.1, zlib-devel >= 1.2.11, cmake >= 3.13") # Configure all groups for RPM configure_rpm_group(core) @@ -239,39 +266,52 @@ endif() # DEB Package Configuration # ============================================================================= -# Macro to configure DEB package for a group +# Macro to configure DEB package for a group. +# CPackDeb looks up per-component variables under the upper-cased component +# name (CPACK_DEBIAN__*), so the LHS must be upper-case even +# though the component itself and the deb package names are lower-case. macro(configure_deb_group GROUP_NAME) + string(TOUPPER "${GROUP_NAME}" _GROUP_UPPER) + # Runtime package (follows lib* naming convention for Debian) - set(CPACK_DEBIAN_${GROUP_NAME}-RUNTIME_PACKAGE_NAME "libaws-sdk-cpp-${GROUP_NAME}") - set(CPACK_DEBIAN_${GROUP_NAME}-RUNTIME_FILE_NAME "DEB-DEFAULT") + set(CPACK_DEBIAN_${_GROUP_UPPER}-RUNTIME_PACKAGE_NAME "libaws-sdk-cpp-${GROUP_NAME}") + set(CPACK_DEBIAN_${_GROUP_UPPER}-RUNTIME_FILE_NAME "DEB-DEFAULT") # Development package - set(CPACK_DEBIAN_${GROUP_NAME}-DEVEL_PACKAGE_NAME "libaws-sdk-cpp-${GROUP_NAME}-dev") - set(CPACK_DEBIAN_${GROUP_NAME}-DEVEL_FILE_NAME "DEB-DEFAULT") + set(CPACK_DEBIAN_${_GROUP_UPPER}-DEVEL_PACKAGE_NAME "libaws-sdk-cpp-${GROUP_NAME}-dev") + set(CPACK_DEBIAN_${_GROUP_UPPER}-DEVEL_FILE_NAME "DEB-DEFAULT") # Static package - set(CPACK_DEBIAN_${GROUP_NAME}-STATIC_PACKAGE_NAME "libaws-sdk-cpp-${GROUP_NAME}-static") - set(CPACK_DEBIAN_${GROUP_NAME}-STATIC_FILE_NAME "DEB-DEFAULT") - - # Development package depends on runtime - set(CPACK_DEBIAN_${GROUP_NAME}-DEVEL_PACKAGE_DEPENDS - "libaws-sdk-cpp-${GROUP_NAME} (= \${CPACK_PACKAGE_VERSION})") - - # Service groups depend on core (except core itself) - if(NOT GROUP_NAME STREQUAL "core") - set(CPACK_DEBIAN_${GROUP_NAME}-RUNTIME_PACKAGE_DEPENDS - "libaws-sdk-cpp-core (= \${CPACK_PACKAGE_VERSION})") - set(CPACK_DEBIAN_${GROUP_NAME}-DEVEL_PACKAGE_DEPENDS - "libaws-sdk-cpp-${GROUP_NAME} (= \${CPACK_PACKAGE_VERSION}), libaws-sdk-cpp-core-dev (= \${CPACK_PACKAGE_VERSION})") + set(CPACK_DEBIAN_${_GROUP_UPPER}-STATIC_PACKAGE_NAME "libaws-sdk-cpp-${GROUP_NAME}-static") + set(CPACK_DEBIAN_${_GROUP_UPPER}-STATIC_FILE_NAME "DEB-DEFAULT") + + # Inter-package deps. Skip for core -- the standalone block below sets core's + # devel depends (with system devel libs) and would otherwise be overwritten. + # NB: this is a macro, so a bare `GROUP_NAME` in if() is a variable lookup, + # not a substitution; we must dereference via ${GROUP_NAME}. + if(NOT "${GROUP_NAME}" STREQUAL "core") + if(BUILD_SHARED_LIBS) + set(CPACK_DEBIAN_${_GROUP_UPPER}-RUNTIME_PACKAGE_DEPENDS + "libaws-sdk-cpp-core (= ${CPACK_PACKAGE_VERSION})") + else() + set(CPACK_DEBIAN_${_GROUP_UPPER}-STATIC_PACKAGE_DEPENDS + "libaws-sdk-cpp-core-static (= ${CPACK_PACKAGE_VERSION})") + endif() + set(CPACK_DEBIAN_${_GROUP_UPPER}-DEVEL_PACKAGE_DEPENDS + "libaws-sdk-cpp-${GROUP_NAME}${_AWS_LIB_VARIANT_SUFFIX} (= ${CPACK_PACKAGE_VERSION}), libaws-sdk-cpp-core-dev (= ${CPACK_PACKAGE_VERSION})") endif() endmacro() -# Core package has system library dependencies -if(BUILD_SHARED_LIBS) - set(CPACK_DEBIAN_CORE-RUNTIME_PACKAGE_DEPENDS "libcurl4 (>= 7.58.0), libssl3 (>= 1.1.1) | libssl1.1 (>= 1.1.1), zlib1g (>= 1:1.2.11)") -endif() +# Runtime deps on system shared libraries are discovered automatically via +# CPACK_DEBIAN_PACKAGE_SHLIBDEPS (dpkg-shlibdeps) from the .so files. Hardcoding +# deb package names (libssl3 on bookworm vs libssl1.1 on bullseye, etc.) +# pins the package to a single Debian/Ubuntu release, so we leave runtime +# depends to shlibdeps. +# +# Devel deps cannot be auto-discovered; the names below target the +# Debian/Ubuntu family which is the primary consumer of deb packages. set(CPACK_DEBIAN_CORE-DEVEL_PACKAGE_DEPENDS - "libaws-sdk-cpp-core (= \${CPACK_PACKAGE_VERSION}), libcurl4-openssl-dev (>= 7.58.0), libssl-dev (>= 1.1.1), zlib1g-dev (>= 1:1.2.11), cmake (>= 3.13)") + "libaws-sdk-cpp-core${_AWS_LIB_VARIANT_SUFFIX} (= ${CPACK_PACKAGE_VERSION}), libcurl4-openssl-dev (>= 7.58.0), libssl-dev (>= 1.1.1), zlib1g-dev (>= 1:1.2.11), cmake (>= 3.13)") # Configure all groups for DEB configure_deb_group(core) @@ -299,3 +339,46 @@ if(BUILD_SHARED_LIBS AND EXISTS "${CMAKE_SOURCE_DIR}/cmake/deb-scripts/postinst" set(CPACK_DEBIAN_CORE-RUNTIME_PACKAGE_CONTROL_EXTRA "${CMAKE_SOURCE_DIR}/cmake/deb-scripts/postinst;${CMAKE_SOURCE_DIR}/cmake/deb-scripts/postrm") endif() + +# ============================================================================= +# aws-crt-cpp vendored submodule components +# ============================================================================= +# +# crt/aws-crt-cpp and its sub-libraries (aws-c-common, aws-c-cal, aws-c-io, s2n, +# ...) are built in-tree and install with the conventional CMake component names +# "Runtime" (.so files) and "Development" (headers, .a, .cmake). We can't easily +# override those install rules, so route the resulting CPack components into +# their own packages with explicit names. +# +# Runtime cross-package deps from aws-sdk-cpp-core -> aws-sdk-cpp-crt are picked +# up automatically by AUTOREQ/SHLIBDEPS via the .so soname links. The devel- +# time dep (headers cross-include) is added explicitly to the core-devel +# packages below since header includes aren't visible to autoreq. + +# RPM +set(CPACK_RPM_RUNTIME_PACKAGE_NAME "aws-sdk-cpp-crt") +set(CPACK_RPM_RUNTIME_FILE_NAME "RPM-DEFAULT") +set(CPACK_RPM_DEVELOPMENT_PACKAGE_NAME "aws-sdk-cpp-crt-devel") +set(CPACK_RPM_DEVELOPMENT_FILE_NAME "RPM-DEFAULT") +set(CPACK_RPM_DEVELOPMENT_PACKAGE_REQUIRES + "aws-sdk-cpp-crt = ${CPACK_PACKAGE_VERSION}") +# Catch-all for any install() without COMPONENT that didn't fit elsewhere. +set(CPACK_RPM_UNSPECIFIED_PACKAGE_NAME "aws-sdk-cpp-crt-extra") +set(CPACK_RPM_UNSPECIFIED_FILE_NAME "RPM-DEFAULT") + +# Append the CRT devel cross-dep to core-devel's Requires. +set(CPACK_RPM_CORE-DEVEL_PACKAGE_REQUIRES + "${CPACK_RPM_CORE-DEVEL_PACKAGE_REQUIRES}, aws-sdk-cpp-crt-devel = ${CPACK_PACKAGE_VERSION}") + +# DEB +set(CPACK_DEBIAN_RUNTIME_PACKAGE_NAME "libaws-sdk-cpp-crt") +set(CPACK_DEBIAN_RUNTIME_FILE_NAME "DEB-DEFAULT") +set(CPACK_DEBIAN_DEVELOPMENT_PACKAGE_NAME "libaws-sdk-cpp-crt-dev") +set(CPACK_DEBIAN_DEVELOPMENT_FILE_NAME "DEB-DEFAULT") +set(CPACK_DEBIAN_DEVELOPMENT_PACKAGE_DEPENDS + "libaws-sdk-cpp-crt (= ${CPACK_PACKAGE_VERSION})") +set(CPACK_DEBIAN_UNSPECIFIED_PACKAGE_NAME "libaws-sdk-cpp-crt-extra") +set(CPACK_DEBIAN_UNSPECIFIED_FILE_NAME "DEB-DEFAULT") + +set(CPACK_DEBIAN_CORE-DEVEL_PACKAGE_DEPENDS + "${CPACK_DEBIAN_CORE-DEVEL_PACKAGE_DEPENDS}, libaws-sdk-cpp-crt-dev (= ${CPACK_PACKAGE_VERSION})") diff --git a/cmake/CPackConfig.cmake b/cmake/CPackConfig.cmake index a6fa4daff6b2..7e2835490287 100644 --- a/cmake/CPackConfig.cmake +++ b/cmake/CPackConfig.cmake @@ -69,8 +69,11 @@ endif() # Support both RPM and DEB generators set(CPACK_GENERATOR "RPM;DEB") -# Component-based packaging (creates separate packages for each component) -set(CPACK_COMPONENTS_GROUPING ONE_PER_GROUP) +# One rpm/deb per component. ONE_PER_GROUP would collapse {group}-runtime and +# {group}-devel into a single package and bypass our per-component name and +# Requires settings, since CPack would look up the group-level CPACK_RPM__* +# variables instead of the per-component CPACK_RPM_-RUNTIME_* / -DEVEL_*. +set(CPACK_COMPONENTS_GROUPING IGNORE) set(CPACK_COMPONENT_INCLUDE_TOPLEVEL_DIRECTORY OFF) # Architecture detection diff --git a/cmake/setup_cmake_find_module.cmake b/cmake/setup_cmake_find_module.cmake index cf3221019302..1571d1d9c506 100644 --- a/cmake/setup_cmake_find_module.cmake +++ b/cmake/setup_cmake_find_module.cmake @@ -47,19 +47,30 @@ if (NOT SIMPLE_INSTALL) "set(AWSSDK_PLATFORM_PREFIX ${SDK_INSTALL_BINARY_PREFIX}/${PLATFORM_INSTALL_QUALIFIER})\n") endif() -# copy version file to destination +# These files are consumer-facing CMake config for find_package(AWSSDK). +# They belong with the core devel package; without an explicit COMPONENT they +# would land in CPack's "Unspecified" bucket and produce a stray rpm/deb. install( FILES "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}/${PROJECT_NAME}ConfigVersion.cmake" - DESTINATION "${LIBRARY_DIRECTORY}/cmake/${PROJECT_NAME}") + DESTINATION "${LIBRARY_DIRECTORY}/cmake/${PROJECT_NAME}" + COMPONENT core-devel) # platform external dependencies install( FILES "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}/platformDeps.cmake" - DESTINATION "${LIBRARY_DIRECTORY}/cmake/${PROJECT_NAME}/") + DESTINATION "${LIBRARY_DIRECTORY}/cmake/${PROJECT_NAME}/" + COMPONENT core-devel) -# copy all cmake files to destination, these files include useful macros, functions and variables for users. -# useful macros and variables will be included in this cmake file for user to use -install(DIRECTORY "${AWS_NATIVE_SDK_ROOT}/cmake/" DESTINATION "${LIBRARY_DIRECTORY}/cmake/${PROJECT_NAME}") +# copy cmake files to destination -- these are consumer-facing macros, functions +# and variables. Exclude build-only scaffolding (CPack glue, packaging scripts) +# that has no value at consume time and would otherwise be shipped. +install(DIRECTORY "${AWS_NATIVE_SDK_ROOT}/cmake/" DESTINATION "${LIBRARY_DIRECTORY}/cmake/${PROJECT_NAME}" + COMPONENT core-devel + PATTERN "CPackConfig.cmake" EXCLUDE + PATTERN "CPackComponents.cmake" EXCLUDE + PATTERN "ServiceGroupMapping.cmake" EXCLUDE + PATTERN "rpm-scripts" EXCLUDE + PATTERN "deb-scripts" EXCLUDE) # following two files are vital for cmake to find correct package, but since we copied all files from above # we left the code here to give you bettern understanding From 8c6983e0787937874d70cf64e8b83d53a9eaf1ef Mon Sep 17 00:00:00 2001 From: James Hickman Date: Thu, 27 Aug 2026 10:39:26 -0700 Subject: [PATCH 4/4] Gate remaining install COMPONENT changes behind ENABLE_CPACK_PACKAGING Four install() calls picked up a COMPONENT argument unconditionally, so they changed behavior even with ENABLE_CPACK_PACKAGING=OFF: the three find_package(AWSSDK) config installs moved from CPack's implicit "Unspecified" bucket to "core-devel", and the exported targets file moved from "Unspecified" to "Devel". A plain `make install` was unaffected, but component-scoped installs (cmake --install --component ...) were not. Wrap those in a variable that expands to nothing when the option is off, so the option genuinely gates the whole feature. The EXCLUDE patterns on the bulk cmake/ directory install are left unconditional on purpose: they only match files this branch adds, so keeping them always-on leaves the installed tree identical to before rather than shipping build-only scaffolding to consumers. Verified by configuring core with the four modified files reverted to upstream and again with ENABLE_CPACK_PACKAGING=OFF: the generated cmake_install.cmake files are identical apart from those EXCLUDEs. With the option ON, core-devel and core-runtime components are still assigned. Co-Authored-By: Claude Opus 5 (1M context) Claude-Session: https://claude.ai/code/session_01YCSRkLxHYetVoe421e5fha --- cmake/setup_cmake_find_module.cmake | 29 ++++++++++++++++++++--------- cmake/utilities.cmake | 14 ++++++++++++-- 2 files changed, 32 insertions(+), 11 deletions(-) diff --git a/cmake/setup_cmake_find_module.cmake b/cmake/setup_cmake_find_module.cmake index 1571d1d9c506..312b443e9d87 100644 --- a/cmake/setup_cmake_find_module.cmake +++ b/cmake/setup_cmake_find_module.cmake @@ -47,25 +47,36 @@ if (NOT SIMPLE_INSTALL) "set(AWSSDK_PLATFORM_PREFIX ${SDK_INSTALL_BINARY_PREFIX}/${PLATFORM_INSTALL_QUALIFIER})\n") endif() -# These files are consumer-facing CMake config for find_package(AWSSDK). -# They belong with the core devel package; without an explicit COMPONENT they -# would land in CPack's "Unspecified" bucket and produce a stray rpm/deb. +# When ENABLE_CPACK_PACKAGING is ON these consumer-facing CMake config files are +# tagged so they land in the core devel package rather than CPack's catch-all +# "Unspecified" bucket (which would produce a stray rpm/deb). When it is OFF the +# variable expands to nothing and the install() calls behave exactly as they did +# before packaging support was added. +if(ENABLE_CPACK_PACKAGING) + set(AWSSDK_CORE_DEVEL_COMPONENT COMPONENT core-devel) +else() + set(AWSSDK_CORE_DEVEL_COMPONENT) +endif() + +# copy version file to destination install( FILES "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}/${PROJECT_NAME}ConfigVersion.cmake" DESTINATION "${LIBRARY_DIRECTORY}/cmake/${PROJECT_NAME}" - COMPONENT core-devel) + ${AWSSDK_CORE_DEVEL_COMPONENT}) # platform external dependencies install( FILES "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}/platformDeps.cmake" DESTINATION "${LIBRARY_DIRECTORY}/cmake/${PROJECT_NAME}/" - COMPONENT core-devel) + ${AWSSDK_CORE_DEVEL_COMPONENT}) -# copy cmake files to destination -- these are consumer-facing macros, functions -# and variables. Exclude build-only scaffolding (CPack glue, packaging scripts) -# that has no value at consume time and would otherwise be shipped. +# copy cmake files to destination, these files include useful macros, functions and variables for users. +# The EXCLUDEs are unconditional: they only ever match files added by this +# packaging support, so keeping them always-on leaves the installed tree +# identical to what it was before, rather than shipping build-only scaffolding +# to consumers when packaging is disabled. install(DIRECTORY "${AWS_NATIVE_SDK_ROOT}/cmake/" DESTINATION "${LIBRARY_DIRECTORY}/cmake/${PROJECT_NAME}" - COMPONENT core-devel + ${AWSSDK_CORE_DEVEL_COMPONENT} PATTERN "CPackConfig.cmake" EXCLUDE PATTERN "CPackComponents.cmake" EXCLUDE PATTERN "ServiceGroupMapping.cmake" EXCLUDE diff --git a/cmake/utilities.cmake b/cmake/utilities.cmake index 7ca3bf0e38bc..2d954a975e69 100644 --- a/cmake/utilities.cmake +++ b/cmake/utilities.cmake @@ -149,7 +149,9 @@ macro(do_packaging) @ONLY) endif() - # Determine the development component for this library + # Determine the development component for this library. Falls back to the + # pre-existing "Devel" name when the packaging mapping is not loaded, so + # the install() below is unchanged with ENABLE_CPACK_PACKAGING=OFF. if(COMMAND get_service_group_component) get_service_group_component(${PROJECT_NAME} SERVICE_GROUP) set(DEVEL_COMPONENT "${SERVICE_GROUP}-devel") @@ -158,11 +160,19 @@ macro(do_packaging) set(DEVEL_COMPONENT "Devel") endif() + # The exported targets file had no COMPONENT before packaging support was + # added; only tag it when packaging is actually enabled. + if(ENABLE_CPACK_PACKAGING) + set(AWSSDK_EXPORT_COMPONENT COMPONENT ${DEVEL_COMPONENT}) + else() + set(AWSSDK_EXPORT_COMPONENT) + endif() + set(ConfigPackageLocation "${LIBRARY_DIRECTORY}/cmake/${PROJECT_NAME}") install(EXPORT "${PROJECT_NAME}-targets" FILE "${PROJECT_NAME}-targets.cmake" DESTINATION ${ConfigPackageLocation} - COMPONENT ${DEVEL_COMPONENT} + ${AWSSDK_EXPORT_COMPONENT} ) install(