summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorDaniel Pfeifer <daniel@pfeifer-mail.de>2016-10-24 20:33:18 (GMT)
committerDaniel Pfeifer <daniel@pfeifer-mail.de>2016-10-24 20:34:52 (GMT)
commitc15dc1972839e175afaa9011f74376dadf08277f (patch)
treef6c1dc85793438cc0337a7870e1bd33a81849077 /Source
parentf660832999e086f02a9f3552c028aed900cd7249 (diff)
downloadCMake-c15dc1972839e175afaa9011f74376dadf08277f.zip
CMake-c15dc1972839e175afaa9011f74376dadf08277f.tar.gz
CMake-c15dc1972839e175afaa9011f74376dadf08277f.tar.bz2
Introduce CM_UNORDERED_SET
Avoid duplicating switch among std::unordered_set, cmsys::hash_set, and std::set.
Diffstat (limited to 'Source')
-rw-r--r--Source/cmGeneratorTarget.cxx49
-rw-r--r--Source/cmTarget.cxx13
-rw-r--r--Source/cmTargetPropertyComputer.cxx13
-rw-r--r--Source/cm_unordered_set.hxx25
4 files changed, 51 insertions, 49 deletions
diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx
index 8ac302a..ca056c0 100644
--- a/Source/cmGeneratorTarget.cxx
+++ b/Source/cmGeneratorTarget.cxx
@@ -21,6 +21,7 @@
#include "cmTargetLinkLibraryType.h"
#include "cmTargetPropertyComputer.h"
#include "cm_auto_ptr.hxx"
+#include "cm_unordered_set.hxx"
#include "cmake.h"
#include <algorithm>
@@ -34,16 +35,6 @@
#include <stdlib.h>
#include <string.h>
-#if defined(CMake_HAVE_CXX_UNORDERED_SET)
-#include <unordered_set>
-#define UNORDERED_SET std::unordered_set
-#elif defined(CMAKE_BUILD_WITH_CMAKE)
-#include <cmsys/hash_set.hxx>
-#define UNORDERED_SET cmsys::hash_set
-#else
-#define UNORDERED_SET std::set
-#endif
-
template <>
const char* cmTargetPropertyComputer::GetSources<cmGeneratorTarget>(
cmGeneratorTarget const* tgt, cmMessenger* /* messenger */,
@@ -926,7 +917,7 @@ static void AddInterfaceEntries(
static bool processSources(
cmGeneratorTarget const* tgt,
const std::vector<cmGeneratorTarget::TargetPropertyEntry*>& entries,
- std::vector<std::string>& srcs, UNORDERED_SET<std::string>& uniqueSrcs,
+ std::vector<std::string>& srcs, CM_UNORDERED_SET<std::string>& uniqueSrcs,
cmGeneratorExpressionDAGChecker* dagChecker, std::string const& config,
bool debugSources)
{
@@ -1053,7 +1044,7 @@ void cmGeneratorTarget::GetSourceFiles(std::vector<std::string>& files,
cmGeneratorExpressionDAGChecker dagChecker(this->GetName(), "SOURCES",
CM_NULLPTR, CM_NULLPTR);
- UNORDERED_SET<std::string> uniqueSrcs;
+ CM_UNORDERED_SET<std::string> uniqueSrcs;
bool contextDependentDirectSources =
processSources(this, this->SourceEntries, files, uniqueSrcs, &dagChecker,
config, debugSources);
@@ -1592,7 +1583,7 @@ class cmTargetCollectLinkLanguages
public:
cmTargetCollectLinkLanguages(cmGeneratorTarget const* target,
const std::string& config,
- UNORDERED_SET<std::string>& languages,
+ CM_UNORDERED_SET<std::string>& languages,
cmGeneratorTarget const* head)
: Config(config)
, Languages(languages)
@@ -1659,7 +1650,7 @@ public:
private:
std::string Config;
- UNORDERED_SET<std::string>& Languages;
+ CM_UNORDERED_SET<std::string>& Languages;
cmGeneratorTarget const* HeadTarget;
const cmGeneratorTarget* Target;
std::set<cmGeneratorTarget const*> Visited;
@@ -1731,7 +1722,7 @@ void cmGeneratorTarget::ComputeLinkClosure(const std::string& config,
LinkClosure& lc) const
{
// Get languages built in this target.
- UNORDERED_SET<std::string> languages;
+ CM_UNORDERED_SET<std::string> languages;
cmLinkImplementation const* impl = this->GetLinkImplementation(config);
assert(impl);
for (std::vector<std::string>::const_iterator li = impl->Languages.begin();
@@ -1748,7 +1739,7 @@ void cmGeneratorTarget::ComputeLinkClosure(const std::string& config,
}
// Store the transitive closure of languages.
- for (UNORDERED_SET<std::string>::const_iterator li = languages.begin();
+ for (CM_UNORDERED_SET<std::string>::const_iterator li = languages.begin();
li != languages.end(); ++li) {
lc.Languages.push_back(*li);
}
@@ -1769,7 +1760,7 @@ void cmGeneratorTarget::ComputeLinkClosure(const std::string& config,
}
// Now consider languages that propagate from linked targets.
- for (UNORDERED_SET<std::string>::const_iterator sit = languages.begin();
+ for (CM_UNORDERED_SET<std::string>::const_iterator sit = languages.begin();
sit != languages.end(); ++sit) {
std::string propagates =
"CMAKE_" + *sit + "_LINKER_PREFERENCE_PROPAGATES";
@@ -2338,7 +2329,7 @@ static void processIncludeDirectories(
cmGeneratorTarget const* tgt,
const std::vector<cmGeneratorTarget::TargetPropertyEntry*>& entries,
std::vector<std::string>& includes,
- UNORDERED_SET<std::string>& uniqueIncludes,
+ CM_UNORDERED_SET<std::string>& uniqueIncludes,
cmGeneratorExpressionDAGChecker* dagChecker, const std::string& config,
bool debugIncludes, const std::string& language)
{
@@ -2451,7 +2442,7 @@ std::vector<std::string> cmGeneratorTarget::GetIncludeDirectories(
const std::string& config, const std::string& lang) const
{
std::vector<std::string> includes;
- UNORDERED_SET<std::string> uniqueIncludes;
+ CM_UNORDERED_SET<std::string> uniqueIncludes;
cmGeneratorExpressionDAGChecker dagChecker(
this->GetName(), "INCLUDE_DIRECTORIES", CM_NULLPTR, CM_NULLPTR);
@@ -2528,7 +2519,8 @@ std::vector<std::string> cmGeneratorTarget::GetIncludeDirectories(
static void processCompileOptionsInternal(
cmGeneratorTarget const* tgt,
const std::vector<cmGeneratorTarget::TargetPropertyEntry*>& entries,
- std::vector<std::string>& options, UNORDERED_SET<std::string>& uniqueOptions,
+ std::vector<std::string>& options,
+ CM_UNORDERED_SET<std::string>& uniqueOptions,
cmGeneratorExpressionDAGChecker* dagChecker, const std::string& config,
bool debugOptions, const char* logName, std::string const& language)
{
@@ -2565,7 +2557,8 @@ static void processCompileOptionsInternal(
static void processCompileOptions(
cmGeneratorTarget const* tgt,
const std::vector<cmGeneratorTarget::TargetPropertyEntry*>& entries,
- std::vector<std::string>& options, UNORDERED_SET<std::string>& uniqueOptions,
+ std::vector<std::string>& options,
+ CM_UNORDERED_SET<std::string>& uniqueOptions,
cmGeneratorExpressionDAGChecker* dagChecker, const std::string& config,
bool debugOptions, std::string const& language)
{
@@ -2578,7 +2571,7 @@ void cmGeneratorTarget::GetCompileOptions(std::vector<std::string>& result,
const std::string& config,
const std::string& language) const
{
- UNORDERED_SET<std::string> uniqueOptions;
+ CM_UNORDERED_SET<std::string> uniqueOptions;
cmGeneratorExpressionDAGChecker dagChecker(
this->GetName(), "COMPILE_OPTIONS", CM_NULLPTR, CM_NULLPTR);
@@ -2618,7 +2611,8 @@ void cmGeneratorTarget::GetCompileOptions(std::vector<std::string>& result,
static void processCompileFeatures(
cmGeneratorTarget const* tgt,
const std::vector<cmGeneratorTarget::TargetPropertyEntry*>& entries,
- std::vector<std::string>& options, UNORDERED_SET<std::string>& uniqueOptions,
+ std::vector<std::string>& options,
+ CM_UNORDERED_SET<std::string>& uniqueOptions,
cmGeneratorExpressionDAGChecker* dagChecker, const std::string& config,
bool debugOptions)
{
@@ -2630,7 +2624,7 @@ static void processCompileFeatures(
void cmGeneratorTarget::GetCompileFeatures(std::vector<std::string>& result,
const std::string& config) const
{
- UNORDERED_SET<std::string> uniqueFeatures;
+ CM_UNORDERED_SET<std::string> uniqueFeatures;
cmGeneratorExpressionDAGChecker dagChecker(
this->GetName(), "COMPILE_FEATURES", CM_NULLPTR, CM_NULLPTR);
@@ -2667,7 +2661,8 @@ void cmGeneratorTarget::GetCompileFeatures(std::vector<std::string>& result,
static void processCompileDefinitions(
cmGeneratorTarget const* tgt,
const std::vector<cmGeneratorTarget::TargetPropertyEntry*>& entries,
- std::vector<std::string>& options, UNORDERED_SET<std::string>& uniqueOptions,
+ std::vector<std::string>& options,
+ CM_UNORDERED_SET<std::string>& uniqueOptions,
cmGeneratorExpressionDAGChecker* dagChecker, const std::string& config,
bool debugOptions, std::string const& language)
{
@@ -2680,7 +2675,7 @@ void cmGeneratorTarget::GetCompileDefinitions(
std::vector<std::string>& list, const std::string& config,
const std::string& language) const
{
- UNORDERED_SET<std::string> uniqueOptions;
+ CM_UNORDERED_SET<std::string> uniqueOptions;
cmGeneratorExpressionDAGChecker dagChecker(
this->GetName(), "COMPILE_DEFINITIONS", CM_NULLPTR, CM_NULLPTR);
@@ -4149,7 +4144,7 @@ void cmGeneratorTarget::ComputeLinkInterface(
this->GetType() == cmStateEnums::INTERFACE_LIBRARY) {
// Shared libraries may have runtime implementation dependencies
// on other shared libraries that are not in the interface.
- UNORDERED_SET<std::string> emitted;
+ CM_UNORDERED_SET<std::string> emitted;
for (std::vector<cmLinkItem>::const_iterator li =
iface.Libraries.begin();
li != iface.Libraries.end(); ++li) {
diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx
index 6f47f85..25ae339 100644
--- a/Source/cmTarget.cxx
+++ b/Source/cmTarget.cxx
@@ -16,6 +16,7 @@
#include "cmState.h"
#include "cmSystemTools.h"
#include "cmTargetPropertyComputer.h"
+#include "cm_unordered_set.hxx"
#include "cmake.h"
#include <algorithm>
@@ -26,16 +27,6 @@
#include <sstream>
#include <string.h>
-#if defined(CMake_HAVE_CXX_UNORDERED_SET)
-#include <unordered_set>
-#define UNORDERED_SET std::unordered_set
-#elif defined(CMAKE_BUILD_WITH_CMAKE)
-#include <cmsys/hash_set.hxx>
-#define UNORDERED_SET cmsys::hash_set
-#else
-#define UNORDERED_SET std::set
-#endif
-
template <>
const char* cmTargetPropertyComputer::ComputeLocationForBuild<cmTarget>(
cmTarget const* tgt)
@@ -1145,7 +1136,7 @@ const char* cmTarget::GetComputedProperty(
const char* cmTarget::GetProperty(const std::string& prop) const
{
- static UNORDERED_SET<std::string> specialProps;
+ static CM_UNORDERED_SET<std::string> specialProps;
#define MAKE_STATIC_PROP(PROP) static const std::string prop##PROP = #PROP
MAKE_STATIC_PROP(LINK_LIBRARIES);
MAKE_STATIC_PROP(TYPE);
diff --git a/Source/cmTargetPropertyComputer.cxx b/Source/cmTargetPropertyComputer.cxx
index 36d1940..7cf1fd8 100644
--- a/Source/cmTargetPropertyComputer.cxx
+++ b/Source/cmTargetPropertyComputer.cxx
@@ -10,16 +10,7 @@
#include "cmSourceFile.h"
#include "cmSourceFileLocation.h"
#include "cmTarget.h"
-
-#if defined(CMake_HAVE_CXX_UNORDERED_SET)
-#include <unordered_set>
-#define UNORDERED_SET std::unordered_set
-#elif defined(CMAKE_BUILD_WITH_CMAKE)
-#include <cmsys/hash_set.hxx>
-#define UNORDERED_SET cmsys::hash_set
-#else
-#define UNORDERED_SET std::set
-#endif
+#include "cm_unordered_set.hxx"
bool cmTargetPropertyComputer::HandleLocationPropertyPolicy(
std::string const& tgtName, cmMessenger* messenger,
@@ -59,7 +50,7 @@ bool cmTargetPropertyComputer::WhiteListedInterfaceProperty(
if (cmHasLiteralPrefix(prop, "INTERFACE_")) {
return true;
}
- static UNORDERED_SET<std::string> builtIns;
+ static CM_UNORDERED_SET<std::string> builtIns;
if (builtIns.empty()) {
builtIns.insert("COMPATIBLE_INTERFACE_BOOL");
builtIns.insert("COMPATIBLE_INTERFACE_NUMBER_MAX");
diff --git a/Source/cm_unordered_set.hxx b/Source/cm_unordered_set.hxx
new file mode 100644
index 0000000..ce58dbf
--- /dev/null
+++ b/Source/cm_unordered_set.hxx
@@ -0,0 +1,25 @@
+/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+ file Copyright.txt or https://cmake.org/licensing for details. */
+#ifndef CM_UNORDERED_SET_HXX
+#define CM_UNORDERED_SET_HXX
+
+#include <cmConfigure.h>
+
+#if defined(CMake_HAVE_CXX_UNORDERED_SET)
+
+#include <unordered_set>
+#define CM_UNORDERED_SET std::unordered_set
+
+#elif defined(CMAKE_BUILD_WITH_CMAKE)
+
+#include <cmsys/hash_set.hxx>
+#define CM_UNORDERED_SET cmsys::hash_set
+
+#else
+
+#include <set>
+#define CM_UNORDERED_SET std::set
+
+#endif
+
+#endif