mirror of
https://github.com/Kitware/CMake.git
synced 2026-06-30 19:57:41 +00:00
BT<> and cmLocalGenerator: Add helpers functions
* Template remove_BT<> to extract content from BT wrapper * cmLocalGenerator::AppendDefines which take std::set<> and std::vector<BT<>> as arguments
This commit is contained in:
@@ -6,12 +6,14 @@
|
||||
|
||||
#include <iosfwd>
|
||||
#include <memory>
|
||||
#include <set>
|
||||
#include <string>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include <cm/optional>
|
||||
#include <cm/string_view>
|
||||
#include <cmext/type_traits>
|
||||
|
||||
#include "cmList.h"
|
||||
#include "cmStack.h"
|
||||
@@ -206,6 +208,36 @@ public:
|
||||
|
||||
std::ostream& operator<<(std::ostream& os, BT<std::string> const& s);
|
||||
|
||||
namespace cm {
|
||||
// Helpers for basic type retrieval
|
||||
template <typename T>
|
||||
T remove_BT(BT<T> const& bt)
|
||||
{
|
||||
return bt.Value;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
std::vector<T> remove_BT(std::vector<BT<T>> const& container)
|
||||
{
|
||||
std::vector<T> result;
|
||||
for (auto const& entry : container) {
|
||||
result.emplace_back(entry.Value);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
template <typename T>
|
||||
std::set<T> remove_BT(std::set<BT<T>> const& container)
|
||||
{
|
||||
std::set<T> result;
|
||||
for (auto const& entry : container) {
|
||||
result.emplace(entry.Value);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
// Wrap type T as a value with potentially multiple backtraces. For purposes
|
||||
// of ordering and equality comparison, only the original value is used. The
|
||||
// backtrace is considered incidental.
|
||||
|
||||
@@ -3914,6 +3914,17 @@ void cmLocalGenerator::AppendDefines(std::set<std::string>& defines,
|
||||
}
|
||||
}
|
||||
|
||||
void cmLocalGenerator::AppendDefines(
|
||||
std::set<std::string>& defines,
|
||||
std::vector<BT<std::string>> const& defines_vec) const
|
||||
{
|
||||
std::set<BT<std::string>> tmp;
|
||||
this->AppendDefines(tmp, defines_vec);
|
||||
for (BT<std::string> const& i : tmp) {
|
||||
defines.emplace(i.Value);
|
||||
}
|
||||
}
|
||||
|
||||
void cmLocalGenerator::AppendDefines(std::set<BT<std::string>>& defines,
|
||||
std::string const& defines_list) const
|
||||
{
|
||||
|
||||
@@ -266,6 +266,8 @@ public:
|
||||
*/
|
||||
void AppendDefines(std::set<std::string>& defines,
|
||||
std::string const& defines_list) const;
|
||||
void AppendDefines(std::set<std::string>& defines,
|
||||
std::vector<BT<std::string>> const& defines_vec) const;
|
||||
void AppendDefines(std::set<BT<std::string>>& defines,
|
||||
std::string const& defines_list) const;
|
||||
void AppendDefines(std::set<BT<std::string>>& defines,
|
||||
|
||||
Reference in New Issue
Block a user