Ninja: use deps = gcc/msvc feature

cmcldeps is now only used for .rc file processing
This commit is contained in:
Peter Kümmel 2013-10-18 12:59:47 +02:00
parent dca43862f1
commit eeb4aece1c
11 changed files with 158 additions and 77 deletions

View File

@ -55,4 +55,4 @@ set(CMAKE_C_IMPLICIT_LINK_DIRECTORIES "@CMAKE_C_IMPLICIT_LINK_DIRECTORIES@")
set(CMAKE_C_IMPLICIT_LINK_FRAMEWORK_DIRECTORIES "@CMAKE_C_IMPLICIT_LINK_FRAMEWORK_DIRECTORIES@") set(CMAKE_C_IMPLICIT_LINK_FRAMEWORK_DIRECTORIES "@CMAKE_C_IMPLICIT_LINK_FRAMEWORK_DIRECTORIES@")
@SET_CMAKE_CMCLDEPS_EXECUTABLE@ @SET_CMAKE_CMCLDEPS_EXECUTABLE@
@SET_CMAKE_CL_SHOWINCLUDE_PREFIX@ @SET_CMAKE_CL_SHOWINCLUDES_PREFIX@

View File

@ -56,4 +56,4 @@ set(CMAKE_CXX_IMPLICIT_LINK_DIRECTORIES "@CMAKE_CXX_IMPLICIT_LINK_DIRECTORIES@")
set(CMAKE_CXX_IMPLICIT_LINK_FRAMEWORK_DIRECTORIES "@CMAKE_CXX_IMPLICIT_LINK_FRAMEWORK_DIRECTORIES@") set(CMAKE_CXX_IMPLICIT_LINK_FRAMEWORK_DIRECTORIES "@CMAKE_CXX_IMPLICIT_LINK_FRAMEWORK_DIRECTORIES@")
@SET_CMAKE_CMCLDEPS_EXECUTABLE@ @SET_CMAKE_CMCLDEPS_EXECUTABLE@
@SET_CMAKE_CL_SHOWINCLUDE_PREFIX@ @SET_CMAKE_CL_SHOWINCLUDES_PREFIX@

View File

