Jelajahi Sumber

modified TryCompile

Ken Martin 23 tahun lalu
induk
melakukan
38e412626b

+ 13 - 4
Source/cmGlobalGenerator.cxx

@@ -138,7 +138,7 @@ void cmGlobalGenerator::LocalGenerate()
 }
 
 int cmGlobalGenerator::TryCompile(const char *, const char *bindir, 
-                                  const char *)
+                                  const char *, const char *target)
 {
   // now build the test
   std::string makeCommand = 
@@ -159,8 +159,17 @@ int cmGlobalGenerator::TryCompile(const char *, const char *bindir,
   cmSystemTools::ChangeDirectory(bindir);
   
   // now build
-  makeCommand += " all";
-  if (!cmSystemTools::RunCommand(makeCommand.c_str(), output))
+  if (target)
+    {
+    makeCommand += " ";
+    makeCommand += target;
+    }
+  else
+    {
+    makeCommand += " all";
+    }
+  int retVal;
+  if (!cmSystemTools::RunCommand(makeCommand.c_str(), output, retVal))
     {
     cmSystemTools::Error("Generator: execution of make failed.");
     // return to the original directory
@@ -168,7 +177,7 @@ int cmGlobalGenerator::TryCompile(const char *, const char *bindir,
     return 1;
     }
   cmSystemTools::ChangeDirectory(cwd.c_str());
-  return 0;
+  return retVal;
 }
 
 cmLocalGenerator *cmGlobalGenerator::CreateLocalGenerator()

+ 1 - 1
Source/cmGlobalGenerator.h

@@ -81,7 +81,7 @@ public:
    * loaded commands, not as part of the usual build process.
    */
   virtual int TryCompile(const char *srcdir, const char *bindir,
-                         const char *projectName);
+                         const char *projectName, const char *targetName);
 
   ///! Set the CMake instance
   void SetCMakeInstance(cmake *cm) {

+ 15 - 4
Source/cmGlobalVisualStudio6Generator.cxx

@@ -46,7 +46,8 @@ void cmGlobalVisualStudio6Generator::EnableLanguage(const char*,
 
 int cmGlobalVisualStudio6Generator::TryCompile(const char *, 
                                                const char *bindir, 
-                                               const char *projectName)
+                                               const char *projectName,
+                                               const char *targetName)
 {
   // now build the test
   std::string makeCommand = 
@@ -80,9 +81,19 @@ int cmGlobalVisualStudio6Generator::TryCompile(const char *,
 #endif
   makeCommand += " ";
   makeCommand += projectName;
-  makeCommand += ".dsw /MAKE \"ALL_BUILD - Debug\" /REBUILD";
+  makeCommand += ".dsw /MAKE \"";
+  if (targetName)
+    {
+    makeCommand += targetName;
+    }
+  else
+    {
+    makeCommand += "ALL_BUILD";
+    }
+  makeCommand += " - Debug\" /REBUILD";
   
-  if (!cmSystemTools::RunCommand(makeCommand.c_str(), output))
+  int retVal;
+  if (!cmSystemTools::RunCommand(makeCommand.c_str(), output, retVal))
     {
     cmSystemTools::Error("Generator: execution of msdev failed.");
     // return to the original directory
@@ -90,7 +101,7 @@ int cmGlobalVisualStudio6Generator::TryCompile(const char *,
     return 1;
     }
   cmSystemTools::ChangeDirectory(cwd.c_str());
-  return 0;
+  return retVal;
 }
 
 ///! Create a local generator appropriate to this Global Generator

+ 1 - 1
Source/cmGlobalVisualStudio6Generator.h

@@ -48,7 +48,7 @@ public:
    * loaded commands, not as part of the usual build process.
    */
   virtual int TryCompile(const char *srcdir, const char *bindir,
-                         const char *projectName);
+                         const char *projectName, const char *targetName);
 
   /**
    * Generate the all required files for building this project/tree. This

+ 14 - 4
Source/cmGlobalVisualStudio7Generator.cxx

@@ -47,7 +47,8 @@ void cmGlobalVisualStudio7Generator::EnableLanguage(const char*,
 
 int cmGlobalVisualStudio7Generator::TryCompile(const char *, 
                                                const char *bindir, 
-                                               const char *projectName)
+                                               const char *projectName,
+                                               const char *targetName)
 {
   // now build the test
   std::string makeCommand = 
@@ -81,9 +82,18 @@ int cmGlobalVisualStudio7Generator::TryCompile(const char *,
 #endif
   makeCommand += " ";
   makeCommand += projectName;
-  makeCommand += ".sln /rebuild Debug /project ALL_BUILD";
+  makeCommand += ".sln /rebuild Debug /project ";
+  if (targetName)
+    {
+    makeCommand += targetName;
+    }
+  else
+    {
+    makeCommand += "ALL_BUILD";
+    }
   
-  if (!cmSystemTools::RunCommand(makeCommand.c_str(), output))
+  int retVal;
+  if (!cmSystemTools::RunCommand(makeCommand.c_str(), output, retVal))
     {
     cmSystemTools::Error("Generator: execution of devenv failed.");
     // return to the original directory
@@ -91,7 +101,7 @@ int cmGlobalVisualStudio7Generator::TryCompile(const char *,
     return 1;
     }
   cmSystemTools::ChangeDirectory(cwd.c_str());
-  return 0;
+  return retVal;
 }
 
 ///! Create a local generator appropriate to this Global Generator

+ 1 - 1
Source/cmGlobalVisualStudio7Generator.h

@@ -48,7 +48,7 @@ public:
    * loaded commands, not as part of the usual build process.
    */
   virtual int TryCompile(const char *srcdir, const char *bindir,
-                         const char *projectName);
+                         const char *projectName, const char *targetName);
 
   /**
    * Generate the all required files for building this project/tree. This