summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2021-10-18 13:38:16 (GMT)
committerKitware Robot <kwrobot@kitware.com>2021-10-18 13:38:28 (GMT)
commit2d620e83809b64fa26ed098086d66095d91ab7cb (patch)
tree737cd253d6c968982a999ce7ff074a0f001465c5
parent1a1a8ff8584f1b4736cc72a8e9834c479ed34c5e (diff)
parent14d98bcfe6fa1dd2f4220e50e99ec099939496d5 (diff)
downloadCMake-2d620e83809b64fa26ed098086d66095d91ab7cb.zip
CMake-2d620e83809b64fa26ed098086d66095d91ab7cb.tar.gz
CMake-2d620e83809b64fa26ed098086d66095d91ab7cb.tar.bz2
Merge topic 'imported-no-system'
14d98bcfe6 export: Propagate IMPORTED_NO_SYSTEM target property to consumers 7df0541055 Add property to mark IMPORTED targets as not SYSTEM Acked-by: Kitware Robot <kwrobot@kitware.com> Tested-by: buildbot <buildbot@kitware.com> Acked-by: Allison Vacanti <alliepiper16@gmail.com> Merge-request: !6627
-rw-r--r--Help/manual/cmake-properties.7.rst1
-rw-r--r--Help/prop_tgt/IMPORTED_NO_SYSTEM.rst17
-rw-r--r--Help/prop_tgt/NO_SYSTEM_FROM_IMPORTED.rst3
-rw-r--r--Help/release/dev/imported-no-system.rst7
-rw-r--r--Source/cmExportFileGenerator.cxx6
-rw-r--r--Source/cmGeneratorTarget.cxx3
-rw-r--r--Tests/ExportImport/Export/CMakeLists.txt15
-rw-r--r--Tests/ExportImport/Export/include/testInterfaceIncludeUser/testInterfaceInclude.h1
-rw-r--r--Tests/ExportImport/Import/A/CMakeLists.txt8
-rw-r--r--Tests/ExportImport/Import/A/imp_testInterfaceInclude1.c6
-rw-r--r--Tests/ExportImport/Import/A/testInterfaceIncludeSystem/testInterfaceInclude.h1
-rw-r--r--Tests/IncludeDirectories/CMakeLists.txt7
12 files changed, 75 insertions, 0 deletions
diff --git a/Help/manual/cmake-properties.7.rst b/Help/manual/cmake-properties.7.rst
index bb5dba3..435b2c6 100644
--- a/Help/manual/cmake-properties.7.rst
+++ b/Help/manual/cmake-properties.7.rst
@@ -239,6 +239,7 @@ Properties on Targets
/prop_tgt/IMPORTED_LOCATION_CONFIG
/prop_tgt/IMPORTED_NO_SONAME
/prop_tgt/IMPORTED_NO_SONAME_CONFIG
+ /prop_tgt/IMPORTED_NO_SYSTEM
/prop_tgt/IMPORTED_OBJECTS
/prop_tgt/IMPORTED_OBJECTS_CONFIG
/prop_tgt/IMPORTED_SONAME
diff --git a/Help/prop_tgt/IMPORTED_NO_SYSTEM.rst b/Help/prop_tgt/IMPORTED_NO_SYSTEM.rst
new file mode 100644
index 0000000..cc726d1
--- /dev/null
+++ b/Help/prop_tgt/IMPORTED_NO_SYSTEM.rst
@@ -0,0 +1,17 @@
+IMPORTED_NO_SYSTEM
+------------------
+
+Specifies that an :ref:`Imported Target <Imported Targets>` is not
+a ``SYSTEM`` library. This has the following effects:
+
+* Entries of :prop_tgt:`INTERFACE_INCLUDE_DIRECTORIES` are not treated
+ as ``SYSTEM`` include directories when compiling consumers, as they
+ would be by default.
+
+This property can also be enabled on a non-imported target. Doing so does
+not affect the build system, but does tell the :command:`install(EXPORT)` and
+:command:`export` commands to enable it on the imported targets they generate.
+
+See the :prop_tgt:`NO_SYSTEM_FROM_IMPORTED` target property to set this
+behavior on the target consuming the include directories rather than
+providing them.
diff --git a/Help/prop_tgt/NO_SYSTEM_FROM_IMPORTED.rst b/Help/prop_tgt/NO_SYSTEM_FROM_IMPORTED.rst
index 880343d..e5cc09b 100644
--- a/Help/prop_tgt/NO_SYSTEM_FROM_IMPORTED.rst
+++ b/Help/prop_tgt/NO_SYSTEM_FROM_IMPORTED.rst
@@ -13,3 +13,6 @@ imported targets as system includes.
This property is initialized by the value of the
:variable:`CMAKE_NO_SYSTEM_FROM_IMPORTED` variable if it is set when a target
is created.
+
+See the :prop_tgt:`IMPORTED_NO_SYSTEM` target property to set this behavior
+on the target providing the include directories rather than consuming them.
diff --git a/Help/release/dev/imported-no-system.rst b/Help/release/dev/imported-no-system.rst
new file mode 100644
index 0000000..a35e8bb
--- /dev/null
+++ b/Help/release/dev/imported-no-system.rst
@@ -0,0 +1,7 @@
+imported-no-system
+------------------
+
+* The :prop_tgt:`IMPORTED_NO_SYSTEM` target property was added to
+ specify that an :ref:`Imported Target <Imported Targets>` should
+ not be treated as a system library (i.e. its include directories
+ are not automatically ``SYSTEM``).
diff --git a/Source/cmExportFileGenerator.cxx b/Source/cmExportFileGenerator.cxx
index c0a4cdc..0eda92c 100644
--- a/Source/cmExportFileGenerator.cxx
+++ b/Source/cmExportFileGenerator.cxx
@@ -1072,6 +1072,12 @@ void cmExportFileGenerator::GenerateImportTargetCode(
os << "set_property(TARGET " << targetName << " PROPERTY DEPRECATION "
<< cmExportFileGeneratorEscape(target->GetDeprecation()) << ")\n";
}
+
+ if (target->GetPropertyAsBool("IMPORTED_NO_SYSTEM")) {
+ os << "set_property(TARGET " << targetName
+ << " PROPERTY IMPORTED_NO_SYSTEM 1)\n";
+ }
+
os << "\n";
}
diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx
index 8033ef5..fc02a47 100644
--- a/Source/cmGeneratorTarget.cxx
+++ b/Source/cmGeneratorTarget.cxx
@@ -747,6 +747,9 @@ void handleSystemIncludesDep(cmLocalGenerator* lg,
if (!depTgt->IsImported() || excludeImported) {
return;
}
+ if (depTgt->GetPropertyAsBool("IMPORTED_NO_SYSTEM")) {
+ return;
+ }
if (cmValue dirs = depTgt->GetProperty("INTERFACE_INCLUDE_DIRECTORIES")) {
cmExpandList(cmGeneratorExpression::Evaluate(*dirs, lg, config, headTarget,
diff --git a/Tests/ExportImport/Export/CMakeLists.txt b/Tests/ExportImport/Export/CMakeLists.txt
index a2968d4..7b33277 100644
--- a/Tests/ExportImport/Export/CMakeLists.txt
+++ b/Tests/ExportImport/Export/CMakeLists.txt
@@ -145,6 +145,19 @@ set_property(TARGET testLibCycleA PROPERTY LINK_INTERFACE_MULTIPLICITY 3)
add_library(testLibNoSONAME SHARED testLibNoSONAME.c)
set_property(TARGET testLibNoSONAME PROPERTY NO_SONAME 1)
+add_library(testInterfaceIncludeUser INTERFACE)
+target_include_directories(testInterfaceIncludeUser
+ INTERFACE
+ "$<INSTALL_INTERFACE:include/testInterfaceIncludeUser>"
+ "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include/testInterfaceIncludeUser>"
+)
+set_property(TARGET testInterfaceIncludeUser PROPERTY IMPORTED_NO_SYSTEM 1)
+install(
+ FILES
+ "${CMAKE_CURRENT_SOURCE_DIR}/include/testInterfaceIncludeUser/testInterfaceInclude.h"
+ DESTINATION include/testInterfaceIncludeUser
+)
+
cmake_policy(PUSH)
cmake_policy(SET CMP0022 NEW)
# Test exporting dependent libraries into different exports
@@ -531,6 +544,7 @@ install(
cmp0022NEW cmp0022OLD
TopDirLib SubDirLinkA
systemlib
+ testInterfaceIncludeUser
EXPORT exp
RUNTIME DESTINATION $<1:bin>$<0:/wrong>
LIBRARY DESTINATION $<1:lib>$<0:/wrong> NAMELINK_SKIP
@@ -590,6 +604,7 @@ export(TARGETS testExe1 testLib1 testLib2 testLib3
cmp0022NEW cmp0022OLD
TopDirLib SubDirLinkA
systemlib
+ testInterfaceIncludeUser
NAMESPACE bld_
FILE ExportBuildTree.cmake
)
diff --git a/Tests/ExportImport/Export/include/testInterfaceIncludeUser/testInterfaceInclude.h b/Tests/ExportImport/Export/include/testInterfaceIncludeUser/testInterfaceInclude.h
new file mode 100644
index 0000000..fa882cb
--- /dev/null
+++ b/Tests/ExportImport/Export/include/testInterfaceIncludeUser/testInterfaceInclude.h
@@ -0,0 +1 @@
+/* empty file */
diff --git a/Tests/ExportImport/Import/A/CMakeLists.txt b/Tests/ExportImport/Import/A/CMakeLists.txt
index 3cb3833..0cd703f 100644
--- a/Tests/ExportImport/Import/A/CMakeLists.txt
+++ b/Tests/ExportImport/Import/A/CMakeLists.txt
@@ -70,6 +70,10 @@ target_link_libraries(imp_testExe1
exp_testLibPerConfigDest
)
+add_library(imp_testInterfaceInclude1 STATIC imp_testInterfaceInclude1.c)
+target_include_directories(imp_testInterfaceInclude1 SYSTEM PRIVATE testInterfaceIncludeSystem)
+target_link_libraries(imp_testInterfaceInclude1 PRIVATE exp_testInterfaceIncludeUser)
+
# Try building a plugin to an executable imported from the install tree.
add_library(imp_mod1 MODULE imp_mod1.c)
target_link_libraries(imp_mod1 exp_testExe2)
@@ -110,6 +114,10 @@ target_link_libraries(imp_testExe1b
bld_testLibPerConfigDest
)
+add_library(imp_testInterfaceInclude1b STATIC imp_testInterfaceInclude1.c)
+target_include_directories(imp_testInterfaceInclude1b SYSTEM PRIVATE testInterfaceIncludeSystem)
+target_link_libraries(imp_testInterfaceInclude1b PRIVATE bld_testInterfaceIncludeUser)
+
add_custom_target(check_testLib1_genex ALL
COMMAND ${CMAKE_COMMAND} -DtestLib1=$<TARGET_FILE:exp_testLib1>
-Dprefix=${CMAKE_INSTALL_PREFIX}
diff --git a/Tests/ExportImport/Import/A/imp_testInterfaceInclude1.c b/Tests/ExportImport/Import/A/imp_testInterfaceInclude1.c
new file mode 100644
index 0000000..88a49b5
--- /dev/null
+++ b/Tests/ExportImport/Import/A/imp_testInterfaceInclude1.c
@@ -0,0 +1,6 @@
+#include "testInterfaceInclude.h"
+
+int imp_testInterfaceInclude1(void)
+{
+ return 0;
+}
diff --git a/Tests/ExportImport/Import/A/testInterfaceIncludeSystem/testInterfaceInclude.h b/Tests/ExportImport/Import/A/testInterfaceIncludeSystem/testInterfaceInclude.h
new file mode 100644
index 0000000..2beeb8b
--- /dev/null
+++ b/Tests/ExportImport/Import/A/testInterfaceIncludeSystem/testInterfaceInclude.h
@@ -0,0 +1 @@
+#error testInterfaceInclude.h included from testInterfaceIncludeSystem
diff --git a/Tests/IncludeDirectories/CMakeLists.txt b/Tests/IncludeDirectories/CMakeLists.txt
index 4c488e6..efbcb7e 100644
--- a/Tests/IncludeDirectories/CMakeLists.txt
+++ b/Tests/IncludeDirectories/CMakeLists.txt
@@ -115,6 +115,13 @@ add_library(ordertest ordertest.cpp)
target_include_directories(ordertest SYSTEM PUBLIC SystemIncludeDirectories/systemlib)
target_include_directories(ordertest PUBLIC SystemIncludeDirectories/userlib)
+add_library(ordertest2 ordertest.cpp)
+target_include_directories(ordertest2 SYSTEM PRIVATE SystemIncludeDirectories/systemlib)
+target_link_libraries(ordertest2 PRIVATE ordertest2_userlib)
+add_library(ordertest2_userlib INTERFACE IMPORTED)
+target_include_directories(ordertest2_userlib INTERFACE SystemIncludeDirectories/userlib)
+set_property(TARGET ordertest2_userlib PROPERTY IMPORTED_NO_SYSTEM 1)
+
add_subdirectory(StandardIncludeDirectories)
add_subdirectory(TargetIncludeDirectories)