summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Source/cmAddCustomCommandCommand.cxx14
-rw-r--r--Source/cmCustomCommand.cxx12
-rw-r--r--Source/cmCustomCommand.h1
-rw-r--r--Source/cmGlobalVisualStudio71Generator.cxx19
-rw-r--r--Source/cmGlobalVisualStudio71Generator.h4
-rw-r--r--Source/cmGlobalVisualStudio7Generator.cxx19
-rw-r--r--Source/cmGlobalVisualStudio7Generator.h4
-rw-r--r--Source/cmGlobalVisualStudio8Generator.cxx14
-rw-r--r--Source/cmGlobalVisualStudio8Generator.h3
-rw-r--r--Source/cmLocalGenerator.cxx2
-rw-r--r--Source/cmLocalVisualStudio7Generator.cxx7
-rw-r--r--Source/cmLocalVisualStudio7Generator.h2
-rw-r--r--Source/cmMakefile.cxx18
-rw-r--r--Source/cmMakefileExecutableTargetGenerator.cxx6
-rw-r--r--Source/cmMakefileExecutableTargetGenerator.h2
-rw-r--r--Source/cmMakefileLibraryTargetGenerator.cxx6
-rw-r--r--Source/cmMakefileLibraryTargetGenerator.h2
-rw-r--r--Source/cmMakefileTargetGenerator.cxx29
-rw-r--r--Source/cmMakefileTargetGenerator.h4
19 files changed, 112 insertions, 56 deletions
diff --git a/Source/cmAddCustomCommandCommand.cxx b/Source/cmAddCustomCommandCommand.cxx
index 3c37d4b4e8..3f0dd26b0d 100644
--- a/Source/cmAddCustomCommandCommand.cxx
+++ b/Source/cmAddCustomCommandCommand.cxx
@@ -32,8 +32,9 @@ bool cmAddCustomCommandCommand::InitialPass(
return false;
}
- std::string source, target, comment, main_dependency,
- working;
+ std::string source, target, main_dependency, working;
+ std::string comment_buffer;
+ const char* comment = 0;
std::vector<std::string> depends, outputs, output;
bool verbatim = false;
@@ -178,7 +179,8 @@ bool cmAddCustomCommandCommand::InitialPass(
outputs.push_back(filename);
break;
case doing_comment:
- comment = copy;
+ comment_buffer = copy;
+ comment = comment_buffer.c_str();
break;
default:
this->SetError("Wrong syntax. Unknown type of argument.");
@@ -223,7 +225,7 @@ bool cmAddCustomCommandCommand::InitialPass(
std::vector<std::string> no_depends;
this->Makefile->AddCustomCommandToTarget(target.c_str(), no_depends,
commandLines, cctype,
- comment.c_str(), working.c_str(),
+ comment, working.c_str(),
escapeOldStyle);
}
else if(target.empty())
@@ -231,7 +233,7 @@ bool cmAddCustomCommandCommand::InitialPass(
// Target is empty, use the output.
this->Makefile->AddCustomCommandToOutput(output, depends,
main_dependency.c_str(),
- commandLines, comment.c_str(),
+ commandLines, comment,
working.c_str(), false,
escapeOldStyle);
}
@@ -240,7 +242,7 @@ bool cmAddCustomCommandCommand::InitialPass(
// Use the old-style mode for backward compatibility.
this->Makefile->AddCustomCommandOldStyle(target.c_str(), outputs, depends,
source.c_str(), commandLines,
- comment.c_str());
+ comment);
}
return true;
}
diff --git a/Source/cmCustomCommand.cxx b/Source/cmCustomCommand.cxx
index 621f7caed2..e3fc69a425 100644
--- a/Source/cmCustomCommand.cxx
+++ b/Source/cmCustomCommand.cxx
@@ -19,6 +19,7 @@
//----------------------------------------------------------------------------
cmCustomCommand::cmCustomCommand()
{
+ this->HaveComment = false;
this->EscapeOldStyle = true;
this->EscapeAllowMakeVars = false;
this->Used = false;
@@ -29,6 +30,7 @@ cmCustomCommand::cmCustomCommand(const cmCustomCommand& r):
Outputs(r.Outputs),
Depends(r.Depends),
CommandLines(r.CommandLines),
+ HaveComment(r.HaveComment),
Comment(r.Comment),
WorkingDirectory(r.WorkingDirectory),
EscapeAllowMakeVars(r.EscapeAllowMakeVars),
@@ -41,13 +43,16 @@ cmCustomCommand::cmCustomCommand(const cmCustomCommand& r):
cmCustomCommand::cmCustomCommand(const std::vector<std::string>& outputs,
const std::vector<std::string>& depends,
const cmCustomCommandLines& commandLines,
- const char* comment,
+ const char* comment,
const char* workingDirectory):
Outputs(outputs),
Depends(depends),
CommandLines(commandLines),
+ HaveComment(comment?true:false),
Comment(comment?comment:""),
- WorkingDirectory(workingDirectory?workingDirectory:"")
+ WorkingDirectory(workingDirectory?workingDirectory:""),
+ EscapeAllowMakeVars(false),
+ EscapeOldStyle(true)
{
this->EscapeOldStyle = true;
this->EscapeAllowMakeVars = false;
@@ -85,7 +90,8 @@ const cmCustomCommandLines& cmCustomCommand::GetCommandLines() const
//----------------------------------------------------------------------------
const char* cmCustomCommand::GetComment() const
{
- return this->Comment.c_str();
+ const char* no_comment = 0;
+ return this->HaveComment? this->Comment.c_str() : no_comment;
}
//----------------------------------------------------------------------------
diff --git a/Source/cmCustomCommand.h b/Source/cmCustomCommand.h
index e493c5dbd5..8f34297410 100644
--- a/Source/cmCustomCommand.h
+++ b/Source/cmCustomCommand.h
@@ -70,6 +70,7 @@ private:
std::vector<std::string> Outputs;
std::vector<std::string> Depends;
cmCustomCommandLines CommandLines;
+ bool HaveComment;
std::string Comment;
std::string WorkingDirectory;
bool EscapeAllowMakeVars;
diff --git a/Source/cmGlobalVisualStudio71Generator.cxx b/Source/cmGlobalVisualStudio71Generator.cxx
index 78631d96f1..0ca3250b14 100644
--- a/Source/cmGlobalVisualStudio71Generator.cxx
+++ b/Source/cmGlobalVisualStudio71Generator.cxx
@@ -253,14 +253,14 @@ void cmGlobalVisualStudio71Generator
cmCustomCommand cc = l->second.GetPostBuildCommands()[0];
const cmCustomCommandLines& cmds = cc.GetCommandLines();
std::string project = cmds[0][0];
- this->WriteProjectConfigurations(fout, project.c_str(),
- l->second.IsInAll());
+ this->WriteProjectConfigurations(fout, project.c_str(),
+ l->second.GetType());
}
else if ((l->second.GetType() != cmTarget::INSTALL_FILES)
&& (l->second.GetType() != cmTarget::INSTALL_PROGRAMS))
{
- this->WriteProjectConfigurations(fout, si->c_str(),
- l->second.IsInAll());
+ this->WriteProjectConfigurations(fout, si->c_str(),
+ l->second.GetType());
++si;
}
}
@@ -415,19 +415,18 @@ void cmGlobalVisualStudio71Generator
// Write a dsp file into the SLN file, Note, that dependencies from
// executables to the libraries it uses are also done here
void cmGlobalVisualStudio71Generator
-::WriteProjectConfigurations(std::ostream& fout,
- const char* name,
- bool in_all_build)
+::WriteProjectConfigurations(std::ostream& fout, const char* name,
+ int targetType)
{
std::string guid = this->GetGUID(name);
for(std::vector<std::string>::iterator i = this->Configurations.begin();
i != this->Configurations.end(); ++i)
{
- fout << "\t\t{" << guid << "}." << *i
+ fout << "\t\t{" << guid << "}." << *i
<< ".ActiveCfg = " << *i << "|Win32\n";
- if (in_all_build)
+ if(targetType != cmTarget::GLOBAL_TARGET)
{
- fout << "\t\t{" << guid << "}." << *i
+ fout << "\t\t{" << guid << "}." << *i
<< ".Build.0 = " << *i << "|Win32\n";
}
}
diff --git a/Source/cmGlobalVisualStudio71Generator.h b/Source/cmGlobalVisualStudio71Generator.h
index 6ccf06a3c6..e730b36410 100644
--- a/Source/cmGlobalVisualStudio71Generator.h
+++ b/Source/cmGlobalVisualStudio71Generator.h
@@ -53,9 +53,9 @@ protected:
const char* name, const char* path, cmTarget &t);
virtual void WriteProjectDepends(std::ostream& fout,
const char* name, const char* path, cmTarget &t);
- virtual void WriteProjectConfigurations(std::ostream& fout,
+ virtual void WriteProjectConfigurations(std::ostream& fout,
const char* name,
- bool in_all);
+ int targetType);
virtual void WriteExternalProject(std::ostream& fout, const char* name,
const char* path,
const std::vector<std::string>& depends);
diff --git a/Source/cmGlobalVisualStudio7Generator.cxx b/Source/cmGlobalVisualStudio7Generator.cxx
index 03595a3af3..22c6647c9d 100644
--- a/Source/cmGlobalVisualStudio7Generator.cxx
+++ b/Source/cmGlobalVisualStudio7Generator.cxx
@@ -536,14 +536,14 @@ void cmGlobalVisualStudio7Generator
cmCustomCommand cc = l->second.GetPostBuildCommands()[0];
const cmCustomCommandLines& cmds = cc.GetCommandLines();
std::string name = cmds[0][0];
- this->WriteProjectConfigurations(fout, name.c_str(),
- l->second.IsInAll());
+ this->WriteProjectConfigurations(fout, name.c_str(),
+ l->second.GetType());
}
else if ((l->second.GetType() != cmTarget::INSTALL_FILES)
&& (l->second.GetType() != cmTarget::INSTALL_PROGRAMS))
{
- this->WriteProjectConfigurations(fout, si->c_str(),
- l->second.IsInAll());
+ this->WriteProjectConfigurations(fout, si->c_str(),
+ l->second.GetType());
++si;
}
}
@@ -651,19 +651,18 @@ cmGlobalVisualStudio7Generator
// Write a dsp file into the SLN file, Note, that dependencies from
// executables to the libraries it uses are also done here
void cmGlobalVisualStudio7Generator
-::WriteProjectConfigurations(std::ostream& fout,
- const char* name,
- bool in_all_build)
+::WriteProjectConfigurations(std::ostream& fout, const char* name,
+ int targetType)
{
std::string guid = this->GetGUID(name);
for(std::vector<std::string>::iterator i = this->Configurations.begin();
i != this->Configurations.end(); ++i)
{
- fout << "\t\t{" << guid << "}." << *i
+ fout << "\t\t{" << guid << "}." << *i
<< ".ActiveCfg = " << *i << "|Win32\n";
- if (in_all_build)
+ if(targetType != cmTarget::GLOBAL_TARGET)
{
- fout << "\t\t{" << guid << "}." << *i
+ fout << "\t\t{" << guid << "}." << *i
<< ".Build.0 = " << *i << "|Win32\n";
}
}
diff --git a/Source/cmGlobalVisualStudio7Generator.h b/Source/cmGlobalVisualStudio7Generator.h
index 9ff97da953..c8902cf9d7 100644
--- a/Source/cmGlobalVisualStudio7Generator.h
+++ b/Source/cmGlobalVisualStudio7Generator.h
@@ -105,9 +105,9 @@ protected:
const char* name, const char* path, cmTarget &t);
virtual void WriteProjectDepends(std::ostream& fout,
const char* name, const char* path, cmTarget &t);
- virtual void WriteProjectConfigurations(std::ostream& fout,
+ virtual void WriteProjectConfigurations(std::ostream& fout,
const char* name,
- bool in_all);
+ int targetType);
virtual void WriteSLNFooter(std::ostream& fout);
virtual void WriteSLNHeader(std::ostream& fout);
virtual void AddPlatformDefinitions(cmMakefile* mf);
diff --git a/Source/cmGlobalVisualStudio8Generator.cxx b/Source/cmGlobalVisualStudio8Generator.cxx
index 1b3236b296..bb87489fe7 100644
--- a/Source/cmGlobalVisualStudio8Generator.cxx
+++ b/Source/cmGlobalVisualStudio8Generator.cxx
@@ -227,20 +227,20 @@ cmGlobalVisualStudio8Generator
//----------------------------------------------------------------------------
void
cmGlobalVisualStudio8Generator
-::WriteProjectConfigurations(std::ostream& fout,
- const char* name, bool in_all_build)
+::WriteProjectConfigurations(std::ostream& fout, const char* name,
+ int targetType)
{
std::string guid = this->GetGUID(name);
for(std::vector<std::string>::iterator i = this->Configurations.begin();
i != this->Configurations.end(); ++i)
{
- fout << "\t\t{" << guid << "}." << *i
- << "|" << this->PlatformName << ".ActiveCfg = "
+ fout << "\t\t{" << guid << "}." << *i
+ << "|" << this->PlatformName << ".ActiveCfg = "
<< *i << "|" << this->PlatformName << "\n";
- if (in_all_build)
+ if(targetType != cmTarget::GLOBAL_TARGET)
{
- fout << "\t\t{" << guid << "}." << *i
- << "|" << this->PlatformName << ".Build.0 = "
+ fout << "\t\t{" << guid << "}." << *i
+ << "|" << this->PlatformName << ".Build.0 = "
<< *i << "|" << this->PlatformName << "\n";
}
}
diff --git a/Source/cmGlobalVisualStudio8Generator.h b/Source/cmGlobalVisualStudio8Generator.h
index b7cf038223..fdc8316104 100644
--- a/Source/cmGlobalVisualStudio8Generator.h
+++ b/Source/cmGlobalVisualStudio8Generator.h
@@ -56,7 +56,8 @@ protected:
virtual void WriteSLNHeader(std::ostream& fout);
virtual void WriteSolutionConfigurations(std::ostream& fout);
virtual void WriteProjectConfigurations(std::ostream& fout,
- const char* name, bool in_all);
+ const char* name,
+ int targetType);
std::string PlatformName; // Win32 or x64
};
#endif
diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx
index bcd05c3804..fe8958093f 100644
--- a/Source/cmLocalGenerator.cxx
+++ b/Source/cmLocalGenerator.cxx
@@ -1910,7 +1910,7 @@ cmLocalGenerator::ConstructComment(const cmCustomCommand& cc,
const char* default_comment)
{
// Check for a comment provided with the command.
- if(cc.GetComment() && *cc.GetComment())
+ if(cc.GetComment())
{
return cc.GetComment();
}
diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx
index 2cdca06bdd..463f8db457 100644
--- a/Source/cmLocalVisualStudio7Generator.cxx
+++ b/Source/cmLocalVisualStudio7Generator.cxx
@@ -44,11 +44,11 @@ void cmLocalVisualStudio7Generator::Generate()
lang.insert("IDL");
lang.insert("DEF");
this->CreateCustomTargetsAndCommands(lang);
- this->FixTargets();
+ this->FixGlobalTargets();
this->OutputVCProjFile();
}
-void cmLocalVisualStudio7Generator::FixTargets()
+void cmLocalVisualStudio7Generator::FixGlobalTargets()
{
// Visual Studio .NET 2003 Service Pack 1 will not run post-build
// commands for targets in which no sources are built. Add dummy
@@ -58,8 +58,7 @@ void cmLocalVisualStudio7Generator::FixTargets()
l != tgts.end(); l++)
{
cmTarget& tgt = l->second;
- if(tgt.GetType() == cmTarget::GLOBAL_TARGET ||
- tgt.GetType() == cmTarget::UTILITY)
+ if(tgt.GetType() == cmTarget::GLOBAL_TARGET)
{
std::vector<std::string> no_depends;
cmCustomCommandLine force_command;
diff --git a/Source/cmLocalVisualStudio7Generator.h b/Source/cmLocalVisualStudio7Generator.h
index c4ea0049a5..d52cc63a32 100644
--- a/Source/cmLocalVisualStudio7Generator.h
+++ b/Source/cmLocalVisualStudio7Generator.h
@@ -71,7 +71,7 @@ private:
std::string& flags);
std::string GetBuildTypeLinkerFlags(std::string rootLinkerFlags,
const char* configName);
- void FixTargets();
+ void FixGlobalTargets();
void OutputVCProjFile();
void WriteVCProjHeader(std::ostream& fout, const char *libName,
cmTarget &tgt, std::vector<cmSourceGroup> &sgs);
diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx
index d99182c857..8ad413981f 100644
--- a/Source/cmMakefile.cxx
+++ b/Source/cmMakefile.cxx
@@ -830,11 +830,21 @@ void cmMakefile::AddUtilityCommand(const char* utilityName, bool all,
target.SetType(cmTarget::UTILITY, utilityName);
target.SetInAll(all);
target.SetMakefile(this);
+
// Store the custom command in the target.
- std::vector<std::string> outputs;
- cmCustomCommand cc(outputs, depends, commandLines, 0, workingDirectory);
- cc.SetEscapeOldStyle(escapeOldStyle);
- target.GetPostBuildCommands().push_back(cc);
+ std::string force = this->GetStartOutputDirectory();
+ force += cmake::GetCMakeFilesDirectory();
+ force += "/";
+ force += utilityName;
+ const char* no_main_dependency = 0;
+ const char* empty_comment = "";
+ bool no_replace = false;
+ this->AddCustomCommandToOutput(force.c_str(), depends,
+ no_main_dependency,
+ commandLines, empty_comment,
+ workingDirectory, no_replace,
+ escapeOldStyle);
+ target.GetSourceLists().push_back(force);
// Add the target to the set of targets.
cmTargets::iterator it =
diff --git a/Source/cmMakefileExecutableTargetGenerator.cxx b/Source/cmMakefileExecutableTargetGenerator.cxx
index 5473bd6720..65e2877d89 100644
--- a/Source/cmMakefileExecutableTargetGenerator.cxx
+++ b/Source/cmMakefileExecutableTargetGenerator.cxx
@@ -25,6 +25,12 @@
#include "cmake.h"
//----------------------------------------------------------------------------
+cmMakefileExecutableTargetGenerator::cmMakefileExecutableTargetGenerator()
+{
+ this->DriveCustomCommandsOnDepends = true;
+}
+
+//----------------------------------------------------------------------------
void cmMakefileExecutableTargetGenerator::WriteRuleFiles()
{
// create the build.make file and directory, put in the common blocks
diff --git a/Source/cmMakefileExecutableTargetGenerator.h b/Source/cmMakefileExecutableTargetGenerator.h
index f6ffad2beb..269fd5f6ae 100644
--- a/Source/cmMakefileExecutableTargetGenerator.h
+++ b/Source/cmMakefileExecutableTargetGenerator.h
@@ -22,6 +22,8 @@
class cmMakefileExecutableTargetGenerator: public cmMakefileTargetGenerator
{
public:
+ cmMakefileExecutableTargetGenerator();
+
/* the main entry point for this class. Writes the Makefiles associated
with this target */
virtual void WriteRuleFiles();
diff --git a/Source/cmMakefileLibraryTargetGenerator.cxx b/Source/cmMakefileLibraryTargetGenerator.cxx
index c7c06ff26f..006caa709d 100644
--- a/Source/cmMakefileLibraryTargetGenerator.cxx
+++ b/Source/cmMakefileLibraryTargetGenerator.cxx
@@ -27,6 +27,12 @@
#include <memory> // auto_ptr
//----------------------------------------------------------------------------
+cmMakefileLibraryTargetGenerator::cmMakefileLibraryTargetGenerator()
+{
+ this->DriveCustomCommandsOnDepends = true;
+}
+
+//----------------------------------------------------------------------------
void cmMakefileLibraryTargetGenerator::WriteRuleFiles()
{
// create the build.make file and directory, put in the common blocks
diff --git a/Source/cmMakefileLibraryTargetGenerator.h b/Source/cmMakefileLibraryTargetGenerator.h
index 502e35bca0..1194afe803 100644
--- a/Source/cmMakefileLibraryTargetGenerator.h
+++ b/Source/cmMakefileLibraryTargetGenerator.h
@@ -23,6 +23,8 @@ class cmMakefileLibraryTargetGenerator:
public cmMakefileTargetGenerator
{
public:
+ cmMakefileLibraryTargetGenerator();
+
/* the main entry point for this class. Writes the Makefiles associated
with this target */
virtual void WriteRuleFiles();
diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx
index cd8239c864..cc16069e52 100644
--- a/Source/cmMakefileTargetGenerator.cxx
+++ b/Source/cmMakefileTargetGenerator.cxx
@@ -35,6 +35,7 @@ cmMakefileTargetGenerator::cmMakefileTargetGenerator()
this->BuildFileStream = 0;
this->InfoFileStream = 0;
this->FlagFileStream = 0;
+ this->DriveCustomCommandsOnDepends = false;
}
cmMakefileTargetGenerator *
@@ -775,6 +776,23 @@ void cmMakefileTargetGenerator::WriteTargetDependRules()
commands.push_back(depCmd.str());
// Make sure all custom command outputs in this target are built.
+ if(this->DriveCustomCommandsOnDepends)
+ {
+ this->DriveCustomCommands(depends);
+ }
+
+ // Write the rule.
+ this->LocalGenerator->WriteMakeRule(*this->BuildFileStream, 0,
+ depMark.c_str(),
+ depends, commands, false);
+}
+
+//----------------------------------------------------------------------------
+void
+cmMakefileTargetGenerator
+::DriveCustomCommands(std::vector<std::string>& depends)
+{
+ // Depend on all custom command outputs.
const std::vector<cmSourceFile*>& sources =
this->Target->GetSourceFiles();
for(std::vector<cmSourceFile*>::const_iterator source = sources.begin();
@@ -790,11 +808,6 @@ void cmMakefileTargetGenerator::WriteTargetDependRules()
}
}
}
-
- // Write the rule.
- this->LocalGenerator->WriteMakeRule(*this->BuildFileStream, 0,
- depMark.c_str(),
- depends, commands, false);
}
//----------------------------------------------------------------------------
@@ -1040,6 +1053,12 @@ void cmMakefileTargetGenerator::WriteTargetDriverRule(const char* main_output,
{
// Setup the comment for the main build driver.
comment = "Rule to build all files generated by this target.";
+
+ // Make sure all custom command outputs in this target are built.
+ if(!this->DriveCustomCommandsOnDepends)
+ {
+ this->DriveCustomCommands(depends);
+ }
}
// Write the driver rule.
diff --git a/Source/cmMakefileTargetGenerator.h b/Source/cmMakefileTargetGenerator.h
index 02223e6ded..dd6bbe62f6 100644
--- a/Source/cmMakefileTargetGenerator.h
+++ b/Source/cmMakefileTargetGenerator.h
@@ -107,6 +107,8 @@ protected:
// write the driver rule to build target outputs
void WriteTargetDriverRule(const char* main_output, bool relink);
+ void DriveCustomCommands(std::vector<std::string>& depends);
+
// Return the a string with -F flags on apple
std::string GetFrameworkFlags();
@@ -122,6 +124,8 @@ protected:
cmGlobalGenerator *GlobalGenerator;
cmMakefile *Makefile;
+ bool DriveCustomCommandsOnDepends;
+
// the full path to the build file
std::string BuildFileName;
std::string BuildFileNameFull;