@@ -11,6 +11,7 @@ project(aws-iot-device-sdk-cpp-v2
11
11
include (CTest )
12
12
13
13
option (BUILD_DEPS "Builds aws common runtime dependencies as part of build. Turn off if you want to control your dependency chain." ON )
14
+ option (USE_EXTERNAL_DEPS_SOURCES "Use dependencies provided by add_subdirectory command" OFF )
14
15
option (BUILD_SAMPLES "(DEPRECATED) Build samples as part of the build" OFF )
15
16
16
17
if (DEFINED CMAKE_PREFIX_PATH )
@@ -57,6 +58,10 @@ else()
57
58
endif ()
58
59
59
60
if (BUILD_DEPS )
61
+ if (USE_EXTERNAL_DEPS_SOURCES )
62
+ message (FATAL_ERROR "USE_EXTERNAL_DEPS_SOURCES option should be used with BUILD_DEPS set to OFF" )
63
+ endif ()
64
+
60
65
list (APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR} /crt/aws-crt-cpp/crt/aws-c-common/cmake" )
61
66
62
67
include (AwsFindPackage )
@@ -70,8 +75,27 @@ if (BUILD_DEPS)
70
75
endif ()
71
76
set (BUILD_TESTING ${BUILD_TESTING_PREV} )
72
77
else ()
78
+ if (USE_EXTERNAL_DEPS_SOURCES )
79
+ function (validate_deps_sources dep_name )
80
+ if (NOT ${dep_name} _SOURCE_DIR )
81
+ message (FATAL_ERROR "USE_EXTERNAL_DEPS_SOURCES option is set, but ${dep_name} project is not configured."
82
+ " ${dep_name} must be added using add_subdirectory command (or one of the higher-level commands that"
83
+ " uses add_subdirectory, like FetchContent)" )
84
+ endif ()
85
+ endfunction ()
86
+
87
+ validate_deps_sources (aws-crt-cpp )
88
+ validate_deps_sources (aws-c-iot )
89
+ validate_deps_sources (aws-c-common )
90
+
91
+ list (APPEND CMAKE_MODULE_PATH "${aws-c-common_SOURCE_DIR}/cmake" )
92
+
93
+ set (IN_SOURCE_BUILD ON )
94
+ else ()
95
+ set (IN_SOURCE_BUILD OFF )
96
+ endif ()
97
+
73
98
include (AwsFindPackage )
74
- set (IN_SOURCE_BUILD OFF )
75
99
endif ()
76
100
77
101
aws_use_package (aws-crt-cpp )
0 commit comments