Commit 565744bd authored by David Cole's avatar David Cole Committed by Kitware Robot

Merge topic 'ninja-cldeps'

eb410e8d Ninja: disable cldeps for bcc32, it's too old, and ninja would also not build
5ead31da Ninja: try work around for bcc32 bug
1333b576 Ninja: build server fixes
9081e3a1 remove warning about unused parameter
f430bea1 Ninja: maybe this fixes the bcc32 build
f2c12887 Ninja: msvc6 for-scoping
44b9bbc8 Ninja: build with old msvc versions
57156a5d Ninja: build server fixes
f1abdce1 Ninja: some bytes of the rc files couldn't be piped correctly
2de963d9 Ninja: don't remove space between command and parameters
50b6f33d Ninja: build cmcldeps with mingw
c05653e1 Ninja: try to make GetProcessId visible
ab245ff3 Ninja: but cl supports /nologo ...
bf58e9ad Ninja: no /nologo option in old rc.exe
2fb07fc4 Ninja: Eclipse and KDevelop fixes for ninja
518c0658 Ninja: don't pollute build dir with preprocessed rc files
...
parents 8d198a71 eb410e8d
......@@ -48,3 +48,6 @@ SET(CMAKE_C_HAS_ISYSROOT "@CMAKE_C_HAS_ISYSROOT@")
SET(CMAKE_C_IMPLICIT_LINK_LIBRARIES "@CMAKE_C_IMPLICIT_LINK_LIBRARIES@")
SET(CMAKE_C_IMPLICIT_LINK_DIRECTORIES "@CMAKE_C_IMPLICIT_LINK_DIRECTORIES@")
@SET_CMAKE_CMCLDEPS_EXECUTABLE@
@SET_CMAKE_CL_SHOWINCLUDE_PREFIX@
......@@ -49,3 +49,6 @@ SET(CMAKE_CXX_HAS_ISYSROOT "@CMAKE_CXX_HAS_ISYSROOT@")
SET(CMAKE_CXX_IMPLICIT_LINK_LIBRARIES "@CMAKE_CXX_IMPLICIT_LINK_LIBRARIES@")
SET(CMAKE_CXX_IMPLICIT_LINK_DIRECTORIES "@CMAKE_CXX_IMPLICIT_LINK_DIRECTORIES@")
@SET_CMAKE_CMCLDEPS_EXECUTABLE@
@SET_CMAKE_CL_SHOWINCLUDE_PREFIX@
#=============================================================================
# Copyright 2012 Kitware, Inc.
#
# Distributed under the OSI-approved BSD License (the "License");
# see accompanying file Copyright.txt for details.
#
# This software is distributed WITHOUT ANY WARRANTY; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the License for more information.
#=============================================================================
# (To distribute this file outside of CMake, substitute the full
# License text for the above reference.)
#
# When using Ninja cl.exe is wrapped by cmcldeps to extract the included
# headers for dependency tracking.
#
# cmcldeps path is set, and cmcldeps needs to know the localized string
# 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)
STRING(REPLACE "cmake.exe" "cmcldeps.exe" CMAKE_CMCLDEPS_EXECUTABLE ${CMAKE_COMMAND})
SET(showdir ${CMAKE_BINARY_DIR}/CMakeFiles/ShowIncludes)
FILE(WRITE ${showdir}/foo.h "\n")
FILE(WRITE ${showdir}/main.c "#include \"foo.h\" \nint main(){}\n")
EXECUTE_PROCESS(COMMAND ${CMAKE_C_COMPILER} /nologo /showIncludes ${showdir}/main.c
WORKING_DIRECTORY ${showdir} OUTPUT_VARIABLE showOut)
STRING(REPLACE main.c "" showOut1 ${showOut})
STRING(REPLACE "/" "\\" header1 ${showdir}/foo.h)
STRING(TOLOWER ${header1} header2)
STRING(REPLACE ${header2} "" showOut2 ${showOut1})
STRING(REPLACE "\n" "" showOut3 ${showOut2})
SET(SET_CMAKE_CMCLDEPS_EXECUTABLE "SET(CMAKE_CMCLDEPS_EXECUTABLE \"${CMAKE_CMCLDEPS_EXECUTABLE}\")")
SET(SET_CMAKE_CL_SHOWINCLUDE_PREFIX "SET(CMAKE_CL_SHOWINCLUDE_PREFIX \"${showOut3}\")")
ENDIF()
......@@ -165,9 +165,7 @@ ENDIF (CMAKE_CROSSCOMPILING
AND "${CMAKE_C_COMPILER_ID}" MATCHES "GNU"
AND NOT _CMAKE_TOOLCHAIN_PREFIX)
INCLUDE(${CMAKE_ROOT}/Modules/CMakeClDeps.cmake)
INCLUDE(CMakeFindBinUtils)
IF(MSVC_C_ARCHITECTURE_ID)
SET(SET_MSVC_C_ARCHITECTURE_ID
......
......@@ -173,6 +173,7 @@ ENDIF (CMAKE_CROSSCOMPILING
AND "${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU"
AND NOT _CMAKE_TOOLCHAIN_PREFIX)
INCLUDE(${CMAKE_ROOT}/Modules/CMakeClDeps.cmake)
INCLUDE(CMakeFindBinUtils)
IF(MSVC_CXX_ARCHITECTURE_ID)
SET(SET_MSVC_CXX_ARCHITECTURE_ID
......
......@@ -383,6 +383,11 @@ IF(CMAKE_ENABLE_NINJA)
cmNinjaUtilityTargetGenerator.h
)
ADD_DEFINITIONS(-DCMAKE_USE_NINJA)
IF(WIN32 AND NOT CYGWIN AND NOT BORLAND)
SET_SOURCE_FILES_PROPERTIES(cmcldeps.cxx PROPERTIES COMPILE_DEFINITIONS _WIN32_WINNT=0x0501)
ADD_EXECUTABLE(cmcldeps cmcldeps.cxx)
INSTALL_TARGETS(/bin cmcldeps)
ENDIF()
ELSE()
MESSAGE(STATUS "Ninja generator disabled, enable it with -DCMAKE_ENABLE_NINJA=ON")
ENDIF()
......
......@@ -33,6 +33,9 @@ cmExtraEclipseCDT4Generator
this->SupportedGlobalGenerators.push_back("NMake Makefiles");
this->SupportedGlobalGenerators.push_back("MinGW Makefiles");
// this->SupportedGlobalGenerators.push_back("MSYS Makefiles");
#endif
#ifdef CMAKE_USE_NINJA
this->SupportedGlobalGenerators.push_back("Ninja");
#endif
this->SupportedGlobalGenerators.push_back("Unix Makefiles");
......@@ -1070,9 +1073,8 @@ void cmExtraEclipseCDT4Generator::CreateCProjectFile() const
}
//insert rules for compiling, preprocessing and assembling individual files
cmLocalUnixMakefileGenerator3* lumg=(cmLocalUnixMakefileGenerator3*)*it;
std::vector<std::string> objectFileTargets;
lumg->GetIndividualFileTargets(objectFileTargets);
(*it)->GetIndividualFileTargets(objectFileTargets);
for(std::vector<std::string>::const_iterator fit=objectFileTargets.begin();
fit != objectFileTargets.end();
++fit)
......
......@@ -44,6 +44,9 @@ cmGlobalKdevelopGenerator::cmGlobalKdevelopGenerator()
:cmExternalMakefileProjectGenerator()
{
this->SupportedGlobalGenerators.push_back("Unix Makefiles");
#ifdef CMAKE_USE_NINJA
this->SupportedGlobalGenerators.push_back("Ninja");
#endif
}
void cmGlobalKdevelopGenerator::Generate()
......
......@@ -43,12 +43,13 @@ void cmGlobalNinjaGenerator::WriteComment(std::ostream& os,
std::string replace = comment;
std::string::size_type lpos = 0;
std::string::size_type rpos;
os << "\n#############################################\n";
while((rpos = replace.find('\n', lpos)) != std::string::npos)
{
os << "# " << replace.substr(lpos, rpos - lpos) << "\n";
lpos = rpos + 1;
}
os << "# " << replace.substr(lpos) << "\n";
os << "# " << replace.substr(lpos) << "\n\n";
}
static bool IsIdentChar(char c)
......@@ -176,7 +177,8 @@ void cmGlobalNinjaGenerator::WriteBuild(std::ostream& os,
// check if a response file rule should be used
const std::string args = arguments.str();
if (cmdLineLimit > 0 && args.size() > (size_t)cmdLineLimit)
if (cmdLineLimit > 0 &&
(args.size() + + builds.str().size()) > (size_t)cmdLineLimit)
builds << "_RSPFILE";
os << builds.str() << args;
......@@ -318,6 +320,8 @@ void cmGlobalNinjaGenerator::WriteRule(std::ostream& os,
cmGlobalNinjaGenerator::Indent(os, 1);
os << "generator = 1\n";
}
os << "\n";
}
void cmGlobalNinjaGenerator::WriteVariable(std::ostream& os,
......@@ -380,6 +384,7 @@ cmGlobalNinjaGenerator::cmGlobalNinjaGenerator()
this->FindMakeProgramFile = "CMakeNinjaFindMake.cmake";
}
//----------------------------------------------------------------------------
// Virtual public methods.
......@@ -458,9 +463,8 @@ void cmGlobalNinjaGenerator
else if(*l == "RC")
{
// check if mingw is used
const char* cc = mf->GetDefinition("CMAKE_C_COMPILER");
if(cc && std::string(cc).find("gcc.exe") != std::string::npos)
{
if(mf->IsOn("CMAKE_COMPILER_IS_MINGW"))
{
UsingMinGW = true;
std::string rc = cmSystemTools::FindProgram("windres");
if(rc.empty())
......@@ -470,7 +474,7 @@ void cmGlobalNinjaGenerator
}
this->cmGlobalGenerator::EnableLanguage(language, mf, optional);
this->ResolveLanguageCompiler(*l, mf, optional);
}
}
}
bool cmGlobalNinjaGenerator::UsingMinGW = false;
......@@ -538,7 +542,9 @@ void cmGlobalNinjaGenerator::AddRule(const std::string& name,
{
// Do not add the same rule twice.
if (this->HasRule(name))
{
return;
}
this->Rules.insert(name);
cmGlobalNinjaGenerator::WriteRule(*this->RulesFileStream,
......@@ -818,7 +824,7 @@ void cmGlobalNinjaGenerator::AddTargetAlias(const std::string& alias,
// Insert the alias into the map. If the alias was already present in the
// map and referred to another target, mark it as ambiguous.
std::pair<TargetAliasMap::iterator, bool> newAlias =
TargetAliases.insert(make_pair(alias, target));
TargetAliases.insert(std::make_pair(alias, target));
if (newAlias.second && newAlias.first->second != target)
newAlias.first->second = 0;
}
......@@ -922,11 +928,22 @@ void cmGlobalNinjaGenerator::WriteTargetRebuildManifest(std::ostream& os)
cmNinjaDeps());
}
std::string cmGlobalNinjaGenerator::ninjaCmd() const
{
cmLocalGenerator* lgen = this->LocalGenerators[0];
if (lgen) {
return lgen->ConvertToOutputFormat(
lgen->GetMakefile()->GetRequiredDefinition("CMAKE_MAKE_PROGRAM"),
cmLocalGenerator::SHELL);
}
return "ninja";
}
void cmGlobalNinjaGenerator::WriteTargetClean(std::ostream& os)
{
WriteRule(*this->RulesFileStream,
"CLEAN",
"ninja -t clean",
(ninjaCmd() + " -t clean").c_str(),
"Cleaning all built files...",
"Rule for cleaning all built files.",
/*depfile=*/ "",
......@@ -947,7 +964,7 @@ void cmGlobalNinjaGenerator::WriteTargetHelp(std::ostream& os)
{
WriteRule(*this->RulesFileStream,
"HELP",
"ninja -t targets",
(ninjaCmd() + " -t tagets").c_str(),
"All primary targets available:",
"Rule for printing all primary targets available.",
/*depfile=*/ "",
......
......@@ -16,6 +16,8 @@
# include "cmGlobalGenerator.h"
# include "cmNinjaTypes.h"
//#define NINJA_GEN_VERBOSE_FILES
class cmLocalGenerator;
class cmGeneratedFileStream;
class cmGeneratorTarget;
......@@ -145,6 +147,9 @@ public:
const cmNinjaDeps& targets,
const std::string& comment = "");
static bool IsMinGW() { return UsingMinGW; }
public:
/// Default constructor.
cmGlobalNinjaGenerator();
......@@ -312,6 +317,8 @@ private:
ASD.insert(deps.begin(), deps.end());
}
std::string ninjaCmd() const;
private:
/// The file containing the build statement. (the relation ship of the
/// compilation DAG).
......@@ -346,6 +353,7 @@ private:
static cmLocalGenerator* LocalGenerator;
static bool UsingMinGW;
};
#endif // ! cmGlobalNinjaGenerator_h
......@@ -872,6 +872,13 @@ cmLocalGenerator::ExpandRuleVariable(std::string const& variable,
return replaceValues.TargetPDB;
}
}
if(replaceValues.DependencyFile )
{
if(variable == "DEP_FILE")
{
return replaceValues.DependencyFile;
}
}
if(replaceValues.Target)
{
......
......@@ -205,6 +205,10 @@ public:
/** Compute the language used to compile the given source file. */
const char* GetSourceFileLanguage(const cmSourceFile& source);
// Fill the vector with the target names for the object files,
// preprocessed files and assembly files.
virtual void GetIndividualFileTargets(std::vector<std::string>&) {}
// Create a struct to hold the varibles passed into
// ExpandRuleVariables
struct RuleVariables
......@@ -236,6 +240,7 @@ public:
const char* LanguageCompileFlags;
const char* Defines;
const char* RuleLauncher;
const char* DependencyFile;
};
/** Set whether to treat conversions to SHELL as a link script shell. */
......
......@@ -46,7 +46,9 @@ void cmLocalNinjaGenerator::Generate()
this->SetConfigName();
this->WriteProcessedMakefile(this->GetBuildFileStream());
#ifdef NINJA_GEN_VERBOSE_FILES
this->WriteProcessedMakefile(this->GetRulesFileStream());
#endif
this->WriteBuildFileTop();
......
......@@ -55,21 +55,6 @@ cmNinjaNormalTargetGenerator::~cmNinjaNormalTargetGenerator()
{
}
void
cmNinjaNormalTargetGenerator
::EnsureDirectoryExists(const std::string& dir)
{
cmSystemTools::MakeDirectory(dir.c_str());
}
void
cmNinjaNormalTargetGenerator
::EnsureParentDirectoryExists(const std::string& path)
{
EnsureDirectoryExists(cmSystemTools::GetParentDirectory(path.c_str()));
}
void cmNinjaNormalTargetGenerator::Generate()
{
if (!this->TargetLinkLanguage) {
......@@ -96,13 +81,11 @@ void cmNinjaNormalTargetGenerator::Generate()
#endif
this->WriteLinkStatement();
}
this->GetBuildFileStream() << "\n";
this->GetRulesFileStream() << "\n";
}
void cmNinjaNormalTargetGenerator::WriteLanguagesRules()
{
#ifdef NINJA_GEN_VERBOSE_FILES
cmGlobalNinjaGenerator::WriteDivider(this->GetRulesFileStream());
this->GetRulesFileStream()
<< "# Rules for each languages for "
......@@ -110,6 +93,7 @@ void cmNinjaNormalTargetGenerator::WriteLanguagesRules()
<< " target "
<< this->GetTargetName()
<< "\n\n";
#endif
std::set<cmStdString> languages;
this->GetTarget()->GetLanguages(languages);
......@@ -180,16 +164,8 @@ cmNinjaNormalTargetGenerator
responseFlag += rspfile;
vars.Objects = responseFlag.c_str();
}
std::string objdir =
this->GetLocalGenerator()->GetHomeRelativeOutputPath();
objdir += objdir.empty() ? "" : "/";
objdir += cmake::GetCMakeFilesDirectoryPostSlash();
objdir += this->GetTargetName();
objdir += ".dir";
objdir = this->GetLocalGenerator()->Convert(objdir.c_str(),
cmLocalGenerator::START_OUTPUT,
cmLocalGenerator::SHELL);
vars.ObjectDir = objdir.c_str();
vars.ObjectDir = "$OBJECT_DIR";
vars.Target = "$out";
vars.SONameFlag = "$SONAME_FLAG";
vars.TargetSOName = "$SONAME";
......@@ -402,13 +378,18 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement()
// Compute architecture specific link flags. Yes, these go into a different
// variable for executables, probably due to a mistake made when duplicating
// code between the Makefile executable and library generators.
this->GetLocalGenerator()
->AddArchitectureFlags(targetType == cmTarget::EXECUTABLE
std::string flags = (targetType == cmTarget::EXECUTABLE
? vars["FLAGS"]
: vars["ARCH_FLAGS"],
: vars["ARCH_FLAGS"]);
this->GetLocalGenerator()->AddArchitectureFlags(flags,
this->GetTarget(),
this->TargetLinkLanguage,
this->GetConfigName());
if (targetType == cmTarget::EXECUTABLE) {
vars["FLAGS"] = flags;
} else {
vars["ARCH_FLAGS"] = flags;
}
if (this->GetTarget()->HasSOName(this->GetConfigName())) {
vars["SONAME_FLAG"] =
this->GetMakefile()->GetSONameFlag(this->TargetLinkLanguage);
......@@ -434,10 +415,24 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement()
EnsureParentDirectoryExists(path);
}
path = this->GetLocalGenerator()->ConvertToOutputFormat(
this->GetTargetPDB().c_str(), cmLocalGenerator::SHELL);
vars["TARGET_PDB"] = path;
EnsureParentDirectoryExists(path);
// TODO move to GetTargetPDB
cmMakefile* mf = this->GetMakefile();
if (mf->GetDefinition("MSVC_C_ARCHITECTURE_ID") ||
mf->GetDefinition("MSVC_CXX_ARCHITECTURE_ID"))
{
path = this->GetTargetPDB();
vars["TARGET_PDB"] = this->GetLocalGenerator()->ConvertToOutputFormat(
ConvertToNinjaPath(path.c_str()).c_str(),
cmLocalGenerator::SHELL);
EnsureParentDirectoryExists(path);
}
if (mf->IsOn("CMAKE_COMPILER_IS_MINGW"))
{
path = GetTarget()->GetSupportDirectory();
vars["OBJECT_DIR"] = ConvertToNinjaPath(path.c_str());
EnsureDirectoryExists(path);
}
std::vector<cmCustomCommand> *cmdLists[3] = {
&this->GetTarget()->GetPreBuildCommands(),
......@@ -483,12 +478,13 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement()
symlinkVars["POST_BUILD"] = postBuildCmdLine;
}
int cmdLineLimit = -1;
int cmdLineLimit;
#ifdef _WIN32
cmdLineLimit = 8100;
cmdLineLimit = 8000;
#else
// TODO
cmdLineLimit = -1; // TODO
#endif
// Write the build statement for this target.
cmGlobalNinjaGenerator::WriteBuild(this->GetBuildFileStream(),
comment.str(),
......
......@@ -35,9 +35,6 @@ private:
void WriteObjectLibStatement();
std::vector<std::string> ComputeLinkCmd();
void EnsureDirectoryExists(const std::string& dir);
void EnsureParentDirectoryExists(const std::string& path);
private:
// Target name info.
std::string TargetNameOut;
......
......@@ -151,6 +151,8 @@ cmNinjaTargetGenerator::ComputeFlagsForObject(cmSourceFile *source,
language.c_str());
std::string includeFlags =
this->LocalGenerator->GetIncludeFlags(includes, language.c_str(), false);
if(cmGlobalNinjaGenerator::IsMinGW())
cmSystemTools::ReplaceString(includeFlags, "\\", "/");
this->LocalGenerator->AppendFlags(flags, includeFlags.c_str());
}
......@@ -298,7 +300,7 @@ std::string cmNinjaTargetGenerator::GetTargetPDB() const
targetFullPathPDB += this->Target->GetPDBName(this->GetConfigName());
}
return ConvertToNinjaPath(targetFullPathPDB.c_str());
return targetFullPathPDB.c_str();
}
......@@ -306,10 +308,11 @@ void
cmNinjaTargetGenerator
::WriteLanguageRules(const std::string& language)
{
#ifdef NINJA_GEN_VERBOSE_FILES
this->GetRulesFileStream()
<< "# Rules for language " << language << "\n\n";
#endif
this->WriteCompileRule(language);
this->GetRulesFileStream() << "\n";
}
void
......@@ -327,20 +330,45 @@ cmNinjaTargetGenerator
vars.Defines = "$DEFINES";
vars.TargetPDB = "$TARGET_PDB";
cmMakefile* mf = this->GetMakefile();
bool useClDeps = false;
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)
{
// 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")
{
useClDeps = true;
std::string qu = "\"";
clDepsBinary = qu + depsPtr + qu;
clShowPrefix = qu + showPtr + qu;
vars.DependencyFile = "$DEP_FILE";
}
}
}
std::string depfile;
std::string depfileFlagsName = "CMAKE_DEPFILE_FLAGS_" + language;
const char *depfileFlags =
this->GetMakefile()->GetDefinition(depfileFlagsName.c_str());
if (depfileFlags) {
std::string depfileFlagsStr = depfileFlags;
depfile = "$out.d";
cmSystemTools::ReplaceString(depfileFlagsStr, "<DEPFILE>",
depfile.c_str());
cmSystemTools::ReplaceString(depfileFlagsStr, "<OBJECT>",
"$out");
cmSystemTools::ReplaceString(depfileFlagsStr, "<CMAKE_C_COMPILER>",
this->GetMakefile()->GetDefinition("CMAKE_C_COMPILER"));
flags += " " + depfileFlagsStr;
const char *depfileFlags = mf->GetDefinition(depfileFlagsName.c_str());
if (depfileFlags || useClDeps) {
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 += " " + depFlagsStr;
}
vars.Flags = flags.c_str();
......@@ -349,8 +377,7 @@ cmNinjaTargetGenerator
std::string compileCmdVar = "CMAKE_";
compileCmdVar += language;
compileCmdVar += "_COMPILE_OBJECT";
std::string compileCmd =
this->GetMakefile()->GetRequiredDefinition(compileCmdVar.c_str());
std::string compileCmd = mf->GetRequiredDefinition(compileCmdVar.c_str());
std::vector<std::string> compileCmds;
cmSystemTools::ExpandListArgument(compileCmd, compileCmds);
......@@ -361,6 +388,14 @@ cmNinjaTargetGenerator
std::string cmdLine =
this->GetLocalGenerator()->BuildCommandLine(compileCmds);
if(useClDeps)
{
std::string cl = mf->GetDefinition("CMAKE_C_COMPILER");
cl = "\"" + cl + "\" ";
cmdLine = clDepsBinary + " " + lang + " $in \"$DEP_FILE\" $out "
+ clShowPrefix + " " + cl + cmdLine;
}
// Write the rule for compiling file of the given language.
cmOStringStream comment;
comment << "Rule for compiling " << language << " files.";
......@@ -481,8 +516,18 @@ cmNinjaTargetGenerator
cmNinjaVars vars;
vars["FLAGS"] = this->ComputeFlagsForObject(source, language);
vars["DEFINES"] = this->ComputeDefines(source, language);
vars["TARGET_PDB"] = this->GetLocalGenerator()->ConvertToOutputFormat(
this->GetTargetPDB().c_str(), cmLocalGenerator::SHELL);
vars["DEP_FILE"] = objectFileName + ".d";;
EnsureParentDirectoryExists(objectFileName);
// TODO move to GetTargetPDB
cmMakefile* mf = this->GetMakefile();
if (mf->GetDefinition("MSVC_C_ARCHITECTURE_ID") ||
mf->GetDefinition("MSVC_CXX_ARCHITECTURE_ID"))
{
vars["TARGET_PDB"] = this->GetLocalGenerator()->ConvertToOutputFormat(
ConvertToNinjaPath(GetTargetPDB().c_str()).c_str(),
cmLocalGenerator::SHELL);
}
if(this->Makefile->IsOn("CMAKE_EXPORT_COMPILE_COMMANDS"))
{
......@@ -563,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()));
}
......@@ -111,6 +111,9 @@ protected:
// Helper to add flag for windows .def file.
void AddModuleDefinitionFlag(std::string& flags);
void EnsureDirectoryExists(const std::string& dir);
void EnsureParentDirectoryExists(const std::string& path);
private:
cmTarget* Target;
cmGeneratorTarget* GeneratorTarget;
......
This diff is collapsed.
......@@ -28,6 +28,10 @@ function(help_xcode_depends)
endif(HELP_XCODE)
endfunction(help_xcode_depends)
if("${CMAKE_GENERATOR}" MATCHES "Ninja")
set(HELP_NINJA 1) # TODO Why is this needed?
endif()
# The Intel compiler causes the MSVC linker to crash during
# incremental linking, so avoid the /INCREMENTAL:YES flag.
if(WIN32 AND "${CMAKE_CXX_COMPILER_ID}" MATCHES "Intel")
......@@ -154,7 +158,7 @@ try_compile(RESULT
OUTPUT_VARIABLE OUTPUT)
# Xcode is in serious need of help here
if(HELP_XCODE)
if(HELP_XCODE OR HELP_NINJA)
try_compile(RESULT
${BuildDepends_BINARY_DIR}/Project
${BuildDepends_SOURCE_DIR}/Project
......@@ -165,7 +169,7 @@ if(HELP_XCODE)
${BuildDepends_SOURCE_DIR}/Project
testRebuild
OUTPUT_VARIABLE OUTPUT)
endif(HELP_XCODE)
endif()
message("Output from second build:\n${OUTPUT}")
if(NOT RESULT)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment