Skip to content
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: 20 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,16 @@ project(viam-cpp-sdk
LANGUAGES CXX
)

# Detect if we're building as a standalone module
# vs being included via FetchContent by a downstream consumer
if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
set(VIAMCPPSDK_STANDALONE_BUILD ON)
message(STATUS "viam-cpp-sdk: Standalone build mode")
else()
set(VIAMCPPSDK_STANDALONE_BUILD OFF)
message(STATUS "viam-cpp-sdk: FetchContent mode (included by parent project)")
endif()


# Configure cmake-level options:

Expand Down Expand Up @@ -113,7 +123,7 @@ option(VIAMCPPSDK_USE_LOCAL_PROTOS "Generate protos against sibling `api` direct
# This causes the SDK's internal code to compile with `-Wall` and
# `-Werror` flags.
#
option(VIAMCPPSDK_USE_WALL_WERROR "Build with -Wall and -Werror flags" ON)
option(VIAMCPPSDK_USE_WALL_WERROR "Build with -Wall and -Werror flags" ${VIAMCPPSDK_STANDALONE_BUILD})


# - `VIAMCPPSDK_SANITIZED_BUILD`
Expand Down Expand Up @@ -141,11 +151,15 @@ option(VIAMCPPSDK_CLANG_TIDY "Run the clang-tidy linter" OFF)
#
option(VIAMCPPSDK_OPENTELEMETRY_TRACING "Compile OpenTelemetry tracing into all gRPC calls" OFF)

# The following options are only defined if this project is not being included as a subproject
if (CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR)
option(VIAMCPPSDK_BUILD_EXAMPLES "Build the example executables" ON)
option(VIAMCPPSDK_BUILD_TESTS "Build the example executables" ON)
endif()
# - `VIAMCPPSDK_BUILD_EXAMPLES `
#
# Defaults to ON for standalone builds, OFF for FetchContent consumers.
option(VIAMCPPSDK_BUILD_EXAMPLES "Build the example executables" ${VIAMCPPSDK_STANDALONE_BUILD})

# - `VIAMCPPSDK_BUILD_TESTS `
#
# Defaults to ON for standalone builds, OFF for FetchContent consumers.
option(VIAMCPPSDK_BUILD_TESTS "Build the example executables" ${VIAMCPPSDK_STANDALONE_BUILD})


# Enforce known toolchains and toolchain minima unless asked not to.
Expand Down
Loading