Browse Source

get_property: Fix testing ALIASED_TARGET target property (#14670)

In the case where the argument is not an ALIAS, the variable should
be set to a -NOTFOUND content.
Stephen Kelly 12 years ago
parent
commit
cd3d0b613e
2 changed files with 23 additions and 1 deletions
  1. 1 1
      Source/cmGetPropertyCommand.cxx
  2. 22 0
      Tests/AliasTarget/CMakeLists.txt

+ 1 - 1
Source/cmGetPropertyCommand.cxx

@@ -298,7 +298,7 @@ bool cmGetPropertyCommand::HandleTargetMode()
         return this->StoreResult(target->GetName());
         }
       }
-    return false;
+    return this->StoreResult((this->Variable + "-NOTFOUND").c_str());
     }
   if(cmTarget* target = this->Makefile->FindTargetToUse(this->Name.c_str()))
     {

+ 22 - 0
Tests/AliasTarget/CMakeLists.txt

@@ -48,3 +48,25 @@ endif()
 
 add_library(iface INTERFACE)
 add_library(Alias::Iface ALIAS iface)
+
+get_target_property(_notAlias1 foo ALIASED_TARGET)
+if (NOT DEFINED _notAlias1)
+  message(SEND_ERROR "_notAlias1 is not defined")
+endif()
+if (_notAlias1)
+  message(SEND_ERROR "_notAlias1 is defined, but foo is not an ALIAS")
+endif()
+if (NOT _notAlias1 STREQUAL _notAlias1-NOTFOUND)
+  message(SEND_ERROR "_notAlias1 not defined to a -NOTFOUND variant")
+endif()
+
+get_property(_notAlias2 TARGET foo PROPERTY ALIASED_TARGET)
+if (NOT DEFINED _notAlias2)
+  message(SEND_ERROR "_notAlias2 is not defined")
+endif()
+if (_notAlias2)
+  message(SEND_ERROR "_notAlias2 is defined, but foo is not an ALIAS")
+endif()
+if (NOT _notAlias2 STREQUAL _notAlias2-NOTFOUND)
+  message(SEND_ERROR "_notAlias2 not defined to a -NOTFOUND variant")
+endif()