Ninja: don't crash on returned 0 pointer
This commit is contained in:
parent
3632f24f13
commit
4a35bd0e69
|
@ -342,26 +342,26 @@ cmNinjaTargetGenerator
|
||||||
cmMakefile* mf = this->GetMakefile();
|
cmMakefile* mf = this->GetMakefile();
|
||||||
|
|
||||||
bool useClDeps = false;
|
bool useClDeps = false;
|
||||||
|
std::string clBinary;
|
||||||
std::string clDepsBinary;
|
std::string clDepsBinary;
|
||||||
std::string clShowPrefix;
|
std::string clShowPrefix;
|
||||||
if (lang == "C" || lang == "CXX" || lang == "RC")
|
if (lang == "C" || lang == "CXX" || lang == "RC")
|
||||||
{
|
{
|
||||||
const char* depsPtr = mf->GetDefinition("CMAKE_CMCLDEPS_EXECUTABLE");
|
clDepsBinary = mf->GetSafeDefinition("CMAKE_CMCLDEPS_EXECUTABLE");
|
||||||
const char* showPtr = mf->GetDefinition("CMAKE_CL_SHOWINCLUDE_PREFIX");
|
if (!clDepsBinary.empty() &&
|
||||||
if (depsPtr && showPtr)
|
!this->GetGlobalGenerator()->GetCMakeInstance()->GetIsInTryCompile())
|
||||||
{
|
{
|
||||||
// don't wrap for try_compile,
|
clShowPrefix = mf->GetSafeDefinition("CMAKE_CL_SHOWINCLUDE_PREFIX");
|
||||||
// TODO but why doesn't it work with cmcldeps?
|
clBinary = mf->GetDefinition("CMAKE_C_COMPILER") ?
|
||||||
const std::string projectName = mf->GetProjectName() ?
|
mf->GetSafeDefinition("CMAKE_C_COMPILER") :
|
||||||
mf->GetProjectName() : "";
|
mf->GetSafeDefinition("CMAKE_CXX_COMPILER");
|
||||||
if (projectName != "CMAKE_TRY_COMPILE"
|
if (!clBinary.empty() && !clShowPrefix.empty())
|
||||||
&& (mf->GetDefinition("CMAKE_C_COMPILER") ||
|
|
||||||
mf->GetDefinition("CMAKE_CXX_COMPILER")))
|
|
||||||
{
|
{
|
||||||
useClDeps = true;
|
useClDeps = true;
|
||||||
std::string qu = "\"";
|
const std::string quote = " \"";
|
||||||
clDepsBinary = qu + depsPtr + qu;
|
clBinary = quote + clBinary + "\" ";
|
||||||
clShowPrefix = qu + showPtr + qu;
|
clDepsBinary = quote + clDepsBinary + "\" ";
|
||||||
|
clShowPrefix = quote + clShowPrefix + "\" ";
|
||||||
vars.DependencyFile = "$DEP_FILE";
|
vars.DependencyFile = "$DEP_FILE";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -395,17 +395,14 @@ cmNinjaTargetGenerator
|
||||||
i != compileCmds.end(); ++i)
|
i != compileCmds.end(); ++i)
|
||||||
this->GetLocalGenerator()->ExpandRuleVariables(*i, vars);
|
this->GetLocalGenerator()->ExpandRuleVariables(*i, vars);
|
||||||
|
|
||||||
std::string cmdLine =
|
std::string cmdLine;
|
||||||
this->GetLocalGenerator()->BuildCommandLine(compileCmds);
|
|
||||||
|
|
||||||
if(useClDeps)
|
if(useClDeps)
|
||||||
{
|
{
|
||||||
std::string cl = mf->GetDefinition("CMAKE_C_COMPILER");
|
cmdLine = clDepsBinary + lang + " $in \"$DEP_FILE\" $out " +
|
||||||
if (cl.empty())
|
clShowPrefix + clBinary;
|
||||||
cl = mf->GetDefinition("CMAKE_CXX_COMPILER");
|
|
||||||
cmdLine = clDepsBinary + " " + lang + " $in \"$DEP_FILE\" $out "
|
|
||||||
+ clShowPrefix + " \"" + cl + "\" " + cmdLine;
|
|
||||||
}
|
}
|
||||||
|
cmdLine += this->GetLocalGenerator()->BuildCommandLine(compileCmds);
|
||||||
|
|
||||||
|
|
||||||
// Write the rule for compiling file of the given language.
|
// Write the rule for compiling file of the given language.
|
||||||
cmOStringStream comment;
|
cmOStringStream comment;
|
||||||
|
|
Loading…
Reference in New Issue