mirror of
https://github.com/Kitware/CMake.git
synced 2026-01-05 05:11:15 -06:00
export: Propagate IMPORTED_NO_SYSTEM target property to consumers
Enabling `IMPORTED_NO_SYSTEM` on a target built within the project has no effect on the build system, but it is still a useful way to set the property on imported targets generated by `install(EXPORT)` and `export()`. Issue: #17364
This commit is contained in:
@@ -8,7 +8,9 @@ a ``SYSTEM`` library. This has the following effects:
|
|||||||
as ``SYSTEM`` include directories when compiling consumers, as they
|
as ``SYSTEM`` include directories when compiling consumers, as they
|
||||||
would be by default.
|
would be by default.
|
||||||
|
|
||||||
Ignored for non-imported targets.
|
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
|
See the :prop_tgt:`NO_SYSTEM_FROM_IMPORTED` target property to set this
|
||||||
behavior on the target consuming the include directories rather than
|
behavior on the target consuming the include directories rather than
|
||||||
|
|||||||
@@ -1072,6 +1072,12 @@ void cmExportFileGenerator::GenerateImportTargetCode(
|
|||||||
os << "set_property(TARGET " << targetName << " PROPERTY DEPRECATION "
|
os << "set_property(TARGET " << targetName << " PROPERTY DEPRECATION "
|
||||||
<< cmExportFileGeneratorEscape(target->GetDeprecation()) << ")\n";
|
<< cmExportFileGeneratorEscape(target->GetDeprecation()) << ")\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (target->GetPropertyAsBool("IMPORTED_NO_SYSTEM")) {
|
||||||
|
os << "set_property(TARGET " << targetName
|
||||||
|
<< " PROPERTY IMPORTED_NO_SYSTEM 1)\n";
|
||||||
|
}
|
||||||
|
|
||||||
os << "\n";
|
os << "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -145,6 +145,19 @@ set_property(TARGET testLibCycleA PROPERTY LINK_INTERFACE_MULTIPLICITY 3)
|
|||||||
add_library(testLibNoSONAME SHARED testLibNoSONAME.c)
|
add_library(testLibNoSONAME SHARED testLibNoSONAME.c)
|
||||||
set_property(TARGET testLibNoSONAME PROPERTY NO_SONAME 1)
|
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(PUSH)
|
||||||
cmake_policy(SET CMP0022 NEW)
|
cmake_policy(SET CMP0022 NEW)
|
||||||
# Test exporting dependent libraries into different exports
|
# Test exporting dependent libraries into different exports
|
||||||
@@ -531,6 +544,7 @@ install(
|
|||||||
cmp0022NEW cmp0022OLD
|
cmp0022NEW cmp0022OLD
|
||||||
TopDirLib SubDirLinkA
|
TopDirLib SubDirLinkA
|
||||||
systemlib
|
systemlib
|
||||||
|
testInterfaceIncludeUser
|
||||||
EXPORT exp
|
EXPORT exp
|
||||||
RUNTIME DESTINATION $<1:bin>$<0:/wrong>
|
RUNTIME DESTINATION $<1:bin>$<0:/wrong>
|
||||||
LIBRARY DESTINATION $<1:lib>$<0:/wrong> NAMELINK_SKIP
|
LIBRARY DESTINATION $<1:lib>$<0:/wrong> NAMELINK_SKIP
|
||||||
@@ -590,6 +604,7 @@ export(TARGETS testExe1 testLib1 testLib2 testLib3
|
|||||||
cmp0022NEW cmp0022OLD
|
cmp0022NEW cmp0022OLD
|
||||||
TopDirLib SubDirLinkA
|
TopDirLib SubDirLinkA
|
||||||
systemlib
|
systemlib
|
||||||
|
testInterfaceIncludeUser
|
||||||
NAMESPACE bld_
|
NAMESPACE bld_
|
||||||
FILE ExportBuildTree.cmake
|
FILE ExportBuildTree.cmake
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -0,0 +1 @@
|
|||||||
|
/* empty file */
|
||||||
@@ -70,6 +70,10 @@ target_link_libraries(imp_testExe1
|
|||||||
exp_testLibPerConfigDest
|
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.
|
# Try building a plugin to an executable imported from the install tree.
|
||||||
add_library(imp_mod1 MODULE imp_mod1.c)
|
add_library(imp_mod1 MODULE imp_mod1.c)
|
||||||
target_link_libraries(imp_mod1 exp_testExe2)
|
target_link_libraries(imp_mod1 exp_testExe2)
|
||||||
@@ -110,6 +114,10 @@ target_link_libraries(imp_testExe1b
|
|||||||
bld_testLibPerConfigDest
|
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
|
add_custom_target(check_testLib1_genex ALL
|
||||||
COMMAND ${CMAKE_COMMAND} -DtestLib1=$<TARGET_FILE:exp_testLib1>
|
COMMAND ${CMAKE_COMMAND} -DtestLib1=$<TARGET_FILE:exp_testLib1>
|
||||||
-Dprefix=${CMAKE_INSTALL_PREFIX}
|
-Dprefix=${CMAKE_INSTALL_PREFIX}
|
||||||
|
|||||||
6
Tests/ExportImport/Import/A/imp_testInterfaceInclude1.c
Normal file
6
Tests/ExportImport/Import/A/imp_testInterfaceInclude1.c
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
#include "testInterfaceInclude.h"
|
||||||
|
|
||||||
|
int imp_testInterfaceInclude1(void)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
#error testInterfaceInclude.h included from testInterfaceIncludeSystem
|
||||||
Reference in New Issue
Block a user