summaryrefslogtreecommitdiffstats
path: root/Source/cmCommonTargetGenerator.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'Source/cmCommonTargetGenerator.cxx')
-rw-r--r--Source/cmCommonTargetGenerator.cxx294
1 files changed, 124 insertions, 170 deletions
diff --git a/Source/cmCommonTargetGenerator.cxx b/Source/cmCommonTargetGenerator.cxx
index d00a416..6b2d1e3 100644
--- a/Source/cmCommonTargetGenerator.cxx
+++ b/Source/cmCommonTargetGenerator.cxx
@@ -20,15 +20,13 @@
#include "cmSystemTools.h"
cmCommonTargetGenerator::cmCommonTargetGenerator(
- cmOutputConverter::RelativeRoot wd,
- cmGeneratorTarget* gt
- )
+ cmOutputConverter::RelativeRoot wd, cmGeneratorTarget* gt)
: WorkingDirectory(wd)
, GeneratorTarget(gt)
, Makefile(gt->Makefile)
, LocalGenerator(static_cast<cmLocalCommonGenerator*>(gt->LocalGenerator))
, GlobalGenerator(static_cast<cmGlobalCommonGenerator*>(
- gt->LocalGenerator->GetGlobalGenerator()))
+ gt->LocalGenerator->GetGlobalGenerator()))
, ConfigName(LocalGenerator->GetConfigName())
, ModuleDefinitionFile(GeneratorTarget->GetModuleDefinitionFile(ConfigName))
, FortranModuleDirectoryComputed(false)
@@ -45,8 +43,7 @@ std::string const& cmCommonTargetGenerator::GetConfigName() const
}
std::string cmCommonTargetGenerator::Convert(
- std::string const& source,
- cmLocalGenerator::RelativeRoot relative,
+ std::string const& source, cmLocalGenerator::RelativeRoot relative,
cmLocalGenerator::OutputFormat output)
{
return this->LocalGenerator->Convert(source, relative, output);
@@ -62,39 +59,35 @@ bool cmCommonTargetGenerator::GetFeatureAsBool(const std::string& feature)
return this->GeneratorTarget->GetFeatureAsBool(feature, this->ConfigName);
}
-void cmCommonTargetGenerator::AddFeatureFlags(
- std::string& flags, const std::string& lang
- )
+void cmCommonTargetGenerator::AddFeatureFlags(std::string& flags,
+ const std::string& lang)
{
// Add language-specific flags.
this->LocalGenerator->AddLanguageFlags(flags, lang, this->ConfigName);
- if(this->GetFeatureAsBool("INTERPROCEDURAL_OPTIMIZATION"))
- {
+ if (this->GetFeatureAsBool("INTERPROCEDURAL_OPTIMIZATION")) {
this->LocalGenerator->AppendFeatureOptions(flags, lang, "IPO");
- }
+ }
}
void cmCommonTargetGenerator::AddModuleDefinitionFlag(std::string& flags)
{
- if(!this->ModuleDefinitionFile)
- {
+ if (!this->ModuleDefinitionFile) {
return;
- }
+ }
// TODO: Create a per-language flag variable.
const char* defFileFlag =
this->Makefile->GetDefinition("CMAKE_LINK_DEF_FILE_FLAG");
- if(!defFileFlag)
- {
+ if (!defFileFlag) {
return;
- }
+ }
// 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->ModuleDefinitionFile->GetFullPath()));
+ this->ModuleDefinitionFile->GetFullPath()));
this->LocalGenerator->AppendFlags(flags, flag);
}
@@ -105,36 +98,31 @@ std::string cmCommonTargetGenerator::ComputeFortranModuleDirectory() const
this->GeneratorTarget->GetProperty("Fortran_MODULE_DIRECTORY");
const char* moddir_flag =
this->Makefile->GetDefinition("CMAKE_Fortran_MODDIR_FLAG");
- if(target_mod_dir && moddir_flag)
- {
+ if (target_mod_dir && moddir_flag) {
// Compute the full path to the module directory.
- if(cmSystemTools::FileIsFullPath(target_mod_dir))
- {
+ if (cmSystemTools::FileIsFullPath(target_mod_dir)) {
// Already a full path.
mod_dir = target_mod_dir;
- }
- else
- {
+ } else {
// Interpret relative to the current output directory.
mod_dir = this->LocalGenerator->GetCurrentBinaryDirectory();
mod_dir += "/";
mod_dir += target_mod_dir;
- }
+ }
// Make sure the module output directory exists.
cmSystemTools::MakeDirectory(mod_dir);
- }
+ }
return mod_dir;
}
std::string cmCommonTargetGenerator::GetFortranModuleDirectory()
{
// Compute the module directory.
- if(!this->FortranModuleDirectoryComputed)
- {
+ if (!this->FortranModuleDirectoryComputed) {
this->FortranModuleDirectoryComputed = true;
this->FortranModuleDirectory = this->ComputeFortranModuleDirectory();
- }
+ }
// Return the computed directory.
return this->FortranModuleDirectory;
@@ -143,154 +131,133 @@ std::string cmCommonTargetGenerator::GetFortranModuleDirectory()
void cmCommonTargetGenerator::AddFortranFlags(std::string& flags)
{
// Enable module output if necessary.
- if(const char* modout_flag =
- this->Makefile->GetDefinition("CMAKE_Fortran_MODOUT_FLAG"))
- {
+ if (const char* modout_flag =
+ this->Makefile->GetDefinition("CMAKE_Fortran_MODOUT_FLAG")) {
this->LocalGenerator->AppendFlags(flags, modout_flag);
- }
+ }
// Add a module output directory flag if necessary.
std::string mod_dir = this->GetFortranModuleDirectory();
- if (!mod_dir.empty())
- {
- mod_dir = this->Convert(mod_dir,
- this->WorkingDirectory,
- cmLocalGenerator::SHELL);
- }
- else
- {
+ if (!mod_dir.empty()) {
+ mod_dir =
+ this->Convert(mod_dir, this->WorkingDirectory, cmLocalGenerator::SHELL);
+ } else {
mod_dir =
this->Makefile->GetSafeDefinition("CMAKE_Fortran_MODDIR_DEFAULT");
- }
- if (!mod_dir.empty())
- {
+ }
+ if (!mod_dir.empty()) {
const char* moddir_flag =
this->Makefile->GetRequiredDefinition("CMAKE_Fortran_MODDIR_FLAG");
std::string modflag = moddir_flag;
modflag += mod_dir;
this->LocalGenerator->AppendFlags(flags, modflag);
- }
+ }
// If there is a separate module path flag then duplicate the
// include path with it. This compiler does not search the include
// path for modules.
- if(const char* modpath_flag =
- this->Makefile->GetDefinition("CMAKE_Fortran_MODPATH_FLAG"))
- {
+ if (const char* modpath_flag =
+ this->Makefile->GetDefinition("CMAKE_Fortran_MODPATH_FLAG")) {
std::vector<std::string> includes;
const std::string& config =
this->Makefile->GetSafeDefinition("CMAKE_BUILD_TYPE");
- this->LocalGenerator->GetIncludeDirectories(includes,
- this->GeneratorTarget,
- "C", config);
- for(std::vector<std::string>::const_iterator idi = includes.begin();
- idi != includes.end(); ++idi)
- {
+ this->LocalGenerator->GetIncludeDirectories(
+ includes, this->GeneratorTarget, "C", config);
+ for (std::vector<std::string>::const_iterator idi = includes.begin();
+ idi != includes.end(); ++idi) {
std::string flg = modpath_flag;
- flg += this->Convert(*idi,
- cmLocalGenerator::NONE,
- cmLocalGenerator::SHELL);
+ flg +=
+ this->Convert(*idi, cmLocalGenerator::NONE, cmLocalGenerator::SHELL);
this->LocalGenerator->AppendFlags(flags, flg);
- }
}
+ }
}
-void
-cmCommonTargetGenerator
-::AppendFortranFormatFlags(std::string& flags, cmSourceFile const& source)
+void cmCommonTargetGenerator::AppendFortranFormatFlags(
+ std::string& flags, cmSourceFile const& source)
{
const char* srcfmt = source.GetProperty("Fortran_FORMAT");
cmLocalGenerator::FortranFormat format =
this->LocalGenerator->GetFortranFormat(srcfmt);
- if(format == cmLocalGenerator::FortranFormatNone)
- {
+ if (format == cmLocalGenerator::FortranFormatNone) {
const char* tgtfmt = this->GeneratorTarget->GetProperty("Fortran_FORMAT");
format = this->LocalGenerator->GetFortranFormat(tgtfmt);
- }
+ }
const char* var = 0;
- switch (format)
- {
+ switch (format) {
case cmLocalGenerator::FortranFormatFixed:
- var = "CMAKE_Fortran_FORMAT_FIXED_FLAG"; break;
+ var = "CMAKE_Fortran_FORMAT_FIXED_FLAG";
+ break;
case cmLocalGenerator::FortranFormatFree:
- var = "CMAKE_Fortran_FORMAT_FREE_FLAG"; break;
- default: break;
- }
- if(var)
- {
- this->LocalGenerator->AppendFlags(
- flags, this->Makefile->GetDefinition(var));
- }
+ var = "CMAKE_Fortran_FORMAT_FREE_FLAG";
+ break;
+ default:
+ break;
+ }
+ if (var) {
+ this->LocalGenerator->AppendFlags(flags,
+ this->Makefile->GetDefinition(var));
+ }
}
std::string cmCommonTargetGenerator::GetFrameworkFlags(std::string const& l)
{
- if(!this->Makefile->IsOn("APPLE"))
- {
- return std::string();
- }
+ if (!this->Makefile->IsOn("APPLE")) {
+ return std::string();
+ }
std::string fwSearchFlagVar = "CMAKE_" + l + "_FRAMEWORK_SEARCH_FLAG";
- const char* fwSearchFlag =
- this->Makefile->GetDefinition(fwSearchFlagVar);
- if(!(fwSearchFlag && *fwSearchFlag))
- {
+ const char* fwSearchFlag = this->Makefile->GetDefinition(fwSearchFlagVar);
+ if (!(fwSearchFlag && *fwSearchFlag)) {
return std::string();
- }
+ }
- std::set<std::string> emitted;
-#ifdef __APPLE__ /* don't insert this when crosscompiling e.g. to iphone */
+ 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 std::string& config =
this->Makefile->GetSafeDefinition("CMAKE_BUILD_TYPE");
- this->LocalGenerator->GetIncludeDirectories(includes,
- this->GeneratorTarget,
+ this->LocalGenerator->GetIncludeDirectories(includes, this->GeneratorTarget,
"C", config);
// check all include directories for frameworks as this
// will already have added a -F for the framework
- for(std::vector<std::string>::iterator i = includes.begin();
- i != includes.end(); ++i)
- {
- if(this->GlobalGenerator->NameResolvesToFramework(*i))
- {
+ for (std::vector<std::string>::iterator i = includes.begin();
+ i != includes.end(); ++i) {
+ if (this->GlobalGenerator->NameResolvesToFramework(*i)) {
std::string frameworkDir = *i;
frameworkDir += "/../";
frameworkDir = cmSystemTools::CollapseFullPath(frameworkDir);
emitted.insert(frameworkDir);
- }
}
+ }
std::string flags;
const char* cfg = this->LocalGenerator->GetConfigName().c_str();
- if(cmComputeLinkInformation* cli =
- this->GeneratorTarget->GetLinkInformation(cfg))
- {
+ if (cmComputeLinkInformation* cli =
+ this->GeneratorTarget->GetLinkInformation(cfg)) {
std::vector<std::string> const& frameworks = cli->GetFrameworkPaths();
- for(std::vector<std::string>::const_iterator i = frameworks.begin();
- i != frameworks.end(); ++i)
- {
- if(emitted.insert(*i).second)
- {
+ for (std::vector<std::string>::const_iterator i = frameworks.begin();
+ i != frameworks.end(); ++i) {
+ if (emitted.insert(*i).second) {
flags += fwSearchFlag;
- flags += this->LocalGenerator
- ->ConvertToOutputFormat(*i, cmLocalGenerator::SHELL);
+ flags += this->LocalGenerator->ConvertToOutputFormat(
+ *i, cmLocalGenerator::SHELL);
flags += " ";
- }
}
}
+ }
return flags;
}
-std::string cmCommonTargetGenerator::GetFlags(const std::string &l)
+std::string cmCommonTargetGenerator::GetFlags(const std::string& l)
{
ByLanguageMap::iterator i = this->FlagsByLanguage.find(l);
- if (i == this->FlagsByLanguage.end())
- {
+ if (i == this->FlagsByLanguage.end()) {
std::string flags;
- const char *lang = l.c_str();
+ const char* lang = l.c_str();
// Add language feature flags.
this->AddFeatureFlags(flags, lang);
@@ -299,104 +266,95 @@ std::string cmCommonTargetGenerator::GetFlags(const std::string &l)
lang, this->ConfigName);
// Fortran-specific flags computed for this target.
- if(l == "Fortran")
- {
+ if (l == "Fortran") {
this->AddFortranFlags(flags);
- }
+ }
- this->LocalGenerator->AddCMP0018Flags(flags, this->GeneratorTarget,
- lang, this->ConfigName);
+ this->LocalGenerator->AddCMP0018Flags(flags, this->GeneratorTarget, lang,
+ this->ConfigName);
- this->LocalGenerator->AddVisibilityPresetFlags(flags,
- this->GeneratorTarget,
- lang);
+ this->LocalGenerator->AddVisibilityPresetFlags(
+ flags, this->GeneratorTarget, lang);
// Append old-style preprocessor definition flags.
- this->LocalGenerator->
- AppendFlags(flags, this->Makefile->GetDefineFlags());
+ this->LocalGenerator->AppendFlags(flags, this->Makefile->GetDefineFlags());
// Add framework directory flags.
- this->LocalGenerator->
- AppendFlags(flags,this->GetFrameworkFlags(l));
+ this->LocalGenerator->AppendFlags(flags, this->GetFrameworkFlags(l));
// Add target-specific flags.
- this->LocalGenerator->AddCompileOptions(flags, this->GeneratorTarget,
- lang, this->ConfigName);
+ this->LocalGenerator->AddCompileOptions(flags, this->GeneratorTarget, lang,
+ this->ConfigName);
ByLanguageMap::value_type entry(l, flags);
i = this->FlagsByLanguage.insert(entry).first;
- }
+ }
return i->second;
}
-std::string cmCommonTargetGenerator::GetDefines(const std::string &l)
+std::string cmCommonTargetGenerator::GetDefines(const std::string& l)
{
ByLanguageMap::iterator i = this->DefinesByLanguage.find(l);
- if (i == this->DefinesByLanguage.end())
- {
+ if (i == this->DefinesByLanguage.end()) {
std::set<std::string> defines;
- const char *lang = l.c_str();
+ const char* lang = l.c_str();
// Add the export symbol definition for shared library objects.
- if(const char* exportMacro =
- this->GeneratorTarget->GetExportMacro())
- {
+ if (const char* exportMacro = this->GeneratorTarget->GetExportMacro()) {
this->LocalGenerator->AppendDefines(defines, exportMacro);
- }
+ }
// Add preprocessor definitions for this target and configuration.
- this->LocalGenerator->AddCompileDefinitions(defines, this->GeneratorTarget,
- this->LocalGenerator->GetConfigName(), l);
+ this->LocalGenerator->AddCompileDefinitions(
+ defines, this->GeneratorTarget, this->LocalGenerator->GetConfigName(),
+ l);
std::string definesString;
this->LocalGenerator->JoinDefines(defines, definesString, lang);
ByLanguageMap::value_type entry(l, definesString);
i = this->DefinesByLanguage.insert(entry).first;
- }
+ }
return i->second;
}
std::string cmCommonTargetGenerator::GetIncludes(std::string const& l)
{
ByLanguageMap::iterator i = this->IncludesByLanguage.find(l);
- if (i == this->IncludesByLanguage.end())
- {
+ if (i == this->IncludesByLanguage.end()) {
std::string includes;
this->AddIncludeFlags(includes, l);
ByLanguageMap::value_type entry(l, includes);
i = this->IncludesByLanguage.insert(entry).first;
- }
+ }
return i->second;
}
-std::vector<std::string>
-cmCommonTargetGenerator::GetLinkedTargetDirectories() const
+std::vector<std::string> cmCommonTargetGenerator::GetLinkedTargetDirectories()
+ const
{
std::vector<std::string> dirs;
std::set<cmGeneratorTarget const*> emitted;
if (cmComputeLinkInformation* cli =
- this->GeneratorTarget->GetLinkInformation(this->ConfigName))
- {
+ this->GeneratorTarget->GetLinkInformation(this->ConfigName)) {
cmComputeLinkInformation::ItemVector const& items = cli->GetItems();
- for(cmComputeLinkInformation::ItemVector::const_iterator
- i = items.begin(); i != items.end(); ++i)
- {
+ for (cmComputeLinkInformation::ItemVector::const_iterator i =
+ items.begin();
+ i != items.end(); ++i) {
cmGeneratorTarget const* linkee = i->Target;
- if(linkee && !linkee->IsImported()
- // We can ignore the INTERFACE_LIBRARY items because
- // Target->GetLinkInformation already processed their
- // link interface and they don't have any output themselves.
- && linkee->GetType() != cmState::INTERFACE_LIBRARY
- && emitted.insert(linkee).second)
- {
+ if (linkee && !linkee->IsImported()
+ // We can ignore the INTERFACE_LIBRARY items because
+ // Target->GetLinkInformation already processed their
+ // link interface and they don't have any output themselves.
+ && linkee->GetType() != cmState::INTERFACE_LIBRARY &&
+ emitted.insert(linkee).second) {
cmLocalGenerator* lg = linkee->GetLocalGenerator();
std::string di = lg->GetCurrentBinaryDirectory();
di += "/";
di += lg->GetTargetDirectory(linkee);
dirs.push_back(di);
- }
}
}
+ }
return dirs;
}
@@ -407,19 +365,17 @@ std::string cmCommonTargetGenerator::GetManifests()
std::vector<std::string> manifests;
for (std::vector<cmSourceFile const*>::iterator mi = manifest_srcs.begin();
- mi != manifest_srcs.end(); ++mi)
- {
- manifests.push_back(this->Convert((*mi)->GetFullPath(),
- this->WorkingDirectory,
- cmOutputConverter::SHELL));
- }
+ mi != manifest_srcs.end(); ++mi) {
+ manifests.push_back(this->Convert(
+ (*mi)->GetFullPath(), this->WorkingDirectory, cmOutputConverter::SHELL));
+ }
return cmJoin(manifests, " ");
}
-void cmCommonTargetGenerator
-::AppendOSXVerFlag(std::string& flags, const std::string& lang,
- const char* name, bool so)
+void cmCommonTargetGenerator::AppendOSXVerFlag(std::string& flags,
+ const std::string& lang,
+ const char* name, bool so)
{
// Lookup the flag to specify the version.
std::string fvar = "CMAKE_";
@@ -430,21 +386,19 @@ void cmCommonTargetGenerator
const char* flag = this->Makefile->GetDefinition(fvar);
// Skip if no such flag.
- if(!flag)
- {
+ if (!flag) {
return;
- }
+ }
// Lookup the target version information.
int major;
int minor;
int patch;
this->GeneratorTarget->GetTargetVersion(so, major, minor, patch);
- if(major > 0 || minor > 0 || patch > 0)
- {
+ if (major > 0 || minor > 0 || patch > 0) {
// Append the flag since a non-zero version is specified.
std::ostringstream vflag;
vflag << flag << major << "." << minor << "." << patch;
this->LocalGenerator->AppendFlags(flags, vflag.str());
- }
+ }
}