@ -20,7 +20,7 @@
# in front of each include path, so it can remove it. # in front of each include path, so it can remove it.
# #
if(MSVC_C_ARCHITECTURE_ID AND CMAKE_GENERATOR MATCHES "Ninja" AND CMAKE_C_COMPILER AND CMAKE_COMMAND) if(CMAKE_GENERATOR MATCHES "Ninja" AND CMAKE_C_COMPILER AND CMAKE_COMMAND)
string(REPLACE "cmake.exe" "cmcldeps.exe" CMAKE_CMCLDEPS_EXECUTABLE ${CMAKE_COMMAND}) string(REPLACE "cmake.exe" "cmcldeps.exe" CMAKE_CMCLDEPS_EXECUTABLE ${CMAKE_COMMAND})
set(showdir ${CMAKE_BINARY_DIR}/CMakeFiles/ShowIncludes) set(showdir ${CMAKE_BINARY_DIR}/CMakeFiles/ShowIncludes)
file(WRITE ${showdir}/foo.h "\n") file(WRITE ${showdir}/foo.h "\n")
@ -30,5 +30,5 @@ if(MSVC_C_ARCHITECTURE_ID AND CMAKE_GENERATOR MATCHES "Ninja" AND CMAKE_C_COMPIL
string(REGEX MATCH "\n([^:]*:[^:]*:[ \t]*)" tmp "${outLine}") string(REGEX MATCH "\n([^:]*:[^:]*:[ \t]*)" tmp "${outLine}")
set(localizedPrefix "${CMAKE_MATCH_1}") set(localizedPrefix "${CMAKE_MATCH_1}")
set(SET_CMAKE_CMCLDEPS_EXECUTABLE "set(CMAKE_CMCLDEPS_EXECUTABLE \"${CMAKE_CMCLDEPS_EXECUTABLE}\")") set(SET_CMAKE_CMCLDEPS_EXECUTABLE "set(CMAKE_CMCLDEPS_EXECUTABLE \"${CMAKE_CMCLDEPS_EXECUTABLE}\")")
set(SET_CMAKE_CL_SHOWINCLUDE_PREFIX "set(CMAKE_CL_SHOWINCLUDE_PREFIX \"${localizedPrefix}\")") set(SET_CMAKE_CL_SHOWINCLUDES_PREFIX "set(CMAKE_CL_SHOWINCLUDES_PREFIX \"${localizedPrefix}\")")
endif() endif()

View File

@ -176,12 +176,13 @@ if (CMAKE_CROSSCOMPILING AND NOT _CMAKE_TOOLCHAIN_PREFIX)
endif () endif ()
include(${CMAKE_ROOT}/Modules/CMakeClDeps.cmake)
include(CMakeFindBinUtils) include(CMakeFindBinUtils)
if(MSVC_C_ARCHITECTURE_ID) if(MSVC_C_ARCHITECTURE_ID)
include(${CMAKE_ROOT}/Modules/CMakeClDeps.cmake)
set(SET_MSVC_C_ARCHITECTURE_ID set(SET_MSVC_C_ARCHITECTURE_ID
"set(MSVC_C_ARCHITECTURE_ID ${MSVC_C_ARCHITECTURE_ID})") "set(MSVC_C_ARCHITECTURE_ID ${MSVC_C_ARCHITECTURE_ID})")
endif() endif()
# configure variables set in this file for fast reload later on # configure variables set in this file for fast reload later on
configure_file(${CMAKE_ROOT}/Modules/CMakeCCompiler.cmake.in configure_file(${CMAKE_ROOT}/Modules/CMakeCCompiler.cmake.in
${CMAKE_PLATFORM_INFO_DIR}/CMakeCCompiler.cmake ${CMAKE_PLATFORM_INFO_DIR}/CMakeCCompiler.cmake

View File

@ -175,12 +175,13 @@ if (CMAKE_CROSSCOMPILING AND NOT _CMAKE_TOOLCHAIN_PREFIX)
endif () endif ()
include(${CMAKE_ROOT}/Modules/CMakeClDeps.cmake)
include(CMakeFindBinUtils) include(CMakeFindBinUtils)
if(MSVC_CXX_ARCHITECTURE_ID) if(MSVC_CXX_ARCHITECTURE_ID)
include(${CMAKE_ROOT}/Modules/CMakeClDeps.cmake)
set(SET_MSVC_CXX_ARCHITECTURE_ID set(SET_MSVC_CXX_ARCHITECTURE_ID
"set(MSVC_CXX_ARCHITECTURE_ID ${MSVC_CXX_ARCHITECTURE_ID})") "set(MSVC_CXX_ARCHITECTURE_ID ${MSVC_CXX_ARCHITECTURE_ID})")
endif() endif()
# configure all variables set in this file # configure all variables set in this file
configure_file(${CMAKE_ROOT}/Modules/CMakeCXXCompiler.cmake.in configure_file(${CMAKE_ROOT}/Modules/CMakeCXXCompiler.cmake.in
${CMAKE_PLATFORM_INFO_DIR}/CMakeCXXCompiler.cmake ${CMAKE_PLATFORM_INFO_DIR}/CMakeCXXCompiler.cmake

View File

@ -102,6 +102,13 @@ std::string cmGlobalNinjaGenerator::EncodePath(const std::string &path)
return EncodeLiteral(result); return EncodeLiteral(result);
} }
std::string cmGlobalNinjaGenerator::EncodeDepfileSpace(const std::string &path)
{
std::string result = path;
cmSystemTools::ReplaceString(result, " ", "\\ ");
return result;
}
void cmGlobalNinjaGenerator::WriteBuild(std::ostream& os, void cmGlobalNinjaGenerator::WriteBuild(std::ostream& os,
const std::string& comment, const std::string& comment,
const std::string& rule, const std::string& rule,
@ -236,9 +243,11 @@ void cmGlobalNinjaGenerator::AddCustomCommandRule()
"$DESC", "$DESC",
"Rule for running custom commands.", "Rule for running custom commands.",
/*depfile*/ "", /*depfile*/ "",
/*deptype*/ "",
/*rspfile*/ "", /*rspfile*/ "",
/*rspcontent*/ "", /*rspcontent*/ "",
/*restat*/ true); /*restat*/ true,
/*generator*/ false);
} }
void void
@ -247,7 +256,7 @@ cmGlobalNinjaGenerator::WriteCustomCommandBuild(const std::string& command,
const std::string& comment, const std::string& comment,
const cmNinjaDeps& outputs, const cmNinjaDeps& outputs,
const cmNinjaDeps& deps, const cmNinjaDeps& deps,
const cmNinjaDeps& orderOnlyDeps) const cmNinjaDeps& orderOnly)
{ {
std::string cmd = command; std::string cmd = command;
#ifdef _WIN32 #ifdef _WIN32
@ -268,7 +277,7 @@ cmGlobalNinjaGenerator::WriteCustomCommandBuild(const std::string& command,
outputs, outputs,
deps, deps,
cmNinjaDeps(), cmNinjaDeps(),
orderOnlyDeps, orderOnly,
vars); vars);
} }
@ -287,9 +296,13 @@ cmGlobalNinjaGenerator::AddMacOSXContentRule()
this->AddRule("COPY_OSX_CONTENT", this->AddRule("COPY_OSX_CONTENT",
cmd.str(), cmd.str(),
"Copying OS X Content $out", "Copying OS X Content $out",
"Rule for copying OS X bundle content file." "Rule for copying OS X bundle content file.",
/*depfile*/ "", /*depfile*/ "",
/*rspfile*/ ""); /*deptype*/ "",
/*rspfile*/ "",
/*rspcontent*/ "",
/*restat*/ false,
/*generator*/ false);
} }
void void
@ -320,6 +333,7 @@ void cmGlobalNinjaGenerator::WriteRule(std::ostream& os,
const std::string& description, const std::string& description,
const std::string& comment, const std::string& comment,
const std::string& depfile, const std::string& depfile,
const std::string& deptype,
const std::string& rspfile, const std::string& rspfile,
const std::string& rspcontent, const std::string& rspcontent,
bool restat, bool restat,
@ -355,6 +369,13 @@ void cmGlobalNinjaGenerator::WriteRule(std::ostream& os,
os << "depfile = " << depfile << "\n"; os << "depfile = " << depfile << "\n";
} }
// Write the deptype if any.
if (!deptype.empty())
{
cmGlobalNinjaGenerator::Indent(os, 1);
os << "deps = " << deptype << "\n";
}
// Write the command. // Write the command.
cmGlobalNinjaGenerator::Indent(os, 1); cmGlobalNinjaGenerator::Indent(os, 1);
os << "command = " << command << "\n"; os << "command = " << command << "\n";
@ -583,6 +604,7 @@ void cmGlobalNinjaGenerator::AddRule(const std::string& name,
const std::string& description, const std::string& description,
const std::string& comment, const std::string& comment,
const std::string& depfile, const std::string& depfile,
const std::string& deptype,
const std::string& rspfile, const std::string& rspfile,
const std::string& rspcontent, const std::string& rspcontent,
bool restat, bool restat,
@ -601,6 +623,7 @@ void cmGlobalNinjaGenerator::AddRule(const std::string& name,
description, description,
comment, comment,
depfile, depfile,
deptype,
rspfile, rspfile,
rspcontent, rspcontent,
restat, restat,
@ -1089,6 +1112,7 @@ void cmGlobalNinjaGenerator::WriteTargetRebuildManifest(std::ostream& os)
"Re-running CMake...", "Re-running CMake...",
"Rule for re-running cmake.", "Rule for re-running cmake.",
/*depfile=*/ "", /*depfile=*/ "",
/*deptype=*/ "",
/*rspfile=*/ "", /*rspfile=*/ "",
/*rspcontent*/ "", /*rspcontent*/ "",
/*restat=*/ false, /*restat=*/ false,
@ -1142,6 +1166,7 @@ void cmGlobalNinjaGenerator::WriteTargetClean(std::ostream& os)
"Cleaning all built files...", "Cleaning all built files...",
"Rule for cleaning all built files.", "Rule for cleaning all built files.",
/*depfile=*/ "", /*depfile=*/ "",
/*deptype=*/ "",
/*rspfile=*/ "", /*rspfile=*/ "",
/*rspcontent*/ "", /*rspcontent*/ "",
/*restat=*/ false, /*restat=*/ false,
@ -1164,6 +1189,7 @@ void cmGlobalNinjaGenerator::WriteTargetHelp(std::ostream& os)
"All primary targets available:", "All primary targets available:",
"Rule for printing all primary targets available.", "Rule for printing all primary targets available.",
/*depfile=*/ "", /*depfile=*/ "",
/*deptype=*/ "",
/*rspfile=*/ "", /*rspfile=*/ "",
/*rspcontent*/ "", /*rspcontent*/ "",
/*restat=*/ false, /*restat=*/ false,

View File

@ -64,6 +64,7 @@ public:
static std::string EncodeIdent(const std::string &ident, std::ostream &vars); static std::string EncodeIdent(const std::string &ident, std::ostream &vars);
static std::string EncodeLiteral(const std::string &lit); static std::string EncodeLiteral(const std::string &lit);
static std::string EncodePath(const std::string &path); static std::string EncodePath(const std::string &path);
static std::string EncodeDepfileSpace(const std::string &path);
/** /**
* Write the given @a comment to the output stream @a os. It * Write the given @a comment to the output stream @a os. It
@ -104,7 +105,7 @@ public:
const std::string& comment, const std::string& comment,
const cmNinjaDeps& outputs, const cmNinjaDeps& outputs,
const cmNinjaDeps& deps = cmNinjaDeps(), const cmNinjaDeps& deps = cmNinjaDeps(),
const cmNinjaDeps& orderOnlyDeps = cmNinjaDeps()); const cmNinjaDeps& orderOnly = cmNinjaDeps());
void WriteMacOSXContentBuild(const std::string& input, void WriteMacOSXContentBuild(const std::string& input,
const std::string& output); const std::string& output);
@ -120,6 +121,7 @@ public:
const std::string& description, const std::string& description,
const std::string& comment, const std::string& comment,
const std::string& depfile, const std::string& depfile,
const std::string& deptype,
const std::string& rspfile, const std::string& rspfile,
const std::string& rspcontent, const std::string& rspcontent,
bool restat, bool restat,
@ -239,11 +241,12 @@ public:
const std::string& command, const std::string& command,
const std::string& description, const std::string& description,
const std::string& comment, const std::string& comment,
const std::string& depfile = "", const std::string& depfile,
const std::string& rspfile = "", const std::string& deptype,
const std::string& rspcontent = "", const std::string& rspfile,
bool restat = false, const std::string& rspcontent,
bool generator = false); bool restat,
bool generator);
bool HasRule(const std::string& name); bool HasRule(const std::string& name);

View File

@ -48,8 +48,22 @@ void cmLocalNinjaGenerator::Generate()
this->WriteProcessedMakefile(this->GetRulesFileStream()); this->WriteProcessedMakefile(this->GetRulesFileStream());
#endif #endif
// We do that only once for the top CMakeLists.txt file.
if(this->isRootMakefile())
{
this->WriteBuildFileTop(); this->WriteBuildFileTop();
const std::string showIncludesPrefix = this->GetMakefile()
->GetSafeDefinition("CMAKE_CL_SHOWINCLUDES_PREFIX");
if (!showIncludesPrefix.empty())
{
cmGlobalNinjaGenerator::WriteComment(this->GetRulesFileStream(),
"localized /showIncludes string");
this->GetRulesFileStream()
<< "msvc_deps_prefix = " << showIncludesPrefix << "\n\n";
}
}
cmTargets& targets = this->GetMakefile()->GetTargets(); cmTargets& targets = this->GetMakefile()->GetTargets();
for(cmTargets::iterator t = targets.begin(); t != targets.end(); ++t) for(cmTargets::iterator t = targets.begin(); t != targets.end(); ++t)
{ {
@ -163,10 +177,6 @@ bool cmLocalNinjaGenerator::isRootMakefile() const
void cmLocalNinjaGenerator::WriteBuildFileTop() void cmLocalNinjaGenerator::WriteBuildFileTop()
{ {
// We do that only once for the top CMakeLists.txt file.
if(!this->isRootMakefile())
return;
// For the build file. // For the build file.
this->WriteProjectHeader(this->GetBuildFileStream()); this->WriteProjectHeader(this->GetBuildFileStream());
this->WriteNinjaFilesInclusion(this->GetBuildFileStream()); this->WriteNinjaFilesInclusion(this->GetBuildFileStream());

View File

@ -261,8 +261,11 @@ cmNinjaNormalTargetGenerator
description.str(), description.str(),
comment.str(), comment.str(),
/*depfile*/ "", /*depfile*/ "",
/*deptype*/ "",
rspfile, rspfile,
rspcontent); rspcontent,
/*restat*/ false,
/*generator*/ false);
} }
if (this->TargetNameOut != this->TargetNameReal && if (this->TargetNameOut != this->TargetNameReal &&
@ -277,14 +280,28 @@ cmNinjaNormalTargetGenerator
" -E cmake_symlink_executable" " -E cmake_symlink_executable"
" $in $out && $POST_BUILD", " $in $out && $POST_BUILD",
"Creating executable symlink $out", "Creating executable symlink $out",
"Rule for creating executable symlink."); "Rule for creating "
"executable symlink.",
/*depfile*/ "",
/*deptype*/ "",
/*rspfile*/ "",
/*rspcontent*/ "",
/*restat*/ false,
/*generator*/ false);
else else
this->GetGlobalGenerator()->AddRule("CMAKE_SYMLINK_LIBRARY", this->GetGlobalGenerator()->AddRule("CMAKE_SYMLINK_LIBRARY",
cmakeCommand + cmakeCommand +
" -E cmake_symlink_library" " -E cmake_symlink_library"
" $in $SONAME $out && $POST_BUILD", " $in $SONAME $out && $POST_BUILD",
"Creating library symlink $out", "Creating library symlink $out",
"Rule for creating library symlink."); "Rule for creating "
"library symlink.",
/*depfile*/ "",
/*deptype*/ "",
/*rspfile*/ "",
/*rspcontent*/ "",
/*restat*/ false,
/*generator*/ false);
} }
} }

