diff options
author | David Cole <david.cole@kitware.com> | 2012-08-20 19:41:36 (GMT) |
---|---|---|
committer | CMake Topic Stage <kwrobot@kitware.com> | 2012-08-20 19:41:36 (GMT) |
commit | 8d8268b30785c50b5256c2fb2df81f6fae17c11d (patch) | |
tree | fffeb53952ec876c3d8ff987cdbb307094c2e39c | |
parent | ba9fde65035f07b483f116d290939c403a04a62d (diff) | |
parent | 4a35bd0e69e5cfaf7ca9604c90b609d1d333bb37 (diff) | |
download | CMake-8d8268b30785c50b5256c2fb2df81f6fae17c11d.zip CMake-8d8268b30785c50b5256c2fb2df81f6fae17c11d.tar.gz CMake-8d8268b30785c50b5256c2fb2df81f6fae17c11d.tar.bz2 |
Merge topic 'cmcldeps-needs-cl'
4a35bd0 Ninja: don't crash on returned 0 pointer
3632f24 Ninja: cmcldeps needs a compiler
-rw-r--r-- | Source/cmNinjaTargetGenerator.cxx | 36 |
1 files changed, 18 insertions, 18 deletions
diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index 3532c8b..b6bdfdc 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -342,24 +342,26 @@ cmNinjaTargetGenerator cmMakefile* mf = this->GetMakefile(); bool useClDeps = false; + std::string clBinary; std::string clDepsBinary; std::string clShowPrefix; if (lang == "C" || lang == "CXX" || lang == "RC") { - const char* depsPtr = mf->GetDefinition("CMAKE_CMCLDEPS_EXECUTABLE"); - const char* showPtr = mf->GetDefinition("CMAKE_CL_SHOWINCLUDE_PREFIX"); - if (depsPtr && showPtr) + clDepsBinary = mf->GetSafeDefinition("CMAKE_CMCLDEPS_EXECUTABLE"); + if (!clDepsBinary.empty() && + !this->GetGlobalGenerator()->GetCMakeInstance()->GetIsInTryCompile()) { - // don't wrap for try_compile, - // TODO but why doesn't it work with cmcldeps? - const std::string projectName = mf->GetProjectName() ? - mf->GetProjectName() : ""; - if (projectName != "CMAKE_TRY_COMPILE") + clShowPrefix = mf->GetSafeDefinition("CMAKE_CL_SHOWINCLUDE_PREFIX"); + clBinary = mf->GetDefinition("CMAKE_C_COMPILER") ? + mf->GetSafeDefinition("CMAKE_C_COMPILER") : + mf->GetSafeDefinition("CMAKE_CXX_COMPILER"); + if (!clBinary.empty() && !clShowPrefix.empty()) { useClDeps = true; - std::string qu = "\""; - clDepsBinary = qu + depsPtr + qu; - clShowPrefix = qu + showPtr + qu; + const std::string quote = " \""; + clBinary = quote + clBinary + "\" "; + clDepsBinary = quote + clDepsBinary + "\" "; + clShowPrefix = quote + clShowPrefix + "\" "; vars.DependencyFile = "$DEP_FILE"; } } @@ -393,16 +395,14 @@ cmNinjaTargetGenerator i != compileCmds.end(); ++i) this->GetLocalGenerator()->ExpandRuleVariables(*i, vars); - std::string cmdLine = - this->GetLocalGenerator()->BuildCommandLine(compileCmds); - + std::string cmdLine; if(useClDeps) { - std::string cl = mf->GetDefinition("CMAKE_C_COMPILER"); - cl = "\"" + cl + "\" "; - cmdLine = clDepsBinary + " " + lang + " $in \"$DEP_FILE\" $out " - + clShowPrefix + " " + cl + cmdLine; + cmdLine = clDepsBinary + lang + " $in \"$DEP_FILE\" $out " + + clShowPrefix + clBinary; } + cmdLine += this->GetLocalGenerator()->BuildCommandLine(compileCmds); + // Write the rule for compiling file of the given language. cmOStringStream comment; |