Skip to content

Commit

Permalink
expose headers depending on special configuration option
Browse files Browse the repository at this point in the history
  • Loading branch information
alexezeder committed Dec 13, 2021
1 parent 3a951a6 commit b90b7c5
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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})
Expand All @@ -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
Expand All @@ -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)
Expand Down Expand Up @@ -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
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:${FMT_INC_DIR}>)

Expand Down Expand Up @@ -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
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:${FMT_INC_DIR}>)

Expand Down

0 comments on commit b90b7c5

Please sign in to comment.