Browse Source

ENH: Add a way for the generated command to include extra flags. This is useful for CTest (or try compile) to add -j2

Andy Cedilnik 20 years ago
parent
commit
782bef7374

+ 2 - 1
Source/CTest/cmCTestBuildCommand.cxx

@@ -108,6 +108,7 @@ bool cmCTestBuildCommand::InitialPass(
     const char* cmakeGeneratorName = m_Makefile->GetDefinition("CTEST_CMAKE_GENERATOR");
     const char* cmakeProjectName = m_Makefile->GetDefinition("CTEST_PROJECT_NAME");
     const char* cmakeBuildConfiguration = m_Makefile->GetDefinition("CTEST_BUILD_CONFIGURATION");
+    const char* cmakeBuildAdditionalFlags = m_Makefile->GetDefinition("CTEST_BUILD_FLAGS");
     if ( cmakeGeneratorName && *cmakeGeneratorName &&
       cmakeProjectName && *cmakeProjectName )
       {
@@ -132,7 +133,7 @@ bool cmCTestBuildCommand::InitialPass(
       const char* cmakeMakeProgram = m_Makefile->GetDefinition("CMAKE_MAKE_PROGRAM");
       std::string buildCommand
         = m_GlobalGenerator->GenerateBuildCommand(cmakeMakeProgram, cmakeProjectName,
-          0, cmakeBuildConfiguration, true);
+          cmakeBuildAdditionalFlags, 0, cmakeBuildConfiguration, true);
       m_CTest->SetCTestConfiguration("MakeCommand", buildCommand.c_str());
       }
     else

+ 3 - 34
Source/cmBuildCommand.cxx

@@ -33,40 +33,9 @@ bool cmBuildCommand::InitialPass(std::vector<std::string> const& args)
   std::string makeprogram = args[1];
   std::string makecommand
     = m_Makefile->GetLocalGenerator()->GetGlobalGenerator()->GenerateBuildCommand(
-    makeprogram.c_str(), m_Makefile->GetProjectName(), 0, "Release", true);
-#if 0
-  std::string makecommand;
-  if(makeprogram.find("msdev") != std::string::npos ||
-     makeprogram.find("MSDEV") != std::string::npos )
-    {
-    makecommand = "\"";
-    makecommand += makeprogram;
-    makecommand += "\"";
-    makecommand += " ";
-    makecommand += m_Makefile->GetProjectName();
-    makecommand += ".dsw /MAKE \"ALL_BUILD - Release\" ";
-    }
-  else if (makeprogram.find("devenv") != std::string::npos ||
-           makeprogram.find("DEVENV") != std::string::npos )
-    {
-    makecommand = "\"";
-    makecommand += makeprogram;
-    makecommand += "\"";
-    makecommand += " ";
-    makecommand += m_Makefile->GetProjectName();
-    makecommand += ".sln /build Release /project ALL_BUILD";
-    }
-  else if (makeprogram.find("xcodebuild") != std::string::npos)
-    {
-    makecommand += makeprogram;
-    }
-  else
-    {
-    makecommand = makeprogram;
-    makecommand += " -i";
-    }
-  std::cerr << "-- Compare: " << makecommand.c_str() << " and " << makecmd.c_str() << ": " << (makecmd == makecommand) << std::endl;
-#endif
+    makeprogram.c_str(), m_Makefile->GetProjectName(), 0,
+    0, "Release", true);
+
   if(cacheValue)
     {
     return true;

+ 11 - 4
Source/cmGlobalGenerator.cxx

@@ -719,8 +719,8 @@ int cmGlobalGenerator::TryCompile(const char *srcdir, const char *bindir,
 }
 
 std::string cmGlobalGenerator::GenerateBuildCommand(const char* makeProgram,
-  const char *projectName, const char *targetName, const char* config,
-  bool ignoreErrors)
+  const char *projectName, const char* additionalOptions, const char *targetName,
+  const char* config, bool ignoreErrors)
 {
   // Project name and config are not used yet.
   (void)projectName;
@@ -738,6 +738,11 @@ std::string cmGlobalGenerator::GenerateBuildCommand(const char* makeProgram,
     {
     makeCommand += " -i";
     }
+  if ( additionalOptions )
+    {
+    makeCommand += " ";
+    makeCommand += additionalOptions;
+    }
   if ( targetName )
     {
     makeCommand += " ";
@@ -770,7 +775,8 @@ int cmGlobalGenerator::Build(
   // should we do a clean first?
   if (clean)
     {
-    std::string cleanCommand = this->GenerateBuildCommand(makeCommandCSTR, projectName, "clean", config, false);
+    std::string cleanCommand = this->GenerateBuildCommand(makeCommandCSTR, projectName,
+      0, "clean", config, false);
     if (!cmSystemTools::RunSingleCommand(cleanCommand.c_str(), output, 
                                          &retVal, 0, false, timeout))
       {
@@ -788,7 +794,8 @@ int cmGlobalGenerator::Build(
     }
   
   // now build
-  std::string makeCommand = this->GenerateBuildCommand(makeCommandCSTR, projectName, target, config, false);
+  std::string makeCommand = this->GenerateBuildCommand(makeCommandCSTR, projectName,
+    0, target, config, false);
 
   if (!cmSystemTools::RunSingleCommand(makeCommand.c_str(), output, 
                                        &retVal, 0, false, timeout))

+ 1 - 1
Source/cmGlobalGenerator.h

@@ -99,7 +99,7 @@ public:
                     const char *makeProgram, const char *config,
                     bool clean);
   virtual std::string GenerateBuildCommand(const char* makeProgram,
-    const char *projectName, const char *targetName,
+    const char *projectName, const char* additionalOptions, const char *targetName,
     const char* config, bool ignoreErrors);
 
   ///! Set the CMake instance

+ 7 - 1
Source/cmGlobalVisualStudio6Generator.cxx

@@ -68,7 +68,8 @@ void cmGlobalVisualStudio6Generator::GenerateConfigurations(cmMakefile* mf)
 }
 
 std::string cmGlobalVisualStudio6Generator::GenerateBuildCommand(const char* makeProgram,
-  const char *projectName, const char *targetName, const char* config, bool ignoreErrors)
+  const char *projectName, const char* additionalOptions, const char *targetName,
+  const char* config, bool ignoreErrors)
 {
   // Ingoring errors is not implemented in visual studio 6
   (void) ignoreErrors;
@@ -134,6 +135,11 @@ std::string cmGlobalVisualStudio6Generator::GenerateBuildCommand(const char* mak
     {
     makeCommand += "\" /BUILD";
     }
+  if ( additionalOptions )
+    {
+    makeCommand += " ";
+    makeCommand += additionalOptions;
+    }
   return makeCommand;
 }
 

+ 1 - 1
Source/cmGlobalVisualStudio6Generator.h

@@ -55,7 +55,7 @@ public:
    * loaded commands, not as part of the usual build process.
    */
   virtual std::string GenerateBuildCommand(const char* makeProgram,
-    const char *projectName, const char *targetName, const char* config,
+    const char *projectName, const char* additionalOptions, const char *targetName, const char* config,
     bool ignoreErrors);
 
   /**

+ 7 - 1
Source/cmGlobalVisualStudio7Generator.cxx

@@ -44,7 +44,8 @@ void cmGlobalVisualStudio7Generator::EnableLanguage(std::vector<std::string>cons
 }
 
 std::string cmGlobalVisualStudio7Generator::GenerateBuildCommand(const char* makeProgram,
-  const char *projectName, const char *targetName, const char* config, bool ignoreErrors)
+  const char *projectName, const char* additionalOptions, const char *targetName,
+  const char* config, bool ignoreErrors)
 {
   // Ingoring errors is not implemented in visual studio 6
   (void) ignoreErrors;
@@ -100,6 +101,11 @@ std::string cmGlobalVisualStudio7Generator::GenerateBuildCommand(const char* mak
     {
     makeCommand += "ALL_BUILD";
     }
+  if ( additionalOptions )
+    {
+    makeCommand += " ";
+    makeCommand += additionalOptions;
+    }
   return makeCommand;
 }
 

+ 1 - 1
Source/cmGlobalVisualStudio7Generator.h

@@ -54,7 +54,7 @@ public:
    * loaded commands, not as part of the usual build process.
    */
   virtual std::string GenerateBuildCommand(const char* makeProgram,
-    const char *projectName, const char *targetName, const char* config,
+    const char *projectName, const char* additionalOptions, const char *targetName, const char* config,
     bool ignoreErrors);
 
   /**

+ 7 - 2
Source/cmGlobalXCodeGenerator.cxx

@@ -132,8 +132,8 @@ void cmGlobalXCodeGenerator::EnableLanguage(std::vector<std::string>const&
 
 //----------------------------------------------------------------------------
 std::string cmGlobalXCodeGenerator::GenerateBuildCommand(const char* makeProgram,
-                                                         const char *projectName, const char *targetName, const char* config,
-                                                         bool ignoreErrors)
+  const char *projectName, const char* additionalOptions, const char *targetName,
+  const char* config, bool ignoreErrors)
 {
   // Config is not used yet
   (void) config;
@@ -190,6 +190,11 @@ std::string cmGlobalXCodeGenerator::GenerateBuildCommand(const char* makeProgram
     {
     makeCommand += " -configuration Debug";
     }
+  if ( additionalOptions )
+    {
+    makeCommand += " ";
+    makeCommand += additionalOptions;
+    }
   makeCommand += " OBJROOT=.";
   return makeCommand;
 }

+ 2 - 2
Source/cmGlobalXCodeGenerator.h

@@ -59,8 +59,8 @@ public:
    * loaded commands, not as part of the usual build process.
    */
   virtual std::string GenerateBuildCommand(const char* makeProgram,
-    const char *projectName, const char *targetName, const char* config,
-    bool ignoreErrors);
+    const char *projectName, const char* additionalOptions, const char *targetName,
+    const char* config, bool ignoreErrors);
 
   /**
    * Generate the all required files for building this project/tree. This