View File

@ -187,6 +187,21 @@ cmNinjaTargetGenerator::ComputeFlagsForObject(cmSourceFile *source,
return flags; return flags;
} }
bool cmNinjaTargetGenerator::needsDepFile(const std::string& lang)
{
cmMakefile* mf = this->GetMakefile();
const bool usingMSVC = std::string("MSVC") ==
(mf->GetDefinition("CMAKE_C_COMPILER_ID") ?
mf->GetSafeDefinition("CMAKE_C_COMPILER_ID") :
mf->GetSafeDefinition("CMAKE_CXX_COMPILER_ID"));
return !usingMSVC || lang == "RC";
}
// TODO: Refactor with // TODO: Refactor with
// void cmMakefileTargetGenerator::WriteTargetLanguageFlags(). // void cmMakefileTargetGenerator::WriteTargetLanguageFlags().
std::string std::string
@ -331,77 +346,75 @@ cmNinjaTargetGenerator
void void
cmNinjaTargetGenerator cmNinjaTargetGenerator
::WriteCompileRule(const std::string& language) ::WriteCompileRule(const std::string& lang)
{ {
cmLocalGenerator::RuleVariables vars; cmLocalGenerator::RuleVariables vars;
vars.RuleLauncher = "RULE_LAUNCH_COMPILE"; vars.RuleLauncher = "RULE_LAUNCH_COMPILE";
vars.CMTarget = this->GetTarget(); vars.CMTarget = this->GetTarget();
std::string lang = language;
vars.Language = lang.c_str(); vars.Language = lang.c_str();
vars.Source = "$in"; vars.Source = "$in";
vars.Object = "$out"; vars.Object = "$out";
std::string flags = "$FLAGS";
vars.Defines = "$DEFINES"; vars.Defines = "$DEFINES";
vars.TargetPDB = "$TARGET_PDB"; vars.TargetPDB = "$TARGET_PDB";
vars.ObjectDir = "$OBJECT_DIR"; vars.ObjectDir = "$OBJECT_DIR";
cmMakefile* mf = this->GetMakefile(); cmMakefile* mf = this->GetMakefile();
bool useClDeps = false; const bool usingMSVC = std::string("MSVC") ==
std::string clBinary; (mf->GetDefinition("CMAKE_C_COMPILER_ID") ?
std::string clDepsBinary; mf->GetSafeDefinition("CMAKE_C_COMPILER_ID") :
std::string clShowPrefix; mf->GetSafeDefinition("CMAKE_CXX_COMPILER_ID"));
if (lang == "C" || lang == "CXX" || lang == "RC")
// Tell ninja dependency format so all deps can be loaded into a database
std::string deptype;
std::string depfile;
std::string cldeps;
std::string flags = "$FLAGS";
if (usingMSVC)
{ {
clDepsBinary = mf->GetSafeDefinition("CMAKE_CMCLDEPS_EXECUTABLE"); if (!mf->GetIsSourceFileTryCompile() && lang == "RC")
if (!clDepsBinary.empty() && !mf->GetIsSourceFileTryCompile())
{ {
clShowPrefix = mf->GetSafeDefinition("CMAKE_CL_SHOWINCLUDE_PREFIX"); deptype = "gcc";
clBinary = mf->GetDefinition("CMAKE_C_COMPILER") ? depfile = "$DEP_FILE";
const std::string cl = mf->GetDefinition("CMAKE_C_COMPILER") ?
mf->GetSafeDefinition("CMAKE_C_COMPILER") : mf->GetSafeDefinition("CMAKE_C_COMPILER") :
mf->GetSafeDefinition("CMAKE_CXX_COMPILER"); mf->GetSafeDefinition("CMAKE_CXX_COMPILER");
if (!clBinary.empty() && !clShowPrefix.empty()) cldeps = "\"";
cldeps += mf->GetSafeDefinition("CMAKE_CMCLDEPS_EXECUTABLE");
cldeps += "\" " + lang + " $in \"$DEP_FILE\" $out \"";
cldeps += mf->GetSafeDefinition("CMAKE_CL_SHOWINCLUDES_PREFIX");
cldeps += "\" \"" + cl + "\" ";
}
else
{ {
useClDeps = true; deptype = "msvc";
const std::string quote = " \""; depfile = "";
clBinary = quote + clBinary + "\" "; flags += " /showIncludes";
clDepsBinary = quote + clDepsBinary + "\" ";
clShowPrefix = quote + clShowPrefix + "\" ";
vars.DependencyFile = "$DEP_FILE";
} }
} }
} else
{
deptype = "gcc";
std::string depfile;
std::string depfileFlagsName = "CMAKE_DEPFILE_FLAGS_" + language;
const char *depfileFlags = mf->GetDefinition(depfileFlagsName.c_str());
if (depfileFlags || useClDeps) {
std::string depFlagsStr = depfileFlags ? depfileFlags : "";
depfile = "$DEP_FILE"; depfile = "$DEP_FILE";
cmSystemTools::ReplaceString(depFlagsStr, "<DEPFILE>", "\"$DEP_FILE\""); const std::string flagsName = "CMAKE_DEPFILE_FLAGS_" + lang;
cmSystemTools::ReplaceString(depFlagsStr, "<OBJECT>", "$out"); std::string depfileFlags = mf->GetSafeDefinition(flagsName.c_str());
cmSystemTools::ReplaceString(depFlagsStr, "<CMAKE_C_COMPILER>", cmSystemTools::ReplaceString(depfileFlags, "<DEPFILE>", "$DEP_FILE");
cmSystemTools::ReplaceString(depfileFlags, "<OBJECT>", "$out");
cmSystemTools::ReplaceString(depfileFlags, "<CMAKE_C_COMPILER>",
mf->GetDefinition("CMAKE_C_COMPILER")); mf->GetDefinition("CMAKE_C_COMPILER"));
flags += " " + depFlagsStr; flags += " " + depfileFlags;
} }
vars.Flags = flags.c_str();
vars.Flags = flags.c_str();
vars.DependencyFile = depfile.c_str();
// Rule for compiling object file. // Rule for compiling object file.
std::string compileCmdVar = "CMAKE_"; const std::string cmdVar = std::string("CMAKE_") + lang + "_COMPILE_OBJECT";
compileCmdVar += language; std::string compileCmd = mf->GetRequiredDefinition(cmdVar.c_str());
compileCmdVar += "_COMPILE_OBJECT";
std::string compileCmd = mf->GetRequiredDefinition(compileCmdVar.c_str());
std::vector<std::string> compileCmds; std::vector<std::string> compileCmds;
cmSystemTools::ExpandListArgument(compileCmd, compileCmds); cmSystemTools::ExpandListArgument(compileCmd, compileCmds);
if(useClDeps) compileCmds.front().insert(0, cldeps);
{
std::string cmdPrefix = clDepsBinary + lang + " $in \"$DEP_FILE\" $out " +
clShowPrefix + clBinary;
compileCmds.front().insert(0, cmdPrefix);
}
for (std::vector<std::string>::iterator i = compileCmds.begin(); for (std::vector<std::string>::iterator i = compileCmds.begin();
i != compileCmds.end(); ++i) i != compileCmds.end(); ++i)
@ -413,14 +426,19 @@ cmNinjaTargetGenerator
// Write the rule for compiling file of the given language. // Write the rule for compiling file of the given language.
cmOStringStream comment; cmOStringStream comment;
comment << "Rule for compiling " << language << " files."; comment << "Rule for compiling " << lang << " files.";
cmOStringStream description; cmOStringStream description;
description << "Building " << language << " object $out"; description << "Building " << lang << " object $out";
this->GetGlobalGenerator()->AddRule(this->LanguageCompilerRule(language), this->GetGlobalGenerator()->AddRule(this->LanguageCompilerRule(lang),
cmdLine, cmdLine,
description.str(), description.str(),
comment.str(), comment.str(),
depfile); depfile,
deptype,
/*rspfile*/ "",
/*rspcontent*/ "",
/*restat*/ false,
/*generator*/ false);
} }
void void
@ -540,7 +558,10 @@ 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);
vars["DEP_FILE"] = objectFileName + ".d";; if (needsDepFile(language)) {
vars["DEP_FILE"] =
cmGlobalNinjaGenerator::EncodeDepfileSpace(objectFileName + ".d");
}
EnsureParentDirectoryExists(objectFileName); EnsureParentDirectoryExists(objectFileName);
std::string objectDir = cmSystemTools::GetFilenamePath(objectFileName); std::string objectDir = cmSystemTools::GetFilenamePath(objectFileName);

View File

@ -42,6 +42,8 @@ public:
std::string GetTargetName() const; std::string GetTargetName() const;
bool needsDepFile(const std::string& lang);
protected: protected:
bool SetMsvcTargetPdbVariable(cmNinjaVars&) const; bool SetMsvcTargetPdbVariable(cmNinjaVars&) const;