diff options
author | Sebastian Holtermann <sebholt@xwmw.org> | 2019-05-12 11:11:51 (GMT) |
---|---|---|
committer | Sebastian Holtermann <sebholt@xwmw.org> | 2019-05-13 13:37:18 (GMT) |
commit | cdff7f4e2a255e083e5a19ac541b4de2874785af (patch) | |
tree | 227828817ddbc2cf408564526ba0d315bcf7555e /Source/cmGlobalXCodeGenerator.cxx | |
parent | 741fb95f660c73035a26b572dfcd3d628d324d57 (diff) | |
download | CMake-cdff7f4e2a255e083e5a19ac541b4de2874785af.zip CMake-cdff7f4e2a255e083e5a19ac541b4de2874785af.tar.gz CMake-cdff7f4e2a255e083e5a19ac541b4de2874785af.tar.bz2 |
cmSystemTools: Add ExpandedListArgument and ExpandedLists methods
Changes
-------
In `cmSystemTools` this
- renames the method `ExpandList` to `ExpandLists` and makes it iterator based
and adds the methods
- `std::vector<std::string> ExpandedLists(InputIt first, InputIt last)`
- `std::vector<std::string> ExpandedListArgument(const std::string& arg,
bool emptyArgs)`
Both return the `std::vector<std::string>` instead of taking a return vector
reference like `cmSystemTools::ExpandLists` and
`cmSystemTools::ExpandListArgument`.
Motivation
----------
Since C++17 return value optimization is mandatory, so returning a
`std:vector<std::string>` from a function should be (at least) as fast as
passing a return vector reference to the function.
The new methods can replace `cmSystemTools::ExpandLists` and
`cmSystemTools::ExpandListArgument` in many cases, which leads to
shorter and simpler syntax.
E.g. the commonly used pattern
```
if (const char* value = X->GetProperty("A_KEY_STRING")) {
std::vector<std::string> valuesList;
cmSystemTools::ExpandListArgument(value, valuesList);
for (std::string const& i : valuesList) {
doSomething(i);
}
}
```
becomes
```
if (const char* value = X->GetProperty("A_KEY_STRING")) {
for (std::string const& i :
cmSystemTools::ExpandedListArgument(value)) {
doSomething(i);
}
}
```
Diffstat (limited to 'Source/cmGlobalXCodeGenerator.cxx')
-rw-r--r-- | Source/cmGlobalXCodeGenerator.cxx | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index db673bb..6cbdefa 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -2485,12 +2485,10 @@ cmXCodeObject* cmGlobalXCodeGenerator::CreateUtilityTarget( std::string cmGlobalXCodeGenerator::AddConfigurations(cmXCodeObject* target, cmGeneratorTarget* gtgt) { - std::string configTypes = - this->CurrentMakefile->GetRequiredDefinition("CMAKE_CONFIGURATION_TYPES"); - std::vector<std::string> configVectorIn; - std::vector<std::string> configVector; - configVectorIn.push_back(configTypes); - cmSystemTools::ExpandList(configVectorIn, configVector); + std::vector<std::string> const configVector = + cmSystemTools::ExpandedListArgument( + this->CurrentMakefile->GetRequiredDefinition( + "CMAKE_CONFIGURATION_TYPES")); cmXCodeObject* configlist = this->CreateObject(cmXCodeObject::XCConfigurationList); cmXCodeObject* buildConfigurations = |