[cmake-commits] alex committed cmExportCommand.cxx 1.1 1.2

cmake-commits at cmake.org cmake-commits at cmake.org
Fri Jun 8 16:19:15 EDT 2007


Update of /cvsroot/CMake/CMake/Source
In directory public:/mounts/ram/cvs-serv8566

Modified Files:
	cmExportCommand.cxx 
Log Message:

ENH: fail if an unknown target is listed

Alex


Index: cmExportCommand.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmExportCommand.cxx,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- cmExportCommand.cxx	8 Jun 2007 15:57:16 -0000	1.1
+++ cmExportCommand.cxx	8 Jun 2007 20:19:13 -0000	1.2
@@ -101,9 +101,25 @@
       currentTarget != targets.end();
       ++currentTarget)
     {
+    cmTarget* target = this->Makefile->GetLocalGenerator()->
+             GetGlobalGenerator()->FindTarget(0, currentTarget->c_str(), true);
+    if (target == 0)
+      {
+      std::string e = "detected unknown target: " + *currentTarget;
+      this->SetError(e.c_str());
+      cmSystemTools::SetFatalErrorOccured();
+      return false;
+      }
+    }
+
+  for(std::vector<std::string>::const_iterator currentTarget = targets.begin();
+      currentTarget != targets.end();
+      ++currentTarget)
+    {
     // Look for a CMake target with the given name, which is an executable
     // and which can be run
-    cmTarget* target = this->Makefile->GetLocalGenerator()->GetGlobalGenerator()->FindTarget(0, currentTarget->c_str(), true);
+    cmTarget* target = this->Makefile->GetLocalGenerator()->
+             GetGlobalGenerator()->FindTarget(0, currentTarget->c_str(), true);
     if ((target != 0)
        && ((target->GetType() == cmTarget::EXECUTABLE)
         || (target->GetType() == cmTarget::STATIC_LIBRARY)
@@ -113,24 +129,30 @@
       switch (target->GetType())
         {
         case cmTarget::EXECUTABLE:
-          fout << "ADD_EXECUTABLE(" << prefix.c_str() << currentTarget->c_str() << " IMPORT )\n";
+          fout << "ADD_EXECUTABLE(" << prefix.c_str() << currentTarget->c_str()
+                                                              << " IMPORT )\n";
           break;
         case cmTarget::STATIC_LIBRARY:
-          fout << "ADD_LIBRARY(" << prefix.c_str() << currentTarget->c_str() << " STATIC IMPORT )\n";
+          fout << "ADD_LIBRARY(" << prefix.c_str() << currentTarget->c_str()
+                                                       << " STATIC IMPORT )\n";
           break;
         case cmTarget::SHARED_LIBRARY:
-          fout << "ADD_LIBRARY(" << prefix.c_str() << currentTarget->c_str() << " SHARED IMPORT )\n";
+          fout << "ADD_LIBRARY(" << prefix.c_str() << currentTarget->c_str()
+                                                       << " SHARED IMPORT )\n";
           break;
         case cmTarget::MODULE_LIBRARY:
-          fout << "ADD_LIBRARY(" << prefix.c_str() << currentTarget->c_str() << " MODULE IMPORT )\n";
+          fout << "ADD_LIBRARY(" << prefix.c_str() << currentTarget->c_str()
+                                                       << " MODULE IMPORT )\n";
           break;
         default:  // should never happen
           break;
         }
 
-      fout << "SET_TARGET_PROPERTIES(" << prefix.c_str() << currentTarget->c_str() << " PROPERTIES \n";
-      fout << "                      LOCATION " << target->GetLocation(0) << "\n";
-      for(std::vector<std::string>::const_iterator currentConfig = configurationTypes.begin();
+      fout << "SET_TARGET_PROPERTIES(" << prefix.c_str()
+                                 << currentTarget->c_str() << " PROPERTIES \n"
+        << "                      LOCATION " << target->GetLocation(0) << "\n";
+      for(std::vector<std::string>::const_iterator
+          currentConfig = configurationTypes.begin();
           currentConfig != configurationTypes.end();
           ++currentConfig)
         {
@@ -139,15 +161,13 @@
           const char* loc = target->GetLocation(currentConfig->c_str());
           if (loc && *loc)
             {
-            fout << "                      " << currentConfig->c_str()<< "_LOCATION " << loc << "\n";
+            fout << "                      " << currentConfig->c_str()
+                                                << "_LOCATION " << loc << "\n";
             }
           }
         }
       fout << "                     )\n\n";
       }
-    else
-      {
-      }
     }
 
   return true;



More information about the Cmake-commits mailing list