diff options
author | Manuel Klimek <klimek@google.com> | 2011-01-13 04:06:25 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2011-04-25 17:27:58 (GMT) |
commit | 3f064efe40cdf9d2eac955581b171e0c723e92a2 (patch) | |
tree | ead063ac30678987869edd6b7e193af3062a5864 | |
parent | 00f88cc09526ac649c53de081cff15ab317f7083 (diff) | |
download | CMake-3f064efe40cdf9d2eac955581b171e0c723e92a2.zip CMake-3f064efe40cdf9d2eac955581b171e0c723e92a2.tar.gz CMake-3f064efe40cdf9d2eac955581b171e0c723e92a2.tar.bz2 |
refactor flags and defines
-rw-r--r-- | Source/cmMakefileTargetGenerator.cxx | 120 | ||||
-rw-r--r-- | Source/cmMakefileTargetGenerator.h | 3 |
2 files changed, 68 insertions, 55 deletions
diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index 69320da..01545fc 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -249,6 +249,66 @@ void cmMakefileTargetGenerator::WriteCommonCodeRules() } //---------------------------------------------------------------------------- +std::string cmMakefileTargetGenerator::GetFlags(const std::string &l) { + std::string flags; + const char *lang = l.c_str(); + + bool shared = ((this->Target->GetType() == cmTarget::SHARED_LIBRARY) || + (this->Target->GetType() == cmTarget::MODULE_LIBRARY)); + + // Add language feature flags. + this->AddFeatureFlags(flags, lang); + + this->LocalGenerator->AddArchitectureFlags(flags, this->Target, + lang, this->ConfigName); + + // Fortran-specific flags computed for this target. + if(l == "Fortran") + { + this->AddFortranFlags(flags); + } + + // Add shared-library flags if needed. + this->LocalGenerator->AddSharedFlags(flags, lang, shared); + + // Add include directory flags. + this->AddIncludeFlags(flags, lang); + + // Append old-style preprocessor definition flags. + this->LocalGenerator-> + AppendFlags(flags, this->Makefile->GetDefineFlags()); + + // Add include directory flags. + this->LocalGenerator-> + AppendFlags(flags,this->GetFrameworkFlags().c_str()); + + return flags; +} + +std::string cmMakefileTargetGenerator::GetDefines(const std::string &l) { + std::string defines; + const char *lang = l.c_str(); + // Add the export symbol definition for shared library objects. + if(const char* exportMacro = this->Target->GetExportMacro()) + { + this->LocalGenerator->AppendDefines(defines, exportMacro, lang); + } + + // Add preprocessor definitions for this target and configuration. + this->LocalGenerator->AppendDefines + (defines, this->Makefile->GetProperty("COMPILE_DEFINITIONS"), lang); + this->LocalGenerator->AppendDefines + (defines, this->Target->GetProperty("COMPILE_DEFINITIONS"), lang); + std::string defPropName = "COMPILE_DEFINITIONS_"; + defPropName += + cmSystemTools::UpperCase(this->LocalGenerator->ConfigurationName); + this->LocalGenerator->AppendDefines + (defines, this->Makefile->GetProperty(defPropName.c_str()), lang); + this->LocalGenerator->AppendDefines + (defines, this->Target->GetProperty(defPropName.c_str()), lang); + return defines; +} + void cmMakefileTargetGenerator::WriteTargetLanguageFlags() { // write language flags for target @@ -262,72 +322,22 @@ void cmMakefileTargetGenerator::WriteTargetLanguageFlags() cmStdString compiler = "CMAKE_"; compiler += *l; compiler += "_COMPILER"; - *this->FlagFileStream << "# compile " << l->c_str() << " with " << + *this->FlagFileStream << "# compile " << l->c_str() << " with " << this->Makefile->GetSafeDefinition(compiler.c_str()) << "\n"; } for(std::set<cmStdString>::const_iterator l = languages.begin(); l != languages.end(); ++l) { - const char *lang = l->c_str(); - std::string flags; - std::string defines; - bool shared = ((this->Target->GetType() == cmTarget::SHARED_LIBRARY) || - (this->Target->GetType() == cmTarget::MODULE_LIBRARY)); - - // Add the export symbol definition for shared library objects. - if(const char* exportMacro = this->Target->GetExportMacro()) - { - this->LocalGenerator->AppendDefines(defines, exportMacro, lang); - } - - // Add preprocessor definitions for this target and configuration. - this->LocalGenerator->AppendDefines - (defines, this->Makefile->GetProperty("COMPILE_DEFINITIONS"), lang); - this->LocalGenerator->AppendDefines - (defines, this->Target->GetProperty("COMPILE_DEFINITIONS"), lang); - std::string defPropName = "COMPILE_DEFINITIONS_"; - defPropName += - cmSystemTools::UpperCase(this->LocalGenerator->ConfigurationName); - this->LocalGenerator->AppendDefines - (defines, this->Makefile->GetProperty(defPropName.c_str()), lang); - this->LocalGenerator->AppendDefines - (defines, this->Target->GetProperty(defPropName.c_str()), lang); - - // Add language feature flags. - this->AddFeatureFlags(flags, lang); - - this->LocalGenerator->AddArchitectureFlags(flags, this->Target, - lang, this->ConfigName); - - // Fortran-specific flags computed for this target. - if(*l == "Fortran") - { - this->AddFortranFlags(flags); - } - - // Add shared-library flags if needed. - this->LocalGenerator->AddSharedFlags(flags, lang, shared); - - // Add include directory flags. - this->AddIncludeFlags(flags, lang); - - // Append old-style preprocessor definition flags. - this->LocalGenerator-> - AppendFlags(flags, this->Makefile->GetDefineFlags()); - - // Add include directory flags. - this->LocalGenerator-> - AppendFlags(flags,this->GetFrameworkFlags().c_str()); - - *this->FlagFileStream << lang << "_FLAGS = " << flags << "\n\n"; - *this->FlagFileStream << lang << "_DEFINES = " << defines << "\n\n"; + *this->FlagFileStream << *l << "_FLAGS = " << this->GetFlags(*l) << "\n\n"; + *this->FlagFileStream << *l << "_DEFINES = " << this->GetDefines(*l) << + "\n\n"; } // Add target-specific flags. if(this->Target->GetProperty("COMPILE_FLAGS")) { - std::string flags; + std::string flags; this->LocalGenerator->AppendFlags (flags, this->Target->GetProperty("COMPILE_FLAGS")); *this->FlagFileStream << "# TARGET_FLAGS = " << flags << "\n\n"; diff --git a/Source/cmMakefileTargetGenerator.h b/Source/cmMakefileTargetGenerator.h index bd26795..0005b48 100644 --- a/Source/cmMakefileTargetGenerator.h +++ b/Source/cmMakefileTargetGenerator.h @@ -216,6 +216,9 @@ protected: std::string MacContentDirectory; std::set<cmStdString> MacContentFolders; + std::string GetFlags(const std::string &l); + std::string GetDefines(const std::string &l); + // Target-wide Fortran module output directory. bool FortranModuleDirectoryComputed; std::string FortranModuleDirectory; |