Skip to content

Issues when building with cmake 3.16 #93

@RianFuro

Description

@RianFuro

I was trying to compile this project as a shared library on Arch Linux with cmake 3.16 installed and ran into some complications along the way.
I realize that none of the issues below are from this repository directly, however as the issue spans over multiple repositories and I wanted to keep things coherent this seemed as good a place as any to create the issue.
I'd be happy to open issues on the respective repositories, if needed.

Here's the rundown:
My environment:

 $ uname -a
Linux workstation 5.4.5-arch1-1 #1 SMP PREEMPT Wed, 18 Dec 2019 19:48:51 +0000 x86_64 GNU/Linux
 $ cmake --version
cmake version 3.16.1

Steps used to build:

cd aws-crt-cpp/;
mkdir build install;
cd build;
cmake -DCMAKE_INSTALL_PREFIX="$PWD/../install" -DBUILD_SHARED_LIBS=ON  -DBUILD_DEPS=ON ../;
cmake --build . --target install;

This builds just fine, however it leaves the cmake-configs in an awkard state. Trying to include the package in another project yields the following:

CMake Error at aws-crt-cpp/install/lib/aws-c-compression/cmake/aws-c-compression-config.cmake:6 (include):
  include could not find load file:

    <path-to-project>/includes-aws-crt-cpp/aws-crt-cpp/install/lib/aws-c-compression/cmake/shared/aws-crt-cpp-targets.cmake

This is because the template for generating the config file for those packages uses @CMAKE_PROJECT_NAME@ for building the path to the targets file. The behavior of this variable seems to have changed at v3.12 (compared to the previous entry v3.11) now giving the topmost project's name. This is true for all submodules except aws-c-io and s2n, where the variable has been changed to @PROJECT_NAME@ in commits awslabs/aws-c-io@250484c and aws/s2n-tls@e50cf9c respectively.

When building this project through awslabs/aws-iot-device-sdk-cpp-v2, I additionally had to deal with this:

CMake Error at jobs/CMakeLists.txt:97 (target_link_libraries):
  Error evaluating generator expression:

    $<TARGET_PROPERTY:LibCrypto::Crypto,INTERFACE_INCLUDE_DIRECTORIES>

  Target "LibCrypto::Crypto" not found.

The error seems to originate from an oddity in how the TARGET_PROPERTY computation expression is looking up symbols. The problem and a workaround is described in this issue on the cmake gitlab. Again this didn't happen in the ubuntu container (cmake v3.10), however i couldn't find a documented change in how TARGET_PROPERTY operates, so I can't pinpoint where the regression happened. While the issue remains open, the described workaround resolves the problem for me:

# s2n/CMakeLists.txt
-target_include_directories(${PROJECT_NAME} PUBLIC $<TARGET_PROPERTY:LibCrypto::Crypto,INTERFACE_INCLUDE_DIRECTORIES>)
+get_target_property(LIBCRYPTO_INTERFACE_INCLUDE_DIRECTORIES LibCrypto::Crypto INTERFACE_INCLUDE_DIRECTORIES)
+target_include_directories(${PROJECT_NAME} PUBLIC "${LIBCRYPTO_INTERFACE_INCLUDE_DIRECTORIES}")

Now I didn't have much to do with cmake before trying to integrate with awslabs/aws-iot-device-sdk-cpp-v2, so this has been somewhat of a learning experience for me and I'm not sure if the steps i took are correct. However I would be happy to open up pull requests at the respective repositories if it helps anyone.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions