Преглед на файлове

cmTarget: Add NAME property

In generator expression contexts, this can be used to determine the
name of the head target in the evaluation.
Stephen Kelly преди 12 години
родител
ревизия
43558156d4
променени са 1 файла, в които са добавени 24 реда и са изтрити 1 реда
  1. 24 1
      Source/cmTarget.cxx

+ 24 - 1
Source/cmTarget.cxx

@@ -944,6 +944,11 @@ void cmTarget::DefineProperties(cmake *cm)
      "This property is the configuration-specific version of "
      "OSX_ARCHITECTURES.");
 
+  cm->DefineProperty
+    ("NAME", cmProperty::TARGET,
+     "Logical name for the target.",
+     "Read-only logical name for the target as used by CMake.");
+
   cm->DefineProperty
     ("EXPORT_NAME", cmProperty::TARGET,
      "Exported name for target files.",
@@ -2971,7 +2976,13 @@ void cmTarget::SetProperty(const char* prop, const char* value)
     {
     return;
     }
-
+  if (strcmp(prop, "NAME") == 0)
+    {
+    cmOStringStream e;
+    e << "NAME property is read-only\n";
+    this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str().c_str());
+    return;
+    }
   if(strcmp(prop,"INCLUDE_DIRECTORIES") == 0)
     {
     cmListFileBacktrace lfbt;
@@ -3038,6 +3049,13 @@ void cmTarget::AppendProperty(const char* prop, const char* value,
     {
     return;
     }
+  if (strcmp(prop, "NAME") == 0)
+    {
+    cmOStringStream e;
+    e << "NAME property is read-only\n";
+    this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str().c_str());
+    return;
+    }
   if(strcmp(prop,"INCLUDE_DIRECTORIES") == 0)
     {
     cmListFileBacktrace lfbt;
@@ -4053,6 +4071,11 @@ const char *cmTarget::GetProperty(const char* prop,
     return 0;
     }
 
+  if (strcmp(prop, "NAME") == 0)
+    {
+    return this->GetName();
+    }
+
   // Watch for special "computed" properties that are dependent on
   // other properties or variables.  Always recompute them.
   if(this->GetType() == cmTarget::EXECUTABLE ||