-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Example CMake Scripts to Build Your Project Against the CPP SDK
Marco Magdy edited this page Nov 15, 2018
·
1 revision
With find_package's COMPONENTS parameter supported in latest commit, users can integrate AWS SDK for CPP with a more simplified way.
find_package(AWSSD REQUIRED COMPONENTS transfer s3-encryption dynamodb)
target_link_libraries(target ${AWSSDK_LINK_LIBRARIES})
Now users:
- No need to add "aws-cpp-sdk-" for each component.
- No need to worry about high level dependencies. E.g. for s3-encryption, you don't have to know know s3-encryption is depend on s3, kms and core and tell that to CMake.
- After find_package, a variable AWSSD_LINK_LIBRARIES will be available for user to do easy link as above.
If you want to find multiple components once and use different components for different targets, AWSSDK_LINK_LIBRARIES
is no long suitable here and you need add them manually and understand the dependency chain like:
find_package(AWSSD REQUIRED COMPONENTS transfer s3-encryption dynamodb)
target_link_libraries(A aws-cpp-sdk-core)
target_link_libraries(B aws-cpp-sdk-transfer aws-cpp-sdk-s3 aws-cpp-sdk-core) # transfer depends on s3, and s3 depends on core
target_linl_libraries(C aws-cpp-sdk-s3-encryption aws-cpp-sdk-kms aws-cpp-sdk-s3 aws-cpp-sdk-core)
If you want to link against different libraries for different targets with static built SDK. You need to add platform dependencies manually as well, but we have all that in a variable called AWSSDK_PLATFORM_DEPS. E.g
find_package(AWSSD REQUIRED COMPONENTS transfer s3-encryption dynamodb)
target_link_libraries(A aws-cpp-sdk-core ${AWSSDK_PLATFORM_DEPS})