diff options
author | Brad King <brad.king@kitware.com> | 2012-11-20 16:47:43 (GMT) |
---|---|---|
committer | CMake Topic Stage <kwrobot@kitware.com> | 2012-11-20 16:47:43 (GMT) |
commit | 53b7e71e8887da8b99dea0e4fbfa9984c4939ffd (patch) | |
tree | b8f38e421b75439e6762ecb9c18a4ba9e828d8d3 /Source | |
parent | 508504ab6f76bfd90a11a77cc1e59e604d41c47a (diff) | |
parent | 45d4f81fde2c5c29698787e30b9bebb91211eb01 (diff) | |
download | CMake-53b7e71e8887da8b99dea0e4fbfa9984c4939ffd.zip CMake-53b7e71e8887da8b99dea0e4fbfa9984c4939ffd.tar.gz CMake-53b7e71e8887da8b99dea0e4fbfa9984c4939ffd.tar.bz2 |
Merge topic 'vs-global-sections'
45d4f81 Merge topic 'per-config-EXCLUDE_FROM_DEFAULT_BUILD' into vs-global-sections
694322e Define properties VS_GLOBAL_SECTION_*
2c91962 Implement properties VS_GLOBAL_SECTION_*
57cadc1 Add tests for VS_SOLUTION_GLOBAL_SECTIONS
Diffstat (limited to 'Source')
-rw-r--r-- | Source/cmGlobalVisualStudio71Generator.cxx | 14 | ||||
-rw-r--r-- | Source/cmGlobalVisualStudio71Generator.h | 1 | ||||
-rw-r--r-- | Source/cmGlobalVisualStudio7Generator.cxx | 72 | ||||
-rw-r--r-- | Source/cmGlobalVisualStudio7Generator.h | 2 | ||||
-rw-r--r-- | Source/cmMakefile.cxx | 40 |
5 files changed, 112 insertions, 17 deletions
diff --git a/Source/cmGlobalVisualStudio71Generator.cxx b/Source/cmGlobalVisualStudio71Generator.cxx index 736efd5..9f318ec 100644 --- a/Source/cmGlobalVisualStudio71Generator.cxx +++ b/Source/cmGlobalVisualStudio71Generator.cxx @@ -128,6 +128,9 @@ void cmGlobalVisualStudio71Generator fout << "\tEndGlobalSection\n"; } + // Write out global sections + this->WriteSLNGlobalSections(fout, root); + // Write the footer for the SLN file this->WriteSLNFooter(fout); } @@ -297,17 +300,6 @@ void cmGlobalVisualStudio71Generator } //---------------------------------------------------------------------------- -// Standard end of dsw file -void cmGlobalVisualStudio71Generator::WriteSLNFooter(std::ostream& fout) -{ - fout << "\tGlobalSection(ExtensibilityGlobals) = postSolution\n" - << "\tEndGlobalSection\n" - << "\tGlobalSection(ExtensibilityAddIns) = postSolution\n" - << "\tEndGlobalSection\n" - << "EndGlobal\n"; -} - -//---------------------------------------------------------------------------- // ouput standard header for dsw file void cmGlobalVisualStudio71Generator::WriteSLNHeader(std::ostream& fout) { diff --git a/Source/cmGlobalVisualStudio71Generator.h b/Source/cmGlobalVisualStudio71Generator.h index 5dd194c..f96a7d9 100644 --- a/Source/cmGlobalVisualStudio71Generator.h +++ b/Source/cmGlobalVisualStudio71Generator.h @@ -70,7 +70,6 @@ protected: const char* path, const char* typeGuid, const std::set<cmStdString>& depends); - virtual void WriteSLNFooter(std::ostream& fout); virtual void WriteSLNHeader(std::ostream& fout); std::string ProjectConfigurationSectionName; diff --git a/Source/cmGlobalVisualStudio7Generator.cxx b/Source/cmGlobalVisualStudio7Generator.cxx index 862f1d3..6f9c028 100644 --- a/Source/cmGlobalVisualStudio7Generator.cxx +++ b/Source/cmGlobalVisualStudio7Generator.cxx @@ -435,6 +435,9 @@ void cmGlobalVisualStudio7Generator this->WriteTargetConfigurations(fout, root, orderedProjectTargets); fout << "\tEndGlobalSection\n"; + // Write out global sections + this->WriteSLNGlobalSections(fout, root); + // Write the footer for the SLN file this->WriteSLNFooter(fout); } @@ -631,14 +634,73 @@ void cmGlobalVisualStudio7Generator::WriteExternalProject(std::ostream& fout, +void cmGlobalVisualStudio7Generator +::WriteSLNGlobalSections(std::ostream& fout, + cmLocalGenerator* root) +{ + bool extensibilityGlobalsOverridden = false; + bool extensibilityAddInsOverridden = false; + const cmPropertyMap& props = root->GetMakefile()->GetProperties(); + for(cmPropertyMap::const_iterator itProp = props.begin(); + itProp != props.end(); ++itProp) + { + if(itProp->first.find("VS_GLOBAL_SECTION_") == 0) + { + std::string sectionType; + std::string name = itProp->first.substr(18); + if(name.find("PRE_") == 0) + { + name = name.substr(4); + sectionType = "preSolution"; + } + else if(name.find("POST_") == 0) + { + name = name.substr(5); + sectionType = "postSolution"; + } + else + continue; + if(!name.empty()) + { + if(name == "ExtensibilityGlobals" && sectionType == "postSolution") + extensibilityGlobalsOverridden = true; + else if(name == "ExtensibilityAddIns" && sectionType == "postSolution") + extensibilityAddInsOverridden = true; + fout << "\tGlobalSection(" << name << ") = " << sectionType << "\n"; + std::vector<std::string> keyValuePairs; + cmSystemTools::ExpandListArgument(itProp->second.GetValue(), + keyValuePairs); + for(std::vector<std::string>::const_iterator itPair = + keyValuePairs.begin(); itPair != keyValuePairs.end(); ++itPair) + { + const std::string::size_type posEqual = itPair->find('='); + if(posEqual != std::string::npos) + { + const std::string key = + cmSystemTools::TrimWhitespace(itPair->substr(0, posEqual)); + const std::string value = + cmSystemTools::TrimWhitespace(itPair->substr(posEqual + 1)); + fout << "\t\t" << key << " = " << value << "\n"; + } + } + fout << "\tEndGlobalSection\n"; + } + } + } + if(!extensibilityGlobalsOverridden) + fout << "\tGlobalSection(ExtensibilityGlobals) = postSolution\n" + << "\tEndGlobalSection\n"; + if(!extensibilityAddInsOverridden) + fout << "\tGlobalSection(ExtensibilityAddIns) = postSolution\n" + << "\tEndGlobalSection\n"; +} + + + // Standard end of dsw file void cmGlobalVisualStudio7Generator::WriteSLNFooter(std::ostream& fout) { - fout << "\tGlobalSection(ExtensibilityGlobals) = postSolution\n" - << "\tEndGlobalSection\n" - << "\tGlobalSection(ExtensibilityAddIns) = postSolution\n" - << "\tEndGlobalSection\n" - << "EndGlobal\n"; + fout << "EndGlobal\n"; } diff --git a/Source/cmGlobalVisualStudio7Generator.h b/Source/cmGlobalVisualStudio7Generator.h index 3775dd4..8ba1f44 100644 --- a/Source/cmGlobalVisualStudio7Generator.h +++ b/Source/cmGlobalVisualStudio7Generator.h @@ -109,6 +109,8 @@ protected: std::ostream& fout, const char* name, const std::set<std::string>& configsPartOfDefaultBuild, const char* platformMapping = NULL); + virtual void WriteSLNGlobalSections(std::ostream& fout, + cmLocalGenerator* root); virtual void WriteSLNFooter(std::ostream& fout); virtual void WriteSLNHeader(std::ostream& fout); virtual std::string WriteUtilityDepend(cmTarget* target); diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index f067da4..8498d72 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -3937,6 +3937,46 @@ void cmMakefile::DefineProperties(cmake *cm) "See the global property of the same name for details. " "This overrides the global property for a directory.", true); + + cm->DefineProperty + ("VS_GLOBAL_SECTION_PRE_<section>", cmProperty::DIRECTORY, + "Specify a preSolution global section in Visual Studio.", + "Setting a property like this generates an entry of the following form " + "in the solution file:\n" + " GlobalSection(<section>) = preSolution\n" + " <contents based on property value>\n" + " EndGlobalSection\n" + "The property must be set to a semicolon-separated list of key=value " + "pairs. Each such pair will be transformed into an entry in the solution " + "global section. Whitespace around key and value is ignored. List " + "elements which do not contain an equal sign are skipped." + "\n" + "This property only works for Visual Studio 7 and above; it is ignored " + "on other generators. The property only applies when set on a directory " + "whose CMakeLists.txt conatins a project() command."); + cm->DefineProperty + ("VS_GLOBAL_SECTION_POST_<section>", cmProperty::DIRECTORY, + "Specify a postSolution global section in Visual Studio.", + "Setting a property like this generates an entry of the following form " + "in the solution file:\n" + " GlobalSection(<section>) = postSolution\n" + " <contents based on property value>\n" + " EndGlobalSection\n" + "The property must be set to a semicolon-separated list of key=value " + "pairs. Each such pair will be transformed into an entry in the solution " + "global section. Whitespace around key and value is ignored. List " + "elements which do not contain an equal sign are skipped." + "\n" + "This property only works for Visual Studio 7 and above; it is ignored " + "on other generators. The property only applies when set on a directory " + "whose CMakeLists.txt conatins a project() command." + "\n" + "Note that CMake generates postSolution sections ExtensibilityGlobals " + "and ExtensibilityAddIns by default. If you set the corresponding " + "property, it will override the default section. For example, setting " + "VS_GLOBAL_SECTION_POST_ExtensibilityGlobals will override the default " + "contents of the ExtensibilityGlobals section, while keeping " + "ExtensibilityAddIns on its default."); } //---------------------------------------------------------------------------- |