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

Add USE_EXTERNAL_DEPS_SOURCES cmake option #714

Merged
merged 4 commits into from
Apr 17, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 25 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -57,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)
Expand All @@ -70,8 +75,27 @@ if (BUILD_DEPS)
endif ()
set(BUILD_TESTING ${BUILD_TESTING_PREV})
else()
if (USE_EXTERNAL_DEPS_SOURCES)
function(validate_deps_sources dep_name)
if (NOT ${dep_name}_SOURCE_DIR)
sfod marked this conversation as resolved.
Show resolved Hide resolved
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)
set(IN_SOURCE_BUILD OFF)
endif()

aws_use_package(aws-crt-cpp)
Expand Down
Loading