aws / aws/aws-sdk-cpp

CMake error when using SDK built with `-DBUILD_SHARED_LIBS=OFF`

Open
#2,635 9 comments 0 reactions 0 assignees View on GitHub
bug Cmake p2
Dominant language
C++
Stars
2.2k
Forks
1.2k
Avg merge
3d 14h
Merged PRs (30d)
12

Description

### Describe the bug

I am getting a CMake error when trying to use the 1.11 line of the SDK. I did not get this error when using both 1.9 and 1.10.

### Expected Behavior

Expected behaviour is no CMake error.

### Current Behavior

The error appears during CMake configure step:
```txt
CMake Error at CMakeLists.txt:5 (add_executable):
Target "s3sample" links to target "ZLIB::ZLIB" but the target was not
found. Perhaps a find_package() call is missing for an IMPORTED target, or
an ALIAS target is missing?
```

### Reproduction Steps

I first stumbled upon the problem on my project that included `aws-sdk-cpp`, `aws-lambda-cpp` and several other dependencies, but was also able to reproduce it on the sample program from this Wiki page: https://github.com/aws/aws-sdk-cpp/wiki/Building-the-SDK-from-source-on-EC2

Steps to reproduce:
1. clone the `aws-sdk-cpp` repo
```
git clone --recurse-submodules https://github.com/aws/aws-sdk-cpp.git
cd aws-sdk-cpp
git checkout --recurse-submodules 1.11.138
```
2. build and install the SDK
```
mkdir build-sdk
cd build-sdk
cmake ../aws-sdk-cpp -D BUILD_ONLY=core -D CMAKE_BUILD_TYPE=RelWithDebInfo -D BUILD_SHARED_LIBS=OFF -D CMAKE_INSTALL_PREFIX=~/aws-sdk-1.11.138
make
make install
```
3. CMake configure the app
```
mkdir build
cd build
cmake .. -D CMAKE_BUILD_TYPE=Release -D CMAKE_PREFIX_PATH=~/aws-sdk-1.11.138
```

### Possible Solution

_No response_

### Additional Information/Context

It seems that using static libraries adds linking the ZLIB:ZLIB target, which then cannot be recognised. Please search for `ZLIB:ZLIB` in the installed `lib/cmake/aws-sdk-cpp-core/aws-sdk-cpp-core-targets.cmake` file.

### AWS CPP SDK version used

1.11.70, 1.11.76, 1.11.138

### Compiler and Version used

gcc (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0

### Operating System and version

Ubuntu 22.04 running on WSL2

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.