From 2eb30a7036214ec960f0666163ff44ef754f6afe Mon Sep 17 00:00:00 2001 From: Da Quexian Date: Wed, 22 Jun 2022 20:18:06 +0800 Subject: add_subdirectory: Add SYSTEM option Fixes: #22401 Signed-off-by: Da Quexian --- Modules/FetchContent.cmake | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) (limited to 'Modules/FetchContent.cmake') 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( ... + [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) -- cgit v1.2.1