summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2015-04-10 20:27:55 (GMT)
committerBrad King <brad.king@kitware.com>2015-04-10 20:27:55 (GMT)
commit74337b87acd837b9631f44b4df3027fe83ee9b42 (patch)
treebe66e236eb7850e0d1e62f10192b56c2a592916c /Source
parent0740677b9c67cfe8d26c9cf4cbddb8410d7f920a (diff)
parent9660a3cceae12ebb3cdc49484dcef590a12eb33c (diff)
downloadCMake-74337b87acd837b9631f44b4df3027fe83ee9b42.zip
CMake-74337b87acd837b9631f44b4df3027fe83ee9b42.tar.gz
CMake-74337b87acd837b9631f44b4df3027fe83ee9b42.tar.bz2
Merge branch 'custom-command-multiple-outputs' into release
Diffstat (limited to 'Source')
-rw-r--r--Source/cmMakefileTargetGenerator.cxx58
-rw-r--r--Source/cmMakefileTargetGenerator.h3
-rw-r--r--Source/kwsys/SystemTools.cxx17
3 files changed, 47 insertions, 31 deletions
diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx
index 4ece016..ea11c79 100644
--- a/Source/cmMakefileTargetGenerator.cxx
+++ b/Source/cmMakefileTargetGenerator.cxx
@@ -767,7 +767,7 @@ cmMakefileTargetGenerator
// Write the rule.
this->WriteMakeRule(*this->BuildFileStream, 0, outputs,
- depends, commands, false);
+ depends, commands);
bool do_preprocess_rules = lang_has_preprocessor &&
this->LocalGenerator->GetCreatePreprocessedSourceRules();
@@ -989,18 +989,30 @@ void cmMakefileTargetGenerator::WriteTargetCleanRules()
}
//----------------------------------------------------------------------------
-void cmMakefileTargetGenerator::WriteMakeRule(
+bool cmMakefileTargetGenerator::WriteMakeRule(
std::ostream& os,
const char* comment,
const std::vector<std::string>& outputs,
const std::vector<std::string>& depends,
const std::vector<std::string>& commands,
- bool symbolic,
bool in_help)
{
+ bool symbolic = false;
if (outputs.size() == 0)
{
- return;
+ return symbolic;
+ }
+
+ // Check whether we need to bother checking for a symbolic output.
+ bool need_symbolic = this->GlobalGenerator->GetNeedSymbolicMark();
+
+ // Check whether the first output is marked as symbolic.
+ if(need_symbolic)
+ {
+ if(cmSourceFile* sf = this->Makefile->GetSource(outputs[0]))
+ {
+ symbolic = sf->GetPropertyAsBool("SYMBOLIC");
+ }
}
// We always attach the actual commands to the first output.
@@ -1010,7 +1022,7 @@ void cmMakefileTargetGenerator::WriteMakeRule(
// For single outputs, we are done.
if (outputs.size() == 1)
{
- return;
+ return symbolic;
}
// For multiple outputs, make the extra ones depend on the first one.
@@ -1023,14 +1035,25 @@ void cmMakefileTargetGenerator::WriteMakeRule(
std::string const out = this->Convert(*o, cmLocalGenerator::HOME_OUTPUT,
cmLocalGenerator::SHELL);
std::vector<std::string> output_commands;
- if (!symbolic)
+
+ bool o_symbolic = false;
+ if(need_symbolic)
+ {
+ if(cmSourceFile* sf = this->Makefile->GetSource(*o))
+ {
+ o_symbolic = sf->GetPropertyAsBool("SYMBOLIC");
+ }
+ }
+ symbolic = symbolic && o_symbolic;
+
+ if (!o_symbolic)
{
output_commands.push_back("@$(CMAKE_COMMAND) -E touch_nocreate " + out);
}
this->LocalGenerator->WriteMakeRule(os, 0, *o, output_depends,
- output_commands, symbolic, in_help);
+ output_commands, o_symbolic, in_help);
- if (!symbolic)
+ if (!o_symbolic)
{
// At build time, remove the first output if this one does not exist
// so that "make" will rerun the real commands that create this one.
@@ -1038,6 +1061,7 @@ void cmMakefileTargetGenerator::WriteMakeRule(
this->MultipleOutputPairs.insert(p);
}
}
+ return symbolic;
}
//----------------------------------------------------------------------------
@@ -1289,30 +1313,16 @@ void cmMakefileTargetGenerator
std::vector<std::string> depends;
this->LocalGenerator->AppendCustomDepend(depends, ccg);
- // Check whether we need to bother checking for a symbolic output.
- bool need_symbolic = this->GlobalGenerator->GetNeedSymbolicMark();
-
// Write the rule.
const std::vector<std::string>& outputs = ccg.GetOutputs();
- std::vector<std::string>::const_iterator o = outputs.begin();
- {
- bool symbolic = false;
- if(need_symbolic)
- {
- if(cmSourceFile* sf = this->Makefile->GetSource(*o))
- {
- symbolic = sf->GetPropertyAsBool("SYMBOLIC");
- }
- }
- this->WriteMakeRule(*this->BuildFileStream, 0, outputs,
- depends, commands, symbolic);
+ bool symbolic = this->WriteMakeRule(*this->BuildFileStream, 0,
+ outputs, depends, commands);
// If the rule has changed make sure the output is rebuilt.
if(!symbolic)
{
this->GlobalGenerator->AddRuleHash(ccg.GetOutputs(), content.str());
}
- }
// Setup implicit dependency scanning.
for(cmCustomCommand::ImplicitDependsList::const_iterator
diff --git a/Source/cmMakefileTargetGenerator.h b/Source/cmMakefileTargetGenerator.h
index f62c51d..42c4f58 100644
--- a/Source/cmMakefileTargetGenerator.h
+++ b/Source/cmMakefileTargetGenerator.h
@@ -224,12 +224,11 @@ protected:
typedef std::map<std::string, std::string> MultipleOutputPairsType;
MultipleOutputPairsType MultipleOutputPairs;
- void WriteMakeRule(std::ostream& os,
+ bool WriteMakeRule(std::ostream& os,
const char* comment,
const std::vector<std::string>& outputs,
const std::vector<std::string>& depends,
const std::vector<std::string>& commands,
- bool symbolic,
bool in_help = false);
// Target name info.
diff --git a/Source/kwsys/SystemTools.cxx b/Source/kwsys/SystemTools.cxx
index b03e7b0..b9b65a0 100644
--- a/Source/kwsys/SystemTools.cxx
+++ b/Source/kwsys/SystemTools.cxx
@@ -1215,15 +1215,22 @@ bool SystemTools::PathCygwinToWin32(const char *path, char *win32_path)
bool SystemTools::Touch(const kwsys_stl::string& filename, bool create)
{
- if(create && !SystemTools::FileExists(filename))
+ if (!SystemTools::FileExists(filename))
{
- FILE* file = Fopen(filename, "a+b");
- if(file)
+ if(create)
+ {
+ FILE* file = Fopen(filename, "a+b");
+ if(file)
+ {
+ fclose(file);
+ return true;
+ }
+ return false;
+ }
+ else
{
- fclose(file);
return true;
}
- return false;
}
#if defined(_WIN32) && !defined(__CYGWIN__)
HANDLE h = CreateFileW(