1
0
mirror of https://github.com/CLIUtils/CLI11.git synced 2025-04-30 20:53:52 +00:00

chore: Mark include files as SYSTEM (#844)

When including CLI11 in a separate project (e.g. via FetchContent) cmake
will now mark the CLI11 include files as system includes, which prevents
compilers from issuing any warnings for stuff it found inside these
headers. This makes sure that downstream users are not confronted with
potential warning messages from CLI11, regardless of what kind of
obscure warnings they might have enabled for their projects.

Fixes #833
This commit is contained in:
Robert Adam 2023-02-10 17:51:56 +01:00 committed by GitHub
parent 1ffded5eae
commit 60f0dcab3d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -53,9 +53,17 @@ endif()
# Allow IDE's to group targets into folders
add_library(CLI11::CLI11 ALIAS CLI11) # for add_subdirectory calls
if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME)
set(SYSTEM_INCL "")
else()
# If this project is included from somewhere else, we mark our headers as system headers to avoid
# the compiler emitting any warnings about them
set(SYSTEM_INCL "SYSTEM")
endif()
# Duplicated because CMake adds the current source dir if you don't.
target_include_directories(
CLI11 ${PUBLIC_OR_INTERFACE} $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>
CLI11 ${SYSTEM_INCL} ${PUBLIC_OR_INTERFACE} $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>)
if(CMAKE_VERSION VERSION_LESS 3.8)