Merge topic 'ninja-msvc-only-C-and-CXX'

8a93d3ea Ninja: Use "deps = msvc" only for C and CXX (#15253)
This commit is contained in:
Brad King 2015-01-30 10:23:05 -05:00 committed by CMake Topic Stage
commit 85fe9400cd
2 changed files with 24 additions and 30 deletions

View File

@ -200,21 +200,21 @@ cmNinjaTargetGenerator::ComputeFlagsForObject(cmSourceFile const* source,
return flags; return flags;
} }
bool cmNinjaTargetGenerator::NeedDepTypeMSVC(const std::string& lang) const
bool cmNinjaTargetGenerator::needsDepFile(const std::string& lang)
{ {
cmMakefile* mf = this->GetMakefile(); if (lang == "C" || lang == "CXX")
{
const bool usingMSVC = std::string("MSVC") == cmMakefile* mf = this->GetMakefile();
(mf->GetDefinition("CMAKE_C_COMPILER_ID") ? return (
mf->GetSafeDefinition("CMAKE_C_COMPILER_ID") : strcmp(mf->GetSafeDefinition("CMAKE_C_COMPILER_ID"), "MSVC") == 0 ||
mf->GetSafeDefinition("CMAKE_CXX_COMPILER_ID")); strcmp(mf->GetSafeDefinition("CMAKE_CXX_COMPILER_ID"), "MSVC") == 0 ||
strcmp(mf->GetSafeDefinition("CMAKE_C_SIMULATE_ID"), "MSVC") == 0 ||
return !usingMSVC || lang == "RC"; strcmp(mf->GetSafeDefinition("CMAKE_CXX_SIMULATE_ID"), "MSVC") == 0
);
}
return false;
} }
// TODO: Refactor with // TODO: Refactor with
// void cmMakefileTargetGenerator::WriteTargetLanguageFlags(). // void cmMakefileTargetGenerator::WriteTargetLanguageFlags().
std::string std::string
@ -391,22 +391,22 @@ cmNinjaTargetGenerator
cmMakefile* mf = this->GetMakefile(); cmMakefile* mf = this->GetMakefile();
const std::string cId = mf->GetDefinition("CMAKE_C_COMPILER_ID")
? mf->GetSafeDefinition("CMAKE_C_COMPILER_ID")
: mf->GetSafeDefinition("CMAKE_CXX_COMPILER_ID");
const std::string sId = mf->GetDefinition("CMAKE_C_SIMULATE_ID")
? mf->GetSafeDefinition("CMAKE_C_SIMULATE_ID")
: mf->GetSafeDefinition("CMAKE_CXX_SIMULATE_ID");
const bool usingMSVC = (cId == "MSVC" || sId == "MSVC");
// Tell ninja dependency format so all deps can be loaded into a database // Tell ninja dependency format so all deps can be loaded into a database
std::string deptype; std::string deptype;
std::string depfile; std::string depfile;
std::string cldeps; std::string cldeps;
std::string flags = "$FLAGS"; std::string flags = "$FLAGS";
if (usingMSVC) if (this->NeedDepTypeMSVC(lang))
{ {
if (!mf->GetIsSourceFileTryCompile() && lang == "RC") deptype = "msvc";
depfile = "";
flags += " /showIncludes";
}
else if (lang == "RC" && this->NeedDepTypeMSVC("C"))
{
// For the MS resource compiler we need cmcldeps, but skip dependencies
// for source-file try_compile cases because they are always fresh.
if (!mf->GetIsSourceFileTryCompile())
{ {
deptype = "gcc"; deptype = "gcc";
depfile = "$DEP_FILE"; depfile = "$DEP_FILE";
@ -419,12 +419,6 @@ cmNinjaTargetGenerator
cldeps += mf->GetSafeDefinition("CMAKE_CL_SHOWINCLUDES_PREFIX"); cldeps += mf->GetSafeDefinition("CMAKE_CL_SHOWINCLUDES_PREFIX");
cldeps += "\" \"" + cl + "\" "; cldeps += "\" \"" + cl + "\" ";
} }
else
{
deptype = "msvc";
depfile = "";
flags += " /showIncludes";
}
} }
else else
{ {
@ -636,7 +630,7 @@ cmNinjaTargetGenerator
cmNinjaVars vars; cmNinjaVars vars;
vars["FLAGS"] = this->ComputeFlagsForObject(source, language); vars["FLAGS"] = this->ComputeFlagsForObject(source, language);
vars["DEFINES"] = this->ComputeDefines(source, language); vars["DEFINES"] = this->ComputeDefines(source, language);
if (needsDepFile(language)) { if (!this->NeedDepTypeMSVC(language)) {
vars["DEP_FILE"] = vars["DEP_FILE"] =
cmGlobalNinjaGenerator::EncodeDepfileSpace(objectFileName + ".d"); cmGlobalNinjaGenerator::EncodeDepfileSpace(objectFileName + ".d");
} }

View File

@ -42,7 +42,7 @@ public:
std::string GetTargetName() const; std::string GetTargetName() const;
bool needsDepFile(const std::string& lang); bool NeedDepTypeMSVC(const std::string& lang) const;
protected: protected: