From ee0301e65ba7833d196d337e1b70c2ee54b00023 Mon Sep 17 00:00:00 2001 From: Igor Abdrakhimov Date: Mon, 15 Apr 2024 16:09:24 -0700 Subject: [PATCH 1/3] Add USE_EXTERNAL_DEPS_SOURCES cmake option --- CMakeLists.txt | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 1d929a52a..09576117f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -11,6 +11,7 @@ project(aws-iot-device-sdk-cpp-v2 include(CTest) option(BUILD_DEPS "Builds aws common runtime dependencies as part of build. Turn off if you want to control your dependency chain." ON) +option(USE_EXTERNAL_DEPS_SOURCES "Use dependencies provided by add_subdirectory command" OFF) option(BUILD_SAMPLES "(DEPRECATED) Build samples as part of the build" OFF) if (DEFINED CMAKE_PREFIX_PATH) @@ -71,7 +72,11 @@ if (BUILD_DEPS) set(BUILD_TESTING ${BUILD_TESTING_PREV}) else() include(AwsFindPackage) - set(IN_SOURCE_BUILD OFF) + if (USE_EXTERNAL_DEPS_SOURCES) + set(IN_SOURCE_BUILD ON) + else() + set(IN_SOURCE_BUILD OFF) + endif() endif() aws_use_package(aws-crt-cpp) From ee2c6feabce806803cfab05f48dcd7cb5a3ad9af Mon Sep 17 00:00:00 2001 From: Igor Abdrakhimov Date: Tue, 16 Apr 2024 10:56:32 -0700 Subject: [PATCH 2/3] Validate dependencies, set CMAKE_MODULE_PATH --- CMakeLists.txt | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 09576117f..0f418770c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -58,6 +58,10 @@ else() endif() if (BUILD_DEPS) + if (USE_EXTERNAL_DEPS_SOURCES) + message(FATAL_ERROR "USE_EXTERNAL_DEPS_SOURCES option should be used with BUILD_DEPS set to OFF") + endif() + list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/crt/aws-crt-cpp/crt/aws-c-common/cmake") include(AwsFindPackage) @@ -71,12 +75,27 @@ if (BUILD_DEPS) endif () set(BUILD_TESTING ${BUILD_TESTING_PREV}) else() - include(AwsFindPackage) if (USE_EXTERNAL_DEPS_SOURCES) + function(validate_deps_sources dep_name) + if (NOT ${dep_name}_SOURCE_DIR) + message(FATAL_ERROR "USE_EXTERNAL_DEPS_SOURCES option is set, but ${dep_name} project is not configured." + " ${dep_name} must be added using add_subdirectory command (or one of the higher-level commands that" + " uses add_subdirectory, like FetchContent)") + endif() + endfunction() + + validate_deps_sources(aws-crt-cpp) + validate_deps_sources(aws-c-iot) + validate_deps_sources(aws-c-common) + + list(APPEND CMAKE_MODULE_PATH "${aws-c-common_SOURCE_DIR)}/cmake") + set(IN_SOURCE_BUILD ON) else() set(IN_SOURCE_BUILD OFF) endif() + + include(AwsFindPackage) endif() aws_use_package(aws-crt-cpp) From 8f30999a714263e43646e973d7009a1db0924c0e Mon Sep 17 00:00:00 2001 From: Igor Abdrakhimov Date: Tue, 16 Apr 2024 13:24:47 -0700 Subject: [PATCH 3/3] Fix typo --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0f418770c..3f5c133aa 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -88,7 +88,7 @@ else() validate_deps_sources(aws-c-iot) validate_deps_sources(aws-c-common) - list(APPEND CMAKE_MODULE_PATH "${aws-c-common_SOURCE_DIR)}/cmake") + list(APPEND CMAKE_MODULE_PATH "${aws-c-common_SOURCE_DIR}/cmake") set(IN_SOURCE_BUILD ON) else()