Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/gabime/spdlog.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Alexandrov <alexandrov88@gmail.com>2018-09-12 23:10:33 +0300
committerSergey Alexandrov <alexandrov88@gmail.com>2018-09-12 23:11:45 +0300
commit75925762e8b244830aee231a595ee2173eaa0cae (patch)
treeb15cf5a6ac7a15774f3ea43dd5dc61ba0dbfea5d /CMakeLists.txt
parentf2ac7d730cb8afd386d897a3900ed145c392c1d9 (diff)
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.
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r--CMakeLists.txt12
1 files changed, 9 insertions, 3 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index c0b8a373..1b885ab7 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -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
)