From 001f9b361711b479ee0d530056e44b7444edfcff Mon Sep 17 00:00:00 2001 From: Brad King Date: Tue, 7 Jul 2015 16:37:56 -0400 Subject: Add common base classes to Makefile and Ninja generators Provide a place to move functionality common to both. --- Source/CMakeLists.txt | 6 ++++++ Source/cmCommonTargetGenerator.cxx | 20 ++++++++++++++++++++ Source/cmCommonTargetGenerator.h | 27 +++++++++++++++++++++++++++ Source/cmGlobalCommonGenerator.cxx | 21 +++++++++++++++++++++ Source/cmGlobalCommonGenerator.h | 27 +++++++++++++++++++++++++++ Source/cmGlobalNinjaGenerator.cxx | 2 +- Source/cmGlobalNinjaGenerator.h | 4 ++-- Source/cmGlobalUnixMakefileGenerator3.cxx | 2 +- Source/cmGlobalUnixMakefileGenerator3.h | 4 ++-- Source/cmLocalCommonGenerator.cxx | 23 +++++++++++++++++++++++ Source/cmLocalCommonGenerator.h | 29 +++++++++++++++++++++++++++++ Source/cmLocalNinjaGenerator.cxx | 2 +- Source/cmLocalNinjaGenerator.h | 4 ++-- Source/cmLocalUnixMakefileGenerator3.cxx | 2 +- Source/cmLocalUnixMakefileGenerator3.h | 4 ++-- Source/cmMakefileTargetGenerator.cxx | 3 ++- Source/cmMakefileTargetGenerator.h | 4 +++- Source/cmNinjaTargetGenerator.cxx | 2 +- Source/cmNinjaTargetGenerator.h | 4 +++- bootstrap | 3 +++ 20 files changed, 177 insertions(+), 16 deletions(-) create mode 100644 Source/cmCommonTargetGenerator.cxx create mode 100644 Source/cmCommonTargetGenerator.h create mode 100644 Source/cmGlobalCommonGenerator.cxx create mode 100644 Source/cmGlobalCommonGenerator.h create mode 100644 Source/cmLocalCommonGenerator.cxx create mode 100644 Source/cmLocalCommonGenerator.h diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt index 6940187..d5fe7d1 100644 --- a/Source/CMakeLists.txt +++ b/Source/CMakeLists.txt @@ -165,6 +165,8 @@ set(SRCS cmCommandArgumentLexer.cxx cmCommandArgumentParser.cxx cmCommandArgumentParserHelper.cxx + cmCommonTargetGenerator.cxx + cmCommonTargetGenerator.h cmComputeComponentGraph.cxx cmComputeComponentGraph.h cmComputeLinkDepends.cxx @@ -260,6 +262,8 @@ set(SRCS cmGeneratorExpression.h cmGeneratorTarget.cxx cmGeneratorTarget.h + cmGlobalCommonGenerator.cxx + cmGlobalCommonGenerator.h cmGlobalGenerator.cxx cmGlobalGenerator.h cmGlobalGeneratorFactory.h @@ -285,6 +289,8 @@ set(SRCS cmListFileCache.cxx cmListFileCache.h cmListFileLexer.c + cmLocalCommonGenerator.cxx + cmLocalCommonGenerator.h cmLocalGenerator.cxx cmLocalGenerator.h cmLocalUnixMakefileGenerator3.cxx diff --git a/Source/cmCommonTargetGenerator.cxx b/Source/cmCommonTargetGenerator.cxx new file mode 100644 index 0000000..e1f7522 --- /dev/null +++ b/Source/cmCommonTargetGenerator.cxx @@ -0,0 +1,20 @@ +/*============================================================================ + CMake - Cross Platform Makefile Generator + Copyright 2000-2015 Kitware, Inc., Insight Software Consortium + + 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. +============================================================================*/ +#include "cmCommonTargetGenerator.h" + +cmCommonTargetGenerator::cmCommonTargetGenerator() +{ +} + +cmCommonTargetGenerator::~cmCommonTargetGenerator() +{ +} diff --git a/Source/cmCommonTargetGenerator.h b/Source/cmCommonTargetGenerator.h new file mode 100644 index 0000000..96f4088 --- /dev/null +++ b/Source/cmCommonTargetGenerator.h @@ -0,0 +1,27 @@ +/*============================================================================ + CMake - Cross Platform Makefile Generator + Copyright 2000-2015 Kitware, Inc., Insight Software Consortium + + 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. +============================================================================*/ +#ifndef cmCommonTargetGenerator_h +#define cmCommonTargetGenerator_h + +#include "cmStandardIncludes.h" + +/** \class cmCommonTargetGenerator + * \brief Common infrastructure for Makefile and Ninja per-target generators + */ +class cmCommonTargetGenerator +{ +public: + cmCommonTargetGenerator(); + virtual ~cmCommonTargetGenerator(); +}; + +#endif diff --git a/Source/cmGlobalCommonGenerator.cxx b/Source/cmGlobalCommonGenerator.cxx new file mode 100644 index 0000000..dc8e5a7 --- /dev/null +++ b/Source/cmGlobalCommonGenerator.cxx @@ -0,0 +1,21 @@ +/*============================================================================ + CMake - Cross Platform Makefile Generator + Copyright 2000-2015 Kitware, Inc., Insight Software Consortium + + 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. +============================================================================*/ +#include "cmGlobalCommonGenerator.h" + +cmGlobalCommonGenerator::cmGlobalCommonGenerator(cmake* cm): + cmGlobalGenerator(cm) +{ +} + +cmGlobalCommonGenerator::~cmGlobalCommonGenerator() +{ +} diff --git a/Source/cmGlobalCommonGenerator.h b/Source/cmGlobalCommonGenerator.h new file mode 100644 index 0000000..7bb0e55 --- /dev/null +++ b/Source/cmGlobalCommonGenerator.h @@ -0,0 +1,27 @@ +/*============================================================================ + CMake - Cross Platform Makefile Generator + Copyright 2000-2015 Kitware, Inc., Insight Software Consortium + + 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. +============================================================================*/ +#ifndef cmGlobalCommonGenerator_h +#define cmGlobalCommonGenerator_h + +#include "cmGlobalGenerator.h" + +/** \class cmGlobalCommonGenerator + * \brief Common infrastructure for Makefile and Ninja global generators. + */ +class cmGlobalCommonGenerator : public cmGlobalGenerator +{ +public: + cmGlobalCommonGenerator(cmake* cm); + ~cmGlobalCommonGenerator(); +}; + +#endif diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx index 722294b..b88b8c8 100644 --- a/Source/cmGlobalNinjaGenerator.cxx +++ b/Source/cmGlobalNinjaGenerator.cxx @@ -505,7 +505,7 @@ void cmGlobalNinjaGenerator::WriteDefault(std::ostream& os, cmGlobalNinjaGenerator::cmGlobalNinjaGenerator(cmake* cm) - : cmGlobalGenerator(cm) + : cmGlobalCommonGenerator(cm) , BuildFileStream(0) , RulesFileStream(0) , CompileCommandsStream(0) diff --git a/Source/cmGlobalNinjaGenerator.h b/Source/cmGlobalNinjaGenerator.h index ffd1cdc..2a749c1 100644 --- a/Source/cmGlobalNinjaGenerator.h +++ b/Source/cmGlobalNinjaGenerator.h @@ -13,7 +13,7 @@ #ifndef cmGlobalNinjaGenerator_h # define cmGlobalNinjaGenerator_h -# include "cmGlobalGenerator.h" +# include "cmGlobalCommonGenerator.h" # include "cmGlobalGeneratorFactory.h" # include "cmNinjaTypes.h" @@ -42,7 +42,7 @@ class cmGeneratorTarget; * - We extensively use Ninja variable overloading system to minimize the * number of generated rules. */ -class cmGlobalNinjaGenerator : public cmGlobalGenerator +class cmGlobalNinjaGenerator : public cmGlobalCommonGenerator { public: /// The default name of Ninja's build file. Typically: build.ninja. diff --git a/Source/cmGlobalUnixMakefileGenerator3.cxx b/Source/cmGlobalUnixMakefileGenerator3.cxx index e6a67d3..42b42d4 100644 --- a/Source/cmGlobalUnixMakefileGenerator3.cxx +++ b/Source/cmGlobalUnixMakefileGenerator3.cxx @@ -21,7 +21,7 @@ #include "cmAlgorithms.h" cmGlobalUnixMakefileGenerator3::cmGlobalUnixMakefileGenerator3(cmake* cm) - : cmGlobalGenerator(cm) + : cmGlobalCommonGenerator(cm) { // This type of makefile always requires unix style paths this->ForceUnixPaths = true; diff --git a/Source/cmGlobalUnixMakefileGenerator3.h b/Source/cmGlobalUnixMakefileGenerator3.h index 14adf2e..fc53fa8 100644 --- a/Source/cmGlobalUnixMakefileGenerator3.h +++ b/Source/cmGlobalUnixMakefileGenerator3.h @@ -12,7 +12,7 @@ #ifndef cmGlobalUnixMakefileGenerator3_h #define cmGlobalUnixMakefileGenerator3_h -#include "cmGlobalGenerator.h" +#include "cmGlobalCommonGenerator.h" #include "cmGlobalGeneratorFactory.h" class cmGeneratedFileStream; @@ -51,7 +51,7 @@ class cmLocalUnixMakefileGenerator3; */ -class cmGlobalUnixMakefileGenerator3 : public cmGlobalGenerator +class cmGlobalUnixMakefileGenerator3 : public cmGlobalCommonGenerator { public: cmGlobalUnixMakefileGenerator3(cmake* cm); diff --git a/Source/cmLocalCommonGenerator.cxx b/Source/cmLocalCommonGenerator.cxx new file mode 100644 index 0000000..0b266f8 --- /dev/null +++ b/Source/cmLocalCommonGenerator.cxx @@ -0,0 +1,23 @@ +/*============================================================================ + CMake - Cross Platform Makefile Generator + Copyright 2000-2015 Kitware, Inc., Insight Software Consortium + + 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. +============================================================================*/ +#include "cmLocalCommonGenerator.h" + +cmLocalCommonGenerator::cmLocalCommonGenerator(cmGlobalGenerator* gg, + cmLocalGenerator* parent, + cmState::Snapshot snapshot): + cmLocalGenerator(gg, parent, snapshot) +{ +} + +cmLocalCommonGenerator::~cmLocalCommonGenerator() +{ +} diff --git a/Source/cmLocalCommonGenerator.h b/Source/cmLocalCommonGenerator.h new file mode 100644 index 0000000..c897e49 --- /dev/null +++ b/Source/cmLocalCommonGenerator.h @@ -0,0 +1,29 @@ +/*============================================================================ + CMake - Cross Platform Makefile Generator + Copyright 2000-2015 Kitware, Inc., Insight Software Consortium + + 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. +============================================================================*/ +#ifndef cmLocalCommonGenerator_h +#define cmLocalCommonGenerator_h + +#include "cmLocalGenerator.h" + +/** \class cmLocalCommonGenerator + * \brief Common infrastructure for Makefile and Ninja local generators. + */ +class cmLocalCommonGenerator: public cmLocalGenerator +{ +public: + cmLocalCommonGenerator(cmGlobalGenerator* gg, + cmLocalGenerator* parent, + cmState::Snapshot snapshot); + ~cmLocalCommonGenerator(); +}; + +#endif diff --git a/Source/cmLocalNinjaGenerator.cxx b/Source/cmLocalNinjaGenerator.cxx index 4db36fc..e712b46 100644 --- a/Source/cmLocalNinjaGenerator.cxx +++ b/Source/cmLocalNinjaGenerator.cxx @@ -25,7 +25,7 @@ cmLocalNinjaGenerator::cmLocalNinjaGenerator(cmGlobalGenerator* gg, cmLocalGenerator* parent, cmState::Snapshot snapshot) - : cmLocalGenerator(gg, parent, snapshot) + : cmLocalCommonGenerator(gg, parent, snapshot) , ConfigName("") , HomeRelativeOutputPath("") { diff --git a/Source/cmLocalNinjaGenerator.h b/Source/cmLocalNinjaGenerator.h index ce966ff..8bc5640 100644 --- a/Source/cmLocalNinjaGenerator.h +++ b/Source/cmLocalNinjaGenerator.h @@ -13,7 +13,7 @@ #ifndef cmLocalNinjaGenerator_h # define cmLocalNinjaGenerator_h -# include "cmLocalGenerator.h" +# include "cmLocalCommonGenerator.h" # include "cmNinjaTypes.h" class cmCustomCommandGenerator; @@ -28,7 +28,7 @@ class cmake; * cmLocalNinjaGenerator produces a local build.ninja file from its * member Makefile. */ -class cmLocalNinjaGenerator : public cmLocalGenerator +class cmLocalNinjaGenerator : public cmLocalCommonGenerator { public: cmLocalNinjaGenerator(cmGlobalGenerator* gg, cmLocalGenerator* parent, diff --git a/Source/cmLocalUnixMakefileGenerator3.cxx b/Source/cmLocalUnixMakefileGenerator3.cxx index e292ba7..e3acbaf 100644 --- a/Source/cmLocalUnixMakefileGenerator3.cxx +++ b/Source/cmLocalUnixMakefileGenerator3.cxx @@ -82,7 +82,7 @@ static std::string cmSplitExtension(std::string const& in, std::string& base) cmLocalUnixMakefileGenerator3:: cmLocalUnixMakefileGenerator3(cmGlobalGenerator* gg, cmLocalGenerator* parent, cmState::Snapshot snapshot) - : cmLocalGenerator(gg, parent, snapshot) + : cmLocalCommonGenerator(gg, parent, snapshot) { this->MakefileVariableSize = 0; this->ColorMakefile = false; diff --git a/Source/cmLocalUnixMakefileGenerator3.h b/Source/cmLocalUnixMakefileGenerator3.h index b097c95..70d59de 100644 --- a/Source/cmLocalUnixMakefileGenerator3.h +++ b/Source/cmLocalUnixMakefileGenerator3.h @@ -12,7 +12,7 @@ #ifndef cmLocalUnixMakefileGenerator3_h #define cmLocalUnixMakefileGenerator3_h -#include "cmLocalGenerator.h" +#include "cmLocalCommonGenerator.h" // for cmDepends::DependencyVector #include "cmDepends.h" @@ -31,7 +31,7 @@ class cmSourceFile; * cmLocalUnixMakefileGenerator3 produces a LocalUnix makefile from its * member Makefile. */ -class cmLocalUnixMakefileGenerator3 : public cmLocalGenerator +class cmLocalUnixMakefileGenerator3 : public cmLocalCommonGenerator { public: cmLocalUnixMakefileGenerator3(cmGlobalGenerator* gg, diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index 09fad5c..2f53899 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -33,7 +33,8 @@ #include cmMakefileTargetGenerator::cmMakefileTargetGenerator(cmGeneratorTarget* target) - : OSXBundleGenerator(0) + : cmCommonTargetGenerator() + , OSXBundleGenerator(0) , MacOSXContentGenerator(0) { this->BuildFileStream = 0; diff --git a/Source/cmMakefileTargetGenerator.h b/Source/cmMakefileTargetGenerator.h index 9182236..a438717 100644 --- a/Source/cmMakefileTargetGenerator.h +++ b/Source/cmMakefileTargetGenerator.h @@ -12,6 +12,8 @@ #ifndef cmMakefileTargetGenerator_h #define cmMakefileTargetGenerator_h +#include "cmCommonTargetGenerator.h" + #include "cmLocalUnixMakefileGenerator3.h" #include "cmOSXBundleGenerator.h" @@ -30,7 +32,7 @@ class cmSourceFile; * \brief Support Routines for writing makefiles * */ -class cmMakefileTargetGenerator +class cmMakefileTargetGenerator: public cmCommonTargetGenerator { public: // constructor to set the ivars diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index b18f368..93b3f4e 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -58,7 +58,7 @@ cmNinjaTargetGenerator::New(cmGeneratorTarget* target) } cmNinjaTargetGenerator::cmNinjaTargetGenerator(cmGeneratorTarget* target) - : + : cmCommonTargetGenerator(), MacOSXContentGenerator(0), OSXBundleGenerator(0), MacContentFolders(), diff --git a/Source/cmNinjaTargetGenerator.h b/Source/cmNinjaTargetGenerator.h index fc361b2..a98f04e 100644 --- a/Source/cmNinjaTargetGenerator.h +++ b/Source/cmNinjaTargetGenerator.h @@ -13,6 +13,8 @@ #ifndef cmNinjaTargetGenerator_h #define cmNinjaTargetGenerator_h +#include "cmCommonTargetGenerator.h" + #include "cmStandardIncludes.h" #include "cmNinjaTypes.h" #include "cmLocalNinjaGenerator.h" @@ -26,7 +28,7 @@ class cmMakefile; class cmSourceFile; class cmCustomCommand; -class cmNinjaTargetGenerator +class cmNinjaTargetGenerator: public cmCommonTargetGenerator { public: /// Create a cmNinjaTargetGenerator according to the @a target's type. diff --git a/bootstrap b/bootstrap index 98cdcd0..d778bbe 100755 --- a/bootstrap +++ b/bootstrap @@ -248,6 +248,7 @@ CMAKE_CXX_SOURCES="\ cmCommandArgumentLexer \ cmCommandArgumentParser \ cmCommandArgumentParserHelper \ + cmCommonTargetGenerator \ cmCPackPropertiesGenerator \ cmDefinitions \ cmDepends \ @@ -276,8 +277,10 @@ CMAKE_CXX_SOURCES="\ cmGeneratorExpressionNode \ cmGeneratorExpressionParser \ cmGeneratorExpression \ + cmGlobalCommonGenerator \ cmGlobalGenerator \ cmInstallDirectoryGenerator \ + cmLocalCommonGenerator \ cmLocalGenerator \ cmInstalledFile \ cmInstallGenerator \ -- cgit v0.12 From e7dcdd1011719b031d580d9094ad1f8c4701ef38 Mon Sep 17 00:00:00 2001 From: Brad King Date: Wed, 8 Jul 2015 11:13:11 -0400 Subject: cmCommonTargetGenerator: Adopt basic target generator members De-duplicate the GeneratorTarget, Target, and Makefile members from the local Makefile and Ninja generators. --- Source/cmCommonTargetGenerator.cxx | 13 ++++++++++++- Source/cmCommonTargetGenerator.h | 15 ++++++++++++++- Source/cmMakefileTargetGenerator.cxx | 5 +---- Source/cmMakefileTargetGenerator.h | 3 --- Source/cmNinjaTargetGenerator.cxx | 5 +---- Source/cmNinjaTargetGenerator.h | 3 --- 6 files changed, 28 insertions(+), 16 deletions(-) diff --git a/Source/cmCommonTargetGenerator.cxx b/Source/cmCommonTargetGenerator.cxx index e1f7522..9d10e39 100644 --- a/Source/cmCommonTargetGenerator.cxx +++ b/Source/cmCommonTargetGenerator.cxx @@ -11,7 +11,18 @@ ============================================================================*/ #include "cmCommonTargetGenerator.h" -cmCommonTargetGenerator::cmCommonTargetGenerator() +#include "cmGeneratorTarget.h" +#include "cmGlobalCommonGenerator.h" +#include "cmLocalCommonGenerator.h" +#include "cmTarget.h" + +cmCommonTargetGenerator::cmCommonTargetGenerator(cmGeneratorTarget* gt) + : GeneratorTarget(gt) + , Target(gt->Target) + , Makefile(gt->Makefile) + , LocalGenerator(static_cast(gt->LocalGenerator)) + , GlobalGenerator(static_cast( + gt->LocalGenerator->GetGlobalGenerator())) { } diff --git a/Source/cmCommonTargetGenerator.h b/Source/cmCommonTargetGenerator.h index 96f4088..e39f2c8 100644 --- a/Source/cmCommonTargetGenerator.h +++ b/Source/cmCommonTargetGenerator.h @@ -14,14 +14,27 @@ #include "cmStandardIncludes.h" +class cmGeneratorTarget; +class cmGlobalCommonGenerator; +class cmLocalCommonGenerator; +class cmMakefile; +class cmTarget; + /** \class cmCommonTargetGenerator * \brief Common infrastructure for Makefile and Ninja per-target generators */ class cmCommonTargetGenerator { public: - cmCommonTargetGenerator(); + cmCommonTargetGenerator(cmGeneratorTarget* gt); virtual ~cmCommonTargetGenerator(); + +protected: + cmGeneratorTarget* GeneratorTarget; + cmTarget* Target; + cmMakefile* Makefile; + cmLocalCommonGenerator* LocalGenerator; + cmGlobalCommonGenerator* GlobalGenerator; }; #endif diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index 2f53899..3e45d10 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -33,7 +33,7 @@ #include cmMakefileTargetGenerator::cmMakefileTargetGenerator(cmGeneratorTarget* target) - : cmCommonTargetGenerator() + : cmCommonTargetGenerator(target) , OSXBundleGenerator(0) , MacOSXContentGenerator(0) { @@ -42,15 +42,12 @@ cmMakefileTargetGenerator::cmMakefileTargetGenerator(cmGeneratorTarget* target) this->FlagFileStream = 0; this->CustomCommandDriver = OnBuild; this->FortranModuleDirectoryComputed = false; - this->Target = target->Target; - this->Makefile = this->Target->GetMakefile(); this->LocalGenerator = static_cast(target->GetLocalGenerator()); this->ConfigName = this->LocalGenerator->ConfigurationName.c_str(); this->GlobalGenerator = static_cast( this->LocalGenerator->GetGlobalGenerator()); - this->GeneratorTarget = target; cmake* cm = this->GlobalGenerator->GetCMakeInstance(); this->NoRuleMessages = false; if(const char* ruleStatus = cm->GetState() diff --git a/Source/cmMakefileTargetGenerator.h b/Source/cmMakefileTargetGenerator.h index a438717..787f246 100644 --- a/Source/cmMakefileTargetGenerator.h +++ b/Source/cmMakefileTargetGenerator.h @@ -175,11 +175,8 @@ protected: virtual void CloseFileStreams(); void RemoveForbiddenFlags(const char* flagVar, const std::string& linkLang, std::string& linkFlags); - cmTarget *Target; - cmGeneratorTarget* GeneratorTarget; cmLocalUnixMakefileGenerator3 *LocalGenerator; cmGlobalUnixMakefileGenerator3 *GlobalGenerator; - cmMakefile *Makefile; std::string ConfigName; enum CustomCommandDriveType { OnBuild, OnDepends, OnUtility }; diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index 93b3f4e..5ede08a 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -58,17 +58,14 @@ cmNinjaTargetGenerator::New(cmGeneratorTarget* target) } cmNinjaTargetGenerator::cmNinjaTargetGenerator(cmGeneratorTarget* target) - : cmCommonTargetGenerator(), + : cmCommonTargetGenerator(target), MacOSXContentGenerator(0), OSXBundleGenerator(0), MacContentFolders(), - Target(target->Target), - Makefile(target->Makefile), LocalGenerator( static_cast(target->GetLocalGenerator())), Objects() { - this->GeneratorTarget = target; MacOSXContentGenerator = new MacOSXContentGeneratorType(this); } diff --git a/Source/cmNinjaTargetGenerator.h b/Source/cmNinjaTargetGenerator.h index a98f04e..87ba17f 100644 --- a/Source/cmNinjaTargetGenerator.h +++ b/Source/cmNinjaTargetGenerator.h @@ -152,9 +152,6 @@ protected: cmNinjaVars& vars); private: - cmTarget* Target; - cmGeneratorTarget* GeneratorTarget; - cmMakefile* Makefile; cmLocalNinjaGenerator* LocalGenerator; /// List of object files for this target. cmNinjaDeps Objects; -- cgit v0.12 From a4a2518dd47bd37f2204a0209c2eeb632d191d1e Mon Sep 17 00:00:00 2001 From: Brad King Date: Wed, 8 Jul 2015 11:21:55 -0400 Subject: cmLocalUnixMakefileGenerator3: Provide GetConfigName() accessor Rename internal member from ConfigurationName to ConfigName to match the ninja generator. --- Source/cmGlobalUnixMakefileGenerator3.cxx | 6 +++--- Source/cmLocalUnixMakefileGenerator3.cxx | 14 +++++++------- Source/cmLocalUnixMakefileGenerator3.h | 3 ++- Source/cmMakefileTargetGenerator.cxx | 12 ++++++------ 4 files changed, 18 insertions(+), 17 deletions(-) diff --git a/Source/cmGlobalUnixMakefileGenerator3.cxx b/Source/cmGlobalUnixMakefileGenerator3.cxx index 42b42d4..c5fca91 100644 --- a/Source/cmGlobalUnixMakefileGenerator3.cxx +++ b/Source/cmGlobalUnixMakefileGenerator3.cxx @@ -483,7 +483,7 @@ cmGlobalUnixMakefileGenerator3 if((!check_all || !gtarget->GetPropertyAsBool("EXCLUDE_FROM_ALL")) && (!check_relink || gtarget->Target - ->NeedRelinkBeforeInstall(lg->ConfigurationName))) + ->NeedRelinkBeforeInstall(lg->GetConfigName()))) { std::string tname = lg->GetRelativeTargetDirectory(*gtarget->Target); tname += "/"; @@ -692,7 +692,7 @@ cmGlobalUnixMakefileGenerator3 // Add a local name for the rule to relink the target before // installation. if(gtarget->Target - ->NeedRelinkBeforeInstall(lg->ConfigurationName)) + ->NeedRelinkBeforeInstall(lg->GetConfigName())) { makeTargetName = lg->GetRelativeTargetDirectory(*gtarget->Target); makeTargetName += "/preinstall"; @@ -865,7 +865,7 @@ cmGlobalUnixMakefileGenerator3 // Add rules to prepare the target for installation. if(gtarget->Target - ->NeedRelinkBeforeInstall(lg->ConfigurationName)) + ->NeedRelinkBeforeInstall(lg->GetConfigName())) { localName = lg->GetRelativeTargetDirectory(*gtarget->Target); localName += "/preinstall"; diff --git a/Source/cmLocalUnixMakefileGenerator3.cxx b/Source/cmLocalUnixMakefileGenerator3.cxx index e3acbaf..1c6bd7c 100644 --- a/Source/cmLocalUnixMakefileGenerator3.cxx +++ b/Source/cmLocalUnixMakefileGenerator3.cxx @@ -104,12 +104,12 @@ void cmLocalUnixMakefileGenerator3::Generate() if(const char* config = this->Makefile->GetDefinition("CMAKE_BUILD_TYPE")) { // Use the build type given by the user. - this->ConfigurationName = config; + this->ConfigName = config; } else { // No configuration type given. - this->ConfigurationName = ""; + this->ConfigName = ""; } // Record whether some options are enabled to avoid checking many @@ -497,7 +497,7 @@ void cmLocalUnixMakefileGenerator3 // Add a local name for the rule to relink the target before // installation. if(t->second->Target - ->NeedRelinkBeforeInstall(this->ConfigurationName)) + ->NeedRelinkBeforeInstall(this->ConfigName)) { makeTargetName = this->GetRelativeTargetDirectory(*t->second->Target); makeTargetName += "/preinstall"; @@ -1017,7 +1017,7 @@ cmLocalUnixMakefileGenerator3 for(std::vector::const_iterator i = ccs.begin(); i != ccs.end(); ++i) { - cmCustomCommandGenerator ccg(*i, this->ConfigurationName, + cmCustomCommandGenerator ccg(*i, this->ConfigName, this->Makefile); this->AppendCustomDepend(depends, ccg); } @@ -1034,7 +1034,7 @@ cmLocalUnixMakefileGenerator3 { // Lookup the real name of the dependency in case it is a CMake target. std::string dep; - if(this->GetRealDependency(*d, this->ConfigurationName, + if(this->GetRealDependency(*d, this->ConfigName, dep)) { depends.push_back(dep); @@ -1053,7 +1053,7 @@ cmLocalUnixMakefileGenerator3 for(std::vector::const_iterator i = ccs.begin(); i != ccs.end(); ++i) { - cmCustomCommandGenerator ccg(*i, this->ConfigurationName, + cmCustomCommandGenerator ccg(*i, this->ConfigName, this->Makefile); this->AppendCustomCommand(commands, ccg, target, true, relative); } @@ -2043,7 +2043,7 @@ void cmLocalUnixMakefileGenerator3 // Build a list of preprocessor definitions for the target. std::set defines; this->AddCompileDefinitions(defines, &target, - this->ConfigurationName, l->first); + this->ConfigName, l->first); if(!defines.empty()) { cmakefileStream diff --git a/Source/cmLocalUnixMakefileGenerator3.h b/Source/cmLocalUnixMakefileGenerator3.h index 70d59de..ed77a5f 100644 --- a/Source/cmLocalUnixMakefileGenerator3.h +++ b/Source/cmLocalUnixMakefileGenerator3.h @@ -46,6 +46,7 @@ public: */ virtual void Generate(); + std::string const& GetConfigName() { return this->ConfigName; } // this returns the relative path between the HomeOutputDirectory and this // local generators StartOutputDirectory @@ -253,7 +254,7 @@ private: ImplicitDependTargetMap ImplicitDepends; - std::string ConfigurationName; + std::string ConfigName; std::string HomeRelativeOutputPath; diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index 3e45d10..3371381 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -44,7 +44,7 @@ cmMakefileTargetGenerator::cmMakefileTargetGenerator(cmGeneratorTarget* target) this->FortranModuleDirectoryComputed = false; this->LocalGenerator = static_cast(target->GetLocalGenerator()); - this->ConfigName = this->LocalGenerator->ConfigurationName.c_str(); + this->ConfigName = this->LocalGenerator->GetConfigName().c_str(); this->GlobalGenerator = static_cast( this->LocalGenerator->GetGlobalGenerator()); @@ -337,7 +337,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, l); + this->LocalGenerator->GetConfigName(), l); std::string definesString; this->LocalGenerator->JoinDefines(defines, definesString, lang); @@ -565,7 +565,7 @@ cmMakefileTargetGenerator this->LocalGenerator->AppendFlags(flags, langFlags); std::string configUpper = - cmSystemTools::UpperCase(this->LocalGenerator->ConfigurationName); + cmSystemTools::UpperCase(this->LocalGenerator->GetConfigName()); // Add Fortran format flags. if(lang == "Fortran") @@ -1156,7 +1156,7 @@ void cmMakefileTargetGenerator::WriteTargetDependRules() << "# Targets to which this target links.\n" << "set(CMAKE_TARGET_LINKED_INFO_FILES\n"; std::set emitted; - const char* cfg = this->LocalGenerator->ConfigurationName.c_str(); + const char* cfg = this->LocalGenerator->GetConfigName().c_str(); if(cmComputeLinkInformation* cli = this->Target->GetLinkInformation(cfg)) { cmComputeLinkInformation::ItemVector const& items = cli->GetItems(); @@ -1597,7 +1597,7 @@ std::string cmMakefileTargetGenerator::GetFrameworkFlags(std::string const& l) } std::string flags; - const char* cfg = this->LocalGenerator->ConfigurationName.c_str(); + const char* cfg = this->LocalGenerator->GetConfigName().c_str(); if(cmComputeLinkInformation* cli = this->Target->GetLinkInformation(cfg)) { std::vector const& frameworks = cli->GetFrameworkPaths(); @@ -1627,7 +1627,7 @@ void cmMakefileTargetGenerator } // Loop over all library dependencies. - const char* cfg = this->LocalGenerator->ConfigurationName.c_str(); + const char* cfg = this->LocalGenerator->GetConfigName().c_str(); if(cmComputeLinkInformation* cli = this->Target->GetLinkInformation(cfg)) { std::vector const& libDeps = cli->GetDepends(); -- cgit v0.12 From 9d41f6d87b28c46d8a6d52f2de91976819e6b4d0 Mon Sep 17 00:00:00 2001 From: Brad King Date: Wed, 8 Jul 2015 11:27:22 -0400 Subject: cmLocalCommonGenerator: Adopt ConfigName member De-duplicate the member from the local Makefile and Ninja generators. --- Source/cmLocalCommonGenerator.cxx | 17 +++++++++++++++++ Source/cmLocalCommonGenerator.h | 6 ++++++ Source/cmLocalNinjaGenerator.cxx | 17 ----------------- Source/cmLocalNinjaGenerator.h | 6 ------ Source/cmLocalUnixMakefileGenerator3.cxx | 12 +----------- Source/cmLocalUnixMakefileGenerator3.h | 4 ---- 6 files changed, 24 insertions(+), 38 deletions(-) diff --git a/Source/cmLocalCommonGenerator.cxx b/Source/cmLocalCommonGenerator.cxx index 0b266f8..4583446 100644 --- a/Source/cmLocalCommonGenerator.cxx +++ b/Source/cmLocalCommonGenerator.cxx @@ -11,6 +11,8 @@ ============================================================================*/ #include "cmLocalCommonGenerator.h" +#include "cmMakefile.h" + cmLocalCommonGenerator::cmLocalCommonGenerator(cmGlobalGenerator* gg, cmLocalGenerator* parent, cmState::Snapshot snapshot): @@ -21,3 +23,18 @@ cmLocalCommonGenerator::cmLocalCommonGenerator(cmGlobalGenerator* gg, cmLocalCommonGenerator::~cmLocalCommonGenerator() { } + +void cmLocalCommonGenerator::SetConfigName() +{ + // Store the configuration name that will be generated. + if(const char* config = this->Makefile->GetDefinition("CMAKE_BUILD_TYPE")) + { + // Use the build type given by the user. + this->ConfigName = config; + } + else + { + // No configuration type given. + this->ConfigName = ""; + } +} diff --git a/Source/cmLocalCommonGenerator.h b/Source/cmLocalCommonGenerator.h index c897e49..c18ec16 100644 --- a/Source/cmLocalCommonGenerator.h +++ b/Source/cmLocalCommonGenerator.h @@ -24,6 +24,12 @@ public: cmLocalGenerator* parent, cmState::Snapshot snapshot); ~cmLocalCommonGenerator(); + + std::string const& GetConfigName() { return this->ConfigName; } + +protected: + void SetConfigName(); + std::string ConfigName; }; #endif diff --git a/Source/cmLocalNinjaGenerator.cxx b/Source/cmLocalNinjaGenerator.cxx index e712b46..a293d06 100644 --- a/Source/cmLocalNinjaGenerator.cxx +++ b/Source/cmLocalNinjaGenerator.cxx @@ -26,7 +26,6 @@ cmLocalNinjaGenerator::cmLocalNinjaGenerator(cmGlobalGenerator* gg, cmLocalGenerator* parent, cmState::Snapshot snapshot) : cmLocalCommonGenerator(gg, parent, snapshot) - , ConfigName("") , HomeRelativeOutputPath("") { this->TargetImplib = "$TARGET_IMPLIB"; @@ -261,22 +260,6 @@ void cmLocalNinjaGenerator::WriteNinjaFilesInclusion(std::ostream& os) os << "\n"; } -void cmLocalNinjaGenerator::SetConfigName() -{ - // Store the configuration name that will be generated. - if(const char* config = - this->GetMakefile()->GetDefinition("CMAKE_BUILD_TYPE")) - { - // Use the build type given by the user. - this->ConfigName = config; - } - else - { - // No configuration type given. - this->ConfigName = ""; - } -} - //---------------------------------------------------------------------------- void cmLocalNinjaGenerator::ComputeObjectFilenames( std::map& mapping, diff --git a/Source/cmLocalNinjaGenerator.h b/Source/cmLocalNinjaGenerator.h index 8bc5640..d10be0c 100644 --- a/Source/cmLocalNinjaGenerator.h +++ b/Source/cmLocalNinjaGenerator.h @@ -46,9 +46,6 @@ public: const cmake* GetCMakeInstance() const; cmake* GetCMakeInstance(); - std::string const& GetConfigName() const - { return this->ConfigName; } - /// @returns the relative path between the HomeOutputDirectory and this /// local generators StartOutputDirectory. std::string GetHomeRelativeOutputPath() const @@ -110,8 +107,6 @@ private: void WriteProcessedMakefile(std::ostream& os); void WritePools(std::ostream& os); - void SetConfigName(); - void WriteCustomCommandRule(); void WriteCustomCommandBuildStatement(cmCustomCommand const *cc, const cmNinjaDeps& orderOnlyDeps); @@ -120,7 +115,6 @@ private: std::string MakeCustomLauncher(cmCustomCommandGenerator const& ccg); - std::string ConfigName; std::string HomeRelativeOutputPath; typedef std::map > diff --git a/Source/cmLocalUnixMakefileGenerator3.cxx b/Source/cmLocalUnixMakefileGenerator3.cxx index 1c6bd7c..5d17a40 100644 --- a/Source/cmLocalUnixMakefileGenerator3.cxx +++ b/Source/cmLocalUnixMakefileGenerator3.cxx @@ -100,17 +100,7 @@ cmLocalUnixMakefileGenerator3::~cmLocalUnixMakefileGenerator3() //---------------------------------------------------------------------------- void cmLocalUnixMakefileGenerator3::Generate() { - // Store the configuration name that will be generated. - if(const char* config = this->Makefile->GetDefinition("CMAKE_BUILD_TYPE")) - { - // Use the build type given by the user. - this->ConfigName = config; - } - else - { - // No configuration type given. - this->ConfigName = ""; - } + this->SetConfigName(); // Record whether some options are enabled to avoid checking many // times later. diff --git a/Source/cmLocalUnixMakefileGenerator3.h b/Source/cmLocalUnixMakefileGenerator3.h index ed77a5f..01ac01b 100644 --- a/Source/cmLocalUnixMakefileGenerator3.h +++ b/Source/cmLocalUnixMakefileGenerator3.h @@ -46,8 +46,6 @@ public: */ virtual void Generate(); - std::string const& GetConfigName() { return this->ConfigName; } - // this returns the relative path between the HomeOutputDirectory and this // local generators StartOutputDirectory const std::string &GetHomeRelativeOutputPath(); @@ -254,8 +252,6 @@ private: ImplicitDependTargetMap ImplicitDepends; - std::string ConfigName; - std::string HomeRelativeOutputPath; struct LocalObjectEntry -- cgit v0.12 From abfa5f2d1fac0a55b430e078884ad1ae252d20cd Mon Sep 17 00:00:00 2001 From: Brad King Date: Wed, 8 Jul 2015 15:02:11 -0400 Subject: cmCommonTargetGenerator: Adopt ConfigName member De-duplicate the member from the Makefile and Ninja target generators. --- Source/cmCommonTargetGenerator.cxx | 6 ++++++ Source/cmCommonTargetGenerator.h | 3 +++ Source/cmMakefileTargetGenerator.cxx | 1 - Source/cmMakefileTargetGenerator.h | 1 - Source/cmNinjaTargetGenerator.cxx | 5 ----- Source/cmNinjaTargetGenerator.h | 2 -- 6 files changed, 9 insertions(+), 9 deletions(-) diff --git a/Source/cmCommonTargetGenerator.cxx b/Source/cmCommonTargetGenerator.cxx index 9d10e39..3edeff3 100644 --- a/Source/cmCommonTargetGenerator.cxx +++ b/Source/cmCommonTargetGenerator.cxx @@ -23,9 +23,15 @@ cmCommonTargetGenerator::cmCommonTargetGenerator(cmGeneratorTarget* gt) , LocalGenerator(static_cast(gt->LocalGenerator)) , GlobalGenerator(static_cast( gt->LocalGenerator->GetGlobalGenerator())) + , ConfigName(LocalGenerator->GetConfigName()) { } cmCommonTargetGenerator::~cmCommonTargetGenerator() { } + +std::string const& cmCommonTargetGenerator::GetConfigName() const +{ + return this->ConfigName; +} diff --git a/Source/cmCommonTargetGenerator.h b/Source/cmCommonTargetGenerator.h index e39f2c8..bf2add3 100644 --- a/Source/cmCommonTargetGenerator.h +++ b/Source/cmCommonTargetGenerator.h @@ -29,12 +29,15 @@ public: cmCommonTargetGenerator(cmGeneratorTarget* gt); virtual ~cmCommonTargetGenerator(); + std::string const& GetConfigName() const; + protected: cmGeneratorTarget* GeneratorTarget; cmTarget* Target; cmMakefile* Makefile; cmLocalCommonGenerator* LocalGenerator; cmGlobalCommonGenerator* GlobalGenerator; + std::string ConfigName; }; #endif diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index 3371381..5c9402e 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -44,7 +44,6 @@ cmMakefileTargetGenerator::cmMakefileTargetGenerator(cmGeneratorTarget* target) this->FortranModuleDirectoryComputed = false; this->LocalGenerator = static_cast(target->GetLocalGenerator()); - this->ConfigName = this->LocalGenerator->GetConfigName().c_str(); this->GlobalGenerator = static_cast( this->LocalGenerator->GetGlobalGenerator()); diff --git a/Source/cmMakefileTargetGenerator.h b/Source/cmMakefileTargetGenerator.h index 787f246..2985f4e 100644 --- a/Source/cmMakefileTargetGenerator.h +++ b/Source/cmMakefileTargetGenerator.h @@ -177,7 +177,6 @@ protected: std::string& linkFlags); cmLocalUnixMakefileGenerator3 *LocalGenerator; cmGlobalUnixMakefileGenerator3 *GlobalGenerator; - std::string ConfigName; enum CustomCommandDriveType { OnBuild, OnDepends, OnUtility }; CustomCommandDriveType CustomCommandDriver; diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index 5ede08a..152bf7c 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -89,11 +89,6 @@ cmGlobalNinjaGenerator* cmNinjaTargetGenerator::GetGlobalGenerator() const return this->LocalGenerator->GetGlobalNinjaGenerator(); } -std::string const& cmNinjaTargetGenerator::GetConfigName() const -{ - return this->LocalGenerator->GetConfigName(); -} - std::string cmNinjaTargetGenerator::LanguageCompilerRule( const std::string& lang) const { diff --git a/Source/cmNinjaTargetGenerator.h b/Source/cmNinjaTargetGenerator.h index 87ba17f..e446876 100644 --- a/Source/cmNinjaTargetGenerator.h +++ b/Source/cmNinjaTargetGenerator.h @@ -67,8 +67,6 @@ protected: cmMakefile* GetMakefile() const { return this->Makefile; } - std::string const& GetConfigName() const; - std::string LanguageCompilerRule(const std::string& lang) const; const char* GetFeature(const std::string& feature); -- cgit v0.12 From beee79373222ea01008cd137dd9a3ffa59cbe347 Mon Sep 17 00:00:00 2001 From: Brad King Date: Wed, 8 Jul 2015 14:49:04 -0400 Subject: cmCommonTargetGenerator: Adopt GetFeature and friends De-duplicate the GetFeature, GetFeatureAsBool, and AddFeatureFlags members from the Makefile and Ninja target generators. --- Source/cmCommonTargetGenerator.cxx | 26 ++++++++++++++++++++++++++ Source/cmCommonTargetGenerator.h | 8 ++++++++ Source/cmMakefileTargetGenerator.cxx | 26 -------------------------- Source/cmMakefileTargetGenerator.h | 7 ------- Source/cmNinjaTargetGenerator.cxx | 26 -------------------------- Source/cmNinjaTargetGenerator.h | 4 ---- 6 files changed, 34 insertions(+), 63 deletions(-) diff --git a/Source/cmCommonTargetGenerator.cxx b/Source/cmCommonTargetGenerator.cxx index 3edeff3..34982b0 100644 --- a/Source/cmCommonTargetGenerator.cxx +++ b/Source/cmCommonTargetGenerator.cxx @@ -35,3 +35,29 @@ std::string const& cmCommonTargetGenerator::GetConfigName() const { return this->ConfigName; } + +//---------------------------------------------------------------------------- +const char* cmCommonTargetGenerator::GetFeature(const std::string& feature) +{ + return this->GeneratorTarget->GetFeature(feature, this->ConfigName); +} + +//---------------------------------------------------------------------------- +bool cmCommonTargetGenerator::GetFeatureAsBool(const std::string& feature) +{ + return this->GeneratorTarget->GetFeatureAsBool(feature, this->ConfigName); +} + +//---------------------------------------------------------------------------- +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")) + { + this->LocalGenerator->AppendFeatureOptions(flags, lang, "IPO"); + } +} diff --git a/Source/cmCommonTargetGenerator.h b/Source/cmCommonTargetGenerator.h index bf2add3..25d19a0 100644 --- a/Source/cmCommonTargetGenerator.h +++ b/Source/cmCommonTargetGenerator.h @@ -32,6 +32,14 @@ public: std::string const& GetConfigName() const; protected: + + // Add language feature flags. + void AddFeatureFlags(std::string& flags, const std::string& lang); + + // Feature query methods. + const char* GetFeature(const std::string& feature); + bool GetFeatureAsBool(const std::string& feature); + cmGeneratorTarget* GeneratorTarget; cmTarget* Target; cmMakefile* Makefile; diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index 5c9402e..42fb89c 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -2099,29 +2099,3 @@ void cmMakefileTargetGenerator::AddModuleDefinitionFlag(std::string& flags) flag += (this->LocalGenerator->ConvertToLinkReference(def)); this->LocalGenerator->AppendFlags(flags, flag); } - -//---------------------------------------------------------------------------- -const char* cmMakefileTargetGenerator::GetFeature(const std::string& feature) -{ - return this->GeneratorTarget->GetFeature(feature, this->ConfigName); -} - -//---------------------------------------------------------------------------- -bool cmMakefileTargetGenerator::GetFeatureAsBool(const std::string& feature) -{ - return this->GeneratorTarget->GetFeatureAsBool(feature, this->ConfigName); -} - -//---------------------------------------------------------------------------- -void cmMakefileTargetGenerator::AddFeatureFlags( - std::string& flags, const std::string& lang - ) -{ - // Add language-specific flags. - this->LocalGenerator->AddLanguageFlags(flags, lang, this->ConfigName); - - if(this->GetFeatureAsBool("INTERPROCEDURAL_OPTIMIZATION")) - { - this->LocalGenerator->AppendFeatureOptions(flags, lang, "IPO"); - } -} diff --git a/Source/cmMakefileTargetGenerator.h b/Source/cmMakefileTargetGenerator.h index 2985f4e..5415423 100644 --- a/Source/cmMakefileTargetGenerator.h +++ b/Source/cmMakefileTargetGenerator.h @@ -258,13 +258,6 @@ protected: // Helper to add flag for windows .def file. void AddModuleDefinitionFlag(std::string& flags); - // Add language feature flags. - void AddFeatureFlags(std::string& flags, const std::string& lang); - - // Feature query methods. - const char* GetFeature(const std::string& feature); - bool GetFeatureAsBool(const std::string& feature); - //================================================================== // Convenience routines that do nothing more than forward to // implementaitons diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index 152bf7c..8bc0ad0 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -96,32 +96,6 @@ std::string cmNinjaTargetGenerator::LanguageCompilerRule( cmGlobalNinjaGenerator::EncodeRuleName(this->Target->GetName()); } -// TODO: Picked up from cmMakefileTargetGenerator. Refactor it. -const char* cmNinjaTargetGenerator::GetFeature(const std::string& feature) -{ - return this->GeneratorTarget->GetFeature(feature, this->GetConfigName()); -} - -// TODO: Picked up from cmMakefileTargetGenerator. Refactor it. -bool cmNinjaTargetGenerator::GetFeatureAsBool(const std::string& feature) -{ - return this->GeneratorTarget->GetFeatureAsBool(feature, - this->GetConfigName()); -} - -// TODO: Picked up from cmMakefileTargetGenerator. Refactor it. -void cmNinjaTargetGenerator::AddFeatureFlags(std::string& flags, - const std::string& lang) -{ - // Add language-specific flags. - this->LocalGenerator->AddLanguageFlags(flags, lang, this->GetConfigName()); - - if(this->GetFeatureAsBool("INTERPROCEDURAL_OPTIMIZATION")) - { - this->LocalGenerator->AppendFeatureOptions(flags, lang, "IPO"); - } -} - std::string cmNinjaTargetGenerator::OrderDependsTargetForTarget() { diff --git a/Source/cmNinjaTargetGenerator.h b/Source/cmNinjaTargetGenerator.h index e446876..639654a 100644 --- a/Source/cmNinjaTargetGenerator.h +++ b/Source/cmNinjaTargetGenerator.h @@ -69,10 +69,6 @@ protected: std::string LanguageCompilerRule(const std::string& lang) const; - const char* GetFeature(const std::string& feature); - bool GetFeatureAsBool(const std::string& feature); - void AddFeatureFlags(std::string& flags, const std::string& lang); - std::string OrderDependsTargetForTarget(); std::string ComputeOrderDependsForTarget(); -- cgit v0.12 From cdb5b65752c5a009ac3bb7425637da808a7a9bca Mon Sep 17 00:00:00 2001 From: Brad King Date: Wed, 8 Jul 2015 15:24:17 -0400 Subject: cmCommonTargetGenerator: Adopt ModuleDefinitionFile member De-duplicate the ModuleDefinitionFile and AddModuleDefinitionFlag members from the Makefile and Ninja target generators. --- Source/cmCommonTargetGenerator.cxx | 26 ++++++++++++++++++++++++++ Source/cmCommonTargetGenerator.h | 6 ++++++ Source/cmLocalCommonGenerator.h | 4 ++++ Source/cmMakefileTargetGenerator.cxx | 31 ++----------------------------- Source/cmMakefileTargetGenerator.h | 3 --- Source/cmNinjaTargetGenerator.cxx | 33 +-------------------------------- Source/cmNinjaTargetGenerator.h | 6 ------ 7 files changed, 39 insertions(+), 70 deletions(-) diff --git a/Source/cmCommonTargetGenerator.cxx b/Source/cmCommonTargetGenerator.cxx index 34982b0..84a35a8 100644 --- a/Source/cmCommonTargetGenerator.cxx +++ b/Source/cmCommonTargetGenerator.cxx @@ -14,6 +14,7 @@ #include "cmGeneratorTarget.h" #include "cmGlobalCommonGenerator.h" #include "cmLocalCommonGenerator.h" +#include "cmMakefile.h" #include "cmTarget.h" cmCommonTargetGenerator::cmCommonTargetGenerator(cmGeneratorTarget* gt) @@ -24,6 +25,7 @@ cmCommonTargetGenerator::cmCommonTargetGenerator(cmGeneratorTarget* gt) , GlobalGenerator(static_cast( gt->LocalGenerator->GetGlobalGenerator())) , ConfigName(LocalGenerator->GetConfigName()) + , ModuleDefinitionFile(GeneratorTarget->GetModuleDefinitionFile(ConfigName)) { } @@ -61,3 +63,27 @@ void cmCommonTargetGenerator::AddFeatureFlags( this->LocalGenerator->AppendFeatureOptions(flags, lang, "IPO"); } } + +//---------------------------------------------------------------------------- +void cmCommonTargetGenerator::AddModuleDefinitionFlag(std::string& flags) +{ + if(this->ModuleDefinitionFile.empty()) + { + return; + } + + // TODO: Create a per-language flag variable. + const char* defFileFlag = + this->Makefile->GetDefinition("CMAKE_LINK_DEF_FILE_FLAG"); + 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)); + this->LocalGenerator->AppendFlags(flags, flag); +} diff --git a/Source/cmCommonTargetGenerator.h b/Source/cmCommonTargetGenerator.h index 25d19a0..deeb5ee 100644 --- a/Source/cmCommonTargetGenerator.h +++ b/Source/cmCommonTargetGenerator.h @@ -40,12 +40,18 @@ protected: const char* GetFeature(const std::string& feature); bool GetFeatureAsBool(const std::string& feature); + // Helper to add flag for windows .def file. + void AddModuleDefinitionFlag(std::string& flags); + cmGeneratorTarget* GeneratorTarget; cmTarget* Target; cmMakefile* Makefile; cmLocalCommonGenerator* LocalGenerator; cmGlobalCommonGenerator* GlobalGenerator; std::string ConfigName; + + // The windows module definition source file (.def), if any. + std::string ModuleDefinitionFile; }; #endif diff --git a/Source/cmLocalCommonGenerator.h b/Source/cmLocalCommonGenerator.h index c18ec16..af94cda 100644 --- a/Source/cmLocalCommonGenerator.h +++ b/Source/cmLocalCommonGenerator.h @@ -14,6 +14,8 @@ #include "cmLocalGenerator.h" +class cmCommonTargetGenerator; + /** \class cmLocalCommonGenerator * \brief Common infrastructure for Makefile and Ninja local generators. */ @@ -30,6 +32,8 @@ public: protected: void SetConfigName(); std::string ConfigName; + + friend class cmCommonTargetGenerator; }; #endif diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index 42fb89c..fe6b4f6 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -1668,11 +1668,9 @@ void cmMakefileTargetGenerator this->AppendTargetDepends(depends); // Add a dependency on the link definitions file, if any. - std::string def = this->GeneratorTarget->GetModuleDefinitionFile( - this->Makefile->GetSafeDefinition("CMAKE_BUILD_TYPE")); - if(!def.empty()) + if(!this->ModuleDefinitionFile.empty()) { - depends.push_back(def); + depends.push_back(this->ModuleDefinitionFile); } // Add user-specified dependencies. @@ -2074,28 +2072,3 @@ void cmMakefileTargetGenerator::AddFortranFlags(std::string& flags) } } } - -//---------------------------------------------------------------------------- -void cmMakefileTargetGenerator::AddModuleDefinitionFlag(std::string& flags) -{ - std::string def = this->GeneratorTarget->GetModuleDefinitionFile( - this->Makefile->GetSafeDefinition("CMAKE_BUILD_TYPE")); - if(def.empty()) - { - return; - } - - // TODO: Create a per-language flag variable. - const char* defFileFlag = - this->Makefile->GetDefinition("CMAKE_LINK_DEF_FILE_FLAG"); - 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(def)); - this->LocalGenerator->AppendFlags(flags, flag); -} diff --git a/Source/cmMakefileTargetGenerator.h b/Source/cmMakefileTargetGenerator.h index 5415423..d2d1df9 100644 --- a/Source/cmMakefileTargetGenerator.h +++ b/Source/cmMakefileTargetGenerator.h @@ -255,9 +255,6 @@ protected: // Compute target-specific Fortran language flags. void AddFortranFlags(std::string& flags); - // Helper to add flag for windows .def file. - void AddModuleDefinitionFlag(std::string& flags); - //================================================================== // Convenience routines that do nothing more than forward to // implementaitons diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index 8bc0ad0..948840a 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -244,7 +244,7 @@ cmNinjaDeps cmNinjaTargetGenerator::ComputeLinkDeps() const // Add a dependency on the link definitions file, if any. if(!this->ModuleDefinitionFile.empty()) { - result.push_back(this->ModuleDefinitionFile); + result.push_back(this->ConvertToNinjaPath(this->ModuleDefinitionFile)); } return result; @@ -574,11 +574,6 @@ cmNinjaTargetGenerator { this->WriteObjectBuildStatement(*si, !orderOnlyDeps.empty()); } - std::string def = this->GeneratorTarget->GetModuleDefinitionFile(config); - if(!def.empty()) - { - this->ModuleDefinitionFile = this->ConvertToNinjaPath(def); - } this->GetBuildFileStream() << "\n"; } @@ -728,32 +723,6 @@ cmNinjaTargetGenerator } } -//---------------------------------------------------------------------------- -void -cmNinjaTargetGenerator -::AddModuleDefinitionFlag(std::string& flags) -{ - if(this->ModuleDefinitionFile.empty()) - { - return; - } - - // TODO: Create a per-language flag variable. - const char* defFileFlag = - this->Makefile->GetDefinition("CMAKE_LINK_DEF_FILE_FLAG"); - 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)); - this->LocalGenerator->AppendFlags(flags, flag); -} - void cmNinjaTargetGenerator ::EnsureDirectoryExists(const std::string& path) const diff --git a/Source/cmNinjaTargetGenerator.h b/Source/cmNinjaTargetGenerator.h index 639654a..ae668dd 100644 --- a/Source/cmNinjaTargetGenerator.h +++ b/Source/cmNinjaTargetGenerator.h @@ -115,9 +115,6 @@ protected: cmNinjaDeps GetObjects() const { return this->Objects; } - // Helper to add flag for windows .def file. - void AddModuleDefinitionFlag(std::string& flags); - void EnsureDirectoryExists(const std::string& dir) const; void EnsureParentDirectoryExists(const std::string& path) const; @@ -153,9 +150,6 @@ private: typedef std::map LanguageFlagMap; LanguageFlagMap LanguageFlags; - - // The windows module definition source file (.def), if any. - std::string ModuleDefinitionFile; }; #endif // ! cmNinjaTargetGenerator_h -- cgit v0.12 From b2f51aef0d518be6be6fba05147dd53125cdb731 Mon Sep 17 00:00:00 2001 From: Brad King Date: Wed, 8 Jul 2015 15:49:03 -0400 Subject: cmCommonTargetGenerator: Adopt Convert method Move it up from cmMakefileTargetGenerator. --- Source/cmCommonTargetGenerator.cxx | 8 ++++++++ Source/cmCommonTargetGenerator.h | 7 +++++++ Source/cmMakefileTargetGenerator.h | 12 ------------ 3 files changed, 15 insertions(+), 12 deletions(-) diff --git a/Source/cmCommonTargetGenerator.cxx b/Source/cmCommonTargetGenerator.cxx index 84a35a8..f79d993 100644 --- a/Source/cmCommonTargetGenerator.cxx +++ b/Source/cmCommonTargetGenerator.cxx @@ -38,6 +38,14 @@ std::string const& cmCommonTargetGenerator::GetConfigName() const return this->ConfigName; } +std::string cmCommonTargetGenerator::Convert( + std::string const& source, + cmLocalGenerator::RelativeRoot relative, + cmLocalGenerator::OutputFormat output) +{ + return this->LocalGenerator->Convert(source, relative, output); +} + //---------------------------------------------------------------------------- const char* cmCommonTargetGenerator::GetFeature(const std::string& feature) { diff --git a/Source/cmCommonTargetGenerator.h b/Source/cmCommonTargetGenerator.h index deeb5ee..f8a7cf3 100644 --- a/Source/cmCommonTargetGenerator.h +++ b/Source/cmCommonTargetGenerator.h @@ -14,6 +14,8 @@ #include "cmStandardIncludes.h" +#include "cmLocalGenerator.h" + class cmGeneratorTarget; class cmGlobalCommonGenerator; class cmLocalCommonGenerator; @@ -52,6 +54,11 @@ protected: // The windows module definition source file (.def), if any. std::string ModuleDefinitionFile; + + std::string Convert(std::string const& source, + cmLocalGenerator::RelativeRoot relative, + cmLocalGenerator::OutputFormat output = + cmLocalGenerator::UNCHANGED); }; #endif diff --git a/Source/cmMakefileTargetGenerator.h b/Source/cmMakefileTargetGenerator.h index d2d1df9..09f3c52 100644 --- a/Source/cmMakefileTargetGenerator.h +++ b/Source/cmMakefileTargetGenerator.h @@ -254,18 +254,6 @@ protected: // Compute target-specific Fortran language flags. void AddFortranFlags(std::string& flags); - - //================================================================== - // Convenience routines that do nothing more than forward to - // implementaitons - std::string Convert(const std::string& source, - cmLocalGenerator::RelativeRoot relative, - cmLocalGenerator::OutputFormat output = - cmLocalGenerator::UNCHANGED) - { - return this->LocalGenerator->Convert(source, relative, output); - } - }; #endif -- cgit v0.12 From 0b22c0b815974de148b5fed3a33a3337380347c9 Mon Sep 17 00:00:00 2001 From: Brad King Date: Wed, 8 Jul 2015 15:50:25 -0400 Subject: cmCommonTargetGenerator: Adopt AddFortranFlags and friends Move AddFortranFlags, GetFortranModuleDirectory, and supporting members up from cmMakefileTargetGenerator. --- Source/cmCommonTargetGenerator.cxx | 97 ++++++++++++++++++++++++++++++++++++ Source/cmCommonTargetGenerator.h | 8 +++ Source/cmMakefileTargetGenerator.cxx | 96 ----------------------------------- Source/cmMakefileTargetGenerator.h | 8 --- 4 files changed, 105 insertions(+), 104 deletions(-) diff --git a/Source/cmCommonTargetGenerator.cxx b/Source/cmCommonTargetGenerator.cxx index f79d993..cbcf682 100644 --- a/Source/cmCommonTargetGenerator.cxx +++ b/Source/cmCommonTargetGenerator.cxx @@ -15,6 +15,7 @@ #include "cmGlobalCommonGenerator.h" #include "cmLocalCommonGenerator.h" #include "cmMakefile.h" +#include "cmSystemTools.h" #include "cmTarget.h" cmCommonTargetGenerator::cmCommonTargetGenerator(cmGeneratorTarget* gt) @@ -26,6 +27,7 @@ cmCommonTargetGenerator::cmCommonTargetGenerator(cmGeneratorTarget* gt) gt->LocalGenerator->GetGlobalGenerator())) , ConfigName(LocalGenerator->GetConfigName()) , ModuleDefinitionFile(GeneratorTarget->GetModuleDefinitionFile(ConfigName)) + , FortranModuleDirectoryComputed(false) { } @@ -95,3 +97,98 @@ void cmCommonTargetGenerator::AddModuleDefinitionFlag(std::string& flags) this->ModuleDefinitionFile)); this->LocalGenerator->AppendFlags(flags, flag); } + +//---------------------------------------------------------------------------- +const char* cmCommonTargetGenerator::GetFortranModuleDirectory() +{ + // Compute the module directory. + if(!this->FortranModuleDirectoryComputed) + { + const char* target_mod_dir = + this->Target->GetProperty("Fortran_MODULE_DIRECTORY"); + const char* moddir_flag = + this->Makefile->GetDefinition("CMAKE_Fortran_MODDIR_FLAG"); + if(target_mod_dir && moddir_flag) + { + // Compute the full path to the module directory. + if(cmSystemTools::FileIsFullPath(target_mod_dir)) + { + // Already a full path. + this->FortranModuleDirectory = target_mod_dir; + } + else + { + // Interpret relative to the current output directory. + this->FortranModuleDirectory = + this->Makefile->GetCurrentBinaryDirectory(); + this->FortranModuleDirectory += "/"; + this->FortranModuleDirectory += target_mod_dir; + } + + // Make sure the module output directory exists. + cmSystemTools::MakeDirectory(this->FortranModuleDirectory.c_str()); + } + this->FortranModuleDirectoryComputed = true; + } + + // Return the computed directory. + if(this->FortranModuleDirectory.empty()) + { + return 0; + } + else + { + return this->FortranModuleDirectory.c_str(); + } +} + +//---------------------------------------------------------------------------- +void cmCommonTargetGenerator::AddFortranFlags(std::string& flags) +{ + // Enable module output if necessary. + 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. + const char* mod_dir = this->GetFortranModuleDirectory(); + if(!mod_dir) + { + mod_dir = this->Makefile->GetDefinition("CMAKE_Fortran_MODDIR_DEFAULT"); + } + if(mod_dir) + { + const char* moddir_flag = + this->Makefile->GetRequiredDefinition("CMAKE_Fortran_MODDIR_FLAG"); + std::string modflag = moddir_flag; + modflag += this->Convert(mod_dir, + cmLocalGenerator::START_OUTPUT, + cmLocalGenerator::SHELL); + 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")) + { + std::vector includes; + const std::string& config = + this->Makefile->GetSafeDefinition("CMAKE_BUILD_TYPE"); + this->LocalGenerator->GetIncludeDirectories(includes, + this->GeneratorTarget, + "C", config); + for(std::vector::const_iterator idi = includes.begin(); + idi != includes.end(); ++idi) + { + std::string flg = modpath_flag; + flg += this->Convert(*idi, + cmLocalGenerator::NONE, + cmLocalGenerator::SHELL); + this->LocalGenerator->AppendFlags(flags, flg); + } + } +} diff --git a/Source/cmCommonTargetGenerator.h b/Source/cmCommonTargetGenerator.h index f8a7cf3..c1c08f6 100644 --- a/Source/cmCommonTargetGenerator.h +++ b/Source/cmCommonTargetGenerator.h @@ -55,6 +55,14 @@ protected: // The windows module definition source file (.def), if any. std::string ModuleDefinitionFile; + // Target-wide Fortran module output directory. + bool FortranModuleDirectoryComputed; + std::string FortranModuleDirectory; + const char* GetFortranModuleDirectory(); + + // Compute target-specific Fortran language flags. + void AddFortranFlags(std::string& flags); + std::string Convert(std::string const& source, cmLocalGenerator::RelativeRoot relative, cmLocalGenerator::OutputFormat output = diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index fe6b4f6..4c9278a 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -41,7 +41,6 @@ cmMakefileTargetGenerator::cmMakefileTargetGenerator(cmGeneratorTarget* target) this->InfoFileStream = 0; this->FlagFileStream = 0; this->CustomCommandDriver = OnBuild; - this->FortranModuleDirectoryComputed = false; this->LocalGenerator = static_cast(target->GetLocalGenerator()); this->GlobalGenerator = @@ -1977,98 +1976,3 @@ void cmMakefileTargetGenerator::AddIncludeFlags(std::string& flags, this->LocalGenerator->AppendFlags(flags, includeFlags); } } - -//---------------------------------------------------------------------------- -const char* cmMakefileTargetGenerator::GetFortranModuleDirectory() -{ - // Compute the module directory. - if(!this->FortranModuleDirectoryComputed) - { - const char* target_mod_dir = - this->Target->GetProperty("Fortran_MODULE_DIRECTORY"); - const char* moddir_flag = - this->Makefile->GetDefinition("CMAKE_Fortran_MODDIR_FLAG"); - if(target_mod_dir && moddir_flag) - { - // Compute the full path to the module directory. - if(cmSystemTools::FileIsFullPath(target_mod_dir)) - { - // Already a full path. - this->FortranModuleDirectory = target_mod_dir; - } - else - { - // Interpret relative to the current output directory. - this->FortranModuleDirectory = - this->Makefile->GetCurrentBinaryDirectory(); - this->FortranModuleDirectory += "/"; - this->FortranModuleDirectory += target_mod_dir; - } - - // Make sure the module output directory exists. - cmSystemTools::MakeDirectory(this->FortranModuleDirectory.c_str()); - } - this->FortranModuleDirectoryComputed = true; - } - - // Return the computed directory. - if(this->FortranModuleDirectory.empty()) - { - return 0; - } - else - { - return this->FortranModuleDirectory.c_str(); - } -} - -//---------------------------------------------------------------------------- -void cmMakefileTargetGenerator::AddFortranFlags(std::string& flags) -{ - // Enable module output if necessary. - 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. - const char* mod_dir = this->GetFortranModuleDirectory(); - if(!mod_dir) - { - mod_dir = this->Makefile->GetDefinition("CMAKE_Fortran_MODDIR_DEFAULT"); - } - if(mod_dir) - { - const char* moddir_flag = - this->Makefile->GetRequiredDefinition("CMAKE_Fortran_MODDIR_FLAG"); - std::string modflag = moddir_flag; - modflag += this->Convert(mod_dir, - cmLocalGenerator::START_OUTPUT, - cmLocalGenerator::SHELL); - 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")) - { - std::vector includes; - const std::string& config = - this->Makefile->GetSafeDefinition("CMAKE_BUILD_TYPE"); - this->LocalGenerator->GetIncludeDirectories(includes, - this->GeneratorTarget, - "C", config); - for(std::vector::const_iterator idi = includes.begin(); - idi != includes.end(); ++idi) - { - std::string flg = modpath_flag; - flg += this->Convert(*idi, - cmLocalGenerator::NONE, - cmLocalGenerator::SHELL); - this->LocalGenerator->AppendFlags(flags, flg); - } - } -} diff --git a/Source/cmMakefileTargetGenerator.h b/Source/cmMakefileTargetGenerator.h index 09f3c52..1c02ddd 100644 --- a/Source/cmMakefileTargetGenerator.h +++ b/Source/cmMakefileTargetGenerator.h @@ -246,14 +246,6 @@ protected: ByLanguageMap FlagsByLanguage; std::string GetDefines(const std::string &l); ByLanguageMap DefinesByLanguage; - - // Target-wide Fortran module output directory. - bool FortranModuleDirectoryComputed; - std::string FortranModuleDirectory; - const char* GetFortranModuleDirectory(); - - // Compute target-specific Fortran language flags. - void AddFortranFlags(std::string& flags); }; #endif -- cgit v0.12 From ab8240189dd67cc15c5aed59b8c0ffde99d3b403 Mon Sep 17 00:00:00 2001 From: Brad King Date: Wed, 8 Jul 2015 15:52:42 -0400 Subject: cmCommonTargetGenerator: Adopt AppendFortranFormatFlags Move up from cmMakefileTargetGenerator. --- Source/cmCommonTargetGenerator.cxx | 30 ++++++++++++++++++++++++++++++ Source/cmCommonTargetGenerator.h | 4 ++++ Source/cmMakefileTargetGenerator.cxx | 29 ----------------------------- Source/cmMakefileTargetGenerator.h | 3 --- 4 files changed, 34 insertions(+), 32 deletions(-) diff --git a/Source/cmCommonTargetGenerator.cxx b/Source/cmCommonTargetGenerator.cxx index cbcf682..c691fa4 100644 --- a/Source/cmCommonTargetGenerator.cxx +++ b/Source/cmCommonTargetGenerator.cxx @@ -15,6 +15,7 @@ #include "cmGlobalCommonGenerator.h" #include "cmLocalCommonGenerator.h" #include "cmMakefile.h" +#include "cmSourceFile.h" #include "cmSystemTools.h" #include "cmTarget.h" @@ -192,3 +193,32 @@ void cmCommonTargetGenerator::AddFortranFlags(std::string& flags) } } } + +//---------------------------------------------------------------------------- +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) + { + const char* tgtfmt = this->Target->GetProperty("Fortran_FORMAT"); + format = this->LocalGenerator->GetFortranFormat(tgtfmt); + } + const char* var = 0; + switch (format) + { + case cmLocalGenerator::FortranFormatFixed: + 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)); + } +} diff --git a/Source/cmCommonTargetGenerator.h b/Source/cmCommonTargetGenerator.h index c1c08f6..0683e3c 100644 --- a/Source/cmCommonTargetGenerator.h +++ b/Source/cmCommonTargetGenerator.h @@ -20,6 +20,7 @@ class cmGeneratorTarget; class cmGlobalCommonGenerator; class cmLocalCommonGenerator; class cmMakefile; +class cmSourceFile; class cmTarget; /** \class cmCommonTargetGenerator @@ -67,6 +68,9 @@ protected: cmLocalGenerator::RelativeRoot relative, cmLocalGenerator::OutputFormat output = cmLocalGenerator::UNCHANGED); + + void AppendFortranFormatFlags(std::string& flags, + cmSourceFile const& source); }; #endif diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index 4c9278a..e4ae677 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -507,35 +507,6 @@ void cmMakefileTargetGenerator //---------------------------------------------------------------------------- void cmMakefileTargetGenerator -::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) - { - const char* tgtfmt = this->Target->GetProperty("Fortran_FORMAT"); - format = this->LocalGenerator->GetFortranFormat(tgtfmt); - } - const char* var = 0; - switch (format) - { - case cmLocalGenerator::FortranFormatFixed: - 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)); - } -} - -//---------------------------------------------------------------------------- -void -cmMakefileTargetGenerator ::WriteObjectBuildFile(std::string &obj, const std::string& lang, cmSourceFile const& source, diff --git a/Source/cmMakefileTargetGenerator.h b/Source/cmMakefileTargetGenerator.h index 1c02ddd..5bf8ad1 100644 --- a/Source/cmMakefileTargetGenerator.h +++ b/Source/cmMakefileTargetGenerator.h @@ -129,9 +129,6 @@ protected: // Return the a string with -F flags on apple std::string GetFrameworkFlags(std::string const& l); - void AppendFortranFormatFlags(std::string& flags, - cmSourceFile const& source); - // append intertarget dependencies void AppendTargetDepends(std::vector& depends); -- cgit v0.12 From 058074d499805aa4579c8986b84459f9993f6fad Mon Sep 17 00:00:00 2001 From: Brad King Date: Wed, 8 Jul 2015 16:38:49 -0400 Subject: cmCommonTargetGenerator: Adopt GetFrameworkFlags Move the member up from cmMakefileTargetGenerator. --- Source/cmCommonTargetGenerator.cxx | 62 ++++++++++++++++++++++++++++++++++++ Source/cmCommonTargetGenerator.h | 3 ++ Source/cmMakefileTargetGenerator.cxx | 61 ----------------------------------- Source/cmMakefileTargetGenerator.h | 3 -- 4 files changed, 65 insertions(+), 64 deletions(-) diff --git a/Source/cmCommonTargetGenerator.cxx b/Source/cmCommonTargetGenerator.cxx index c691fa4..afe557c 100644 --- a/Source/cmCommonTargetGenerator.cxx +++ b/Source/cmCommonTargetGenerator.cxx @@ -11,6 +11,7 @@ ============================================================================*/ #include "cmCommonTargetGenerator.h" +#include "cmComputeLinkInformation.h" #include "cmGeneratorTarget.h" #include "cmGlobalCommonGenerator.h" #include "cmLocalCommonGenerator.h" @@ -222,3 +223,64 @@ cmCommonTargetGenerator flags, this->Makefile->GetDefinition(var)); } } + +//---------------------------------------------------------------------------- +std::string cmCommonTargetGenerator::GetFrameworkFlags(std::string const& l) +{ + 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)) + { + return std::string(); + } + + std::set emitted; +#ifdef __APPLE__ /* don't insert this when crosscompiling e.g. to iphone */ + emitted.insert("/System/Library/Frameworks"); +#endif + std::vector includes; + + const std::string& config = + this->Makefile->GetSafeDefinition("CMAKE_BUILD_TYPE"); + 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::iterator i = includes.begin(); + i != includes.end(); ++i) + { + if(this->Target->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->Target->GetLinkInformation(cfg)) + { + std::vector const& frameworks = cli->GetFrameworkPaths(); + for(std::vector::const_iterator i = frameworks.begin(); + i != frameworks.end(); ++i) + { + if(emitted.insert(*i).second) + { + flags += fwSearchFlag; + flags += this->LocalGenerator + ->ConvertToOutputFormat(*i, cmLocalGenerator::SHELL); + flags += " "; + } + } + } + return flags; +} diff --git a/Source/cmCommonTargetGenerator.h b/Source/cmCommonTargetGenerator.h index 0683e3c..644d972 100644 --- a/Source/cmCommonTargetGenerator.h +++ b/Source/cmCommonTargetGenerator.h @@ -71,6 +71,9 @@ protected: void AppendFortranFormatFlags(std::string& flags, cmSourceFile const& source); + + // Return the a string with -F flags on apple + std::string GetFrameworkFlags(std::string const& l); }; #endif diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index e4ae677..68137ef 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -1525,67 +1525,6 @@ void cmMakefileTargetGenerator::WriteTargetDriverRule( } //---------------------------------------------------------------------------- -std::string cmMakefileTargetGenerator::GetFrameworkFlags(std::string const& l) -{ - 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)) - { - return std::string(); - } - - std::set emitted; -#ifdef __APPLE__ /* don't insert this when crosscompiling e.g. to iphone */ - emitted.insert("/System/Library/Frameworks"); -#endif - std::vector includes; - - const std::string& config = - this->Makefile->GetSafeDefinition("CMAKE_BUILD_TYPE"); - 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::iterator i = includes.begin(); - i != includes.end(); ++i) - { - if(this->Target->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->Target->GetLinkInformation(cfg)) - { - std::vector const& frameworks = cli->GetFrameworkPaths(); - for(std::vector::const_iterator i = frameworks.begin(); - i != frameworks.end(); ++i) - { - if(emitted.insert(*i).second) - { - flags += fwSearchFlag; - flags += this->LocalGenerator - ->ConvertToOutputFormat(*i, cmLocalGenerator::SHELL); - flags += " "; - } - } - } - return flags; -} - -//---------------------------------------------------------------------------- void cmMakefileTargetGenerator ::AppendTargetDepends(std::vector& depends) { diff --git a/Source/cmMakefileTargetGenerator.h b/Source/cmMakefileTargetGenerator.h index 5bf8ad1..e3e3a13 100644 --- a/Source/cmMakefileTargetGenerator.h +++ b/Source/cmMakefileTargetGenerator.h @@ -126,9 +126,6 @@ protected: void DriveCustomCommands(std::vector& depends); - // Return the a string with -F flags on apple - std::string GetFrameworkFlags(std::string const& l); - // append intertarget dependencies void AppendTargetDepends(std::vector& depends); -- cgit v0.12 From 6a56740e27fe74b757ff48999a2f152816ee8e52 Mon Sep 17 00:00:00 2001 From: Brad King Date: Thu, 9 Jul 2015 09:54:56 -0400 Subject: cmNinjaTargetGenerator: Add Fortran flag generation Make ComputeFlagsForObject consistent with the Makefile generator in regard to Fortran flags. --- Source/cmNinjaTargetGenerator.cxx | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index 948840a..7d3962a 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -110,13 +110,6 @@ std::string cmNinjaTargetGenerator::ComputeFlagsForObject(cmSourceFile const* source, const std::string& language) { - // TODO: Fortran support. - // // Fortran-specific flags computed for this target. - // if(*l == "Fortran") - // { - // this->AddFortranFlags(flags); - // } - bool hasLangCached = this->LanguageFlags.count(language) != 0; std::string& languageFlags = this->LanguageFlags[language]; if(!hasLangCached) @@ -128,6 +121,12 @@ cmNinjaTargetGenerator::ComputeFlagsForObject(cmSourceFile const* source, language, this->GetConfigName()); + // Fortran-specific flags computed for this target. + if(language == "Fortran") + { + this->AddFortranFlags(languageFlags); + } + // Add shared-library flags if needed. this->LocalGenerator->AddCMP0018Flags(languageFlags, this->Target, language, @@ -166,6 +165,12 @@ cmNinjaTargetGenerator::ComputeFlagsForObject(cmSourceFile const* source, std::string flags = languageFlags; + // Add Fortran format flags. + if(language == "Fortran") + { + this->AppendFortranFormatFlags(flags, *source); + } + // Add source file specific flags. this->LocalGenerator->AppendFlags(flags, source->GetProperty("COMPILE_FLAGS")); -- cgit v0.12 From 73bfad72d3b9ce021074b612bfa0a24bd6a6b04a Mon Sep 17 00:00:00 2001 From: Brad King Date: Thu, 9 Jul 2015 09:58:13 -0400 Subject: cmNinjaTargetGenerator: Factor out AddIncludeFlags helper Factor an AddIncludeFlags method out of ComputeFlagsForObject just like cmMakefileTargetGenerator has already. --- Source/cmNinjaTargetGenerator.cxx | 39 +++++++++++++++++++++++---------------- Source/cmNinjaTargetGenerator.h | 2 ++ 2 files changed, 25 insertions(+), 16 deletions(-) diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index 7d3962a..6ae45a9 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -135,23 +135,8 @@ cmNinjaTargetGenerator::ComputeFlagsForObject(cmSourceFile const* source, this->LocalGenerator->AddVisibilityPresetFlags(languageFlags, this->Target, language); - std::vector includes; - this->LocalGenerator->GetIncludeDirectories(includes, - this->GeneratorTarget, - language, - this->GetConfigName()); // Add include directory flags. - std::string includeFlags = - this->LocalGenerator->GetIncludeFlags(includes, this->GeneratorTarget, - language, - language == "RC" ? true : false, // full include paths for RC - // needed by cmcldeps - false, - this->GetConfigName()); - if (this->GetGlobalGenerator()->IsGCCOnWindows()) - cmSystemTools::ReplaceString(includeFlags, "\\", "/"); - - this->LocalGenerator->AppendFlags(languageFlags, includeFlags); + this->AddIncludeFlags(languageFlags, language); // Append old-style preprocessor definition flags. this->LocalGenerator->AppendFlags(languageFlags, @@ -180,6 +165,28 @@ cmNinjaTargetGenerator::ComputeFlagsForObject(cmSourceFile const* source, return flags; } +void cmNinjaTargetGenerator::AddIncludeFlags(std::string& languageFlags, + std::string const& language) +{ + std::vector includes; + this->LocalGenerator->GetIncludeDirectories(includes, + this->GeneratorTarget, + language, + this->GetConfigName()); + // Add include directory flags. + std::string includeFlags = + this->LocalGenerator->GetIncludeFlags(includes, this->GeneratorTarget, + language, + language == "RC" ? true : false, // full include paths for RC + // needed by cmcldeps + false, + this->GetConfigName()); + if (this->GetGlobalGenerator()->IsGCCOnWindows()) + cmSystemTools::ReplaceString(includeFlags, "\\", "/"); + + this->LocalGenerator->AppendFlags(languageFlags, includeFlags); +} + bool cmNinjaTargetGenerator::NeedDepTypeMSVC(const std::string& lang) const { if (lang == "C" || lang == "CXX") diff --git a/Source/cmNinjaTargetGenerator.h b/Source/cmNinjaTargetGenerator.h index ae668dd..0cd5e48 100644 --- a/Source/cmNinjaTargetGenerator.h +++ b/Source/cmNinjaTargetGenerator.h @@ -81,6 +81,8 @@ protected: std::string ComputeFlagsForObject(cmSourceFile const* source, const std::string& language); + void AddIncludeFlags(std::string& flags, std::string const& lang); + std::string ComputeDefines(cmSourceFile const* source, const std::string& language); -- cgit v0.12 From 7891f5d7e70e650cac940a4b942390492191e656 Mon Sep 17 00:00:00 2001 From: Brad King Date: Thu, 9 Jul 2015 10:03:42 -0400 Subject: cmMakefileTargetGenerator: Fix comment typo --- Source/cmMakefileTargetGenerator.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index 68137ef..4145739 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -306,7 +306,7 @@ std::string cmMakefileTargetGenerator::GetFlags(const std::string &l) this->LocalGenerator-> AppendFlags(flags, this->Makefile->GetDefineFlags()); - // Add include directory flags. + // Add framework directory flags. this->LocalGenerator-> AppendFlags(flags,this->GetFrameworkFlags(l)); -- cgit v0.12 From f4875bbdd6cc090f5c79f358c55c8b936c6254fd Mon Sep 17 00:00:00 2001 From: Brad King Date: Thu, 9 Jul 2015 10:04:01 -0400 Subject: cmNinjaTargetGenerator: Add OX X framework flags Teach ComputeFlagsForObject to add -F flags just like the Makefile generator does. --- Source/cmNinjaTargetGenerator.cxx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index 6ae45a9..cd54c4d 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -142,6 +142,10 @@ cmNinjaTargetGenerator::ComputeFlagsForObject(cmSourceFile const* source, this->LocalGenerator->AppendFlags(languageFlags, this->Makefile->GetDefineFlags()); + // Add framework directory flags. + this->LocalGenerator-> + AppendFlags(languageFlags, this->GetFrameworkFlags(language)); + // Add target-specific flags. this->LocalGenerator->AddCompileOptions(languageFlags, this->Target, language, @@ -160,8 +164,6 @@ cmNinjaTargetGenerator::ComputeFlagsForObject(cmSourceFile const* source, this->LocalGenerator->AppendFlags(flags, source->GetProperty("COMPILE_FLAGS")); - // TODO: Handle Apple frameworks. - return flags; } -- cgit v0.12 From 0837538e461cfdbc5c673d7f2bf64f6631099bdf Mon Sep 17 00:00:00 2001 From: Brad King Date: Thu, 9 Jul 2015 10:05:12 -0400 Subject: cmCommonTargetGenerator: Adopt GetFlags method De-duplicate per-target flag computation in Makefile and Ninja target generators. --- Source/cmCommonTargetGenerator.cxx | 48 ++++++++++++++++++++++++++++++++++ Source/cmCommonTargetGenerator.h | 7 +++++ Source/cmMakefileTargetGenerator.cxx | 48 ---------------------------------- Source/cmMakefileTargetGenerator.h | 3 --- Source/cmNinjaTargetGenerator.cxx | 50 +----------------------------------- Source/cmNinjaTargetGenerator.h | 3 --- 6 files changed, 56 insertions(+), 103 deletions(-) diff --git a/Source/cmCommonTargetGenerator.cxx b/Source/cmCommonTargetGenerator.cxx index afe557c..70e9ce2 100644 --- a/Source/cmCommonTargetGenerator.cxx +++ b/Source/cmCommonTargetGenerator.cxx @@ -284,3 +284,51 @@ std::string cmCommonTargetGenerator::GetFrameworkFlags(std::string const& l) } return flags; } + +//---------------------------------------------------------------------------- +std::string cmCommonTargetGenerator::GetFlags(const std::string &l) +{ + ByLanguageMap::iterator i = this->FlagsByLanguage.find(l); + if (i == this->FlagsByLanguage.end()) + { + std::string flags; + const char *lang = l.c_str(); + + // Add language feature flags. + this->AddFeatureFlags(flags, lang); + + this->LocalGenerator->AddArchitectureFlags(flags, this->GeneratorTarget, + lang, this->ConfigName); + + // Fortran-specific flags computed for this target. + if(l == "Fortran") + { + this->AddFortranFlags(flags); + } + + this->LocalGenerator->AddCMP0018Flags(flags, this->Target, + lang, this->ConfigName); + + this->LocalGenerator->AddVisibilityPresetFlags(flags, this->Target, + lang); + + // Add include directory flags. + this->AddIncludeFlags(flags, lang); + + // Append old-style preprocessor definition flags. + this->LocalGenerator-> + AppendFlags(flags, this->Makefile->GetDefineFlags()); + + // Add framework directory flags. + this->LocalGenerator-> + AppendFlags(flags,this->GetFrameworkFlags(l)); + + // Add target-specific flags. + this->LocalGenerator->AddCompileOptions(flags, this->Target, + lang, this->ConfigName); + + ByLanguageMap::value_type entry(l, flags); + i = this->FlagsByLanguage.insert(entry).first; + } + return i->second; +} diff --git a/Source/cmCommonTargetGenerator.h b/Source/cmCommonTargetGenerator.h index 644d972..5407c61 100644 --- a/Source/cmCommonTargetGenerator.h +++ b/Source/cmCommonTargetGenerator.h @@ -74,6 +74,13 @@ protected: // Return the a string with -F flags on apple std::string GetFrameworkFlags(std::string const& l); + + virtual void AddIncludeFlags(std::string& flags, + std::string const& lang) = 0; + + typedef std::map ByLanguageMap; + std::string GetFlags(const std::string &l); + ByLanguageMap FlagsByLanguage; }; #endif diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index 4145739..10799c6 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -272,54 +272,6 @@ void cmMakefileTargetGenerator::WriteCommonCodeRules() << "\n\n"; } -//---------------------------------------------------------------------------- -std::string cmMakefileTargetGenerator::GetFlags(const std::string &l) -{ - ByLanguageMap::iterator i = this->FlagsByLanguage.find(l); - if (i == this->FlagsByLanguage.end()) - { - std::string flags; - const char *lang = l.c_str(); - - // Add language feature flags. - this->AddFeatureFlags(flags, lang); - - this->LocalGenerator->AddArchitectureFlags(flags, this->GeneratorTarget, - lang, this->ConfigName); - - // Fortran-specific flags computed for this target. - if(l == "Fortran") - { - this->AddFortranFlags(flags); - } - - this->LocalGenerator->AddCMP0018Flags(flags, this->Target, - lang, this->ConfigName); - - this->LocalGenerator->AddVisibilityPresetFlags(flags, this->Target, - lang); - - // Add include directory flags. - this->AddIncludeFlags(flags, lang); - - // Append old-style preprocessor definition flags. - this->LocalGenerator-> - AppendFlags(flags, this->Makefile->GetDefineFlags()); - - // Add framework directory flags. - this->LocalGenerator-> - AppendFlags(flags,this->GetFrameworkFlags(l)); - - // Add target-specific flags. - this->LocalGenerator->AddCompileOptions(flags, this->Target, - lang, this->ConfigName); - - ByLanguageMap::value_type entry(l, flags); - i = this->FlagsByLanguage.insert(entry).first; - } - return i->second; -} - std::string cmMakefileTargetGenerator::GetDefines(const std::string &l) { ByLanguageMap::iterator i = this->DefinesByLanguage.find(l); diff --git a/Source/cmMakefileTargetGenerator.h b/Source/cmMakefileTargetGenerator.h index e3e3a13..9d05cd5 100644 --- a/Source/cmMakefileTargetGenerator.h +++ b/Source/cmMakefileTargetGenerator.h @@ -235,9 +235,6 @@ protected: cmOSXBundleGenerator* OSXBundleGenerator; MacOSXContentGeneratorType* MacOSXContentGenerator; - typedef std::map ByLanguageMap; - std::string GetFlags(const std::string &l); - ByLanguageMap FlagsByLanguage; std::string GetDefines(const std::string &l); ByLanguageMap DefinesByLanguage; }; diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index cd54c4d..05120da 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -110,55 +110,7 @@ std::string cmNinjaTargetGenerator::ComputeFlagsForObject(cmSourceFile const* source, const std::string& language) { - bool hasLangCached = this->LanguageFlags.count(language) != 0; - std::string& languageFlags = this->LanguageFlags[language]; - if(!hasLangCached) - { - this->AddFeatureFlags(languageFlags, language); - - this->GetLocalGenerator()->AddArchitectureFlags(languageFlags, - this->GeneratorTarget, - language, - this->GetConfigName()); - - // Fortran-specific flags computed for this target. - if(language == "Fortran") - { - this->AddFortranFlags(languageFlags); - } - - // Add shared-library flags if needed. - this->LocalGenerator->AddCMP0018Flags(languageFlags, this->Target, - language, - this->GetConfigName()); - - this->LocalGenerator->AddVisibilityPresetFlags(languageFlags, this->Target, - language); - - // Add include directory flags. - this->AddIncludeFlags(languageFlags, language); - - // Append old-style preprocessor definition flags. - this->LocalGenerator->AppendFlags(languageFlags, - this->Makefile->GetDefineFlags()); - - // Add framework directory flags. - this->LocalGenerator-> - AppendFlags(languageFlags, this->GetFrameworkFlags(language)); - - // Add target-specific flags. - this->LocalGenerator->AddCompileOptions(languageFlags, this->Target, - language, - this->GetConfigName()); - } - - std::string flags = languageFlags; - - // Add Fortran format flags. - if(language == "Fortran") - { - this->AppendFortranFormatFlags(flags, *source); - } + std::string flags = this->GetFlags(language); // Add source file specific flags. this->LocalGenerator->AppendFlags(flags, diff --git a/Source/cmNinjaTargetGenerator.h b/Source/cmNinjaTargetGenerator.h index 0cd5e48..8912431 100644 --- a/Source/cmNinjaTargetGenerator.h +++ b/Source/cmNinjaTargetGenerator.h @@ -149,9 +149,6 @@ private: /// List of object files for this target. cmNinjaDeps Objects; std::vector CustomCommands; - - typedef std::map LanguageFlagMap; - LanguageFlagMap LanguageFlags; }; #endif // ! cmNinjaTargetGenerator_h -- cgit v0.12 From eacacacdceb4a259ba76edb2219c7f8e6cb3f47e Mon Sep 17 00:00:00 2001 From: Brad King Date: Thu, 9 Jul 2015 10:10:25 -0400 Subject: cmCommonTargetGenerator: Adopt GetDefines method Move the member up from cmMakefileTargetGenerator so it can be re-used later by cmNinjaTargetGenerator. --- Source/cmCommonTargetGenerator.cxx | 26 ++++++++++++++++++++++++++ Source/cmCommonTargetGenerator.h | 2 ++ Source/cmMakefileTargetGenerator.cxx | 26 -------------------------- Source/cmMakefileTargetGenerator.h | 3 --- 4 files changed, 28 insertions(+), 29 deletions(-) diff --git a/Source/cmCommonTargetGenerator.cxx b/Source/cmCommonTargetGenerator.cxx index 70e9ce2..ce351ee 100644 --- a/Source/cmCommonTargetGenerator.cxx +++ b/Source/cmCommonTargetGenerator.cxx @@ -332,3 +332,29 @@ std::string cmCommonTargetGenerator::GetFlags(const std::string &l) } return i->second; } + +std::string cmCommonTargetGenerator::GetDefines(const std::string &l) +{ + ByLanguageMap::iterator i = this->DefinesByLanguage.find(l); + if (i == this->DefinesByLanguage.end()) + { + std::set 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); + } + + // Add preprocessor definitions for this target and configuration. + this->LocalGenerator->AddCompileDefinitions(defines, this->Target, + 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; +} diff --git a/Source/cmCommonTargetGenerator.h b/Source/cmCommonTargetGenerator.h index 5407c61..e184dba 100644 --- a/Source/cmCommonTargetGenerator.h +++ b/Source/cmCommonTargetGenerator.h @@ -81,6 +81,8 @@ protected: typedef std::map ByLanguageMap; std::string GetFlags(const std::string &l); ByLanguageMap FlagsByLanguage; + std::string GetDefines(const std::string &l); + ByLanguageMap DefinesByLanguage; }; #endif diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index 10799c6..ef4bbbe 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -272,32 +272,6 @@ void cmMakefileTargetGenerator::WriteCommonCodeRules() << "\n\n"; } -std::string cmMakefileTargetGenerator::GetDefines(const std::string &l) -{ - ByLanguageMap::iterator i = this->DefinesByLanguage.find(l); - if (i == this->DefinesByLanguage.end()) - { - std::set 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); - } - - // Add preprocessor definitions for this target and configuration. - this->LocalGenerator->AddCompileDefinitions(defines, this->Target, - 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; -} - void cmMakefileTargetGenerator::WriteTargetLanguageFlags() { // write language flags for target diff --git a/Source/cmMakefileTargetGenerator.h b/Source/cmMakefileTargetGenerator.h index 9d05cd5..b885672 100644 --- a/Source/cmMakefileTargetGenerator.h +++ b/Source/cmMakefileTargetGenerator.h @@ -234,9 +234,6 @@ protected: std::set MacContentFolders; cmOSXBundleGenerator* OSXBundleGenerator; MacOSXContentGeneratorType* MacOSXContentGenerator; - - std::string GetDefines(const std::string &l); - ByLanguageMap DefinesByLanguage; }; #endif -- cgit v0.12 From fed5eb5b0e0e955bf01351b93c43cc248fd9f5ed Mon Sep 17 00:00:00 2001 From: Brad King Date: Thu, 9 Jul 2015 10:15:08 -0400 Subject: cmNinjaTargetGenerator: Use GetDefines method Simplify the per-source ComputeDefines implementation by getting target-wide defines from GetDefines. Technically this changes behavior by no-longer de-duplicating/sorting defines from both the target and the source, but this makes it consistent with the Makefile generator. It may also later help move target-wide defines into per-target compilation rules. --- Source/cmNinjaTargetGenerator.cxx | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index 05120da..a72bc72 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -163,16 +163,6 @@ cmNinjaTargetGenerator:: ComputeDefines(cmSourceFile const* source, const std::string& language) { std::set defines; - - // Add the export symbol definition for shared library objects. - if(const char* exportMacro = this->Target->GetExportMacro()) - { - this->LocalGenerator->AppendDefines(defines, exportMacro); - } - - // Add preprocessor definitions for this target and configuration. - this->LocalGenerator->AddCompileDefinitions(defines, this->Target, - this->GetConfigName(), language); this->LocalGenerator->AppendDefines (defines, source->GetProperty("COMPILE_DEFINITIONS")); @@ -184,7 +174,7 @@ ComputeDefines(cmSourceFile const* source, const std::string& language) source->GetProperty(defPropName)); } - std::string definesString; + std::string definesString = this->GetDefines(language); this->LocalGenerator->JoinDefines(defines, definesString, language); -- cgit v0.12