diff --git a/CMakeLists.txt b/CMakeLists.txt index 811d3d2c..931e2806 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,6 +5,8 @@ if (POLICY CMP0069) cmake_policy(SET CMP0069 NEW) # Enable LTO/IPO if available in the compiler, see AwsCFlags endif() +option(USE_EXTERNAL_DEPS_SOURCES "Use dependencies provided by add_subdirectory command" OFF) + if (DEFINED CMAKE_PREFIX_PATH) file(TO_CMAKE_PATH "${CMAKE_PREFIX_PATH}" CMAKE_PREFIX_PATH) endif() @@ -25,6 +27,18 @@ string(REPLACE ";" "${AWS_MODULE_DIR};" AWS_MODULE_PATH "${CMAKE_PREFIX_PATH}${A # Append that generated list to the module search path list(APPEND CMAKE_MODULE_PATH ${AWS_MODULE_PATH}) +if (USE_EXTERNAL_DEPS_SOURCES) + set(IN_SOURCE_BUILD ON) + + if (NOT aws-c-common_SOURCE_DIR) + message(FATAL_ERROR "USE_EXTERNAL_DEPS_SOURCES option is set, but aws-c-common project is not configured." + " aws-c-common must be added using add_subdirectory command (or one of the higher-level commands that" + " uses add_subdirectory, like FetchContent)") + endif() + + list(APPEND CMAKE_MODULE_PATH "${aws-c-common_SOURCE_DIR}/cmake") +endif() + include(AwsCFlags) include(AwsCheckHeaders) include(AwsSharedLibSetup)