Browse Source

Merge topic 'make-imported-targets-more-equal'

680a3c63bb target_*: Allow setting INTERFACE properties of UNKNOWN IMPORTED targets
62b5d1e4ad cmTargetPropCommandBase: Order target type condition by order in enum

Acked-by: Kitware Robot <[email protected]>
Merge-request: !3581
Brad King 6 years ago
parent
commit
5396c5fce4

+ 4 - 3
Source/cmTargetPropCommandBase.cxx

@@ -32,12 +32,13 @@ bool cmTargetPropCommandBase::HandleArguments(
     this->HandleMissingTarget(args[0]);
     return false;
   }
-  if ((this->Target->GetType() != cmStateEnums::SHARED_LIBRARY) &&
+  if ((this->Target->GetType() != cmStateEnums::EXECUTABLE) &&
       (this->Target->GetType() != cmStateEnums::STATIC_LIBRARY) &&
-      (this->Target->GetType() != cmStateEnums::OBJECT_LIBRARY) &&
+      (this->Target->GetType() != cmStateEnums::SHARED_LIBRARY) &&
       (this->Target->GetType() != cmStateEnums::MODULE_LIBRARY) &&
+      (this->Target->GetType() != cmStateEnums::OBJECT_LIBRARY) &&
       (this->Target->GetType() != cmStateEnums::INTERFACE_LIBRARY) &&
-      (this->Target->GetType() != cmStateEnums::EXECUTABLE)) {
+      (this->Target->GetType() != cmStateEnums::UNKNOWN_LIBRARY)) {
     this->SetError("called with non-compilable target type");
     return false;
   }

+ 1 - 1
Tests/RunCMake/add_library/UNKNOWNwithOnlyObjectSources-stderr.txt

@@ -1,4 +1,4 @@
 ^CMake Error at UNKNOWNwithOnlyObjectSources.cmake:[0-9]+ \(target_sources\):
-  target_sources called with non-compilable target type
+  target_sources may only set INTERFACE properties on IMPORTED targets
 Call Stack \(most recent call first\):
   CMakeLists.txt:[0-9]+ \(include\)$

+ 1 - 0
Tests/RunCMake/target_compile_definitions/RunCMakeTest.cmake

@@ -1,3 +1,4 @@
 include(RunCMake)
 
 run_cmake(empty_keyword_args)
+run_cmake(unknown_imported_target)

+ 11 - 0
Tests/RunCMake/target_compile_definitions/unknown_imported_target.cmake

@@ -0,0 +1,11 @@
+# Test that target_compile_definitions works on UNKNOWN IMPORTED target
+add_library(imported UNKNOWN IMPORTED)
+target_compile_definitions(imported INTERFACE FOO)
+
+get_target_property(IMPORTED_INTERFACE_CDS imported INTERFACE_COMPILE_DEFINITIONS)
+
+if (NOT FOO IN_LIST IMPORTED_INTERFACE_CDS)
+  message(
+    FATAL_ERROR "FOO should be in INTERFACE_COMPILE_DEFINITIONS.\n"
+    "Actual INTERFACE_COMPILE_DEFINITIONS: " ${IMPORTED_INTERFACE_CDS})
+endif()