Change the default value for SPDLOG_BUILD_xxx

The value based on whether spdlog is used as a third-party dependency or
as a standalone project. If spdlog is included through add_subdirectory,
the tests/examples/benchmarsk are disabled by default, and if spdlog is
configured standalone, then they are enabled by default.
This commit is contained in:
Sergey Alexandrov 2018-09-12 16:10:33 -04:00
parent f2ac7d730c
commit 75925762e8
No known key found for this signature in database
GPG Key ID: B70F82225D2CBAF4

View File

@ -45,11 +45,17 @@ include(cmake/sanitizers.cmake)
add_library(spdlog INTERFACE)
add_library(spdlog::spdlog ALIAS spdlog)
option(SPDLOG_BUILD_EXAMPLES "Build examples" ON)
option(SPDLOG_BUILD_BENCH "Build benchmarks" ON)
# Check if spdlog is being used directly or via add_subdirectory
set(SPDLOG_MASTER_PROJECT OFF)
if (CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR)
set(SPDLOG_MASTER_PROJECT ON)
endif()
option(SPDLOG_BUILD_EXAMPLES "Build examples" ${SPDLOG_MASTER_PROJECT})
option(SPDLOG_BUILD_BENCH "Build benchmarks" ${SPDLOG_MASTER_PROJECT})
cmake_dependent_option(SPDLOG_BUILD_TESTING
"Build spdlog tests" ON
"Build spdlog tests" ${SPDLOG_MASTER_PROJECT}
"BUILD_TESTING" OFF
)