summaryrefslogtreecommitdiffstats
path: root/Source/cmMakefileTargetGenerator.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'Source/cmMakefileTargetGenerator.cxx')
-rw-r--r--Source/cmMakefileTargetGenerator.cxx414
1 files changed, 237 insertions, 177 deletions
diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx
index c3ca85d..403f6e6 100644
--- a/Source/cmMakefileTargetGenerator.cxx
+++ b/Source/cmMakefileTargetGenerator.cxx
@@ -21,6 +21,7 @@
#include "cmTarget.h"
#include "cmake.h"
#include "cmComputeLinkInformation.h"
+#include "cmCustomCommandGenerator.h"
#include "cmGeneratorExpression.h"
#include "cmMakefileExecutableTargetGenerator.h"
@@ -127,15 +128,16 @@ void cmMakefileTargetGenerator::CreateRuleFile()
//----------------------------------------------------------------------------
void cmMakefileTargetGenerator::WriteTargetBuildRules()
{
+ const std::string& config =
+ this->Makefile->GetSafeDefinition("CMAKE_BUILD_TYPE");
+
// write the custom commands for this target
// Look for files registered for cleaning in this directory.
if(const char* additional_clean_files =
this->Makefile->GetProperty
("ADDITIONAL_MAKE_CLEAN_FILES"))
{
- const char *config = this->Makefile->GetDefinition("CMAKE_BUILD_TYPE");
- cmListFileBacktrace lfbt;
- cmGeneratorExpression ge(lfbt);
+ cmGeneratorExpression ge;
cmsys::auto_ptr<cmCompiledGeneratorExpression> cge =
ge.Parse(additional_clean_files);
@@ -151,56 +153,55 @@ void cmMakefileTargetGenerator::WriteTargetBuildRules()
// First generate the object rule files. Save a list of all object
// files for this target.
- std::vector<cmSourceFile*> customCommands;
- this->GeneratorTarget->GetCustomCommands(customCommands);
- for(std::vector<cmSourceFile*>::const_iterator
+ std::vector<cmSourceFile const*> customCommands;
+ this->GeneratorTarget->GetCustomCommands(customCommands, config);
+ for(std::vector<cmSourceFile const*>::const_iterator
si = customCommands.begin();
si != customCommands.end(); ++si)
{
- cmCustomCommand const* cc = (*si)->GetCustomCommand();
- this->GenerateCustomRuleFile(*cc);
+ cmCustomCommandGenerator ccg(*(*si)->GetCustomCommand(),
+ this->ConfigName,
+ this->Makefile);
+ this->GenerateCustomRuleFile(ccg);
if (clean)
{
- const std::vector<std::string>& outputs = cc->GetOutputs();
+ const std::vector<std::string>& outputs = ccg.GetOutputs();
for(std::vector<std::string>::const_iterator o = outputs.begin();
o != outputs.end(); ++o)
{
this->CleanFiles.push_back
- (this->Convert(o->c_str(),
+ (this->Convert(*o,
cmLocalGenerator::START_OUTPUT,
cmLocalGenerator::UNCHANGED));
}
}
}
- std::vector<cmSourceFile*> headerSources;
- this->GeneratorTarget->GetHeaderSources(headerSources);
+ std::vector<cmSourceFile const*> headerSources;
+ this->GeneratorTarget->GetHeaderSources(headerSources, config);
this->OSXBundleGenerator->GenerateMacOSXContentStatements(
headerSources,
this->MacOSXContentGenerator);
- std::vector<cmSourceFile*> extraSources;
- this->GeneratorTarget->GetExtraSources(extraSources);
+ std::vector<cmSourceFile const*> extraSources;
+ this->GeneratorTarget->GetExtraSources(extraSources, config);
this->OSXBundleGenerator->GenerateMacOSXContentStatements(
extraSources,
this->MacOSXContentGenerator);
- std::vector<cmSourceFile*> externalObjects;
- this->GeneratorTarget->GetExternalObjects(externalObjects);
- for(std::vector<cmSourceFile*>::const_iterator
+ std::vector<cmSourceFile const*> externalObjects;
+ this->GeneratorTarget->GetExternalObjects(externalObjects, config);
+ for(std::vector<cmSourceFile const*>::const_iterator
si = externalObjects.begin();
si != externalObjects.end(); ++si)
{
this->ExternalObjects.push_back((*si)->GetFullPath());
}
- std::vector<cmSourceFile*> objectSources;
- this->GeneratorTarget->GetObjectSources(objectSources);
- for(std::vector<cmSourceFile*>::const_iterator
+ std::vector<cmSourceFile const*> objectSources;
+ this->GeneratorTarget->GetObjectSources(objectSources, config);
+ for(std::vector<cmSourceFile const*>::const_iterator
si = objectSources.begin(); si != objectSources.end(); ++si)
{
// Generate this object file's rule file.
this->WriteObjectRuleFiles(**si);
}
-
- // Add object library contents as external objects.
- this->GeneratorTarget->UseObjectLibraries(this->ExternalObjects);
}
//----------------------------------------------------------------------------
@@ -215,7 +216,7 @@ void cmMakefileTargetGenerator::WriteCommonCodeRules()
*this->BuildFileStream
<< "# Include any dependencies generated for this target.\n"
<< this->LocalGenerator->IncludeDirective << " " << root
- << this->Convert(dependFileNameFull.c_str(),
+ << this->Convert(dependFileNameFull,
cmLocalGenerator::HOME_OUTPUT,
cmLocalGenerator::MAKEFILE)
<< "\n\n";
@@ -226,7 +227,7 @@ void cmMakefileTargetGenerator::WriteCommonCodeRules()
*this->BuildFileStream
<< "# Include the progress variables for this target.\n"
<< this->LocalGenerator->IncludeDirective << " " << root
- << this->Convert(this->ProgressFileNameFull.c_str(),
+ << this->Convert(this->ProgressFileNameFull,
cmLocalGenerator::HOME_OUTPUT,
cmLocalGenerator::MAKEFILE)
<< "\n\n";
@@ -259,7 +260,7 @@ void cmMakefileTargetGenerator::WriteCommonCodeRules()
*this->BuildFileStream
<< "# Include the compile flags for this target's objects.\n"
<< this->LocalGenerator->IncludeDirective << " " << root
- << this->Convert(this->FlagFileNameFull.c_str(),
+ << this->Convert(this->FlagFileNameFull,
cmLocalGenerator::HOME_OUTPUT,
cmLocalGenerator::MAKEFILE)
<< "\n\n";
@@ -301,7 +302,7 @@ std::string cmMakefileTargetGenerator::GetFlags(const std::string &l)
// Add include directory flags.
this->LocalGenerator->
- AppendFlags(flags,this->GetFrameworkFlags(l).c_str());
+ AppendFlags(flags,this->GetFrameworkFlags(l));
// Add target-specific flags.
this->LocalGenerator->AddCompileOptions(flags, this->Target,
@@ -328,7 +329,7 @@ std::string cmMakefileTargetGenerator::GetDefines(const std::string &l)
// Add preprocessor definitions for this target and configuration.
this->LocalGenerator->AddCompileDefinitions(defines, this->Target,
- this->LocalGenerator->ConfigurationName.c_str());
+ this->LocalGenerator->ConfigurationName);
std::string definesString;
this->LocalGenerator->JoinDefines(defines, definesString, lang);
@@ -342,21 +343,22 @@ std::string cmMakefileTargetGenerator::GetDefines(const std::string &l)
void cmMakefileTargetGenerator::WriteTargetLanguageFlags()
{
// write language flags for target
- std::set<cmStdString> languages;
- this->Target->GetLanguages(languages);
+ std::set<std::string> languages;
+ this->Target->GetLanguages(languages,
+ this->Makefile->GetSafeDefinition("CMAKE_BUILD_TYPE"));
// put the compiler in the rules.make file so that if it changes
// things rebuild
- for(std::set<cmStdString>::const_iterator l = languages.begin();
+ for(std::set<std::string>::const_iterator l = languages.begin();
l != languages.end(); ++l)
{
- cmStdString compiler = "CMAKE_";
+ std::string compiler = "CMAKE_";
compiler += *l;
compiler += "_COMPILER";
- *this->FlagFileStream << "# compile " << l->c_str() << " with " <<
- this->Makefile->GetSafeDefinition(compiler.c_str()) << "\n";
+ *this->FlagFileStream << "# compile " << *l << " with " <<
+ this->Makefile->GetSafeDefinition(compiler) << "\n";
}
- for(std::set<cmStdString>::const_iterator l = languages.begin();
+ for(std::set<std::string>::const_iterator l = languages.begin();
l != languages.end(); ++l)
{
*this->FlagFileStream << *l << "_FLAGS = " << this->GetFlags(*l) << "\n\n";
@@ -369,7 +371,7 @@ void cmMakefileTargetGenerator::WriteTargetLanguageFlags()
//----------------------------------------------------------------------------
void
cmMakefileTargetGenerator::MacOSXContentGeneratorType::operator()
- (cmSourceFile& source, const char* pkgloc)
+ (cmSourceFile const& source, const char* pkgloc)
{
// Skip OS X content when not building a Framework or Bundle.
if(!this->Generator->GetTarget()->IsBundleOnApple())
@@ -388,9 +390,9 @@ cmMakefileTargetGenerator::MacOSXContentGeneratorType::operator()
output += "/";
output += cmSystemTools::GetFilenameName(input);
this->Generator->CleanFiles.push_back(
- this->Generator->Convert(output.c_str(),
+ this->Generator->Convert(output,
cmLocalGenerator::START_OUTPUT));
- output = this->Generator->Convert(output.c_str(),
+ output = this->Generator->Convert(output,
cmLocalGenerator::HOME_OUTPUT);
// Create a rule to copy the content into the bundle.
@@ -403,27 +405,29 @@ cmMakefileTargetGenerator::MacOSXContentGeneratorType::operator()
commands, copyEcho.c_str(),
cmLocalUnixMakefileGenerator3::EchoBuild);
std::string copyCommand = "$(CMAKE_COMMAND) -E copy ";
- copyCommand += this->Generator->Convert(input.c_str(),
+ copyCommand += this->Generator->Convert(input,
cmLocalGenerator::NONE,
cmLocalGenerator::SHELL);
copyCommand += " ";
- copyCommand += this->Generator->Convert(output.c_str(),
+ copyCommand += this->Generator->Convert(output,
cmLocalGenerator::NONE,
cmLocalGenerator::SHELL);
commands.push_back(copyCommand);
this->Generator->LocalGenerator->WriteMakeRule(
*this->Generator->BuildFileStream, 0,
- output.c_str(),
+ output,
depends, commands, false);
this->Generator->ExtraFiles.insert(output);
}
//----------------------------------------------------------------------------
-void cmMakefileTargetGenerator::WriteObjectRuleFiles(cmSourceFile& source)
+void cmMakefileTargetGenerator
+::WriteObjectRuleFiles(cmSourceFile const& source)
{
// Identify the language of the source file.
- const char* lang = this->LocalGenerator->GetSourceFileLanguage(source);
- if(!lang)
+ const std::string& lang =
+ this->LocalGenerator->GetSourceFileLanguage(source);
+ if(lang.empty())
{
// don't know anything about this file so skip it
return;
@@ -455,7 +459,7 @@ void cmMakefileTargetGenerator::WriteObjectRuleFiles(cmSourceFile& source)
// Create the directory containing the object file. This may be a
// subdirectory under the target's directory.
- std::string dir = cmSystemTools::GetFilenamePath(obj.c_str());
+ std::string dir = cmSystemTools::GetFilenamePath(obj);
cmSystemTools::MakeDirectory
(this->LocalGenerator->ConvertToFullPath(dir).c_str());
@@ -481,9 +485,9 @@ void cmMakefileTargetGenerator::WriteObjectRuleFiles(cmSourceFile& source)
objFullPath += "/";
objFullPath += obj;
objFullPath =
- this->Convert(objFullPath.c_str(), cmLocalGenerator::FULL);
+ this->Convert(objFullPath, cmLocalGenerator::FULL);
std::string srcFullPath =
- this->Convert(source.GetFullPath().c_str(), cmLocalGenerator::FULL);
+ this->Convert(source.GetFullPath(), cmLocalGenerator::FULL);
this->LocalGenerator->
AddImplicitDepends(*this->Target, lang,
objFullPath.c_str(),
@@ -493,7 +497,7 @@ void cmMakefileTargetGenerator::WriteObjectRuleFiles(cmSourceFile& source)
//----------------------------------------------------------------------------
void
cmMakefileTargetGenerator
-::AppendFortranFormatFlags(std::string& flags, cmSourceFile& source)
+::AppendFortranFormatFlags(std::string& flags, cmSourceFile const& source)
{
const char* srcfmt = source.GetProperty("Fortran_FORMAT");
cmLocalGenerator::FortranFormat format =
@@ -523,8 +527,8 @@ cmMakefileTargetGenerator
void
cmMakefileTargetGenerator
::WriteObjectBuildFile(std::string &obj,
- const char *lang,
- cmSourceFile& source,
+ const std::string& lang,
+ cmSourceFile const& source,
std::vector<std::string>& depends)
{
this->LocalGenerator->AppendRuleDepend(depends,
@@ -546,13 +550,13 @@ cmMakefileTargetGenerator
std::string langFlags = "$(";
langFlags += lang;
langFlags += "_FLAGS)";
- this->LocalGenerator->AppendFlags(flags, langFlags.c_str());
+ this->LocalGenerator->AppendFlags(flags, langFlags);
std::string configUpper =
cmSystemTools::UpperCase(this->LocalGenerator->ConfigurationName);
// Add Fortran format flags.
- if(strcmp(lang, "Fortran") == 0)
+ if(lang == "Fortran")
{
this->AppendFortranFormatFlags(flags, source);
}
@@ -584,7 +588,7 @@ cmMakefileTargetGenerator
std::string defPropName = "COMPILE_DEFINITIONS_";
defPropName += configUpper;
if(const char* config_compile_defs =
- source.GetProperty(defPropName.c_str()))
+ source.GetProperty(defPropName))
{
this->LocalGenerator->AppendDefines(defines, config_compile_defs);
*this->FlagFileStream
@@ -598,10 +602,10 @@ cmMakefileTargetGenerator
std::string sourceFile = source.GetFullPath();
if(this->LocalGenerator->UseRelativePaths)
{
- sourceFile = this->Convert(sourceFile.c_str(),
+ sourceFile = this->Convert(sourceFile,
cmLocalGenerator::START_OUTPUT);
}
- sourceFile = this->Convert(sourceFile.c_str(),
+ sourceFile = this->Convert(sourceFile,
cmLocalGenerator::NONE,
cmLocalGenerator::SHELL);
@@ -624,9 +628,11 @@ cmMakefileTargetGenerator
std::string targetOutPathReal;
std::string targetOutPathPDB;
+ std::string targetOutPathCompilePDB;
{
std::string targetFullPathReal;
std::string targetFullPathPDB;
+ std::string targetFullPathCompilePDB;
if(this->Target->GetType() == cmTarget::EXECUTABLE ||
this->Target->GetType() == cmTarget::STATIC_LIBRARY ||
this->Target->GetType() == cmTarget::SHARED_LIBRARY ||
@@ -638,30 +644,50 @@ cmMakefileTargetGenerator
targetFullPathPDB += "/";
targetFullPathPDB += this->Target->GetPDBName(this->ConfigName);
}
- targetOutPathReal = this->Convert(targetFullPathReal.c_str(),
+ if(this->Target->GetType() <= cmTarget::OBJECT_LIBRARY)
+ {
+ targetFullPathCompilePDB =
+ this->Target->GetCompilePDBPath(this->ConfigName);
+ if(targetFullPathCompilePDB.empty())
+ {
+ targetFullPathCompilePDB = this->Target->GetSupportDirectory() + "/";
+ }
+ }
+
+ targetOutPathReal = this->Convert(targetFullPathReal,
cmLocalGenerator::START_OUTPUT,
cmLocalGenerator::SHELL);
targetOutPathPDB =
- this->Convert(targetFullPathPDB.c_str(),cmLocalGenerator::NONE,
+ this->Convert(targetFullPathPDB,cmLocalGenerator::NONE,
+ cmLocalGenerator::SHELL);
+ targetOutPathCompilePDB =
+ this->Convert(targetFullPathCompilePDB,
+ cmLocalGenerator::START_OUTPUT,
cmLocalGenerator::SHELL);
}
cmLocalGenerator::RuleVariables vars;
vars.RuleLauncher = "RULE_LAUNCH_COMPILE";
vars.CMTarget = this->Target;
- vars.Language = lang;
+ vars.Language = lang.c_str();
vars.Target = targetOutPathReal.c_str();
vars.TargetPDB = targetOutPathPDB.c_str();
+ vars.TargetCompilePDB = targetOutPathCompilePDB.c_str();
vars.Source = sourceFile.c_str();
std::string shellObj =
- this->Convert(obj.c_str(),
+ this->Convert(obj,
cmLocalGenerator::NONE,
- cmLocalGenerator::SHELL).c_str();
+ cmLocalGenerator::SHELL);
vars.Object = shellObj.c_str();
std::string objectDir = this->Target->GetSupportDirectory();
- objectDir = this->Convert(objectDir.c_str(),
+ objectDir = this->Convert(objectDir,
cmLocalGenerator::START_OUTPUT,
cmLocalGenerator::SHELL);
vars.ObjectDir = objectDir.c_str();
+ std::string objectFileDir = cmSystemTools::GetFilenamePath(obj);
+ objectFileDir = this->Convert(objectFileDir,
+ cmLocalGenerator::START_OUTPUT,
+ cmLocalGenerator::SHELL);
+ vars.ObjectFileDir = objectFileDir.c_str();
vars.Flags = flags.c_str();
std::string definesString = "$(";
@@ -672,8 +698,7 @@ cmMakefileTargetGenerator
vars.Defines = definesString.c_str();
- bool lang_is_c_or_cxx = ((strcmp(lang, "C") == 0) ||
- (strcmp(lang, "CXX") == 0));
+ bool lang_is_c_or_cxx = ((lang == "C") || (lang == "CXX"));
// Construct the compile rules.
{
@@ -681,7 +706,7 @@ cmMakefileTargetGenerator
compileRuleVar += lang;
compileRuleVar += "_COMPILE_OBJECT";
std::string compileRule =
- this->Makefile->GetRequiredDefinition(compileRuleVar.c_str());
+ this->Makefile->GetRequiredDefinition(compileRuleVar);
std::vector<std::string> compileCommands;
cmSystemTools::ExpandListArgument(compileRule, compileCommands);
@@ -720,7 +745,7 @@ cmMakefileTargetGenerator
// Write the rule.
this->LocalGenerator->WriteMakeRule(*this->BuildFileStream, 0,
- relativeObj.c_str(),
+ relativeObj,
depends, commands, false);
// Check for extra outputs created by the compilation.
@@ -738,7 +763,7 @@ cmMakefileTargetGenerator
this->GenerateExtraOutput(eoi->c_str(), relativeObj.c_str(), false);
// Register this as an extra file to clean.
- this->CleanFiles.push_back(eoi->c_str());
+ this->CleanFiles.push_back(*eoi);
}
}
@@ -774,15 +799,15 @@ cmMakefileTargetGenerator
preprocessRuleVar += lang;
preprocessRuleVar += "_CREATE_PREPROCESSED_SOURCE";
if(const char* preprocessRule =
- this->Makefile->GetDefinition(preprocessRuleVar.c_str()))
+ this->Makefile->GetDefinition(preprocessRuleVar))
{
std::vector<std::string> preprocessCommands;
cmSystemTools::ExpandListArgument(preprocessRule, preprocessCommands);
std::string shellObjI =
- this->Convert(objI.c_str(),
+ this->Convert(objI,
cmLocalGenerator::NONE,
- cmLocalGenerator::SHELL).c_str();
+ cmLocalGenerator::SHELL);
vars.PreprocessedSource = shellObjI.c_str();
// Expand placeholders in the commands.
@@ -808,7 +833,7 @@ cmMakefileTargetGenerator
}
this->LocalGenerator->WriteMakeRule(*this->BuildFileStream, 0,
- relativeObjI.c_str(),
+ relativeObjI,
force_depends, commands, false);
}
@@ -831,15 +856,15 @@ cmMakefileTargetGenerator
assemblyRuleVar += lang;
assemblyRuleVar += "_CREATE_ASSEMBLY_SOURCE";
if(const char* assemblyRule =
- this->Makefile->GetDefinition(assemblyRuleVar.c_str()))
+ this->Makefile->GetDefinition(assemblyRuleVar))
{
std::vector<std::string> assemblyCommands;
cmSystemTools::ExpandListArgument(assemblyRule, assemblyCommands);
std::string shellObjS =
- this->Convert(objS.c_str(),
+ this->Convert(objS,
cmLocalGenerator::NONE,
- cmLocalGenerator::SHELL).c_str();
+ cmLocalGenerator::SHELL);
vars.AssemblySource = shellObjS.c_str();
// Expand placeholders in the commands.
@@ -865,7 +890,7 @@ cmMakefileTargetGenerator
}
this->LocalGenerator->WriteMakeRule(*this->BuildFileStream, 0,
- relativeObjS.c_str(),
+ relativeObjS,
force_depends, commands, false);
}
}
@@ -877,7 +902,7 @@ cmMakefileTargetGenerator
std::vector<std::string> p_depends;
// always provide an empty requires target
this->LocalGenerator->WriteMakeRule(*this->BuildFileStream, 0,
- objectRequires.c_str(), p_depends,
+ objectRequires, p_depends,
no_commands, true);
// write a build rule to recursively build what this obj provides
@@ -891,19 +916,19 @@ cmMakefileTargetGenerator
tgtMakefileName += "/build.make";
r_commands.push_back
(this->LocalGenerator->GetRecursiveMakeCall(tgtMakefileName.c_str(),
- temp.c_str()));
+ temp));
p_depends.clear();
p_depends.push_back(objectRequires);
this->LocalGenerator->WriteMakeRule(*this->BuildFileStream, 0,
- objectProvides.c_str(), p_depends,
+ objectProvides, p_depends,
r_commands, true);
// write the provides.build rule dependency on the obj file
p_depends.clear();
p_depends.push_back(relativeObj);
this->LocalGenerator->WriteMakeRule(*this->BuildFileStream, 0,
- temp.c_str(), p_depends, no_commands,
+ temp, p_depends, no_commands,
false);
}
@@ -932,7 +957,7 @@ void cmMakefileTargetGenerator::WriteTargetRequiresRules()
// Write the rule.
this->LocalGenerator->WriteMakeRule(*this->BuildFileStream, 0,
- depTarget.c_str(),
+ depTarget,
depends, no_commands, true);
}
@@ -957,7 +982,7 @@ void cmMakefileTargetGenerator::WriteTargetCleanRules()
// Write the rule.
this->LocalGenerator->WriteMakeRule(*this->BuildFileStream, 0,
- cleanTarget.c_str(),
+ cleanTarget,
depends, commands, true);
}
@@ -993,8 +1018,8 @@ void cmMakefileTargetGenerator::WriteTargetDependRules()
pi != this->MultipleOutputPairs.end(); ++pi)
{
*this->InfoFileStream
- << " " << this->LocalGenerator->EscapeForCMake(pi->first.c_str())
- << " " << this->LocalGenerator->EscapeForCMake(pi->second.c_str())
+ << " " << this->LocalGenerator->EscapeForCMake(pi->first)
+ << " " << this->LocalGenerator->EscapeForCMake(pi->second)
<< "\n";
}
*this->InfoFileStream << " )\n\n";
@@ -1053,7 +1078,8 @@ void cmMakefileTargetGenerator::WriteTargetDependRules()
<< "set(CMAKE_C_TARGET_INCLUDE_PATH\n";
std::vector<std::string> includes;
- const char *config = this->Makefile->GetDefinition("CMAKE_BUILD_TYPE");
+ const std::string& config =
+ this->Makefile->GetSafeDefinition("CMAKE_BUILD_TYPE");
this->LocalGenerator->GetIncludeDirectories(includes,
this->GeneratorTarget,
"C", config);
@@ -1062,7 +1088,7 @@ void cmMakefileTargetGenerator::WriteTargetDependRules()
{
*this->InfoFileStream
<< " \""
- << this->LocalGenerator->Convert(i->c_str(),
+ << this->LocalGenerator->Convert(*i,
cmLocalGenerator::HOME_OUTPUT)
<< "\"\n";
}
@@ -1126,7 +1152,7 @@ void cmMakefileTargetGenerator::WriteTargetDependRules()
<< this->Convert(this->Makefile->GetStartOutputDirectory(),
cmLocalGenerator::FULL, cmLocalGenerator::SHELL)
<< " "
- << this->Convert(this->InfoFileNameFull.c_str(),
+ << this->Convert(this->InfoFileNameFull,
cmLocalGenerator::FULL, cmLocalGenerator::SHELL);
if(this->LocalGenerator->GetColorMakefile())
{
@@ -1142,7 +1168,7 @@ void cmMakefileTargetGenerator::WriteTargetDependRules()
// Write the rule.
this->LocalGenerator->WriteMakeRule(*this->BuildFileStream, 0,
- depTarget.c_str(),
+ depTarget,
depends, commands, true);
}
@@ -1153,13 +1179,15 @@ cmMakefileTargetGenerator
{
// Depend on all custom command outputs.
std::vector<cmSourceFile*> sources;
- this->Target->GetSourceFiles(sources);
+ this->Target->GetSourceFiles(sources,
+ this->Makefile->GetSafeDefinition("CMAKE_BUILD_TYPE"));
for(std::vector<cmSourceFile*>::const_iterator source = sources.begin();
source != sources.end(); ++source)
{
if(cmCustomCommand* cc = (*source)->GetCustomCommand())
{
- const std::vector<std::string>& outputs = cc->GetOutputs();
+ cmCustomCommandGenerator ccg(*cc, this->ConfigName, this->Makefile);
+ const std::vector<std::string>& outputs = ccg.GetOutputs();
for(std::vector<std::string>::const_iterator o = outputs.begin();
o != outputs.end(); ++o)
{
@@ -1171,7 +1199,7 @@ cmMakefileTargetGenerator
//----------------------------------------------------------------------------
void cmMakefileTargetGenerator
-::WriteObjectDependRules(cmSourceFile& source,
+::WriteObjectDependRules(cmSourceFile const& source,
std::vector<std::string>& depends)
{
// Create the list of dependencies known at cmake time. These are
@@ -1184,18 +1212,18 @@ void cmMakefileTargetGenerator
for(std::vector<std::string>::iterator i = deps.begin();
i != deps.end(); ++i)
{
- depends.push_back(i->c_str());
+ depends.push_back(*i);
}
}
}
//----------------------------------------------------------------------------
void cmMakefileTargetGenerator
-::GenerateCustomRuleFile(const cmCustomCommand& cc)
+::GenerateCustomRuleFile(cmCustomCommandGenerator const& ccg)
{
// Collect the commands.
std::vector<std::string> commands;
- std::string comment = this->LocalGenerator->ConstructComment(cc);
+ std::string comment = this->LocalGenerator->ConstructComment(ccg);
if(!comment.empty())
{
// add in a progress call if needed
@@ -1210,37 +1238,37 @@ void cmMakefileTargetGenerator
// Now append the actual user-specified commands.
cmOStringStream content;
- this->LocalGenerator->AppendCustomCommand(commands, cc, this->Target, false,
+ this->LocalGenerator->AppendCustomCommand(commands, ccg, this->Target, false,
cmLocalGenerator::HOME_OUTPUT,
&content);
// Collect the dependencies.
std::vector<std::string> depends;
- this->LocalGenerator->AppendCustomDepend(depends, cc);
+ this->LocalGenerator->AppendCustomDepend(depends, ccg);
// Check whether we need to bother checking for a symbolic output.
bool need_symbolic = this->GlobalGenerator->GetNeedSymbolicMark();
// Write the rule.
- const std::vector<std::string>& outputs = cc.GetOutputs();
+ const std::vector<std::string>& outputs = ccg.GetOutputs();
std::vector<std::string>::const_iterator o = outputs.begin();
{
bool symbolic = false;
if(need_symbolic)
{
- if(cmSourceFile* sf = this->Makefile->GetSource(o->c_str()))
+ if(cmSourceFile* sf = this->Makefile->GetSource(*o))
{
symbolic = sf->GetPropertyAsBool("SYMBOLIC");
}
}
this->LocalGenerator->WriteMakeRule(*this->BuildFileStream, 0,
- o->c_str(), depends, commands,
+ *o, depends, commands,
symbolic);
// If the rule has changed make sure the output is rebuilt.
if(!symbolic)
{
- this->GlobalGenerator->AddRuleHash(cc.GetOutputs(), content.str());
+ this->GlobalGenerator->AddRuleHash(ccg.GetOutputs(), content.str());
}
}
@@ -1251,7 +1279,7 @@ void cmMakefileTargetGenerator
bool symbolic = false;
if(need_symbolic)
{
- if(cmSourceFile* sf = this->Makefile->GetSource(o->c_str()))
+ if(cmSourceFile* sf = this->Makefile->GetSource(*o))
{
symbolic = sf->GetPropertyAsBool("SYMBOLIC");
}
@@ -1261,15 +1289,15 @@ void cmMakefileTargetGenerator
// Setup implicit dependency scanning.
for(cmCustomCommand::ImplicitDependsList::const_iterator
- idi = cc.GetImplicitDepends().begin();
- idi != cc.GetImplicitDepends().end(); ++idi)
+ idi = ccg.GetCC().GetImplicitDepends().begin();
+ idi != ccg.GetCC().GetImplicitDepends().end(); ++idi)
{
std::string objFullPath =
- this->Convert(outputs[0].c_str(), cmLocalGenerator::FULL);
+ this->Convert(outputs[0], cmLocalGenerator::FULL);
std::string srcFullPath =
- this->Convert(idi->second.c_str(), cmLocalGenerator::FULL);
+ this->Convert(idi->second, cmLocalGenerator::FULL);
this->LocalGenerator->
- AddImplicitDepends(*this->Target, idi->first.c_str(),
+ AddImplicitDepends(*this->Target, idi->first,
objFullPath.c_str(),
srcFullPath.c_str());
}
@@ -1314,7 +1342,7 @@ cmMakefileTargetGenerator::AppendProgress(std::vector<std::string>& commands)
progressDir += cmake::GetCMakeFilesDirectory();
cmOStringStream progCmd;
progCmd << "$(CMAKE_COMMAND) -E cmake_progress_report ";
- progCmd << this->LocalGenerator->Convert(progressDir.c_str(),
+ progCmd << this->LocalGenerator->Convert(progressDir,
cmLocalGenerator::FULL,
cmLocalGenerator::SHELL);
progCmd << " $(CMAKE_PROGRESS_" << this->NumberOfProgressActions << ")";
@@ -1325,7 +1353,8 @@ cmMakefileTargetGenerator::AppendProgress(std::vector<std::string>& commands)
void
cmMakefileTargetGenerator
::WriteObjectsVariable(std::string& variableName,
- std::string& variableNameExternal)
+ std::string& variableNameExternal,
+ bool useWatcomQuote)
{
// Write a make variable assignment that lists all objects for the
// target.
@@ -1334,10 +1363,8 @@ cmMakefileTargetGenerator
"_OBJECTS");
*this->BuildFileStream
<< "# Object files for target " << this->Target->GetName() << "\n"
- << variableName.c_str() << " =";
+ << variableName << " =";
std::string object;
- const char* objName =
- this->Makefile->GetDefinition("CMAKE_NO_QUOTED_OBJECTS");
const char* lineContinue =
this->Makefile->GetDefinition("CMAKE_MAKE_LINE_CONTINUE");
if(!lineContinue)
@@ -1348,17 +1375,9 @@ cmMakefileTargetGenerator
i != this->Objects.end(); ++i)
{
*this->BuildFileStream << " " << lineContinue << "\n";
- if(objName)
- {
- *this->BuildFileStream <<
- this->Convert(i->c_str(), cmLocalGenerator::START_OUTPUT,
- cmLocalGenerator::MAKEFILE);
- }
- else
- {
- *this->BuildFileStream <<
- this->LocalGenerator->ConvertToQuotedOutputPath(i->c_str());
- }
+ *this->BuildFileStream <<
+ this->LocalGenerator->ConvertToQuotedOutputPath(i->c_str(),
+ useWatcomQuote);
}
*this->BuildFileStream << "\n";
@@ -1371,26 +1390,18 @@ cmMakefileTargetGenerator
<< "\n"
<< "# External object files for target "
<< this->Target->GetName() << "\n"
- << variableNameExternal.c_str() << " =";
+ << variableNameExternal << " =";
for(std::vector<std::string>::const_iterator i =
this->ExternalObjects.begin();
i != this->ExternalObjects.end(); ++i)
{
- object = this->Convert(i->c_str(),cmLocalGenerator::START_OUTPUT);
+ object = this->Convert(*i,cmLocalGenerator::START_OUTPUT);
*this->BuildFileStream
<< " " << lineContinue << "\n"
<< this->Makefile->GetSafeDefinition("CMAKE_OBJECT_NAME");
- if(objName)
- {
- *this->BuildFileStream <<
- this->Convert(i->c_str(), cmLocalGenerator::START_OUTPUT,
- cmLocalGenerator::MAKEFILE);
- }
- else
- {
- *this->BuildFileStream <<
- this->LocalGenerator->ConvertToQuotedOutputPath(i->c_str());
- }
+ *this->BuildFileStream <<
+ this->LocalGenerator->ConvertToQuotedOutputPath(i->c_str(),
+ useWatcomQuote);
}
*this->BuildFileStream << "\n" << "\n";
}
@@ -1420,7 +1431,7 @@ public:
{
// Construct the name of the next object.
this->NextObject =
- this->LocalGenerator->Convert(obj.c_str(),
+ this->LocalGenerator->Convert(obj,
cmLocalGenerator::START_OUTPUT,
cmLocalGenerator::RESPONSE);
@@ -1477,24 +1488,22 @@ cmMakefileTargetGenerator
}
//----------------------------------------------------------------------------
-void cmMakefileTargetGenerator::WriteTargetDriverRule(const char* main_output,
- bool relink)
+void cmMakefileTargetGenerator::WriteTargetDriverRule(
+ const std::string& main_output,
+ bool relink)
{
// Compute the name of the driver target.
std::string dir =
this->LocalGenerator->GetRelativeTargetDirectory(*this->Target);
std::string buildTargetRuleName = dir;
buildTargetRuleName += relink?"/preinstall":"/build";
- buildTargetRuleName = this->Convert(buildTargetRuleName.c_str(),
+ buildTargetRuleName = this->Convert(buildTargetRuleName,
cmLocalGenerator::HOME_OUTPUT,
cmLocalGenerator::UNCHANGED);
// Build the list of target outputs to drive.
std::vector<std::string> depends;
- if(main_output)
- {
- depends.push_back(main_output);
- }
+ depends.push_back(main_output);
const char* comment = 0;
if(relink)
@@ -1514,7 +1523,7 @@ void cmMakefileTargetGenerator::WriteTargetDriverRule(const char* main_output,
}
// Make sure the extra files are built.
- for(std::set<cmStdString>::const_iterator i = this->ExtraFiles.begin();
+ for(std::set<std::string>::const_iterator i = this->ExtraFiles.begin();
i != this->ExtraFiles.end(); ++i)
{
depends.push_back(*i);
@@ -1524,7 +1533,7 @@ void cmMakefileTargetGenerator::WriteTargetDriverRule(const char* main_output,
// Write the driver rule.
std::vector<std::string> no_commands;
this->LocalGenerator->WriteMakeRule(*this->BuildFileStream, comment,
- buildTargetRuleName.c_str(),
+ buildTargetRuleName,
depends, no_commands, true);
}
@@ -1538,19 +1547,20 @@ std::string cmMakefileTargetGenerator::GetFrameworkFlags(std::string const& l)
std::string fwSearchFlagVar = "CMAKE_" + l + "_FRAMEWORK_SEARCH_FLAG";
const char* fwSearchFlag =
- this->Makefile->GetDefinition(fwSearchFlagVar.c_str());
+ this->Makefile->GetDefinition(fwSearchFlagVar);
if(!(fwSearchFlag && *fwSearchFlag))
{
return std::string();
}
- std::set<cmStdString> emitted;
+ std::set<std::string> emitted;
#ifdef __APPLE__ /* don't insert this when crosscompiling e.g. to iphone */
emitted.insert("/System/Library/Frameworks");
#endif
std::vector<std::string> includes;
- const char *config = this->Makefile->GetDefinition("CMAKE_BUILD_TYPE");
+ const std::string& config =
+ this->Makefile->GetSafeDefinition("CMAKE_BUILD_TYPE");
this->LocalGenerator->GetIncludeDirectories(includes,
this->GeneratorTarget,
"C", config);
@@ -1559,7 +1569,7 @@ std::string cmMakefileTargetGenerator::GetFrameworkFlags(std::string const& l)
for(std::vector<std::string>::iterator i = includes.begin();
i != includes.end(); ++i)
{
- if(this->Target->NameResolvesToFramework(i->c_str()))
+ if(this->Target->NameResolvesToFramework(*i))
{
std::string frameworkDir = *i;
frameworkDir += "/../";
@@ -1579,7 +1589,7 @@ std::string cmMakefileTargetGenerator::GetFrameworkFlags(std::string const& l)
if(emitted.insert(*i).second)
{
flags += fwSearchFlag;
- flags += this->Convert(i->c_str(),
+ flags += this->Convert(*i,
cmLocalGenerator::START_OUTPUT,
cmLocalGenerator::SHELL, true);
flags += " ";
@@ -1650,9 +1660,11 @@ void cmMakefileTargetGenerator
this->AppendTargetDepends(depends);
// Add a dependency on the link definitions file, if any.
- if(!this->GeneratorTarget->ModuleDefinitionFile.empty())
+ std::string def = this->GeneratorTarget->GetModuleDefinitionFile(
+ this->Makefile->GetSafeDefinition("CMAKE_BUILD_TYPE"));
+ if(!def.empty())
{
- depends.push_back(this->GeneratorTarget->ModuleDefinitionFile);
+ depends.push_back(def);
}
// Add user-specified dependencies.
@@ -1664,7 +1676,8 @@ void cmMakefileTargetGenerator
}
//----------------------------------------------------------------------------
-std::string cmMakefileTargetGenerator::GetLinkRule(const char* linkRuleVar)
+std::string cmMakefileTargetGenerator::GetLinkRule(
+ const std::string& linkRuleVar)
{
std::string linkRule = this->Makefile->GetRequiredDefinition(linkRuleVar);
if(this->Target->HasImplibGNUtoMS())
@@ -1672,7 +1685,7 @@ std::string cmMakefileTargetGenerator::GetLinkRule(const char* linkRuleVar)
std::string ruleVar = "CMAKE_";
ruleVar += this->Target->GetLinkerLanguage(this->ConfigName);
ruleVar += "_GNUtoMS_RULE";
- if(const char* rule = this->Makefile->GetDefinition(ruleVar.c_str()))
+ if(const char* rule = this->Makefile->GetDefinition(ruleVar))
{
linkRule += rule;
}
@@ -1690,8 +1703,8 @@ void cmMakefileTargetGenerator
}
void cmMakefileTargetGenerator::RemoveForbiddenFlags(const char* flagVar,
- const char* linkLang,
- std::string& linkFlags)
+ const std::string& linkLang,
+ std::string& linkFlags)
{
// check for language flags that are not allowed at link time, and
// remove them, -w on darwin for gcc -w -dynamiclib sends -w to libtool
@@ -1701,7 +1714,7 @@ void cmMakefileTargetGenerator::RemoveForbiddenFlags(const char* flagVar,
removeFlags += linkLang;
removeFlags += flagVar;
std::string removeflags =
- this->Makefile->GetSafeDefinition(removeFlags.c_str());
+ this->Makefile->GetSafeDefinition(removeFlags);
std::vector<std::string> removeList;
cmSystemTools::ExpandListArgument(removeflags, removeList);
@@ -1779,7 +1792,7 @@ cmMakefileTargetGenerator
// Create the makefile command to invoke the link script.
std::string link_command = "$(CMAKE_COMMAND) -E cmake_link_script ";
- link_command += this->Convert(linkScriptName.c_str(),
+ link_command += this->Convert(linkScriptName,
cmLocalGenerator::START_OUTPUT,
cmLocalGenerator::SHELL);
link_command += " --verbose=$(VERBOSE)";
@@ -1815,13 +1828,57 @@ cmMakefileTargetGenerator
//----------------------------------------------------------------------------
void
cmMakefileTargetGenerator
+::CreateLinkLibs(std::string& linkLibs, bool relink,
+ bool useResponseFile,
+ std::vector<std::string>& makefile_depends,
+ bool useWatcomQuote)
+{
+ std::string frameworkPath;
+ std::string linkPath;
+ this->LocalGenerator
+ ->OutputLinkLibraries(linkLibs, frameworkPath, linkPath,
+ *this->GeneratorTarget, relink,
+ useResponseFile,
+ useWatcomQuote);
+ linkLibs = frameworkPath + linkPath + linkLibs;
+
+ if(useResponseFile)
+ {
+ // Lookup the response file reference flag.
+ std::string responseFlagVar = "CMAKE_";
+ responseFlagVar += this->Target->GetLinkerLanguage(this->ConfigName);
+ responseFlagVar += "_RESPONSE_FILE_LINK_FLAG";
+ const char* responseFlag =
+ this->Makefile->GetDefinition(responseFlagVar);
+ if(!responseFlag)
+ {
+ responseFlag = "@";
+ }
+
+ // Create this response file.
+ std::string link_rsp =
+ this->CreateResponseFile("linklibs.rsp", linkLibs, makefile_depends);
+
+ // Reference the response file.
+ linkLibs = responseFlag;
+ linkLibs += this->Convert(link_rsp,
+ cmLocalGenerator::NONE,
+ cmLocalGenerator::SHELL);
+ }
+}
+
+//----------------------------------------------------------------------------
+void
+cmMakefileTargetGenerator
::CreateObjectLists(bool useLinkScript, bool useArchiveRules,
bool useResponseFile, std::string& buildObjs,
- std::vector<std::string>& makefile_depends)
+ std::vector<std::string>& makefile_depends,
+ bool useWatcomQuote)
{
std::string variableName;
std::string variableNameExternal;
- this->WriteObjectsVariable(variableName, variableNameExternal);
+ this->WriteObjectsVariable(variableName, variableNameExternal,
+ useWatcomQuote);
if(useResponseFile)
{
// MSVC response files cannot exceed 128K.
@@ -1836,7 +1893,7 @@ cmMakefileTargetGenerator
responseFlagVar += this->Target->GetLinkerLanguage(this->ConfigName);
responseFlagVar += "_RESPONSE_FILE_LINK_FLAG";
const char* responseFlag =
- this->Makefile->GetDefinition(responseFlagVar.c_str());
+ this->Makefile->GetDefinition(responseFlagVar);
if(!responseFlag)
{
responseFlag = "@";
@@ -1860,7 +1917,7 @@ cmMakefileTargetGenerator
// Reference the response file.
buildObjs += responseFlag;
- buildObjs += this->Convert(objects_rsp.c_str(),
+ buildObjs += this->Convert(objects_rsp,
cmLocalGenerator::NONE,
cmLocalGenerator::SHELL);
}
@@ -1884,16 +1941,17 @@ cmMakefileTargetGenerator
//----------------------------------------------------------------------------
void cmMakefileTargetGenerator::AddIncludeFlags(std::string& flags,
- const char* lang)
+ const std::string& lang)
{
std::string responseVar = "CMAKE_";
responseVar += lang;
responseVar += "_USE_RESPONSE_FILE_FOR_INCLUDES";
- bool useResponseFile = this->Makefile->IsOn(responseVar.c_str());
+ bool useResponseFile = this->Makefile->IsOn(responseVar);
std::vector<std::string> includes;
- const char *config = this->Makefile->GetDefinition("CMAKE_BUILD_TYPE");
+ const std::string& config =
+ this->Makefile->GetSafeDefinition("CMAKE_BUILD_TYPE");
this->LocalGenerator->GetIncludeDirectories(includes,
this->GeneratorTarget,
lang, config);
@@ -1914,11 +1972,11 @@ void cmMakefileTargetGenerator::AddIncludeFlags(std::string& flags,
std::string arg = "@" +
this->CreateResponseFile(name.c_str(), includeFlags,
this->FlagFileDepends[lang]);
- this->LocalGenerator->AppendFlags(flags, arg.c_str());
+ this->LocalGenerator->AppendFlags(flags, arg);
}
else
{
- this->LocalGenerator->AppendFlags(flags, includeFlags.c_str());
+ this->LocalGenerator->AppendFlags(flags, includeFlags);
}
}
@@ -1990,7 +2048,7 @@ void cmMakefileTargetGenerator::AddFortranFlags(std::string& flags)
modflag += this->Convert(mod_dir,
cmLocalGenerator::START_OUTPUT,
cmLocalGenerator::SHELL);
- this->LocalGenerator->AppendFlags(flags, modflag.c_str());
+ this->LocalGenerator->AppendFlags(flags, modflag);
}
// If there is a separate module path flag then duplicate the
@@ -2000,7 +2058,8 @@ void cmMakefileTargetGenerator::AddFortranFlags(std::string& flags)
this->Makefile->GetDefinition("CMAKE_Fortran_MODPATH_FLAG"))
{
std::vector<std::string> includes;
- const char *config = this->Makefile->GetDefinition("CMAKE_BUILD_TYPE");
+ const std::string& config =
+ this->Makefile->GetSafeDefinition("CMAKE_BUILD_TYPE");
this->LocalGenerator->GetIncludeDirectories(includes,
this->GeneratorTarget,
"C", config);
@@ -2008,10 +2067,10 @@ void cmMakefileTargetGenerator::AddFortranFlags(std::string& flags)
idi != includes.end(); ++idi)
{
std::string flg = modpath_flag;
- flg += this->Convert(idi->c_str(),
+ flg += this->Convert(*idi,
cmLocalGenerator::NONE,
cmLocalGenerator::SHELL);
- this->LocalGenerator->AppendFlags(flags, flg.c_str());
+ this->LocalGenerator->AppendFlags(flags, flg);
}
}
}
@@ -2019,7 +2078,9 @@ void cmMakefileTargetGenerator::AddFortranFlags(std::string& flags)
//----------------------------------------------------------------------------
void cmMakefileTargetGenerator::AddModuleDefinitionFlag(std::string& flags)
{
- if(this->GeneratorTarget->ModuleDefinitionFile.empty())
+ std::string def = this->GeneratorTarget->GetModuleDefinitionFile(
+ this->Makefile->GetSafeDefinition("CMAKE_BUILD_TYPE"));
+ if(def.empty())
{
return;
}
@@ -2035,26 +2096,25 @@ void cmMakefileTargetGenerator::AddModuleDefinitionFlag(std::string& flags)
// Append the flag and value. Use ConvertToLinkReference to help
// vs6's "cl -link" pass it to the linker.
std::string flag = defFileFlag;
- flag += (this->LocalGenerator->ConvertToLinkReference(
- this->GeneratorTarget->ModuleDefinitionFile.c_str()));
- this->LocalGenerator->AppendFlags(flags, flag.c_str());
+ flag += (this->LocalGenerator->ConvertToLinkReference(def));
+ this->LocalGenerator->AppendFlags(flags, flag);
}
//----------------------------------------------------------------------------
-const char* cmMakefileTargetGenerator::GetFeature(const char* feature)
+const char* cmMakefileTargetGenerator::GetFeature(const std::string& feature)
{
return this->Target->GetFeature(feature, this->ConfigName);
}
//----------------------------------------------------------------------------
-bool cmMakefileTargetGenerator::GetFeatureAsBool(const char* feature)
+bool cmMakefileTargetGenerator::GetFeatureAsBool(const std::string& feature)
{
- return cmSystemTools::IsOn(this->GetFeature(feature));
+ return this->Target->GetFeatureAsBool(feature, this->ConfigName);
}
//----------------------------------------------------------------------------
void cmMakefileTargetGenerator::AddFeatureFlags(
- std::string& flags, const char* lang
+ std::string& flags, const std::string& lang
)
{
// Add language-specific flags.