diff options
author | Peter Kuemmel <syntheticpp@gmx.net> | 2012-06-12 22:52:46 (GMT) |
---|---|---|
committer | Peter Kuemmel <syntheticpp@gmx.net> | 2012-06-12 22:52:46 (GMT) |
commit | 43200c145d9690701f0cc6dbd5c60ee3ece5edf8 (patch) | |
tree | 126a97e913a088f18bfb5d91e789f19b04d8eb27 /Source/cmNinjaTargetGenerator.cxx | |
parent | 12cc6434bfad53a4bc45b0ab36d27489346dfadc (diff) | |
download | CMake-43200c145d9690701f0cc6dbd5c60ee3ece5edf8.zip CMake-43200c145d9690701f0cc6dbd5c60ee3ece5edf8.tar.gz CMake-43200c145d9690701f0cc6dbd5c60ee3ece5edf8.tar.bz2 |
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.
Diffstat (limited to 'Source/cmNinjaTargetGenerator.cxx')
-rw-r--r-- | Source/cmNinjaTargetGenerator.cxx | 59 |
1 files changed, 41 insertions, 18 deletions
diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index 5c6a45d..ce1aac2 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())); +} |