summaryrefslogtreecommitdiff
path: root/Modules/FetchContent.cmake
diff options
context:
space:
mode:
authorDa Quexian <daquexian566@gmail.com>2022-06-22 20:18:06 +0800
committerBrad King <brad.king@kitware.com>2022-09-26 10:56:54 -0400
commit2eb30a7036214ec960f0666163ff44ef754f6afe (patch)
tree19f7bc19562409245f326da04371acbca8e9ea85 /Modules/FetchContent.cmake
parent80e4a155e0feddf1a02fb2701dff5ddbb427552a (diff)
downloadcmake-2eb30a7036214ec960f0666163ff44ef754f6afe.tar.gz
add_subdirectory: Add SYSTEM option
Fixes: #22401 Signed-off-by: Da Quexian <daquexian566@gmail.com>
Diffstat (limited to 'Modules/FetchContent.cmake')
-rw-r--r--Modules/FetchContent.cmake19
1 files changed, 17 insertions, 2 deletions
diff --git a/Modules/FetchContent.cmake b/Modules/FetchContent.cmake
index c4c3a930c8..d538053593 100644
--- a/Modules/FetchContent.cmake
+++ b/Modules/FetchContent.cmake
@@ -111,6 +111,7 @@ Commands
FetchContent_Declare(
<name>
<contentOptions>...
+ [SYSTEM]
[OVERRIDE_FIND_PACKAGE |
FIND_PACKAGE_ARGS args...]
)
@@ -229,6 +230,16 @@ Commands
to intercept any direct call to :command:`find_package`, except if that
call contains the ``BYPASS_PROVIDER`` option.
+ .. versionadded:: 3.25
+
+ ``SYSTEM``
+ If the ``SYSTEM`` argument is provided, targets created by
+ the dependency will have their :prop_tgt:`SYSTEM` property
+ set to true when populated by :command:`FetchContent_MakeAvailable`.
+ The entries in their :prop_tgt:`INTERFACE_INCLUDE_DIRECTORIES`
+ will be treated as ``SYSTEM`` include directories when
+ compiling consumers.
+
.. command:: FetchContent_MakeAvailable
.. versionadded:: 3.14
@@ -1931,13 +1942,17 @@ macro(FetchContent_MakeAvailable)
if("${__cmake_contentDetails}" STREQUAL "")
message(FATAL_ERROR "No details have been set for content: ${__cmake_contentName}")
endif()
- cmake_parse_arguments(__cmake_arg "" "SOURCE_SUBDIR" "" ${__cmake_contentDetails})
+ cmake_parse_arguments(__cmake_arg "SYSTEM" "SOURCE_SUBDIR" "" ${__cmake_contentDetails})
if(NOT "${__cmake_arg_SOURCE_SUBDIR}" STREQUAL "")
string(APPEND __cmake_srcdir "/${__cmake_arg_SOURCE_SUBDIR}")
endif()
if(EXISTS ${__cmake_srcdir}/CMakeLists.txt)
- add_subdirectory(${__cmake_srcdir} ${${__cmake_contentNameLower}_BINARY_DIR})
+ if (__cmake_arg_SYSTEM)
+ add_subdirectory(${__cmake_srcdir} ${${__cmake_contentNameLower}_BINARY_DIR} SYSTEM)
+ else()
+ add_subdirectory(${__cmake_srcdir} ${${__cmake_contentNameLower}_BINARY_DIR})
+ endif()
endif()
unset(__cmake_srcdir)