From f76fa0fcaf628ac2a4c087ba54e0a8219dec2a24 Mon Sep 17 00:00:00 2001 From: "Arthur Brainville (Ybalrid)" Date: Sun, 3 May 2020 16:28:01 +0200 Subject: [PATCH] Add an option that allow user to disable warnings This option is false by default, thus do not change the current behavior of the build system. This is useful when the user vendor spdlog's code into his own codebase and do not want to have the compiler warn about spdlog's code. This also is an easy way to prevent CMake to set non-compatible flags on `clang-cl` (clang for Visual Studio) like `-pedantic`. In practice, this patch does: -add option `SPDLOG_DISABLE_WARNINGS`, `off` state by default -add conditional test checking that the option above is `off`. If the option is manually turned on by the user: behavior is to skip the call to `spdlog_enable_warnings` on `spdlog` build target. If the user does nothing, current behavior is unchanged. --- CMakeLists.txt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 508a0b65..38c4b757 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -125,7 +125,11 @@ target_include_directories(spdlog PUBLIC "$" "$") target_link_libraries(spdlog PUBLIC Threads::Threads) -spdlog_enable_warnings(spdlog) + +option(SPDLOG_DISABLE_WARNINGS "Skip enabling warnings when building spdlog" off) +if(NOT SPDLOG_DISABLE_WARNINGS) + spdlog_enable_warnings(spdlog) +endif() set_target_properties(spdlog PROPERTIES VERSION ${SPDLOG_VERSION} SOVERSION ${SPDLOG_VERSION_MAJOR}) set_target_properties(spdlog PROPERTIES DEBUG_POSTFIX d)