summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Kuemmel <syntheticpp@gmx.net>2012-06-13 00:52:46 +0200
committerPeter Kuemmel <syntheticpp@gmx.net>2012-06-13 00:52:46 +0200
commit43200c145d9690701f0cc6dbd5c60ee3ece5edf8 (patch)
tree126a97e913a088f18bfb5d91e789f19b04d8eb27
parent12cc6434bfad53a4bc45b0ab36d27489346dfadc (diff)
downloadcmake-43200c145d9690701f0cc6dbd5c60ee3ece5edf8.tar.gz
Ninja: work with ninja/master, don't compile rc files with cl
Ninja generates for paths with spaces wrong results for $out.d, using the new DEP_FILE variable instead.
-rw-r--r--Source/cmLocalGenerator.cxx7
-rw-r--r--Source/cmLocalGenerator.h1
-rw-r--r--Source/cmNinjaNormalTargetGenerator.cxx15
-rw-r--r--Source/cmNinjaNormalTargetGenerator.h3
-rw-r--r--Source/cmNinjaTargetGenerator.cxx59
-rw-r--r--Source/cmNinjaTargetGenerator.h3
6 files changed, 52 insertions, 36 deletions
diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx
index 8265d72b4d..90ed27000a 100644
--- a/Source/cmLocalGenerator.cxx
+++ b/Source/cmLocalGenerator.cxx
@@ -872,6 +872,13 @@ cmLocalGenerator::ExpandRuleVariable(std::string const& variable,
return replaceValues.TargetPDB;
}
}
+ if(replaceValues.DependencyFile )
+ {
+ if(variable == "DEP_FILE")
+ {
+ return replaceValues.DependencyFile;
+ }
+ }
if(replaceValues.Target)
{
diff --git a/Source/cmLocalGenerator.h b/Source/cmLocalGenerator.h
index cb84a307b8..f53700abca 100644
--- a/Source/cmLocalGenerator.h
+++ b/Source/cmLocalGenerator.h
@@ -235,6 +235,7 @@ public:
const char* LanguageCompileFlags;
const char* Defines;
const char* RuleLauncher;
+ const char* DependencyFile;
};
/** Set whether to treat conversions to SHELL as a link script shell. */
diff --git a/Source/cmNinjaNormalTargetGenerator.cxx b/Source/cmNinjaNormalTargetGenerator.cxx
index df1418f1de..81715dcd4e 100644
--- a/Source/cmNinjaNormalTargetGenerator.cxx
+++ b/Source/cmNinjaNormalTargetGenerator.cxx
@@ -55,21 +55,6 @@ cmNinjaNormalTargetGenerator::~cmNinjaNormalTargetGenerator()
{
}
-void
-cmNinjaNormalTargetGenerator
-::EnsureDirectoryExists(const std::string& dir)
-{
- cmSystemTools::MakeDirectory(dir.c_str());
-}
-
-void
-cmNinjaNormalTargetGenerator
-::EnsureParentDirectoryExists(const std::string& path)
-{
- EnsureDirectoryExists(cmSystemTools::GetParentDirectory(path.c_str()));
-}
-
-
void cmNinjaNormalTargetGenerator::Generate()
{
if (!this->TargetLinkLanguage) {
diff --git a/Source/cmNinjaNormalTargetGenerator.h b/Source/cmNinjaNormalTargetGenerator.h
index 3be1c94e1e..1ef95675b9 100644
--- a/Source/cmNinjaNormalTargetGenerator.h
+++ b/Source/cmNinjaNormalTargetGenerator.h
@@ -35,9 +35,6 @@ private:
void WriteObjectLibStatement();
std::vector<std::string> ComputeLinkCmd();
- void EnsureDirectoryExists(const std::string& dir);
- void EnsureParentDirectoryExists(const std::string& path);
-
private:
// Target name info.
std::string TargetNameOut;
diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx
index 5c6a45d637..ce1aac2fc2 100644
--- a/Source/cmNinjaTargetGenerator.cxx
+++ b/Source/cmNinjaTargetGenerator.cxx
@@ -333,19 +333,29 @@ cmNinjaTargetGenerator
vars.Defines = "$DEFINES";
vars.TargetPDB = "$TARGET_PDB";
+
cmMakefile* mf = this->GetMakefile();
+
bool useClDeps = false;
- const char* clDepsBinary = mf->GetDefinition("CMAKE_CMCLDEPS_EXECUTABLE");
- const char* clShowPrefix = mf->GetDefinition("CMAKE_CL_SHOWINCLUDE_PREFIX");
- const char* projectName = mf->GetProjectName();
- if (clDepsBinary && clShowPrefix)
+ std::string clDepsBinary;
+ std::string clShowPrefix;
+ if (lang == "C" || lang == "CXX")
{
- useClDeps = true;
- if (projectName && std::string(projectName) == "CMAKE_TRY_COMPILE")
+ const char* depsPtr = mf->GetDefinition("CMAKE_CMCLDEPS_EXECUTABLE");
+ const char* showPtr = mf->GetDefinition("CMAKE_CL_SHOWINCLUDE_PREFIX");
+ if (depsPtr && showPtr)
{
// don't wrap for try_compile,
// TODO but why doesn't it work with cmcldeps?
- useClDeps = false;
+ const std::string projectName = mf->GetProjectName() ?
+ mf->GetProjectName() : "";
+ if (projectName != "CMAKE_TRY_COMPILE")
+ {
+ useClDeps = true;
+ clDepsBinary = depsPtr;
+ clShowPrefix = showPtr;
+ vars.DependencyFile = "$DEP_FILE";
+ }
}
}
@@ -354,15 +364,13 @@ cmNinjaTargetGenerator
std::string depfileFlagsName = "CMAKE_DEPFILE_FLAGS_" + language;
const char *depfileFlags = mf->GetDefinition(depfileFlagsName.c_str());
if (depfileFlags || useClDeps) {
- std::string depfileFlagsStr = depfileFlags ? depfileFlags : "";
- depfile = "$out.d";
- cmSystemTools::ReplaceString(depfileFlagsStr, "<DEPFILE>",
- depfile.c_str());
- cmSystemTools::ReplaceString(depfileFlagsStr, "<OBJECT>",
- "$out");
- cmSystemTools::ReplaceString(depfileFlagsStr, "<CMAKE_C_COMPILER>",
+ std::string depFlagsStr = depfileFlags ? depfileFlags : "";
+ depfile = "$DEP_FILE";
+ cmSystemTools::ReplaceString(depFlagsStr, "<DEPFILE>", "\"$DEP_FILE\"");
+ cmSystemTools::ReplaceString(depFlagsStr, "<OBJECT>", "$out");
+ cmSystemTools::ReplaceString(depFlagsStr, "<CMAKE_C_COMPILER>",
mf->GetDefinition("CMAKE_C_COMPILER"));
- flags += " " + depfileFlagsStr;
+ flags += " " + depFlagsStr;
}
vars.Flags = flags.c_str();
@@ -384,9 +392,8 @@ cmNinjaTargetGenerator
if(useClDeps)
{
- std::string prefix = clShowPrefix;
- cmdLine = "\"" + std::string(clDepsBinary) + "\" $in $out.d $out \""
- + prefix + "\" " + cmdLine;
+ cmdLine = "\"" + clDepsBinary + "\" $in \"$DEP_FILE\" $out \""
+ + clShowPrefix + "\" " + cmdLine;
}
// Write the rule for compiling file of the given language.
@@ -509,6 +516,8 @@ cmNinjaTargetGenerator
cmNinjaVars vars;
vars["FLAGS"] = this->ComputeFlagsForObject(source, language);
vars["DEFINES"] = this->ComputeDefines(source, language);
+ vars["DEP_FILE"] = objectFileName + ".d";;
+ EnsureParentDirectoryExists(objectFileName);
// TODO move to GetTargetPDB
cmMakefile* mf = this->GetMakefile();
@@ -599,3 +608,17 @@ cmNinjaTargetGenerator
this->ModuleDefinitionFile.c_str()));
this->LocalGenerator->AppendFlags(flags, flag.c_str());
}
+
+void
+cmNinjaTargetGenerator
+::EnsureDirectoryExists(const std::string& dir)
+{
+ cmSystemTools::MakeDirectory(dir.c_str());
+}
+
+void
+cmNinjaTargetGenerator
+::EnsureParentDirectoryExists(const std::string& path)
+{
+ EnsureDirectoryExists(cmSystemTools::GetParentDirectory(path.c_str()));
+}
diff --git a/Source/cmNinjaTargetGenerator.h b/Source/cmNinjaTargetGenerator.h
index b64ce1e1ec..af43a8b38b 100644
--- a/Source/cmNinjaTargetGenerator.h
+++ b/Source/cmNinjaTargetGenerator.h
@@ -111,6 +111,9 @@ protected:
// Helper to add flag for windows .def file.
void AddModuleDefinitionFlag(std::string& flags);
+ void EnsureDirectoryExists(const std::string& dir);
+ void EnsureParentDirectoryExists(const std::string& path);
+
private:
cmTarget* Target;
cmGeneratorTarget* GeneratorTarget;