mirror of
https://github.com/Kitware/CMake.git
synced 2026-05-03 04:40:18 -05:00
Teach target_* commands to set INTERFACE properties of IMPORTED targets
Now, several `INTERFACE_*` properties can be set on `IMPORTED` targets, not only via `set_property` and `set_target_properties` but also via `target_compile_definitions`, `target_compile_features`, `target_compile_options`, `target_include_directories`, `target_sources` and `target_link_libraries`. Fixes: #15689 Issue: #17197
This commit is contained in:
@@ -1,5 +0,0 @@
|
||||
^CMake Error at UNKNOWNwithNoSourcesButLinkObjects.cmake:[0-9]+ \(target_link_libraries\):
|
||||
Cannot specify link libraries for target \"TestUnknownLibWithoutSources\"
|
||||
which is not built by this project.
|
||||
Call Stack \(most recent call first\):
|
||||
CMakeLists.txt:[0-9]+ \(include\)$
|
||||
@@ -2,4 +2,4 @@ enable_language(CXX)
|
||||
add_library(ObjectLibDependency OBJECT test.cpp)
|
||||
|
||||
add_library(TestUnknownLibWithoutSources UNKNOWN IMPORTED)
|
||||
target_link_libraries(TestUnknownLibWithoutSources PUBLIC $<TARGET_OBJECTS:ObjectLibDependency>)
|
||||
target_link_libraries(TestUnknownLibWithoutSources INTERFACE $<TARGET_OBJECTS:ObjectLibDependency>)
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
CMake Error at imported_target.cmake:[0-9]+ \(target_compile_features\):
|
||||
Cannot specify compile features for imported target "main".
|
||||
^CMake Error at imported_target.cmake:[0-9]+ \(target_compile_features\):
|
||||
target_compile_features may only set INTERFACE properties on INTERFACE
|
||||
targets
|
||||
Call Stack \(most recent call first\):
|
||||
CMakeLists.txt:3 \(include\)
|
||||
CMakeLists.txt:3 \(include\)$
|
||||
|
||||
@@ -1,4 +1,10 @@
|
||||
enable_language(CXX)
|
||||
|
||||
add_library(main INTERFACE IMPORTED)
|
||||
target_compile_features(main INTERFACE cxx_delegating_constructors)
|
||||
add_library(lib1-interface INTERFACE IMPORTED)
|
||||
target_compile_features(lib1-interface INTERFACE cxx_delegating_constructors)
|
||||
|
||||
add_library(lib2-interface INTERFACE IMPORTED)
|
||||
target_compile_features(lib2-interface PUBLIC cxx_delegating_constructors)
|
||||
|
||||
add_library(lib-shared SHARED IMPORTED)
|
||||
target_compile_features(lib-shared INTERFACE cxx_delegating_constructors)
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
add_library(UnknownImportedGlobal UNKNOWN IMPORTED GLOBAL)
|
||||
target_link_libraries(UnknownImportedGlobal INTERFACE z)
|
||||
@@ -0,0 +1,5 @@
|
||||
^CMake Error at ImportedTargetFailure.cmake:[0-9]+ \(target_link_libraries\):
|
||||
IMPORTED library can only be used with the INTERFACE keyword of
|
||||
target_link_libraries
|
||||
Call Stack \(most recent call first\):
|
||||
CMakeLists\.txt:[0-9]+ \(include\)$
|
||||
@@ -0,0 +1,2 @@
|
||||
add_library(UnknownImportedGlobal UNKNOWN IMPORTED GLOBAL)
|
||||
target_link_libraries(UnknownImportedGlobal PRIVATE z)
|
||||
@@ -4,6 +4,8 @@ run_cmake(CMP0023-WARN)
|
||||
run_cmake(CMP0023-NEW)
|
||||
run_cmake(CMP0023-WARN-2)
|
||||
run_cmake(CMP0023-NEW-2)
|
||||
run_cmake(ImportedTarget)
|
||||
run_cmake(ImportedTargetFailure)
|
||||
run_cmake(MixedSignature)
|
||||
run_cmake(Separate-PRIVATE-LINK_PRIVATE-uses)
|
||||
run_cmake(SubDirTarget)
|
||||
|
||||
Reference in New Issue
Block a user