Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix configure_file output path by adding CMAKE_BINARY_DIR #437

Merged
merged 1 commit into from
Oct 9, 2024

Conversation

benjacam
Copy link
Contributor

Motivation

I am trying to build the aws-iot-device-client with BUILD_SDK=OFF and where the CMake build directory is not placed directly under the aws-iot-device-client. The build failed, reporting (for the googletest case):

CMake Error at aws-iot-device-client/CMakeLists.txt:264 (add_subdirectory):
  add_subdirectory given source "/home/x/test/build/googletest-src" which
  is not an existing directory.

The motivation for having the build directory in a non-standard location is to build aws-iot-device-client against a seperate checkout of the SDK along with other software that uses the SDK as part of a larger cross-compile build.

Modifications

Change summary

The solution is to add ${CMAKE_BINARY_DIR} to the output argument of the configure_file CMake function. With this, the CMakeLists.txt.gtest or CMakeLists.txt.awssdk file will correctly be copied to the build/binary directory and the build completes successfully.

Testing

Failure case:
Example top level CMakeLists.txt which is part of larger build:

cmake_minimum_required(VERSION 3.10)
project(my-aws-project)
add_subdirectory(aws-iot-device-sdk-cpp-v2)
add_subdirectory(aws-iot-device-client)

Test steps:

git clone https://github.com/awslabs/aws-iot-device-client.git
git clone https://github.com/aws/aws-iot-device-sdk-cpp-v2.git
pushd aws-iot-device-sdk-cpp-v2; git submodule update --init --recursive; popd
mkdir build
cd build
cmake ../ -DCMAKE_TOOLCHAIN_FILE=$TOOLCHAIN -DBUILD_SDK=OFF
#
This fails!

This is fixed with this pull request.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@HarshGandhi-AWS HarshGandhi-AWS merged commit c5f7512 into awslabs:main Oct 9, 2024
23 of 50 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants