This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake".
The branch, master has been updated via f07200fe163640f708c62de3cbdc0fb49a7e0471 (commit) via c1580ecc13cf2dea3f047d1018e705bd34cecc53 (commit) via 1af08229a7b871ea592cdf6d2aa41e47787eb713 (commit) via 00d265e3c812516e2a71faed4f352b36f51112e2 (commit) via 1b945f95bafc9a795b092904f7c6bd84dad940e8 (commit) via e0a8ff31480df672e42e2382e8ed7f33ea65afb4 (commit) via 8d934d861be8c2a8b43d4c421715fb1e8c0c54fd (commit) via 026f65d284deaea9f2dba41ed956fabf84e17b6d (commit) via 9e64e617eb295c7e2725d871225659ae7bcf7c48 (commit) via e791ffac61912f6540742aabaf4cb78a4d475a16 (commit) via a982916304fc7a66edb7a587144cb192f13ef6be (commit) from 00132e60a6b85d12a6614d773e8d0d86810ede76 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=f07200fe163640f708c62de3cbdc0fb49a7e0471 commit f07200fe163640f708c62de3cbdc0fb49a7e0471 Merge: c1580ec e791ffa Author: Brad King <brad.k...@kitware.com> AuthorDate: Wed Jun 12 16:48:04 2019 +0000 Commit: Kitware Robot <kwro...@kitware.com> CommitDate: Wed Jun 12 12:48:13 2019 -0400 Merge topic 'add-test-command-expand-lists' e791ffac61 add_test: Add COMMAND_EXPAND_LISTS option Acked-by: Kitware Robot <kwro...@kitware.com> Merge-request: !3422 https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=c1580ecc13cf2dea3f047d1018e705bd34cecc53 commit c1580ecc13cf2dea3f047d1018e705bd34cecc53 Merge: 1af0822 00d265e Author: Brad King <brad.k...@kitware.com> AuthorDate: Wed Jun 12 16:45:55 2019 +0000 Commit: Kitware Robot <kwro...@kitware.com> CommitDate: Wed Jun 12 12:46:18 2019 -0400 Merge topic 'cmPropertyMap_unordered_map' 00d265e3c8 cmPropertyMap: Use std::unordered_map as container instead of std::map 1b945f95ba cmPropertyMap: Add RemoveProperty method e0a8ff3148 cmPropertyMap: Use std::string as value container class 8d934d861b cmPropertyMap: Make std::map container private 026f65d284 cmPropertyMap: Add GetList method 9e64e617eb cmPropertyMap: Rename GetPropertyList method to GetKeys Acked-by: Kitware Robot <kwro...@kitware.com> Merge-request: !3435 https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=1af08229a7b871ea592cdf6d2aa41e47787eb713 commit 1af08229a7b871ea592cdf6d2aa41e47787eb713 Merge: 00132e6 a982916 Author: Brad King <brad.k...@kitware.com> AuthorDate: Wed Jun 12 16:44:56 2019 +0000 Commit: Kitware Robot <kwro...@kitware.com> CommitDate: Wed Jun 12 12:45:15 2019 -0400 Merge topic 'language-dependent-linker-flags' a982916304 Support per-language library link flags Acked-by: Kitware Robot <kwro...@kitware.com> Merge-request: !3429 https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=00d265e3c812516e2a71faed4f352b36f51112e2 commit 00d265e3c812516e2a71faed4f352b36f51112e2 Author: Sebastian Holtermann <sebh...@xwmw.org> AuthorDate: Mon Jun 3 10:29:12 2019 +0200 Commit: Sebastian Holtermann <sebh...@xwmw.org> CommitDate: Sat Jun 8 12:25:35 2019 +0200 cmPropertyMap: Use std::unordered_map as container instead of std::map diff --git a/Source/cmPropertyMap.cxx b/Source/cmPropertyMap.cxx index 64bceb5..3ed4c05 100644 --- a/Source/cmPropertyMap.cxx +++ b/Source/cmPropertyMap.cxx @@ -2,6 +2,7 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmPropertyMap.h" +#include <algorithm> #include <utility> void cmPropertyMap::Clear() @@ -59,15 +60,21 @@ std::vector<std::string> cmPropertyMap::GetKeys() const for (auto const& item : Map_) { keyList.push_back(item.first); } + std::sort(keyList.begin(), keyList.end()); return keyList; } std::vector<std::pair<std::string, std::string>> cmPropertyMap::GetList() const { - std::vector<std::pair<std::string, std::string>> kvList; + typedef std::pair<std::string, std::string> StringPair; + std::vector<StringPair> kvList; kvList.reserve(Map_.size()); for (auto const& item : Map_) { kvList.emplace_back(item.first, item.second); } + std::sort(kvList.begin(), kvList.end(), + [](StringPair const& a, StringPair const& b) { + return a.first < b.first; + }); return kvList; } diff --git a/Source/cmPropertyMap.h b/Source/cmPropertyMap.h index 6284e8c..9aed349 100644 --- a/Source/cmPropertyMap.h +++ b/Source/cmPropertyMap.h @@ -5,11 +5,14 @@ #include "cmConfigure.h" // IWYU pragma: keep -#include <map> #include <string> +#include <unordered_map> #include <utility> #include <vector> +/** \class cmPropertyMap + * \brief String property map. + */ class cmPropertyMap { public: @@ -34,6 +37,7 @@ public: void RemoveProperty(const std::string& name); // -- Lists + //! Get a sorted list of property keys std::vector<std::string> GetKeys() const; @@ -41,7 +45,7 @@ public: std::vector<std::pair<std::string, std::string>> GetList() const; private: - std::map<std::string, std::string> Map_; + std::unordered_map<std::string, std::string> Map_; }; #endif https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=1b945f95bafc9a795b092904f7c6bd84dad940e8 commit 1b945f95bafc9a795b092904f7c6bd84dad940e8 Author: Sebastian Holtermann <sebh...@xwmw.org> AuthorDate: Mon Jun 3 09:19:58 2019 +0200 Commit: Sebastian Holtermann <sebh...@xwmw.org> CommitDate: Sat Jun 8 12:25:35 2019 +0200 cmPropertyMap: Add RemoveProperty method The new `cmPropertyMap::RemoveProperty` allows to remove a property from the map. diff --git a/Source/cmPropertyMap.cxx b/Source/cmPropertyMap.cxx index 0874977..64bceb5 100644 --- a/Source/cmPropertyMap.cxx +++ b/Source/cmPropertyMap.cxx @@ -36,6 +36,11 @@ void cmPropertyMap::AppendProperty(const std::string& name, const char* value, } } +void cmPropertyMap::RemoveProperty(const std::string& name) +{ + Map_.erase(name); +} + const char* cmPropertyMap::GetPropertyValue(const std::string& name) const { { diff --git a/Source/cmPropertyMap.h b/Source/cmPropertyMap.h index 165eb92..6284e8c 100644 --- a/Source/cmPropertyMap.h +++ b/Source/cmPropertyMap.h @@ -14,17 +14,25 @@ class cmPropertyMap { public: // -- General + //! Clear property list void Clear(); // -- Properties + + //! Set the property value void SetProperty(const std::string& name, const char* value); + //! Append to the property value void AppendProperty(const std::string& name, const char* value, bool asString = false); + //! Get the property value const char* GetPropertyValue(const std::string& name) const; + //! Remove the property @a name from the map + void RemoveProperty(const std::string& name); + // -- Lists //! Get a sorted list of property keys std::vector<std::string> GetKeys() const; https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=e0a8ff31480df672e42e2382e8ed7f33ea65afb4 commit e0a8ff31480df672e42e2382e8ed7f33ea65afb4 Author: Sebastian Holtermann <sebh...@xwmw.org> AuthorDate: Mon Jun 3 09:26:59 2019 +0200 Commit: Sebastian Holtermann <sebh...@xwmw.org> CommitDate: Sat Jun 8 12:25:35 2019 +0200 cmPropertyMap: Use std::string as value container class diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt index 695e075..67bc598 100644 --- a/Source/CMakeLists.txt +++ b/Source/CMakeLists.txt @@ -338,7 +338,6 @@ set(SRCS cmProcessOutput.h cmProcessTools.cxx cmProcessTools.h - cmProperty.cxx cmProperty.h cmPropertyDefinition.cxx cmPropertyDefinition.h diff --git a/Source/cmExportFileGenerator.cxx b/Source/cmExportFileGenerator.cxx index 6621797..c366183 100644 --- a/Source/cmExportFileGenerator.cxx +++ b/Source/cmExportFileGenerator.cxx @@ -12,7 +12,6 @@ #include "cmMessageType.h" #include "cmOutputConverter.h" #include "cmPolicies.h" -#include "cmProperty.h" #include "cmPropertyMap.h" #include "cmStateTypes.h" #include "cmSystemTools.h" diff --git a/Source/cmJsonObjects.cxx b/Source/cmJsonObjects.cxx index 657d681..8d065e1 100644 --- a/Source/cmJsonObjects.cxx +++ b/Source/cmJsonObjects.cxx @@ -14,7 +14,6 @@ #include "cmLinkLineComputer.h" #include "cmLocalGenerator.h" #include "cmMakefile.h" -#include "cmProperty.h" #include "cmPropertyMap.h" #include "cmSourceFile.h" #include "cmState.h" diff --git a/Source/cmProperty.cxx b/Source/cmProperty.cxx deleted file mode 100644 index 27f0ecd..0000000 --- a/Source/cmProperty.cxx +++ /dev/null @@ -1,26 +0,0 @@ -/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying - file Copyright.txt or https://cmake.org/licensing for details. */ -#include "cmProperty.h" - -void cmProperty::Set(const char* value) -{ - this->Value = value; - this->ValueHasBeenSet = true; -} - -void cmProperty::Append(const char* value, bool asString) -{ - if (!this->Value.empty() && *value && !asString) { - this->Value += ";"; - } - this->Value += value; - this->ValueHasBeenSet = true; -} - -const char* cmProperty::GetValue() const -{ - if (this->ValueHasBeenSet) { - return this->Value.c_str(); - } - return nullptr; -} diff --git a/Source/cmProperty.h b/Source/cmProperty.h index d11c5ef..80f131a 100644 --- a/Source/cmProperty.h +++ b/Source/cmProperty.h @@ -5,8 +5,6 @@ #include "cmConfigure.h" // IWYU pragma: keep -#include <string> - class cmProperty { public: @@ -22,22 +20,6 @@ public: CACHED_VARIABLE, INSTALL }; - - // set this property - void Set(const char* value); - - // append to this property - void Append(const char* value, bool asString = false); - - // get the value - const char* GetValue() const; - - // construct with the value not set - cmProperty() { this->ValueHasBeenSet = false; } - -protected: - std::string Value; - bool ValueHasBeenSet; }; #endif diff --git a/Source/cmPropertyMap.cxx b/Source/cmPropertyMap.cxx index 7177a63..0874977 100644 --- a/Source/cmPropertyMap.cxx +++ b/Source/cmPropertyMap.cxx @@ -16,7 +16,7 @@ void cmPropertyMap::SetProperty(const std::string& name, const char* value) return; } - Map_[name].Set(value); + Map_[name] = value; } void cmPropertyMap::AppendProperty(const std::string& name, const char* value, @@ -27,7 +27,13 @@ void cmPropertyMap::AppendProperty(const std::string& name, const char* value, return; } - Map_[name].Append(value, asString); + { + std::string& pVal = Map_[name]; + if (!pVal.empty() && !asString) { + pVal += ';'; + } + pVal += value; + } } const char* cmPropertyMap::GetPropertyValue(const std::string& name) const @@ -35,7 +41,7 @@ const char* cmPropertyMap::GetPropertyValue(const std::string& name) const { auto it = Map_.find(name); if (it != Map_.end()) { - return it->second.GetValue(); + return it->second.c_str(); } } return nullptr; @@ -56,7 +62,7 @@ std::vector<std::pair<std::string, std::string>> cmPropertyMap::GetList() const std::vector<std::pair<std::string, std::string>> kvList; kvList.reserve(Map_.size()); for (auto const& item : Map_) { - kvList.emplace_back(item.first, item.second.GetValue()); + kvList.emplace_back(item.first, item.second); } return kvList; } diff --git a/Source/cmPropertyMap.h b/Source/cmPropertyMap.h index 4fcbf58..165eb92 100644 --- a/Source/cmPropertyMap.h +++ b/Source/cmPropertyMap.h @@ -5,8 +5,6 @@ #include "cmConfigure.h" // IWYU pragma: keep -#include "cmProperty.h" - #include <map> #include <string> #include <utility> @@ -35,7 +33,7 @@ public: std::vector<std::pair<std::string, std::string>> GetList() const; private: - std::map<std::string, cmProperty> Map_; + std::map<std::string, std::string> Map_; }; #endif diff --git a/Source/cmTestGenerator.cxx b/Source/cmTestGenerator.cxx index 3840e50..174fb8a 100644 --- a/Source/cmTestGenerator.cxx +++ b/Source/cmTestGenerator.cxx @@ -10,7 +10,6 @@ #include "cmListFileCache.h" #include "cmLocalGenerator.h" #include "cmOutputConverter.h" -#include "cmProperty.h" #include "cmPropertyMap.h" #include "cmRange.h" #include "cmStateTypes.h" diff --git a/bootstrap b/bootstrap index 38fa32b..569a6a4 100755 --- a/bootstrap +++ b/bootstrap @@ -388,7 +388,6 @@ CMAKE_CXX_SOURCES="\ cmPolicies \ cmProcessOutput \ cmProjectCommand \ - cmProperty \ cmPropertyDefinition \ cmPropertyDefinitionMap \ cmPropertyMap \ https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=8d934d861be8c2a8b43d4c421715fb1e8c0c54fd commit 8d934d861be8c2a8b43d4c421715fb1e8c0c54fd Author: Sebastian Holtermann <sebh...@xwmw.org> AuthorDate: Sun Jun 2 13:34:31 2019 +0200 Commit: Sebastian Holtermann <sebh...@xwmw.org> CommitDate: Sat Jun 8 12:25:35 2019 +0200 cmPropertyMap: Make std::map container private diff --git a/Source/cmExportFileGenerator.cxx b/Source/cmExportFileGenerator.cxx index a12e0c4..6621797 100644 --- a/Source/cmExportFileGenerator.cxx +++ b/Source/cmExportFileGenerator.cxx @@ -1205,12 +1205,9 @@ bool cmExportFileGenerator::PopulateExportProperties( std::string& errorMessage) { auto& targetProperties = gte->Target->GetProperties(); - const auto& exportProperties = targetProperties.find("EXPORT_PROPERTIES"); - if (exportProperties != targetProperties.end()) { - std::vector<std::string> propsToExport; - cmSystemTools::ExpandListArgument(exportProperties->second.GetValue(), - propsToExport); - for (auto& prop : propsToExport) { + if (const char* exportProperties = + targetProperties.GetPropertyValue("EXPORT_PROPERTIES")) { + for (auto& prop : cmSystemTools::ExpandedListArgument(exportProperties)) { /* Black list reserved properties */ if (cmSystemTools::StringStartsWith(prop, "IMPORTED_") || cmSystemTools::StringStartsWith(prop, "INTERFACE_")) { diff --git a/Source/cmPropertyMap.cxx b/Source/cmPropertyMap.cxx index 09b30ba..7177a63 100644 --- a/Source/cmPropertyMap.cxx +++ b/Source/cmPropertyMap.cxx @@ -2,30 +2,21 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmPropertyMap.h" -#include <assert.h> #include <utility> -cmProperty* cmPropertyMap::GetOrCreateProperty(const std::string& name) +void cmPropertyMap::Clear() { - cmPropertyMap::iterator it = this->find(name); - cmProperty* prop; - if (it == this->end()) { - prop = &(*this)[name]; - } else { - prop = &(it->second); - } - return prop; + Map_.clear(); } void cmPropertyMap::SetProperty(const std::string& name, const char* value) { if (!value) { - this->erase(name); + Map_.erase(name); return; } - cmProperty* prop = this->GetOrCreateProperty(name); - prop->Set(value); + Map_[name].Set(value); } void cmPropertyMap::AppendProperty(const std::string& name, const char* value, @@ -36,26 +27,25 @@ void cmPropertyMap::AppendProperty(const std::string& name, const char* value, return; } - cmProperty* prop = this->GetOrCreateProperty(name); - prop->Append(value, asString); + Map_[name].Append(value, asString); } const char* cmPropertyMap::GetPropertyValue(const std::string& name) const { - assert(!name.empty()); - - cmPropertyMap::const_iterator it = this->find(name); - if (it == this->end()) { - return nullptr; + { + auto it = Map_.find(name); + if (it != Map_.end()) { + return it->second.GetValue(); + } } - return it->second.GetValue(); + return nullptr; } std::vector<std::string> cmPropertyMap::GetKeys() const { std::vector<std::string> keyList; - keyList.reserve(this->size()); - for (auto const& item : *this) { + keyList.reserve(Map_.size()); + for (auto const& item : Map_) { keyList.push_back(item.first); } return keyList; @@ -64,8 +54,8 @@ std::vector<std::string> cmPropertyMap::GetKeys() const std::vector<std::pair<std::string, std::string>> cmPropertyMap::GetList() const { std::vector<std::pair<std::string, std::string>> kvList; - kvList.reserve(this->size()); - for (auto const& item : *this) { + kvList.reserve(Map_.size()); + for (auto const& item : Map_) { kvList.emplace_back(item.first, item.second.GetValue()); } return kvList; diff --git a/Source/cmPropertyMap.h b/Source/cmPropertyMap.h index e2348a3..4fcbf58 100644 --- a/Source/cmPropertyMap.h +++ b/Source/cmPropertyMap.h @@ -12,12 +12,14 @@ #include <utility> #include <vector> -class cmPropertyMap : public std::map<std::string, cmProperty> +class cmPropertyMap { public: - // -- Properties - cmProperty* GetOrCreateProperty(const std::string& name); + // -- General + //! Clear property list + void Clear(); + // -- Properties void SetProperty(const std::string& name, const char* value); void AppendProperty(const std::string& name, const char* value, @@ -31,6 +33,9 @@ public: //! Get a sorted by key list of property key,value pairs std::vector<std::pair<std::string, std::string>> GetList() const; + +private: + std::map<std::string, cmProperty> Map_; }; #endif diff --git a/Source/cmState.cxx b/Source/cmState.cxx index fa7df0b..091c2e0 100644 --- a/Source/cmState.cxx +++ b/Source/cmState.cxx @@ -267,7 +267,7 @@ void cmState::RemoveCacheEntryProperty(std::string const& key, cmStateSnapshot cmState::Reset() { - this->GlobalProperties.clear(); + this->GlobalProperties.Clear(); this->PropertyDefinitions.clear(); this->GlobVerificationManager->Reset(); @@ -289,7 +289,7 @@ cmStateSnapshot cmState::Reset() it->LinkDirectoriesBacktraces.clear(); it->DirectoryEnd = pos; it->NormalTargetNames.clear(); - it->Properties.clear(); + it->Properties.Clear(); it->Children.clear(); } diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index 9368414..634c990 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -774,11 +774,11 @@ void cmVisualStudio10TargetGenerator::WriteDotNetReferences(Elem& e0) cmSystemTools::ExpandListArgument(vsDotNetReferences, references); } cmPropertyMap const& props = this->GeneratorTarget->Target->GetProperties(); - for (auto const& i : props) { + for (auto const& i : props.GetList()) { if (i.first.find("VS_DOTNET_REFERENCE_") == 0) { std::string name = i.first.substr(20); if (!name.empty()) { - std::string path = i.second.GetValue(); + std::string path = i.second; if (!cmsys::SystemTools::FileIsFullPath(path)) { path = this->Makefile->GetCurrentSourceDirectory() + "/" + path; } @@ -870,10 +870,10 @@ void cmVisualStudio10TargetGenerator::WriteDotNetReferenceCustomTags( typedef std::map<std::string, std::string> CustomTags; CustomTags tags; cmPropertyMap const& props = this->GeneratorTarget->Target->GetProperties(); - for (const auto& i : props) { + for (const auto& i : props.GetList()) { if (i.first.find(refPropFullPrefix) == 0) { std::string refTag = i.first.substr(refPropFullPrefix.length()); - std::string refVal = i.second.GetValue(); + std::string refVal = i.second; if (!refTag.empty() && !refVal.empty()) { tags[refTag] = refVal; } @@ -967,12 +967,12 @@ void cmVisualStudio10TargetGenerator::WriteEmbeddedResourceGroup(Elem& e0) } } const cmPropertyMap& props = oi->GetProperties(); - for (const auto& p : props) { + for (const std::string& p : props.GetKeys()) { static const std::string propNamePrefix = "VS_CSHARP_"; - if (p.first.find(propNamePrefix) == 0) { - std::string tagName = p.first.substr(propNamePrefix.length()); + if (p.find(propNamePrefix) == 0) { + std::string tagName = p.substr(propNamePrefix.length()); if (!tagName.empty()) { - std::string value = props.GetPropertyValue(p.first); + std::string value = props.GetPropertyValue(p); if (!value.empty()) { e2.Element(tagName.c_str(), value); } @@ -4681,12 +4681,12 @@ void cmVisualStudio10TargetGenerator::GetCSharpSourceProperties( { if (this->ProjectType == csproj) { const cmPropertyMap& props = sf->GetProperties(); - for (auto const& p : props) { + for (const std::string& p : props.GetKeys()) { static const std::string propNamePrefix = "VS_CSHARP_"; - if (p.first.find(propNamePrefix) == 0) { - std::string tagName = p.first.substr(propNamePrefix.length()); + if (p.find(propNamePrefix) == 0) { + std::string tagName = p.substr(propNamePrefix.length()); if (!tagName.empty()) { - const std::string val = props.GetPropertyValue(p.first); + const std::string val = props.GetPropertyValue(p); if (!val.empty()) { tags[tagName] = val; } else { https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=026f65d284deaea9f2dba41ed956fabf84e17b6d commit 026f65d284deaea9f2dba41ed956fabf84e17b6d Author: Sebastian Holtermann <sebh...@xwmw.org> AuthorDate: Sun Jun 2 12:43:16 2019 +0200 Commit: Sebastian Holtermann <sebh...@xwmw.org> CommitDate: Sat Jun 8 12:25:35 2019 +0200 cmPropertyMap: Add GetList method diff --git a/Source/cmJsonObjects.cxx b/Source/cmJsonObjects.cxx index 636a8e1..657d681 100644 --- a/Source/cmJsonObjects.cxx +++ b/Source/cmJsonObjects.cxx @@ -363,12 +363,12 @@ static Json::Value DumpCTestInfo(cmLocalGenerator* lg, cmTest* testInfo, // Build up the list of properties that may have been specified Json::Value properties = Json::arrayValue; - for (auto& prop : testInfo->GetProperties()) { + for (auto& prop : testInfo->GetProperties().GetList()) { Json::Value entry = Json::objectValue; entry[kKEY_KEY] = prop.first; // Remove config variables from the value too. - auto cge_value = ge.Parse(prop.second.GetValue()); + auto cge_value = ge.Parse(prop.second); const std::string& processed_value = cge_value->Evaluate(lg, config); entry[kVALUE_KEY] = processed_value; properties.append(entry); diff --git a/Source/cmPropertyMap.cxx b/Source/cmPropertyMap.cxx index a97e1f0..09b30ba 100644 --- a/Source/cmPropertyMap.cxx +++ b/Source/cmPropertyMap.cxx @@ -60,3 +60,13 @@ std::vector<std::string> cmPropertyMap::GetKeys() const } return keyList; } + +std::vector<std::pair<std::string, std::string>> cmPropertyMap::GetList() const +{ + std::vector<std::pair<std::string, std::string>> kvList; + kvList.reserve(this->size()); + for (auto const& item : *this) { + kvList.emplace_back(item.first, item.second.GetValue()); + } + return kvList; +} diff --git a/Source/cmPropertyMap.h b/Source/cmPropertyMap.h index 5c93627..e2348a3 100644 --- a/Source/cmPropertyMap.h +++ b/Source/cmPropertyMap.h @@ -9,6 +9,7 @@ #include <map> #include <string> +#include <utility> #include <vector> class cmPropertyMap : public std::map<std::string, cmProperty> @@ -27,6 +28,9 @@ public: // -- Lists //! Get a sorted list of property keys std::vector<std::string> GetKeys() const; + + //! Get a sorted by key list of property key,value pairs + std::vector<std::pair<std::string, std::string>> GetList() const; }; #endif diff --git a/Source/cmTestGenerator.cxx b/Source/cmTestGenerator.cxx index 571cd09..3840e50 100644 --- a/Source/cmTestGenerator.cxx +++ b/Source/cmTestGenerator.cxx @@ -117,13 +117,12 @@ void cmTestGenerator::GenerateScriptForConfig(std::ostream& os, os << ")\n"; // Output properties for the test. - cmPropertyMap& pm = this->Test->GetProperties(); os << indent << "set_tests_properties(" << this->Test->GetName() << " PROPERTIES "; - for (auto const& i : pm) { + for (auto const& i : this->Test->GetProperties().GetList()) { os << " " << i.first << " " << cmOutputConverter::EscapeForCMake( - ge.Parse(i.second.GetValue())->Evaluate(this->LG, config)); + ge.Parse(i.second)->Evaluate(this->LG, config)); } this->GenerateInternalProperties(os); os << ")" << std::endl; @@ -173,12 +172,11 @@ void cmTestGenerator::GenerateOldStyle(std::ostream& fout, Indent indent) fout << ")" << std::endl; // Output properties for the test. - cmPropertyMap& pm = this->Test->GetProperties(); fout << indent << "set_tests_properties(" << this->Test->GetName() << " PROPERTIES "; - for (auto const& i : pm) { + for (auto const& i : this->Test->GetProperties().GetList()) { fout << " " << i.first << " " - << cmOutputConverter::EscapeForCMake(i.second.GetValue()); + << cmOutputConverter::EscapeForCMake(i.second); } this->GenerateInternalProperties(fout); fout << ")" << std::endl; https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=9e64e617eb295c7e2725d871225659ae7bcf7c48 commit 9e64e617eb295c7e2725d871225659ae7bcf7c48 Author: Sebastian Holtermann <sebh...@xwmw.org> AuthorDate: Sun Jun 2 12:35:33 2019 +0200 Commit: Sebastian Holtermann <sebh...@xwmw.org> CommitDate: Sat Jun 8 12:25:35 2019 +0200 cmPropertyMap: Rename GetPropertyList method to GetKeys diff --git a/Source/cmCacheManager.cxx b/Source/cmCacheManager.cxx index 358f095..e8fc350 100644 --- a/Source/cmCacheManager.cxx +++ b/Source/cmCacheManager.cxx @@ -620,7 +620,7 @@ bool cmCacheManager::CacheIterator::GetValueAsBool() const std::vector<std::string> cmCacheManager::CacheEntry::GetPropertyList() const { - return this->Properties.GetPropertyList(); + return this->Properties.GetKeys(); } const char* cmCacheManager::CacheEntry::GetProperty( diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 036a07d..de0f371 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -5032,13 +5032,7 @@ void cmGeneratorTarget::ComputeVersionedName(std::string& vName, std::vector<std::string> cmGeneratorTarget::GetPropertyKeys() const { - cmPropertyMap const& propsObject = this->Target->GetProperties(); - std::vector<std::string> props; - props.reserve(propsObject.size()); - for (auto const& it : propsObject) { - props.push_back(it.first); - } - return props; + return this->Target->GetProperties().GetKeys(); } void cmGeneratorTarget::ReportPropertyOrigin( diff --git a/Source/cmPropertyMap.cxx b/Source/cmPropertyMap.cxx index 3f6d7c8..a97e1f0 100644 --- a/Source/cmPropertyMap.cxx +++ b/Source/cmPropertyMap.cxx @@ -2,7 +2,6 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmPropertyMap.h" -#include <algorithm> #include <assert.h> #include <utility> @@ -18,16 +17,6 @@ cmProperty* cmPropertyMap::GetOrCreateProperty(const std::string& name) return prop; } -std::vector<std::string> cmPropertyMap::GetPropertyList() const -{ - std::vector<std::string> keyList; - for (auto const& i : *this) { - keyList.push_back(i.first); - } - std::sort(keyList.begin(), keyList.end()); - return keyList; -} - void cmPropertyMap::SetProperty(const std::string& name, const char* value) { if (!value) { @@ -61,3 +50,13 @@ const char* cmPropertyMap::GetPropertyValue(const std::string& name) const } return it->second.GetValue(); } + +std::vector<std::string> cmPropertyMap::GetKeys() const +{ + std::vector<std::string> keyList; + keyList.reserve(this->size()); + for (auto const& item : *this) { + keyList.push_back(item.first); + } + return keyList; +} diff --git a/Source/cmPropertyMap.h b/Source/cmPropertyMap.h index 5a05150..5c93627 100644 --- a/Source/cmPropertyMap.h +++ b/Source/cmPropertyMap.h @@ -14,16 +14,19 @@ class cmPropertyMap : public std::map<std::string, cmProperty> { public: + // -- Properties cmProperty* GetOrCreateProperty(const std::string& name); - std::vector<std::string> GetPropertyList() const; - void SetProperty(const std::string& name, const char* value); void AppendProperty(const std::string& name, const char* value, bool asString = false); const char* GetPropertyValue(const std::string& name) const; + + // -- Lists + //! Get a sorted list of property keys + std::vector<std::string> GetKeys() const; }; #endif diff --git a/Source/cmStateDirectory.cxx b/Source/cmStateDirectory.cxx index 182d3fe..6ca1c9f 100644 --- a/Source/cmStateDirectory.cxx +++ b/Source/cmStateDirectory.cxx @@ -6,7 +6,6 @@ #include <algorithm> #include <assert.h> #include <iterator> -#include <utility> #include "cmAlgorithms.h" #include "cmProperty.h" @@ -667,12 +666,7 @@ bool cmStateDirectory::GetPropertyAsBool(const std::string& prop) const std::vector<std::string> cmStateDirectory::GetPropertyKeys() const { - std::vector<std::string> keys; - keys.reserve(this->DirectoryState->Properties.size()); - for (auto const& it : this->DirectoryState->Properties) { - keys.push_back(it.first); - } - return keys; + return this->DirectoryState->Properties.GetKeys(); } void cmStateDirectory::AddNormalTargetName(std::string const& name) https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=e791ffac61912f6540742aabaf4cb78a4d475a16 commit e791ffac61912f6540742aabaf4cb78a4d475a16 Author: Sergey Bobrenok <bobro...@gmail.com> AuthorDate: Wed May 15 22:10:39 2019 +0700 Commit: Brad King <brad.k...@kitware.com> CommitDate: Fri Jun 7 13:14:29 2019 -0400 add_test: Add COMMAND_EXPAND_LISTS option Add a `COMMAND_EXPAND_LISTS` option to the `add_test` command to cause `;`-separated lists produced by generator expressions to be expanded into multiple arguments. The `add_custom_command` command already has such an option. Fixes: #17284 diff --git a/Help/command/add_test.rst b/Help/command/add_test.rst index 46b9b63..884b2ee 100644 --- a/Help/command/add_test.rst +++ b/Help/command/add_test.rst @@ -7,7 +7,8 @@ Add a test to the project to be run by :manual:`ctest(1)`. add_test(NAME <name> COMMAND <command> [<arg>...] [CONFIGURATIONS <config>...] - [WORKING_DIRECTORY <dir>]) + [WORKING_DIRECTORY <dir>] + [COMMAND_EXPAND_LISTS]) Adds a test called ``<name>``. The test name may not contain spaces, quotes, or other characters special in CMake syntax. The options are: @@ -28,6 +29,11 @@ quotes, or other characters special in CMake syntax. The options are: directory set to the build directory corresponding to the current source directory. +``COMMAND_EXPAND_LISTS`` + Lists in ``COMMAND`` arguments will be expanded, including those + created with + :manual:`generator expressions <cmake-generator-expressions(7)>`. + The given test command is expected to exit with code ``0`` to pass and non-zero to fail, or vice-versa if the :prop_test:`WILL_FAIL` test property is set. Any output written to stdout or stderr will be diff --git a/Help/release/dev/add_test-expand_lists.rst b/Help/release/dev/add_test-expand_lists.rst new file mode 100644 index 0000000..88d26b7 --- /dev/null +++ b/Help/release/dev/add_test-expand_lists.rst @@ -0,0 +1,6 @@ +add_test-expand_lists +--------------------- + +* The command :command:`add_test` learned the option ``COMMAND_EXPAND_LISTS`` + which causes lists in the ``COMMAND`` argument to be expanded, including + lists created by generator expressions. diff --git a/Source/cmAddTestCommand.cxx b/Source/cmAddTestCommand.cxx index bf28702..b0c462b 100644 --- a/Source/cmAddTestCommand.cxx +++ b/Source/cmAddTestCommand.cxx @@ -58,6 +58,7 @@ bool cmAddTestCommand::HandleNameMode(std::vector<std::string> const& args) std::vector<std::string> configurations; std::string working_directory; std::vector<std::string> command; + bool command_expand_lists = false; // Read the arguments. enum Doing @@ -88,6 +89,13 @@ bool cmAddTestCommand::HandleNameMode(std::vector<std::string> const& args) return false; } doing = DoingWorkingDirectory; + } else if (args[i] == "COMMAND_EXPAND_LISTS") { + if (command_expand_lists) { + this->SetError(" may be given at most one COMMAND_EXPAND_LISTS."); + return false; + } + command_expand_lists = true; + doing = DoingNone; } else if (doing == DoingName) { name = args[i]; doing = DoingNone; @@ -134,6 +142,7 @@ bool cmAddTestCommand::HandleNameMode(std::vector<std::string> const& args) if (!working_directory.empty()) { test->SetProperty("WORKING_DIRECTORY", working_directory.c_str()); } + test->SetCommandExpandLists(command_expand_lists); this->Makefile->AddTestGenerator(new cmTestGenerator(test, configurations)); return true; diff --git a/Source/cmTest.cxx b/Source/cmTest.cxx index 7d45cf5..01f2b96 100644 --- a/Source/cmTest.cxx +++ b/Source/cmTest.cxx @@ -8,7 +8,8 @@ #include "cmSystemTools.h" cmTest::cmTest(cmMakefile* mf) - : Backtrace(mf->GetBacktrace()) + : CommandExpandLists(false) + , Backtrace(mf->GetBacktrace()) { this->Makefile = mf; this->OldStyle = true; @@ -59,3 +60,13 @@ void cmTest::AppendProperty(const std::string& prop, const char* value, { this->Properties.AppendProperty(prop, value, asString); } + +bool cmTest::GetCommandExpandLists() const +{ + return this->CommandExpandLists; +} + +void cmTest::SetCommandExpandLists(bool b) +{ + this->CommandExpandLists = b; +} diff --git a/Source/cmTest.h b/Source/cmTest.h index 88dc730..02d8f46 100644 --- a/Source/cmTest.h +++ b/Source/cmTest.h @@ -51,10 +51,15 @@ public: bool GetOldStyle() const { return this->OldStyle; } void SetOldStyle(bool b) { this->OldStyle = b; } + /** Set/Get whether lists in command lines should be expanded. */ + bool GetCommandExpandLists() const; + void SetCommandExpandLists(bool b); + private: cmPropertyMap Properties; std::string Name; std::vector<std::string> Command; + bool CommandExpandLists; bool OldStyle; diff --git a/Source/cmTestGenerator.cxx b/Source/cmTestGenerator.cxx index 571cd09..ce960dc 100644 --- a/Source/cmTestGenerator.cxx +++ b/Source/cmTestGenerator.cxx @@ -76,12 +76,22 @@ void cmTestGenerator::GenerateScriptForConfig(std::ostream& os, // Start the test command. os << indent << "add_test(" << this->Test->GetName() << " "; - // Get the test command line to be executed. - std::vector<std::string> const& command = this->Test->GetCommand(); + // Evaluate command line arguments + std::vector<std::string> argv = + EvaluateCommandLineArguments(this->Test->GetCommand(), ge, config); + + // Expand arguments if COMMAND_EXPAND_LISTS is set + if (this->Test->GetCommandExpandLists()) { + argv = cmSystemTools::ExpandedLists(argv.begin(), argv.end()); + // Expanding lists on an empty command may have left it empty + if (argv.empty()) { + argv.emplace_back(); + } + } // Check whether the command executable is a target whose name is to // be translated. - std::string exe = command[0]; + std::string exe = argv[0]; cmGeneratorTarget* target = this->LG->FindGeneratorTargetToUse(exe); if (target && target->GetType() == cmStateEnums::EXECUTABLE) { // Use the target file on disk. @@ -101,16 +111,14 @@ void cmTestGenerator::GenerateScriptForConfig(std::ostream& os, } } else { // Use the command name given. - exe = ge.Parse(exe)->Evaluate(this->LG, config); cmSystemTools::ConvertToUnixSlashes(exe); } // Generate the command line with full escapes. os << cmOutputConverter::EscapeForCMake(exe); - for (std::string const& arg : cmMakeRange(command).advance(1)) { - os << " " - << cmOutputConverter::EscapeForCMake( - ge.Parse(arg)->Evaluate(this->LG, config)); + + for (auto const& arg : cmMakeRange(argv).advance(1)) { + os << " " << cmOutputConverter::EscapeForCMake(arg); } // Finish the test command. @@ -208,3 +216,16 @@ void cmTestGenerator::GenerateInternalProperties(std::ostream& os) os << "\""; } + +std::vector<std::string> cmTestGenerator::EvaluateCommandLineArguments( + const std::vector<std::string>& argv, cmGeneratorExpression& ge, + const std::string& config) const +{ + // Evaluate executable name and arguments + auto evaluatedRange = + cmMakeRange(argv).transform([&](const std::string& arg) { + return ge.Parse(arg)->Evaluate(this->LG, config); + }); + + return { evaluatedRange.begin(), evaluatedRange.end() }; +} diff --git a/Source/cmTestGenerator.h b/Source/cmTestGenerator.h index 8b9cf78..7ac68eb 100644 --- a/Source/cmTestGenerator.h +++ b/Source/cmTestGenerator.h @@ -11,6 +11,7 @@ #include <string> #include <vector> +class cmGeneratorExpression; class cmLocalGenerator; class cmTest; @@ -38,6 +39,9 @@ public: private: void GenerateInternalProperties(std::ostream& os); + std::vector<std::string> EvaluateCommandLineArguments( + const std::vector<std::string>& argv, cmGeneratorExpression& ge, + const std::string& config) const; protected: void GenerateScriptConfigs(std::ostream& os, Indent indent) override; diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt index 69f8162..9a9d543 100644 --- a/Tests/RunCMake/CMakeLists.txt +++ b/Tests/RunCMake/CMakeLists.txt @@ -565,3 +565,5 @@ if(${CMAKE_GENERATOR} MATCHES "Visual Studio ([^9]|9[0-9])") add_RunCMake_test(CSharpCustomCommand) add_RunCMake_test(CSharpReferenceImport) endif() + +add_RunCMake_test("CTestCommandExpandLists") diff --git a/Tests/RunCMake/CTestCommandExpandLists/CMakeLists.txt b/Tests/RunCMake/CTestCommandExpandLists/CMakeLists.txt new file mode 100644 index 0000000..3e470a2 --- /dev/null +++ b/Tests/RunCMake/CTestCommandExpandLists/CMakeLists.txt @@ -0,0 +1,3 @@ +cmake_minimum_required(VERSION 3.14) +project(${RunCMake_TEST} NONE) +include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/CTestCommandExpandLists/CMakeLists.txt.in b/Tests/RunCMake/CTestCommandExpandLists/CMakeLists.txt.in new file mode 100644 index 0000000..7d56c90 --- /dev/null +++ b/Tests/RunCMake/CTestCommandExpandLists/CMakeLists.txt.in @@ -0,0 +1,3 @@ +cmake_minimum_required(VERSION 3.14) +project(@CASE_NAME@ NONE) +include("@RunCMake_SOURCE_DIR@/@CASE_NAME@.cmake") diff --git a/Tests/RunCMake/CTestCommandExpandLists/RunCMakeTest.cmake b/Tests/RunCMake/CTestCommandExpandLists/RunCMakeTest.cmake new file mode 100644 index 0000000..7c3779e --- /dev/null +++ b/Tests/RunCMake/CTestCommandExpandLists/RunCMakeTest.cmake @@ -0,0 +1,5 @@ +include(RunCTest) + +run_ctest(expandGeneratorExpressionResult) +run_ctest(expandEmptyCommand) +run_cmake(multipleExpandOptions) diff --git a/Tests/RunCMake/CTestCommandExpandLists/compare_options.cmake b/Tests/RunCMake/CTestCommandExpandLists/compare_options.cmake new file mode 100644 index 0000000..a32e579 --- /dev/null +++ b/Tests/RunCMake/CTestCommandExpandLists/compare_options.cmake @@ -0,0 +1,14 @@ +set(range 1 2 3 4 5 6 7 8 9 10) +set(aargs "") +set(bargs "") +foreach(n IN LISTS range) + set(aval "${A${n}ARG}") + set(bval "${B${n}ARG}") + if(aval OR bval) + list(APPEND aargs "\"${aval}\"") + list(APPEND bargs "\"${bval}\"") + endif() +endforeach() +if(NOT "${aargs}" STREQUAL "${bargs}") + message(FATAL_ERROR "COMPARE_OPTIONS: \n\t${aargs} != \n\t${bargs}") +endif() diff --git a/Tests/RunCMake/CTestCommandExpandLists/expandEmptyCommand-result.txt b/Tests/RunCMake/CTestCommandExpandLists/expandEmptyCommand-result.txt new file mode 100644 index 0000000..b57e2de --- /dev/null +++ b/Tests/RunCMake/CTestCommandExpandLists/expandEmptyCommand-result.txt @@ -0,0 +1 @@ +(-1|255) diff --git a/Tests/RunCMake/CTestCommandExpandLists/expandEmptyCommand-stderr.txt b/Tests/RunCMake/CTestCommandExpandLists/expandEmptyCommand-stderr.txt new file mode 100644 index 0000000..c656b4c --- /dev/null +++ b/Tests/RunCMake/CTestCommandExpandLists/expandEmptyCommand-stderr.txt @@ -0,0 +1 @@ +Unable to find executable: diff --git a/Tests/RunCMake/CTestCommandExpandLists/expandEmptyCommand-stdout.txt b/Tests/RunCMake/CTestCommandExpandLists/expandEmptyCommand-stdout.txt new file mode 100644 index 0000000..0752580 --- /dev/null +++ b/Tests/RunCMake/CTestCommandExpandLists/expandEmptyCommand-stdout.txt @@ -0,0 +1,13 @@ +Test project .*/Tests/RunCMake/CTestCommandExpandLists/expandEmptyCommand-build +.* +Start 1: CommandExpandEmptyList +Could not find executable + +Looked in the following places: +.* +1/1 Test #1: CommandExpandEmptyList +\.+\*\*\*Not Run +[0-9.]+ sec ++ +0% tests passed, 1 tests failed out of 1 ++ +Total Test time \(real\) = +[0-9.]+ sec ++ +The following tests FAILED: +.* +1 - CommandExpandEmptyList \(Not Run\)$ diff --git a/Tests/RunCMake/CTestCommandExpandLists/expandEmptyCommand.cmake b/Tests/RunCMake/CTestCommandExpandLists/expandEmptyCommand.cmake new file mode 100644 index 0000000..b75828e --- /dev/null +++ b/Tests/RunCMake/CTestCommandExpandLists/expandEmptyCommand.cmake @@ -0,0 +1,10 @@ +include(CTest) + +set(argv /bin/true) +list(POP_BACK argv) + +add_test( + NAME CommandExpandEmptyList + COMMAND "$<JOIN:${argv},;>" + COMMAND_EXPAND_LISTS +) diff --git a/Tests/RunCMake/CTestCommandExpandLists/expandGeneratorExpressionResult-result.txt b/Tests/RunCMake/CTestCommandExpandLists/expandGeneratorExpressionResult-result.txt new file mode 100644 index 0000000..573541a --- /dev/null +++ b/Tests/RunCMake/CTestCommandExpandLists/expandGeneratorExpressionResult-result.txt @@ -0,0 +1 @@ +0 diff --git a/Tests/RunCMake/CTestCommandExpandLists/expandGeneratorExpressionResult-stdout.txt b/Tests/RunCMake/CTestCommandExpandLists/expandGeneratorExpressionResult-stdout.txt new file mode 100644 index 0000000..2f21592 --- /dev/null +++ b/Tests/RunCMake/CTestCommandExpandLists/expandGeneratorExpressionResult-stdout.txt @@ -0,0 +1,7 @@ +Test project .*/Tests/RunCMake/CTestCommandExpandLists/expandGeneratorExpressionResult-build +.* +Start 1: CommandExpandList +1/1 Test #1: CommandExpandList +\.+ +Passed +[0-9.]+ sec ++ +100% tests passed, 0 tests failed out of 1 ++ +Total Test time \(real\) = +[0-9.]+ sec diff --git a/Tests/RunCMake/CTestCommandExpandLists/expandGeneratorExpressionResult.cmake b/Tests/RunCMake/CTestCommandExpandLists/expandGeneratorExpressionResult.cmake new file mode 100644 index 0000000..20608ae --- /dev/null +++ b/Tests/RunCMake/CTestCommandExpandLists/expandGeneratorExpressionResult.cmake @@ -0,0 +1,19 @@ +include(CTest) + + +set(cmp_args "1ARG=COMMAND_EXPAND_LISTS" "2ARG=test" "3ARG=outfile" + "4ARG=content") +set(AARGS "") +foreach(arg IN LISTS cmp_args) + list(APPEND AARGS "-DA${arg}") +endforeach() + + + +add_test( + NAME CommandExpandList + COMMAND ${CMAKE_COMMAND} ${AARGS} -V + "-DB$<JOIN:${cmp_args},;-DB>" + "-P" "${CMAKE_CURRENT_LIST_DIR}/compare_options.cmake" + COMMAND_EXPAND_LISTS +) diff --git a/Tests/RunCMake/CTestCommandExpandLists/multipleExpandOptions-result.txt b/Tests/RunCMake/CTestCommandExpandLists/multipleExpandOptions-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CTestCommandExpandLists/multipleExpandOptions-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CTestCommandExpandLists/multipleExpandOptions-stderr.txt b/Tests/RunCMake/CTestCommandExpandLists/multipleExpandOptions-stderr.txt new file mode 100644 index 0000000..e48513f --- /dev/null +++ b/Tests/RunCMake/CTestCommandExpandLists/multipleExpandOptions-stderr.txt @@ -0,0 +1,2 @@ +CMake Error at multipleExpandOptions\.cmake:3 \(add_test\): + +add_test may be given at most one COMMAND_EXPAND_LISTS\. diff --git a/Tests/RunCMake/CTestCommandExpandLists/multipleExpandOptions-stdout.txt b/Tests/RunCMake/CTestCommandExpandLists/multipleExpandOptions-stdout.txt new file mode 100644 index 0000000..55bb894 --- /dev/null +++ b/Tests/RunCMake/CTestCommandExpandLists/multipleExpandOptions-stdout.txt @@ -0,0 +1,2 @@ +-- Configuring incomplete, errors occurred! +See also ".*/Tests/RunCMake/CTestCommandExpandLists/multipleExpandOptions-build/CMakeFiles/CMakeOutput\.log". diff --git a/Tests/RunCMake/CTestCommandExpandLists/multipleExpandOptions.cmake b/Tests/RunCMake/CTestCommandExpandLists/multipleExpandOptions.cmake new file mode 100644 index 0000000..dcf2dc4 --- /dev/null +++ b/Tests/RunCMake/CTestCommandExpandLists/multipleExpandOptions.cmake @@ -0,0 +1,8 @@ +include(CTest) + +add_test( + NAME MultipleExpandOptions + COMMAND /bin/true + COMMAND_EXPAND_LISTS + COMMAND_EXPAND_LISTS +) diff --git a/Tests/RunCMake/CTestCommandExpandLists/test.cmake.in b/Tests/RunCMake/CTestCommandExpandLists/test.cmake.in new file mode 100644 index 0000000..d9a8ccb --- /dev/null +++ b/Tests/RunCMake/CTestCommandExpandLists/test.cmake.in @@ -0,0 +1,15 @@ +cmake_minimum_required(VERSION 3.14) + +set(CTEST_SITE "test-site") +set(CTEST_BUILD_NAME "test-build-name") +set(CTEST_SOURCE_DIRECTORY "@RunCMake_BINARY_DIR@/@CASE_NAME@") +set(CTEST_BINARY_DIRECTORY "@RunCMake_BINARY_DIR@/@CASE_NAME@-build") +set(CTEST_CMAKE_GENERATOR "@RunCMake_GENERATOR@") +set(CTEST_CMAKE_GENERATOR_PLATFORM "@RunCMake_GENERATOR_PLATFORM@") +set(CTEST_CMAKE_GENERATOR_TOOLSET "@RunCMake_GENERATOR_TOOLSET@") +set(CTEST_BUILD_CONFIGURATION "$ENV{CMAKE_CONFIG_TYPE}") + +ctest_start(Experimental) +ctest_configure() +ctest_build() +ctest_test() https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=a982916304fc7a66edb7a587144cb192f13ef6be commit a982916304fc7a66edb7a587144cb192f13ef6be Author: Saleem Abdulrasool <compn...@compnerd.org> AuthorDate: Wed Jun 5 22:01:16 2019 -0700 Commit: Saleem Abdulrasool <compn...@compnerd.org> CommitDate: Thu Jun 6 15:28:43 2019 -0700 Support per-language library link flags This changes the behaviour of the generators to use a per-language library search path flag. This is needed for multi-language projects with different compilers (e.g. cl + gfortran). Since the adjusted variable has been part of the user settings, we control this based on a policy. Fixes: #19307 diff --git a/Modules/CMakeSwiftInformation.cmake b/Modules/CMakeSwiftInformation.cmake index 21f18d4..6f99c1f 100644 --- a/Modules/CMakeSwiftInformation.cmake +++ b/Modules/CMakeSwiftInformation.cmake @@ -23,6 +23,8 @@ set(CMAKE_Swift_COMPILE_OPTIONS_TARGET "-target ") set(CMAKE_Swift_COMPILER_ARG1 -frontend) set(CMAKE_Swift_DEFINE_FLAG -D) set(CMAKE_Swift_FRAMEWORK_SEARCH_FLAG "-F ") +set(CMAKE_Swift_LIBRARY_PATH_FLAG "-L ") +set(CMAKE_Swift_LIBRARY_PATH_TERMINATOR "") set(CMAKE_Swift_LINKER_WRAPPER_FLAG "-Xlinker" " ") set(CMAKE_Swift_RESPONSE_FILE_LINK_FLAG @) diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index fe5c8af..3abf2dd 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -1444,10 +1444,23 @@ void cmLocalGenerator::OutputLinkLibraries( std::string linkLanguage = cli.GetLinkLanguage(); - const std::string& libPathFlag = - this->Makefile->GetRequiredDefinition("CMAKE_LIBRARY_PATH_FLAG"); - const std::string& libPathTerminator = - this->Makefile->GetSafeDefinition("CMAKE_LIBRARY_PATH_TERMINATOR"); + std::string libPathFlag; + if (const char* value = this->Makefile->GetDefinition( + "CMAKE_" + cli.GetLinkLanguage() + "_LIBRARY_PATH_FLAG")) { + libPathFlag = value; + } else { + libPathFlag = + this->Makefile->GetRequiredDefinition("CMAKE_LIBRARY_PATH_FLAG"); + } + + std::string libPathTerminator; + if (const char* value = this->Makefile->GetDefinition( + "CMAKE_" + cli.GetLinkLanguage() + "_LIBRARY_PATH_TERMINATOR")) { + libPathTerminator = value; + } else { + libPathTerminator = + this->Makefile->GetRequiredDefinition("CMAKE_LIBRARY_PATH_TERMINATOR"); + } // Add standard libraries for this language. std::string standardLibsVar = "CMAKE_"; ----------------------------------------------------------------------- Summary of changes: Help/command/add_test.rst | 8 ++- Help/release/dev/add_test-expand_lists.rst | 6 ++ Modules/CMakeSwiftInformation.cmake | 2 + Source/CMakeLists.txt | 1 - Source/cmAddTestCommand.cxx | 9 +++ Source/cmCacheManager.cxx | 2 +- Source/cmExportFileGenerator.cxx | 10 +-- Source/cmGeneratorTarget.cxx | 8 +-- Source/cmJsonObjects.cxx | 5 +- Source/cmLocalGenerator.cxx | 21 ++++-- Source/cmProperty.cxx | 26 -------- Source/cmProperty.h | 18 ----- Source/cmPropertyMap.cxx | 77 +++++++++++++--------- Source/cmPropertyMap.h | 34 ++++++++-- Source/cmState.cxx | 4 +- Source/cmStateDirectory.cxx | 8 +-- Source/cmTest.cxx | 13 +++- Source/cmTest.h | 5 ++ Source/cmTestGenerator.cxx | 48 +++++++++----- Source/cmTestGenerator.h | 4 ++ Source/cmVisualStudio10TargetGenerator.cxx | 24 +++---- Tests/RunCMake/CMakeLists.txt | 2 + .../CMakeLists.txt | 0 .../CTestCommandExpandLists/CMakeLists.txt.in | 3 + .../CTestCommandExpandLists/RunCMakeTest.cmake | 5 ++ .../CTestCommandExpandLists}/compare_options.cmake | 0 .../expandEmptyCommand-result.txt} | 0 .../expandEmptyCommand-stderr.txt | 1 + .../expandEmptyCommand-stdout.txt | 13 ++++ .../expandEmptyCommand.cmake | 10 +++ .../expandGeneratorExpressionResult-result.txt} | 0 .../expandGeneratorExpressionResult-stdout.txt | 7 ++ .../expandGeneratorExpressionResult.cmake | 19 ++++++ .../multipleExpandOptions-result.txt} | 0 .../multipleExpandOptions-stderr.txt | 2 + .../multipleExpandOptions-stdout.txt | 2 + .../multipleExpandOptions.cmake | 8 +++ .../RunCMake/CTestCommandExpandLists/test.cmake.in | 15 +++++ bootstrap | 1 - 39 files changed, 279 insertions(+), 142 deletions(-) create mode 100644 Help/release/dev/add_test-expand_lists.rst delete mode 100644 Source/cmProperty.cxx copy Tests/RunCMake/{MetaCompileFeatures => CTestCommandExpandLists}/CMakeLists.txt (100%) create mode 100644 Tests/RunCMake/CTestCommandExpandLists/CMakeLists.txt.in create mode 100644 Tests/RunCMake/CTestCommandExpandLists/RunCMakeTest.cmake copy Tests/{CustomCommand => RunCMake/CTestCommandExpandLists}/compare_options.cmake (100%) copy Tests/RunCMake/{ctest_submit/RepeatRETURN_VALUE-result.txt => CTestCommandExpandLists/expandEmptyCommand-result.txt} (100%) create mode 100644 Tests/RunCMake/CTestCommandExpandLists/expandEmptyCommand-stderr.txt create mode 100644 Tests/RunCMake/CTestCommandExpandLists/expandEmptyCommand-stdout.txt create mode 100644 Tests/RunCMake/CTestCommandExpandLists/expandEmptyCommand.cmake copy Tests/RunCMake/{target_link_options/LINK_OPTIONS-static-result.txt => CTestCommandExpandLists/expandGeneratorExpressionResult-result.txt} (100%) create mode 100644 Tests/RunCMake/CTestCommandExpandLists/expandGeneratorExpressionResult-stdout.txt create mode 100644 Tests/RunCMake/CTestCommandExpandLists/expandGeneratorExpressionResult.cmake copy Tests/RunCMake/{while/MissingArgument-result.txt => CTestCommandExpandLists/multipleExpandOptions-result.txt} (100%) create mode 100644 Tests/RunCMake/CTestCommandExpandLists/multipleExpandOptions-stderr.txt create mode 100644 Tests/RunCMake/CTestCommandExpandLists/multipleExpandOptions-stdout.txt create mode 100644 Tests/RunCMake/CTestCommandExpandLists/multipleExpandOptions.cmake create mode 100644 Tests/RunCMake/CTestCommandExpandLists/test.cmake.in hooks/post-receive -- CMake _______________________________________________ Cmake-commits mailing list Cmake-commits@cmake.org https://cmake.org/mailman/listinfo/cmake-commits