From 3f7a3a860e407aabd74ff3268887d8cdf920ca12 Mon Sep 17 00:00:00 2001 From: dpayne Date: Sun, 11 Dec 2022 00:09:53 -0800 Subject: [PATCH] Adding system includes option --- CMakeLists.txt | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a66e8405..7205efc3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -82,6 +82,7 @@ option(SPDLOG_SANITIZE_ADDRESS "Enable address sanitizer in tests" OFF) option(SPDLOG_BUILD_WARNINGS "Enable compiler warnings" OFF) # install options +option(SPDLOG_SYSTEM_INCLUDES "Include as system headers (skip for clang-tidy)." OFF) option(SPDLOG_INSTALL "Generate the install target" ${SPDLOG_MASTER_PROJECT}) option(SPDLOG_USE_STD_FORMAT "Use std::format instead of fmt library." OFF) option(SPDLOG_FMT_EXTERNAL "Use external fmt library instead of bundled" OFF) @@ -170,8 +171,16 @@ endif() add_library(spdlog::spdlog ALIAS spdlog) +set(SPDLOG_INCLUDES_LEVEL "PUBLIC") +set(SPDLOG_HEADER_INCLUDES_LEVEL "") +if(SPDLOG_SYSTEM_INCLUDES) + set(SPDLOG_INCLUDES_LEVEL "SYSTEM") + set(SPDLOG_HEADER_INCLUDES_LEVEL "SYSTEM") +endif() + + target_compile_definitions(spdlog PUBLIC SPDLOG_COMPILED_LIB) -target_include_directories(spdlog PUBLIC "$" +target_include_directories(spdlog ${SPDLOG_INCLUDES_LEVEL} "$" "$") target_link_libraries(spdlog PUBLIC Threads::Threads) spdlog_enable_warnings(spdlog) @@ -190,7 +199,7 @@ endif() add_library(spdlog_header_only INTERFACE) add_library(spdlog::spdlog_header_only ALIAS spdlog_header_only) -target_include_directories(spdlog_header_only INTERFACE "$" +target_include_directories(spdlog_header_only ${SPDLOG_HEADER_INCLUDES_LEVEL} INTERFACE "$" "$") target_link_libraries(spdlog_header_only INTERFACE Threads::Threads)