From b90b7c5daa642d0b3f6d818e1225d533be3057e0 Mon Sep 17 00:00:00 2001 From: Alexey Ochapov Date: Mon, 13 Dec 2021 05:20:15 +0300 Subject: [PATCH] expose headers depending on special configuration option --- CMakeLists.txt | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e4a48b0d792df..e65408f7bc733 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -73,6 +73,12 @@ option(FMT_PEDANTIC "Enable extra warnings and expensive tests." OFF) option(FMT_WERROR "Halt the compilation with an error on compiler warnings." OFF) +if (FMT_MASTER_PROJECT) + set(FMT_EXPOSE_HEADERS_AS_SYSTEM_DEFAULT OFF) +else () + set(FMT_EXPOSE_HEADERS_AS_SYSTEM_DEFAULT ON) +endif () + # Options that control generation of various targets. option(FMT_DOC "Generate the doc target." ${FMT_MASTER_PROJECT}) option(FMT_INSTALL "Generate the install target." ${FMT_MASTER_PROJECT}) @@ -81,6 +87,7 @@ option(FMT_FUZZ "Generate the fuzz target." OFF) option(FMT_CUDA_TEST "Generate the cuda-test target." OFF) option(FMT_OS "Include core requiring OS (Windows/Posix) " ON) option(FMT_MODULE "Build a module instead of a traditional library." OFF) +option(FMT_EXPOSE_HEADERS_AS_SYSTEM "Expose headers with marking them as system." ${FMT_EXPOSE_HEADERS_AS_SYSTEM_DEFAULT}) set(FMT_CAN_MODULE OFF) if (CMAKE_CXX_STANDARD GREATER 17 AND @@ -96,6 +103,10 @@ if (FMT_TEST AND FMT_MODULE) # The tests require {fmt} to be compiled as traditional library message(STATUS "Testing is incompatible with build mode 'module'.") endif () +set(FMT_SYSTEM_HEADERS_ATTRIBUTE "") +if (FMT_EXPOSE_HEADERS_AS_SYSTEM) + set(FMT_SYSTEM_HEADERS_ATTRIBUTE SYSTEM) +endif () # Get version from core.h file(READ include/fmt/core.h core_h) @@ -262,7 +273,7 @@ endif () target_compile_features(fmt INTERFACE ${FMT_REQUIRED_FEATURES}) -target_include_directories(fmt PUBLIC +target_include_directories(fmt ${FMT_SYSTEM_HEADERS_ATTRIBUTE} PUBLIC $ $) @@ -298,7 +309,7 @@ add_library(fmt::fmt-header-only ALIAS fmt-header-only) target_compile_definitions(fmt-header-only INTERFACE FMT_HEADER_ONLY=1) target_compile_features(fmt-header-only INTERFACE ${FMT_REQUIRED_FEATURES}) -target_include_directories(fmt-header-only INTERFACE +target_include_directories(fmt-header-only ${FMT_SYSTEM_HEADERS_ATTRIBUTE} INTERFACE $ $)