summaryrefslogtreecommitdiffstats
path: root/Tests/RunCMake/set_property/IMPORTED_GLOBAL.cmake
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2017-11-08 14:08:08 (GMT)
committerKitware Robot <kwrobot@kitware.com>2017-11-08 14:08:15 (GMT)
commit30fcf13be6680d6a4eb112f98cc2d99c6881f401 (patch)
treef967b05d19f98294a6147adf67bcb060a744ac32 /Tests/RunCMake/set_property/IMPORTED_GLOBAL.cmake
parent9f30cd13dad63b2a327162285711cd36dcc20b92 (diff)
parent6a3922bebea607dcc23944b1fe79b7b613a893d1 (diff)
downloadCMake-30fcf13be6680d6a4eb112f98cc2d99c6881f401.zip
CMake-30fcf13be6680d6a4eb112f98cc2d99c6881f401.tar.gz
CMake-30fcf13be6680d6a4eb112f98cc2d99c6881f401.tar.bz2
Merge topic 'imported-promotion'
6a3922be Add new target-property `IMPORTED_GLOBAL`. 854e482a cmTarget: Simplified and fixed a string-comparision. Acked-by: Kitware Robot <kwrobot@kitware.com> Merge-request: !1254
Diffstat (limited to 'Tests/RunCMake/set_property/IMPORTED_GLOBAL.cmake')
-rw-r--r--Tests/RunCMake/set_property/IMPORTED_GLOBAL.cmake53
1 files changed, 53 insertions, 0 deletions
diff --git a/Tests/RunCMake/set_property/IMPORTED_GLOBAL.cmake b/Tests/RunCMake/set_property/IMPORTED_GLOBAL.cmake
new file mode 100644
index 0000000..08308eb
--- /dev/null
+++ b/Tests/RunCMake/set_property/IMPORTED_GLOBAL.cmake
@@ -0,0 +1,53 @@
+macro(print_property TARGET PROP)
+ get_property(val TARGET ${TARGET} PROPERTY ${PROP})
+ message(STATUS "${TARGET}: Target ${PROP} is '${val}'")
+endmacro()
+
+# Changing property on IMPORTED target created with `GLOBAL` option.
+add_library(ImportedGlobalTarget SHARED IMPORTED GLOBAL)
+print_property(ImportedGlobalTarget IMPORTED_GLOBAL)
+set_property(TARGET ImportedGlobalTarget PROPERTY IMPORTED_GLOBAL FALSE)
+print_property(ImportedGlobalTarget IMPORTED_GLOBAL)
+set_property(TARGET ImportedGlobalTarget PROPERTY IMPORTED_GLOBAL TRUE)
+print_property(ImportedGlobalTarget IMPORTED_GLOBAL)
+set_property(TARGET ImportedGlobalTarget PROPERTY IMPORTED_GLOBAL TRUE)
+print_property(ImportedGlobalTarget IMPORTED_GLOBAL)
+# Appending property is never allowed!
+set_property(TARGET ImportedGlobalTarget APPEND PROPERTY IMPORTED_GLOBAL TRUE)
+print_property(ImportedGlobalTarget IMPORTED_GLOBAL)
+
+# Changing property on IMPORTED target created without `GLOBAL` option.
+add_library(ImportedLocalTarget SHARED IMPORTED)
+print_property(ImportedLocalTarget IMPORTED_GLOBAL)
+set_property(TARGET ImportedLocalTarget PROPERTY IMPORTED_GLOBAL TRUE)
+print_property(ImportedLocalTarget IMPORTED_GLOBAL)
+set_property(TARGET ImportedLocalTarget PROPERTY IMPORTED_GLOBAL TRUE)
+print_property(ImportedLocalTarget IMPORTED_GLOBAL)
+set_property(TARGET ImportedLocalTarget PROPERTY IMPORTED_GLOBAL FALSE)
+print_property(ImportedLocalTarget IMPORTED_GLOBAL)
+
+# Setting property on non-IMPORTED target is never allowed!
+add_library(NonImportedTarget SHARED test.cpp)
+print_property(NonImportedTarget IMPORTED_GLOBAL)
+set_property(TARGET NonImportedTarget PROPERTY IMPORTED_GLOBAL TRUE)
+print_property(NonImportedTarget IMPORTED_GLOBAL)
+
+# Local IMPORTED targets can only be promoted from same directory!
+add_library(ImportedLocalTarget2 SHARED IMPORTED)
+print_property(ImportedLocalTarget2 IMPORTED_GLOBAL)
+add_subdirectory(IMPORTED_GLOBAL)
+# Note: The value should not have changed. However, it does change because the
+# check for the same directory comes after it was changed! (At least, that is
+# not really bad because the generation will fail due to this error.)
+print_property(ImportedLocalTarget2 IMPORTED_GLOBAL)
+
+# Global IMPORTED targets from subdir are always visible
+# no matter how they became global.
+print_property(ImportedSubdirTarget1 IMPORTED_GLOBAL)
+print_property(ImportedSubdirTarget2 IMPORTED_GLOBAL)
+
+# Changing property on IMPORTED target from subdir is never possible.
+set_property(TARGET ImportedSubdirTarget1 PROPERTY IMPORTED_GLOBAL FALSE)
+print_property(ImportedSubdirTarget1 IMPORTED_GLOBAL)
+set_property(TARGET ImportedSubdirTarget2 PROPERTY IMPORTED_GLOBAL FALSE)
+print_property(ImportedSubdirTarget2 IMPORTED_GLOBAL)