summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Source/CPack/WiX/cmCPackWIXGenerator.cxx5
-rw-r--r--Source/CPack/cmCPackNSISGenerator.cxx6
-rw-r--r--Source/CTest/cmCTestMultiProcessHandler.cxx16
-rw-r--r--Source/CTest/cmCTestTestHandler.cxx23
-rw-r--r--Source/cmAlgorithms.h40
-rw-r--r--Source/cmComputeLinkInformation.cxx13
-rw-r--r--Source/cmConditionEvaluator.cxx3
-rw-r--r--Source/cmExportBuildAndroidMKGenerator.cxx5
-rw-r--r--Source/cmExportBuildFileGenerator.cxx3
-rw-r--r--Source/cmExportCommand.cxx6
-rw-r--r--Source/cmGeneratorExpressionNode.cxx13
-rw-r--r--Source/cmGeneratorTarget.cxx42
-rw-r--r--Source/cmGlobalGenerator.cxx13
-rw-r--r--Source/cmGlobalGhsMultiGenerator.cxx7
-rw-r--r--Source/cmGlobalNinjaGenerator.cxx3
-rw-r--r--Source/cmGlobalXCodeGenerator.cxx12
-rw-r--r--Source/cmLinkItem.h5
-rw-r--r--Source/cmLinkLineDeviceComputer.cxx9
-rw-r--r--Source/cmListCommand.cxx2
-rw-r--r--Source/cmLocalGenerator.cxx14
-rw-r--r--Source/cmLocalVisualStudio7Generator.cxx5
-rw-r--r--Source/cmMakefile.cxx23
-rw-r--r--Source/cmQtAutoGen.cxx4
-rw-r--r--Source/cmServerProtocol.cxx3
-rw-r--r--Source/cmSourceGroupCommand.cxx5
-rw-r--r--Source/cmVisualStudio10TargetGenerator.cxx9
-rw-r--r--Source/cmXCodeObject.h11
-rw-r--r--Source/cmXCodeScheme.cxx4
-rw-r--r--Source/cmake.cxx2
-rw-r--r--Source/cmcmd.cxx8
30 files changed, 140 insertions, 174 deletions
diff --git a/Source/CPack/WiX/cmCPackWIXGenerator.cxx b/Source/CPack/WiX/cmCPackWIXGenerator.cxx
index 458a335..64eded5 100644
--- a/Source/CPack/WiX/cmCPackWIXGenerator.cxx
+++ b/Source/CPack/WiX/cmCPackWIXGenerator.cxx
@@ -2,6 +2,7 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmCPackWIXGenerator.h"
+#include "cmAlgorithms.h"
#include "cmCPackComponentGroup.h"
#include "cmCPackLog.h"
#include "cmCryptoHash.h"
@@ -942,9 +943,7 @@ void cmCPackWIXGenerator::AddDirectoryAndFileDefinitions(
shortcut.workingDirectoryId = directoryId;
shortcuts.insert(cmWIXShortcuts::START_MENU, id, shortcut);
- if (!desktopExecutables.empty() &&
- std::find(desktopExecutables.begin(), desktopExecutables.end(),
- executableName) != desktopExecutables.end()) {
+ if (cmContains(desktopExecutables, executableName)) {
shortcuts.insert(cmWIXShortcuts::DESKTOP, id, shortcut);
}
}
diff --git a/Source/CPack/cmCPackNSISGenerator.cxx b/Source/CPack/cmCPackNSISGenerator.cxx
index cfa34dc..5440a6b 100644
--- a/Source/CPack/cmCPackNSISGenerator.cxx
+++ b/Source/CPack/cmCPackNSISGenerator.cxx
@@ -2,6 +2,7 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmCPackNSISGenerator.h"
+#include "cmAlgorithms.h"
#include "cmCPackComponentGroup.h"
#include "cmCPackGenerator.h"
#include "cmCPackLog.h"
@@ -501,10 +502,7 @@ int cmCPackNSISGenerator::InitializeInternal()
<< ".lnk\"" << std::endl;
// see if CPACK_CREATE_DESKTOP_LINK_ExeName is on
// if so add a desktop link
- if (!cpackPackageDesktopLinksVector.empty() &&
- std::find(cpackPackageDesktopLinksVector.begin(),
- cpackPackageDesktopLinksVector.end(),
- execName) != cpackPackageDesktopLinksVector.end()) {
+ if (cmContains(cpackPackageDesktopLinksVector, execName)) {
str << " StrCmp \"$INSTALL_DESKTOP\" \"1\" 0 +2\n";
str << " CreateShortCut \"$DESKTOP\\" << linkName
<< R"(.lnk" "$INSTDIR\)" << cpackNsisExecutablesDirectory << "\\"
diff --git a/Source/CTest/cmCTestMultiProcessHandler.cxx b/Source/CTest/cmCTestMultiProcessHandler.cxx
index ae965ea..2d07420 100644
--- a/Source/CTest/cmCTestMultiProcessHandler.cxx
+++ b/Source/CTest/cmCTestMultiProcessHandler.cxx
@@ -173,8 +173,7 @@ bool cmCTestMultiProcessHandler::StartTestProcess(int test)
// Find any failed dependencies for this test. We assume the more common
// scenario has no failed tests, so make it the outer loop.
for (std::string const& f : *this->Failed) {
- if (this->Properties[test]->RequireSuccessDepends.find(f) !=
- this->Properties[test]->RequireSuccessDepends.end()) {
+ if (cmContains(this->Properties[test]->RequireSuccessDepends, f)) {
testRun->AddFailedDependency(f);
}
}
@@ -275,7 +274,7 @@ bool cmCTestMultiProcessHandler::StartTest(int test)
{
// Check for locked resources
for (std::string const& i : this->Properties[test]->LockedResources) {
- if (this->LockedResources.find(i) != this->LockedResources.end()) {
+ if (cmContains(this->LockedResources, i)) {
return false;
}
}
@@ -621,9 +620,7 @@ void cmCTestMultiProcessHandler::CreateParallelTestCostList()
// In parallel test runs add previously failed tests to the front
// of the cost list and queue other tests for further sorting
for (auto const& t : this->Tests) {
- if (std::find(this->LastTestsFailed.begin(), this->LastTestsFailed.end(),
- this->Properties[t.first]->Name) !=
- this->LastTestsFailed.end()) {
+ if (cmContains(this->LastTestsFailed, this->Properties[t.first]->Name)) {
// If the test failed last time, it should be run first.
this->SortedTests.push_back(t.first);
alreadySortedTests.insert(t.first);
@@ -662,7 +659,7 @@ void cmCTestMultiProcessHandler::CreateParallelTestCostList()
TestComparator(this));
for (auto const& j : sortedCopy) {
- if (alreadySortedTests.find(j) == alreadySortedTests.end()) {
+ if (!cmContains(alreadySortedTests, j)) {
this->SortedTests.push_back(j);
alreadySortedTests.insert(j);
}
@@ -694,7 +691,7 @@ void cmCTestMultiProcessHandler::CreateSerialTestCostList()
TestSet alreadySortedTests;
for (int test : presortedList) {
- if (alreadySortedTests.find(test) != alreadySortedTests.end()) {
+ if (cmContains(alreadySortedTests, test)) {
continue;
}
@@ -702,8 +699,7 @@ void cmCTestMultiProcessHandler::CreateSerialTestCostList()
GetAllTestDependencies(test, dependencies);
for (int testDependency : dependencies) {
- if (alreadySortedTests.find(testDependency) ==
- alreadySortedTests.end()) {
+ if (!cmContains(alreadySortedTests, testDependency)) {
alreadySortedTests.insert(testDependency);
this->SortedTests.push_back(testDependency);
}
diff --git a/Source/CTest/cmCTestTestHandler.cxx b/Source/CTest/cmCTestTestHandler.cxx
index a3c480a..32d1d5c 100644
--- a/Source/CTest/cmCTestTestHandler.cxx
+++ b/Source/CTest/cmCTestTestHandler.cxx
@@ -20,6 +20,7 @@
#include "cm_memory.hxx"
+#include "cmAlgorithms.h"
#include "cmCTest.h"
#include "cmCTestMultiProcessHandler.h"
#include "cmCommand.h"
@@ -715,7 +716,7 @@ void cmCTestTestHandler::PrintLabelOrSubprojectSummary(bool doSubProject)
cmCTestTestProperties& p = *result.Properties;
for (std::string const& l : p.Labels) {
// only use labels found in labels
- if (labels.find(l) != labels.end()) {
+ if (cmContains(labels, l)) {
labelTimes[l] +=
result.ExecutionTime.count() * result.Properties->Processors;
++labelCounts[l];
@@ -857,17 +858,14 @@ void cmCTestTestHandler::ComputeTestList()
if (this->UseUnion) {
// if it is not in the list and not in the regexp then skip
- if ((!this->TestsToRun.empty() &&
- std::find(this->TestsToRun.begin(), this->TestsToRun.end(), cnt) ==
- this->TestsToRun.end()) &&
+ if ((!this->TestsToRun.empty() && !cmContains(this->TestsToRun, cnt)) &&
!tp.IsInBasedOnREOptions) {
continue;
}
} else {
// is this test in the list of tests to run? If not then skip it
if ((!this->TestsToRun.empty() &&
- std::find(this->TestsToRun.begin(), this->TestsToRun.end(),
- inREcnt) == this->TestsToRun.end()) ||
+ !cmContains(this->TestsToRun, inREcnt)) ||
!tp.IsInBasedOnREOptions) {
continue;
}
@@ -896,9 +894,7 @@ void cmCTestTestHandler::ComputeTestListForRerunFailed()
cnt++;
// if this test is not in our list of tests to run, then skip it.
- if ((!this->TestsToRun.empty() &&
- std::find(this->TestsToRun.begin(), this->TestsToRun.end(), cnt) ==
- this->TestsToRun.end())) {
+ if ((!this->TestsToRun.empty() && !cmContains(TestsToRun, cnt))) {
continue;
}
@@ -1019,8 +1015,7 @@ void cmCTestTestHandler::UpdateForFixtures(ListOfTests& tests) const
sIt != setupRange.second; ++sIt) {
const std::string& setupTestName = sIt->second->Name;
tests[i].RequireSuccessDepends.insert(setupTestName);
- if (std::find(tests[i].Depends.begin(), tests[i].Depends.end(),
- setupTestName) == tests[i].Depends.end()) {
+ if (!cmContains(tests[i].Depends, setupTestName)) {
tests[i].Depends.push_back(setupTestName);
}
}
@@ -1127,8 +1122,7 @@ void cmCTestTestHandler::UpdateForFixtures(ListOfTests& tests) const
const std::vector<size_t>& indices = cIt->second;
for (size_t index : indices) {
const std::string& reqTestName = tests[index].Name;
- if (std::find(p.Depends.begin(), p.Depends.end(), reqTestName) ==
- p.Depends.end()) {
+ if (!cmContains(p.Depends, reqTestName)) {
p.Depends.push_back(reqTestName);
}
}
@@ -1141,8 +1135,7 @@ void cmCTestTestHandler::UpdateForFixtures(ListOfTests& tests) const
const std::vector<size_t>& indices = cIt->second;
for (size_t index : indices) {
const std::string& setupTestName = tests[index].Name;
- if (std::find(p.Depends.begin(), p.Depends.end(), setupTestName) ==
- p.Depends.end()) {
+ if (!cmContains(p.Depends, setupTestName)) {
p.Depends.push_back(setupTestName);
}
}
diff --git a/Source/cmAlgorithms.h b/Source/cmAlgorithms.h
index d7ea483..59aa86f 100644
--- a/Source/cmAlgorithms.h
+++ b/Source/cmAlgorithms.h
@@ -14,6 +14,16 @@
#include <utility>
#include <vector>
+template <std::size_t N>
+struct cmOverloadPriority : cmOverloadPriority<N - 1>
+{
+};
+
+template <>
+struct cmOverloadPriority<0>
+{
+};
+
template <typename FwdIt>
FwdIt cmRotate(FwdIt first, FwdIt middle, FwdIt last)
{
@@ -30,6 +40,34 @@ void cmEraseIf(Container& cont, Predicate pred)
cont.erase(std::remove_if(cont.begin(), cont.end(), pred), cont.end());
}
+template <typename Range, typename Key>
+auto cmContainsImpl(Range const& range, Key const& key, cmOverloadPriority<2>)
+ -> decltype(range.exists(key))
+{
+ return range.exists(key);
+}
+
+template <typename Range, typename Key>
+auto cmContainsImpl(Range const& range, Key const& key, cmOverloadPriority<1>)
+ -> decltype(range.find(key) != range.end())
+{
+ return range.find(key) != range.end();
+}
+
+template <typename Range, typename Key>
+bool cmContainsImpl(Range const& range, Key const& key, cmOverloadPriority<0>)
+{
+ using std::begin;
+ using std::end;
+ return std::find(begin(range), end(range), key) != end(range);
+}
+
+template <typename Range, typename Key>
+bool cmContains(Range const& range, Key const& key)
+{
+ return cmContainsImpl(range, key, cmOverloadPriority<2>{});
+}
+
namespace ContainerAlgorithms {
template <typename T>
@@ -176,7 +214,7 @@ ForwardIterator cmRemoveDuplicates(ForwardIterator first, ForwardIterator last)
ForwardIterator result = first;
while (first != last) {
- if (uniq.find(first) == uniq.end()) {
+ if (!cmContains(uniq, first)) {
if (result != first) {
*result = std::move(*first);
}
diff --git a/Source/cmComputeLinkInformation.cxx b/Source/cmComputeLinkInformation.cxx
index 5f5317c..8387aa7 100644
--- a/Source/cmComputeLinkInformation.cxx
+++ b/Source/cmComputeLinkInformation.cxx
@@ -2,6 +2,7 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmComputeLinkInformation.h"
+#include "cmAlgorithms.h"
#include "cmComputeLinkDepends.h"
#include "cmGeneratorTarget.h"
#include "cmGlobalGenerator.h"
@@ -553,7 +554,7 @@ void cmComputeLinkInformation::AddImplicitLinkInfo(std::string const& lang)
std::vector<std::string> libsVec;
cmExpandList(libs, libsVec);
for (std::string const& i : libsVec) {
- if (this->ImplicitLinkLibs.find(i) == this->ImplicitLinkLibs.end()) {
+ if (!cmContains(this->ImplicitLinkLibs, i)) {
this->AddItem(i, nullptr);
}
}
@@ -998,8 +999,8 @@ void cmComputeLinkInformation::AddTargetItem(std::string const& item,
// For compatibility with CMake 2.4 include the item's directory in
// the linker search path.
if (this->OldLinkDirMode && !target->IsFrameworkOnApple() &&
- this->OldLinkDirMask.find(cmSystemTools::GetFilenamePath(item)) ==
- this->OldLinkDirMask.end()) {
+ !cmContains(this->OldLinkDirMask,
+ cmSystemTools::GetFilenamePath(item))) {
this->OldLinkDirItems.push_back(item);
}
@@ -1052,8 +1053,8 @@ void cmComputeLinkInformation::AddFullItem(std::string const& item)
// For compatibility with CMake 2.4 include the item's directory in
// the linker search path.
if (this->OldLinkDirMode &&
- this->OldLinkDirMask.find(cmSystemTools::GetFilenamePath(item)) ==
- this->OldLinkDirMask.end()) {
+ !cmContains(this->OldLinkDirMask,
+ cmSystemTools::GetFilenamePath(item))) {
this->OldLinkDirItems.push_back(item);
}
@@ -1072,7 +1073,7 @@ bool cmComputeLinkInformation::CheckImplicitDirItem(std::string const& item)
// Check if this item is in an implicit link directory.
std::string dir = cmSystemTools::GetFilenamePath(item);
- if (this->ImplicitLinkDirs.find(dir) == this->ImplicitLinkDirs.end()) {
+ if (!cmContains(this->ImplicitLinkDirs, dir)) {
// Only libraries in implicit link directories are converted to
// pathless items.
return false;
diff --git a/Source/cmConditionEvaluator.cxx b/Source/cmConditionEvaluator.cxx
index 3a53067..008528b 100644
--- a/Source/cmConditionEvaluator.cxx
+++ b/Source/cmConditionEvaluator.cxx
@@ -3,7 +3,6 @@
#include "cmConditionEvaluator.h"
#include "cmsys/RegularExpression.hxx"
-#include <algorithm>
#include <functional>
#include <sstream>
#include <stdio.h>
@@ -672,7 +671,7 @@ bool cmConditionEvaluator::HandleLevel2(cmArgumentList& newArgs,
std::vector<std::string> list;
cmExpandList(def2, list, true);
- result = std::find(list.begin(), list.end(), def) != list.end();
+ result = cmContains(list, def);
}
this->HandleBinaryOp(result, reducible, arg, newArgs, argP1, argP2);
diff --git a/Source/cmExportBuildAndroidMKGenerator.cxx b/Source/cmExportBuildAndroidMKGenerator.cxx
index 22cc0bc..9b1e15e 100644
--- a/Source/cmExportBuildAndroidMKGenerator.cxx
+++ b/Source/cmExportBuildAndroidMKGenerator.cxx
@@ -2,10 +2,10 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmExportBuildAndroidMKGenerator.h"
-#include <algorithm>
#include <sstream>
#include <utility>
+#include "cmAlgorithms.h"
#include "cmGeneratorTarget.h"
#include "cmLinkItem.h"
#include "cmMakefile.h"
@@ -167,8 +167,7 @@ void cmExportBuildAndroidMKGenerator::GenerateInterfaceProperties(
// Tell the NDK build system if prebuilt static libraries use C++.
if (target->GetType() == cmStateEnums::STATIC_LIBRARY) {
cmLinkImplementation const* li = target->GetLinkImplementation(config);
- if (std::find(li->Languages.begin(), li->Languages.end(), "CXX") !=
- li->Languages.end()) {
+ if (cmContains(li->Languages, "CXX")) {
os << "LOCAL_HAS_CPP := true\n";
}
}
diff --git a/Source/cmExportBuildFileGenerator.cxx b/Source/cmExportBuildFileGenerator.cxx
index 33806f2..dee50ac 100644
--- a/Source/cmExportBuildFileGenerator.cxx
+++ b/Source/cmExportBuildFileGenerator.cxx
@@ -16,7 +16,6 @@
#include "cmTargetExport.h"
#include "cmake.h"
-#include <algorithm>
#include <map>
#include <set>
#include <sstream>
@@ -306,7 +305,7 @@ cmExportBuildFileGenerator::FindBuildExportInfo(cmGlobalGenerator* gg,
const cmExportBuildFileGenerator* exportSet = exp.second;
std::vector<std::string> targets;
exportSet->GetTargets(targets);
- if (std::find(targets.begin(), targets.end(), name) != targets.end()) {
+ if (cmContains(targets, name)) {
exportFiles.push_back(exp.first);
ns = exportSet->GetNamespace();
}
diff --git a/Source/cmExportCommand.cxx b/Source/cmExportCommand.cxx
index a849aa2..598eafe 100644
--- a/Source/cmExportCommand.cxx
+++ b/Source/cmExportCommand.cxx
@@ -5,11 +5,11 @@
#include "cm_static_string_view.hxx"
#include "cmsys/RegularExpression.hxx"
-#include <algorithm>
#include <map>
#include <sstream>
#include <utility>
+#include "cmAlgorithms.h"
#include "cmArgumentParser.h"
#include "cmExportBuildAndroidMKGenerator.h"
#include "cmExportBuildFileGenerator.h"
@@ -133,9 +133,7 @@ bool cmExportCommand::InitialPass(std::vector<std::string> const& args,
}
ExportSet = it->second;
} else if (!arguments.Targets.empty() ||
- std::find(keywordsMissingValue.begin(),
- keywordsMissingValue.end(),
- "TARGETS") != keywordsMissingValue.end()) {
+ cmContains(keywordsMissingValue, "TARGETS")) {
for (std::string const& currentTarget : arguments.Targets) {
if (this->Makefile->IsAlias(currentTarget)) {
std::ostringstream e;
diff --git a/Source/cmGeneratorExpressionNode.cxx b/Source/cmGeneratorExpressionNode.cxx
index 53bc3cd..12ea2ef 100644
--- a/Source/cmGeneratorExpressionNode.cxx
+++ b/Source/cmGeneratorExpressionNode.cxx
@@ -306,10 +306,7 @@ static const struct InListNode : public cmGeneratorExpressionNode
break;
}
- return std::find(values.cbegin(), values.cend(), parameters.front()) ==
- values.cend()
- ? "0"
- : "1";
+ return cmContains(values, parameters.front()) ? "1" : "0";
}
} inListNode;
@@ -915,9 +912,8 @@ static const struct ConfigurationTestNode : public cmGeneratorExpressionNode
if (const char* mapValue =
context->CurrentTarget->GetProperty(mapProp)) {
cmExpandList(cmSystemTools::UpperCase(mapValue), mappedConfigs);
- return std::find(mappedConfigs.begin(), mappedConfigs.end(),
- cmSystemTools::UpperCase(parameters.front())) !=
- mappedConfigs.end()
+ return cmContains(mappedConfigs,
+ cmSystemTools::UpperCase(parameters.front()))
? "1"
: "0";
}
@@ -1510,8 +1506,7 @@ static const struct CompileFeaturesNode : public cmGeneratorExpressionNode
const char* standardDefault = context->LG->GetMakefile()->GetDefinition(
"CMAKE_" + lit.first + "_STANDARD_DEFAULT");
for (std::string const& it : lit.second) {
- if (std::find(langAvailable.begin(), langAvailable.end(), it) ==
- langAvailable.end()) {
+ if (!cmContains(langAvailable, it)) {
return "0";
}
if (standardDefault && !*standardDefault) {
diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx
index 9412d82..932dd41 100644
--- a/Source/cmGeneratorTarget.cxx
+++ b/Source/cmGeneratorTarget.cxx
@@ -1421,9 +1421,8 @@ std::vector<BT<std::string>> cmGeneratorTarget::GetSourceFilePaths(
cmExpandList(debugProp, debugProperties);
}
- bool debugSources = !this->DebugSourcesDone &&
- std::find(debugProperties.begin(), debugProperties.end(), "SOURCES") !=
- debugProperties.end();
+ bool debugSources =
+ !this->DebugSourcesDone && cmContains(debugProperties, "SOURCES");
if (this->LocalGenerator->GetGlobalGenerator()->GetConfigureDoneCMP0026()) {
this->DebugSourcesDone = true;
@@ -2647,7 +2646,7 @@ cmTargetTraceDependencies::cmTargetTraceDependencies(cmGeneratorTarget* target)
for (cmSourceFile* sf : sources) {
const std::set<cmGeneratorTarget const*> tgts =
this->GlobalGenerator->GetFilenameTargetDepends(sf);
- if (tgts.find(this->GeneratorTarget) != tgts.end()) {
+ if (cmContains(tgts, this->GeneratorTarget)) {
std::ostringstream e;
e << "Evaluation output file\n \"" << sf->GetFullPath()
<< "\"\ndepends on the sources of a target it is used in. This "
@@ -3072,8 +3071,7 @@ std::vector<BT<std::string>> cmGeneratorTarget::GetIncludeDirectories(
}
bool debugIncludes = !this->DebugIncludesDone &&
- std::find(debugProperties.begin(), debugProperties.end(),
- "INCLUDE_DIRECTORIES") != debugProperties.end();
+ cmContains(debugProperties, "INCLUDE_DIRECTORIES");
if (this->GlobalGenerator->GetConfigureDoneCMP0026()) {
this->DebugIncludesDone = true;
@@ -3183,8 +3181,7 @@ std::vector<BT<std::string>> cmGeneratorTarget::GetCompileOptions(
}
bool debugOptions = !this->DebugCompileOptionsDone &&
- std::find(debugProperties.begin(), debugProperties.end(),
- "COMPILE_OPTIONS") != debugProperties.end();
+ cmContains(debugProperties, "COMPILE_OPTIONS");
if (this->GlobalGenerator->GetConfigureDoneCMP0026()) {
this->DebugCompileOptionsDone = true;
@@ -3230,8 +3227,7 @@ std::vector<BT<std::string>> cmGeneratorTarget::GetCompileFeatures(
}
bool debugFeatures = !this->DebugCompileFeaturesDone &&
- std::find(debugProperties.begin(), debugProperties.end(),
- "COMPILE_FEATURES") != debugProperties.end();
+ cmContains(debugProperties, "COMPILE_FEATURES");
if (this->GlobalGenerator->GetConfigureDoneCMP0026()) {
this->DebugCompileFeaturesDone = true;
@@ -3279,8 +3275,7 @@ std::vector<BT<std::string>> cmGeneratorTarget::GetCompileDefinitions(
}
bool debugDefines = !this->DebugCompileDefinitionsDone &&
- std::find(debugProperties.begin(), debugProperties.end(),
- "COMPILE_DEFINITIONS") != debugProperties.end();
+ cmContains(debugProperties, "COMPILE_DEFINITIONS");
if (this->GlobalGenerator->GetConfigureDoneCMP0026()) {
this->DebugCompileDefinitionsDone = true;
@@ -3353,9 +3348,8 @@ std::vector<BT<std::string>> cmGeneratorTarget::GetLinkOptions(
cmExpandList(debugProp, debugProperties);
}
- bool debugOptions = !this->DebugLinkOptionsDone &&
- std::find(debugProperties.begin(), debugProperties.end(),
- "LINK_OPTIONS") != debugProperties.end();
+ bool debugOptions =
+ !this->DebugLinkOptionsDone && cmContains(debugProperties, "LINK_OPTIONS");
if (this->GlobalGenerator->GetConfigureDoneCMP0026()) {
this->DebugLinkOptionsDone = true;
@@ -3612,8 +3606,7 @@ std::vector<BT<std::string>> cmGeneratorTarget::GetLinkDirectories(
}
bool debugDirectories = !this->DebugLinkDirectoriesDone &&
- std::find(debugProperties.begin(), debugProperties.end(),
- "LINK_DIRECTORIES") != debugProperties.end();
+ cmContains(debugProperties, "LINK_DIRECTORIES");
if (this->GlobalGenerator->GetConfigureDoneCMP0026()) {
this->DebugLinkDirectoriesDone = true;
@@ -4784,9 +4777,7 @@ PropertyType checkInterfacePropertyCompatibility(cmGeneratorTarget const* tgt,
PropertyType propContent = getTypedProperty<PropertyType>(tgt, p);
std::vector<std::string> headPropKeys = tgt->GetPropertyKeys();
- const bool explicitlySet =
- std::find(headPropKeys.begin(), headPropKeys.end(), p) !=
- headPropKeys.end();
+ const bool explicitlySet = cmContains(headPropKeys, p);
const bool impliedByUse = tgt->IsNullImpliedByLinkLibraries(p);
assert((impliedByUse ^ explicitlySet) || (!impliedByUse && !explicitlySet));
@@ -4826,8 +4817,7 @@ PropertyType checkInterfacePropertyCompatibility(cmGeneratorTarget const* tgt,
std::vector<std::string> propKeys = theTarget->GetPropertyKeys();
- const bool ifaceIsSet = std::find(propKeys.begin(), propKeys.end(),
- interfaceProperty) != propKeys.end();
+ const bool ifaceIsSet = cmContains(propKeys, interfaceProperty);
PropertyType ifacePropContent = getTypedProperty<PropertyType>(
theTarget, interfaceProperty, genexInterpreter.get());
@@ -5112,9 +5102,8 @@ void cmGeneratorTarget::ReportPropertyOrigin(
cmExpandList(debugProp, debugProperties);
}
- bool debugOrigin = !this->DebugCompatiblePropertiesDone[p] &&
- std::find(debugProperties.begin(), debugProperties.end(), p) !=
- debugProperties.end();
+ bool debugOrigin =
+ !this->DebugCompatiblePropertiesDone[p] && cmContains(debugProperties, p);
if (this->GlobalGenerator->GetConfigureDoneCMP0026()) {
this->DebugCompatiblePropertiesDone[p] = true;
@@ -6226,8 +6215,7 @@ cmGeneratorTarget::GetLinkImplementationLibrariesInternal(
bool cmGeneratorTarget::IsNullImpliedByLinkLibraries(
const std::string& p) const
{
- return this->LinkImplicitNullProperties.find(p) !=
- this->LinkImplicitNullProperties.end();
+ return cmContains(this->LinkImplicitNullProperties, p);
}
void cmGeneratorTarget::ComputeLinkImplementationLibraries(
diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx
index 86fcae0..5791137 100644
--- a/Source/cmGlobalGenerator.cxx
+++ b/Source/cmGlobalGenerator.cxx
@@ -368,8 +368,7 @@ bool cmGlobalGenerator::IsExportedTargetsFile(
if (it == this->BuildExportSets.end()) {
return false;
}
- return this->BuildExportExportSets.find(filename) ==
- this->BuildExportExportSets.end();
+ return !cmContains(this->BuildExportExportSets, filename);
}
// Find the make program for the generator, required for try compiles
@@ -497,7 +496,7 @@ void cmGlobalGenerator::EnableLanguage(
if (lang == "NONE") {
this->SetLanguageEnabled("NONE", mf);
} else {
- if (this->LanguagesReady.find(lang) == this->LanguagesReady.end()) {
+ if (!cmContains(this->LanguagesReady, lang)) {
std::ostringstream e;
e << "The test project needs language " << lang
<< " which is not enabled.";
@@ -1097,8 +1096,7 @@ void cmGlobalGenerator::SetLanguageEnabledMaps(const std::string& l,
{
// use LanguageToLinkerPreference to detect whether this functions has
// run before
- if (this->LanguageToLinkerPreference.find(l) !=
- this->LanguageToLinkerPreference.end()) {
+ if (cmContains(this->LanguageToLinkerPreference, l)) {
return;
}
@@ -2153,7 +2151,7 @@ void cmGlobalGenerator::AddAlias(const std::string& name,
bool cmGlobalGenerator::IsAlias(const std::string& name) const
{
- return this->AliasTargets.find(name) != this->AliasTargets.end();
+ return cmContains(this->AliasTargets, name);
}
void cmGlobalGenerator::IndexTarget(cmTarget* t)
@@ -2703,8 +2701,7 @@ bool cmGlobalGenerator::IsReservedTarget(std::string const& name)
"clean", "edit_cache", "rebuild_cache",
"ZERO_CHECK" };
- return std::find(cm::cbegin(reservedTargets), cm::cend(reservedTargets),
- name) != cm::cend(reservedTargets);
+ return cmContains(reservedTargets, name);
}
void cmGlobalGenerator::SetExternalMakefileProjectGenerator(
diff --git a/Source/cmGlobalGhsMultiGenerator.cxx b/Source/cmGlobalGhsMultiGenerator.cxx
index 4db829f..c719ff5 100644
--- a/Source/cmGlobalGhsMultiGenerator.cxx
+++ b/Source/cmGlobalGhsMultiGenerator.cxx
@@ -2,6 +2,7 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmGlobalGhsMultiGenerator.h"
+#include "cmAlgorithms.h"
#include "cmDocumentationEntry.h"
#include "cmGeneratedFileStream.h"
#include "cmGeneratorTarget.h"
@@ -589,16 +590,14 @@ cmGlobalGhsMultiGenerator::GenerateBuildCommand(
/* if multiple top-projects are found in build directory
* then prefer projectName top-project.
*/
- auto p = std::find(files.begin(), files.end(), proj);
- if (p == files.end()) {
+ if (!cmContains(files, proj)) {
proj = files.at(0);
}
}
makeCommand.Add("-top", proj);
if (!targetNames.empty()) {
- if (std::find(targetNames.begin(), targetNames.end(), "clean") !=
- targetNames.end()) {
+ if (cmContains(targetNames, "clean")) {
makeCommand.Add("-clean");
} else {
for (const auto& tname : targetNames) {
diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx
index 29caa16..a457911 100644
--- a/Source/cmGlobalNinjaGenerator.cxx
+++ b/Source/cmGlobalNinjaGenerator.cxx
@@ -571,8 +571,7 @@ void cmGlobalNinjaGenerator::CheckNinjaFeatures()
bool cmGlobalNinjaGenerator::CheckLanguages(
std::vector<std::string> const& languages, cmMakefile* mf) const
{
- if (std::find(languages.begin(), languages.end(), "Fortran") !=
- languages.end()) {
+ if (cmContains(languages, "Fortran")) {
return this->CheckFortran(mf);
}
return true;
diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx
index 19e64e4..584c5fb 100644
--- a/Source/cmGlobalXCodeGenerator.cxx
+++ b/Source/cmGlobalXCodeGenerator.cxx
@@ -354,8 +354,7 @@ cmGlobalXCodeGenerator::GenerateBuildCommand(
projectArg += "proj";
makeCommand.Add(projectArg);
}
- if (std::find(targetNames.begin(), targetNames.end(), "clean") !=
- targetNames.end()) {
+ if (cmContains(targetNames, "clean")) {
makeCommand.Add("clean");
makeCommand.Add("-target", "ALL_BUILD");
} else {
@@ -903,8 +902,7 @@ void cmGlobalXCodeGenerator::AddXCodeProjBuildRule(
target->GetLocalGenerator()->GetCurrentSourceDirectory();
listfile += "/CMakeLists.txt";
cmSourceFile* srcCMakeLists = target->Makefile->GetOrCreateSource(listfile);
- if (std::find(sources.begin(), sources.end(), srcCMakeLists) ==
- sources.end()) {
+ if (!cmContains(sources, srcCMakeLists)) {
sources.push_back(srcCMakeLists);
}
}
@@ -1417,10 +1415,8 @@ void cmGlobalXCodeGenerator::ForceLinkerLanguage(cmGeneratorTarget* gtgt)
bool cmGlobalXCodeGenerator::IsHeaderFile(cmSourceFile* sf)
{
- const std::vector<std::string>& hdrExts =
- this->CMakeInstance->GetHeaderExtensions();
- return (std::find(hdrExts.begin(), hdrExts.end(), sf->GetExtension()) !=
- hdrExts.end());
+ return cmContains(this->CMakeInstance->GetHeaderExtensions(),
+ sf->GetExtension());
}
cmXCodeObject* cmGlobalXCodeGenerator::CreateBuildPhase(
diff --git a/Source/cmLinkItem.h b/Source/cmLinkItem.h
index d71ff49..2d9378b 100644
--- a/Source/cmLinkItem.h
+++ b/Source/cmLinkItem.h
@@ -5,12 +5,12 @@
#include "cmConfigure.h" // IWYU pragma: keep
-#include <algorithm>
#include <map>
#include <ostream>
#include <string>
#include <vector>
+#include "cmAlgorithms.h"
#include "cmListFileCache.h"
#include "cmSystemTools.h"
#include "cmTargetLinkLibraryType.h"
@@ -120,8 +120,7 @@ inline cmTargetLinkLibraryType CMP0003_ComputeLinkType(
// Check if any entry in the list matches this configuration.
std::string configUpper = cmSystemTools::UpperCase(config);
- if (std::find(debugConfigs.begin(), debugConfigs.end(), configUpper) !=
- debugConfigs.end()) {
+ if (cmContains(debugConfigs, configUpper)) {
return DEBUG_LibraryType;
}
// The current configuration is not a debug configuration.
diff --git a/Source/cmLinkLineDeviceComputer.cxx b/Source/cmLinkLineDeviceComputer.cxx
index 7cacb24..bc8292a 100644
--- a/Source/cmLinkLineDeviceComputer.cxx
+++ b/Source/cmLinkLineDeviceComputer.cxx
@@ -3,12 +3,11 @@
#include "cmLinkLineDeviceComputer.h"
-#include <algorithm>
#include <set>
#include <sstream>
#include <utility>
-#include <vector>
+#include "cmAlgorithms.h"
#include "cmComputeLinkInformation.h"
#include "cmGeneratorTarget.h"
#include "cmGlobalGenerator.h"
@@ -187,14 +186,10 @@ bool requireDeviceLinking(cmGeneratorTarget& target, cmLocalGenerator& lg,
// Determine if we have any dependencies that require
// us to do a device link step
- const std::string cuda_lang("CUDA");
cmGeneratorTarget::LinkClosure const* closure =
target.GetLinkClosure(config);
- bool closureHasCUDA =
- (std::find(closure->Languages.begin(), closure->Languages.end(),
- cuda_lang) != closure->Languages.end());
- if (closureHasCUDA) {
+ if (cmContains(closure->Languages, "CUDA")) {
cmComputeLinkInformation* pcli = target.GetLinkInformation(config);
if (pcli) {
cmLinkLineDeviceComputer deviceLinkComputer(
diff --git a/Source/cmListCommand.cxx b/Source/cmListCommand.cxx
index cbb1d3a..9a6653f 100644
--- a/Source/cmListCommand.cxx
+++ b/Source/cmListCommand.cxx
@@ -121,7 +121,7 @@ bool cmListCommand::GetList(std::vector<std::string>& list,
// expand the variable into a list
cmExpandList(listString, list, true);
// if no empty elements then just return
- if (std::find(list.begin(), list.end(), std::string()) == list.end()) {
+ if (!cmContains(list, std::string())) {
return true;
}
// if we have empty elements we need to check policy CMP0007
diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx
index c3cfc5f..cdb2947 100644
--- a/Source/cmLocalGenerator.cxx
+++ b/Source/cmLocalGenerator.cxx
@@ -996,8 +996,7 @@ std::vector<BT<std::string>> cmLocalGenerator::GetIncludeDirectoriesImplicit(
// directly. In this case adding -I/usr/include can hide SDK headers so we
// must still exclude it.
if ((lang == "C" || lang == "CXX" || lang == "CUDA") &&
- std::find(impDirVec.begin(), impDirVec.end(), "/usr/include") ==
- impDirVec.end() &&
+ !cmContains(impDirVec, "/usr/include") &&
std::find_if(impDirVec.begin(), impDirVec.end(),
[](std::string const& d) {
return cmHasLiteralSuffix(d, "/usr/include");
@@ -1018,15 +1017,13 @@ std::vector<BT<std::string>> cmLocalGenerator::GetIncludeDirectoriesImplicit(
&lang](std::string const& dir) {
return (
// Do not exclude directories that are not in an excluded set.
- ((implicitSet.find(cmSystemTools::GetRealPath(dir)) ==
- implicitSet.end()) &&
- (implicitExclude.find(dir) == implicitExclude.end()))
+ ((!cmContains(implicitSet, cmSystemTools::GetRealPath(dir))) &&
+ (!cmContains(implicitExclude, dir)))
// Do not exclude entries of the CPATH environment variable even though
// they are implicitly searched by the compiler. They are meant to be
// user-specified directories that can be re-ordered or converted to
// -isystem without breaking real compiler builtin headers.
- || ((lang == "C" || lang == "CXX") &&
- (this->EnvCPATH.find(dir) != this->EnvCPATH.end())));
+ || ((lang == "C" || lang == "CXX") && cmContains(this->EnvCPATH, dir)));
};
// Get the target-specific include directories.
@@ -1073,8 +1070,7 @@ std::vector<BT<std::string>> cmLocalGenerator::GetIncludeDirectoriesImplicit(
if (!stripImplicitDirs) {
// Append implicit directories that were requested by the user only
for (BT<std::string> const& udr : userDirs) {
- if (implicitSet.find(cmSystemTools::GetRealPath(udr.Value)) !=
- implicitSet.end()) {
+ if (cmContains(implicitSet, cmSystemTools::GetRealPath(udr.Value))) {
emitBT(udr);
}
}
diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx
index 3d76396..630fb54 100644
--- a/Source/cmLocalVisualStudio7Generator.cxx
+++ b/Source/cmLocalVisualStudio7Generator.cxx
@@ -1540,9 +1540,8 @@ cmLocalVisualStudio7GeneratorFCInfo::cmLocalVisualStudio7GeneratorFCInfo(
const std::string& linkLanguage = gt->GetLinkerLanguage(config.c_str());
// If HEADER_FILE_ONLY is set, we must suppress this generation in
// the project file
- fc.ExcludedFromBuild = sf.GetPropertyAsBool("HEADER_FILE_ONLY") ||
- std::find(acs.Configs.begin(), acs.Configs.end(), ci) ==
- acs.Configs.end();
+ fc.ExcludedFromBuild =
+ sf.GetPropertyAsBool("HEADER_FILE_ONLY") || !cmContains(acs.Configs, ci);
if (fc.ExcludedFromBuild) {
needfc = true;
}
diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx
index 657c3bf..53816d2 100644
--- a/Source/cmMakefile.cxx
+++ b/Source/cmMakefile.cxx
@@ -1583,7 +1583,7 @@ void cmMakefile::Configure()
allowedCommands.insert("message");
isProblem = false;
for (cmListFileFunction const& func : listFile.Functions) {
- if (allowedCommands.find(func.Name.Lower) == allowedCommands.end()) {
+ if (!cmContains(allowedCommands, func.Name.Lower)) {
isProblem = true;
break;
}
@@ -4012,7 +4012,7 @@ cmTarget* cmMakefile::FindTargetToUse(const std::string& name,
bool cmMakefile::IsAlias(const std::string& name) const
{
- if (this->AliasTargets.find(name) != this->AliasTargets.end()) {
+ if (cmContains(this->AliasTargets, name)) {
return true;
}
return this->GetGlobalGenerator()->IsAlias(name);
@@ -4379,8 +4379,7 @@ bool cmMakefile::AddRequiredTargetFeature(cmTarget* target,
std::vector<std::string> availableFeatures;
cmExpandList(features, availableFeatures);
- if (std::find(availableFeatures.begin(), availableFeatures.end(), feature) ==
- availableFeatures.end()) {
+ if (!cmContains(availableFeatures, feature)) {
std::ostringstream e;
e << "The compiler feature \"" << feature << "\" is not known to " << lang
<< " compiler\n\""
@@ -4649,31 +4648,31 @@ void cmMakefile::CheckNeededCxxLanguage(const std::string& feature,
this->GetDefinition("CMAKE_CXX98_COMPILE_FEATURES")) {
std::vector<std::string> props;
cmExpandList(propCxx98, props);
- needCxx98 = std::find(props.begin(), props.end(), feature) != props.end();
+ needCxx98 = cmContains(props, feature);
}
if (const char* propCxx11 =
this->GetDefinition("CMAKE_CXX11_COMPILE_FEATURES")) {
std::vector<std::string> props;
cmExpandList(propCxx11, props);
- needCxx11 = std::find(props.begin(), props.end(), feature) != props.end();
+ needCxx11 = cmContains(props, feature);
}
if (const char* propCxx14 =
this->GetDefinition("CMAKE_CXX14_COMPILE_FEATURES")) {
std::vector<std::string> props;
cmExpandList(propCxx14, props);
- needCxx14 = std::find(props.begin(), props.end(), feature) != props.end();
+ needCxx14 = cmContains(props, feature);
}
if (const char* propCxx17 =
this->GetDefinition("CMAKE_CXX17_COMPILE_FEATURES")) {
std::vector<std::string> props;
cmExpandList(propCxx17, props);
- needCxx17 = std::find(props.begin(), props.end(), feature) != props.end();
+ needCxx17 = cmContains(props, feature);
}
if (const char* propCxx20 =
this->GetDefinition("CMAKE_CXX20_COMPILE_FEATURES")) {
std::vector<std::string> props;
cmExpandList(propCxx20, props);
- needCxx20 = std::find(props.begin(), props.end(), feature) != props.end();
+ needCxx20 = cmContains(props, feature);
}
}
@@ -4773,19 +4772,19 @@ void cmMakefile::CheckNeededCLanguage(const std::string& feature,
this->GetDefinition("CMAKE_C90_COMPILE_FEATURES")) {
std::vector<std::string> props;
cmExpandList(propC90, props);
- needC90 = std::find(props.begin(), props.end(), feature) != props.end();
+ needC90 = cmContains(props, feature);
}
if (const char* propC99 =
this->GetDefinition("CMAKE_C99_COMPILE_FEATURES")) {
std::vector<std::string> props;
cmExpandList(propC99, props);
- needC99 = std::find(props.begin(), props.end(), feature) != props.end();
+ needC99 = cmContains(props, feature);
}
if (const char* propC11 =
this->GetDefinition("CMAKE_C11_COMPILE_FEATURES")) {
std::vector<std::string> props;
cmExpandList(propC11, props);
- needC11 = std::find(props.begin(), props.end(), feature) != props.end();
+ needC11 = cmContains(props, feature);
}
}
diff --git a/Source/cmQtAutoGen.cxx b/Source/cmQtAutoGen.cxx
index 3026b33..fe04fba 100644
--- a/Source/cmQtAutoGen.cxx
+++ b/Source/cmQtAutoGen.cxx
@@ -53,9 +53,7 @@ void MergeOptions(std::vector<std::string>& baseOpts,
}
}
// Test if this is a value option and change the existing value
- if (!optName.empty() &&
- (std::find(valueOpts.begin(), valueOpts.end(), optName) !=
- valueOpts.end())) {
+ if (!optName.empty() && cmContains(valueOpts, optName)) {
const Iter existItNext(existIt + 1);
const CIter fitNext(fit + 1);
if ((existItNext != baseOpts.end()) && (fitNext != fitEnd)) {
diff --git a/Source/cmServerProtocol.cxx b/Source/cmServerProtocol.cxx
index 8fcb710..670161d 100644
--- a/Source/cmServerProtocol.cxx
+++ b/Source/cmServerProtocol.cxx
@@ -2,6 +2,7 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmServerProtocol.h"
+#include "cmAlgorithms.h"
#include "cmExternalMakefileProjectGenerator.h"
#include "cmFileMonitor.h"
#include "cmGlobalGenerator.h"
@@ -433,7 +434,7 @@ cmServerResponse cmServerProtocol1::ProcessCache(
keys = allKeys;
} else {
for (auto const& i : keys) {
- if (std::find(allKeys.begin(), allKeys.end(), i) == allKeys.end()) {
+ if (!cmContains(allKeys, i)) {
return request.ReportError("Key \"" + i + "\" not found in cache.");
}
}
diff --git a/Source/cmSourceGroupCommand.cxx b/Source/cmSourceGroupCommand.cxx
index 880773b..146e06d 100644
--- a/Source/cmSourceGroupCommand.cxx
+++ b/Source/cmSourceGroupCommand.cxx
@@ -2,11 +2,11 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmSourceGroupCommand.h"
-#include <algorithm>
#include <set>
#include <stddef.h>
#include <utility>
+#include "cmAlgorithms.h"
#include "cmMakefile.h"
#include "cmSourceGroup.h"
#include "cmStringAlgorithms.h"
@@ -140,8 +140,7 @@ cmSourceGroupCommand::getExpectedOptions() const
bool cmSourceGroupCommand::isExpectedOption(
const std::string& argument, const ExpectedOptions& expectedOptions)
{
- return std::find(expectedOptions.begin(), expectedOptions.end(), argument) !=
- expectedOptions.end();
+ return cmContains(expectedOptions, argument);
}
void cmSourceGroupCommand::parseArguments(
diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx
index 0e4b0af..0758208 100644
--- a/Source/cmVisualStudio10TargetGenerator.cxx
+++ b/Source/cmVisualStudio10TargetGenerator.cxx
@@ -2603,8 +2603,7 @@ bool cmVisualStudio10TargetGenerator::ComputeClOptions(
std::string langForClCompile;
if (this->ProjectType == csproj) {
langForClCompile = "CSharp";
- } else if (std::find(cm::cbegin(clLangs), cm::cend(clLangs), linkLanguage) !=
- cm::cend(clLangs)) {
+ } else if (cmContains(clLangs, linkLanguage)) {
langForClCompile = linkLanguage;
} else {
std::set<std::string> languages;
@@ -3470,8 +3469,7 @@ bool cmVisualStudio10TargetGenerator::ComputeLinkOptions(
std::vector<std::string> libVec;
std::vector<std::string> vsTargetVec;
this->AddLibraries(cli, libVec, vsTargetVec, config);
- if (std::find(linkClosure->Languages.begin(), linkClosure->Languages.end(),
- "CUDA") != linkClosure->Languages.end() &&
+ if (cmContains(linkClosure->Languages, "CUDA") &&
this->CudaOptions[config] != nullptr) {
switch (this->CudaOptions[config]->GetCudaRuntime()) {
case cmVisualStudioGeneratorOptions::CudaRuntimeStatic:
@@ -3758,8 +3756,7 @@ void cmVisualStudio10TargetGenerator::AddTargetsFileAndConfigPair(
{
for (TargetsFileAndConfigs& i : this->TargetsFileAndConfigsVec) {
if (cmSystemTools::ComparePath(targetsFile, i.File)) {
- if (std::find(i.Configs.begin(), i.Configs.end(), config) ==
- i.Configs.end()) {
+ if (!cmContains(i.Configs, config)) {
i.Configs.push_back(config);
}
return;
diff --git a/Source/cmXCodeObject.h b/Source/cmXCodeObject.h
index 51e5d36..0552676 100644
--- a/Source/cmXCodeObject.h
+++ b/Source/cmXCodeObject.h
@@ -12,6 +12,8 @@
#include <utility>
#include <vector>
+#include "cmAlgorithms.h"
+
class cmGeneratorTarget;
class cmXCodeObject
@@ -80,15 +82,10 @@ public:
void SetObject(cmXCodeObject* value) { this->Object = value; }
cmXCodeObject* GetObject() { return this->Object; }
void AddObject(cmXCodeObject* value) { this->List.push_back(value); }
- bool HasObject(cmXCodeObject* o) const
- {
- return !(std::find(this->List.begin(), this->List.end(), o) ==
- this->List.end());
- }
+ bool HasObject(cmXCodeObject* o) const { return cmContains(this->List, o); }
void AddUniqueObject(cmXCodeObject* value)
{
- if (std::find(this->List.begin(), this->List.end(), value) ==
- this->List.end()) {
+ if (!cmContains(this->List, value)) {
this->List.push_back(value);
}
}
diff --git a/Source/cmXCodeScheme.cxx b/Source/cmXCodeScheme.cxx
index a565a9c..112d1c1 100644
--- a/Source/cmXCodeScheme.cxx
+++ b/Source/cmXCodeScheme.cxx
@@ -393,9 +393,7 @@ std::string cmXCodeScheme::FindConfiguration(const std::string& name)
// Try to find the desired configuration by name,
// and if it's not found return first from the list
//
- if (std::find(this->ConfigList.begin(), this->ConfigList.end(), name) ==
- this->ConfigList.end() &&
- !this->ConfigList.empty()) {
+ if (!cmContains(this->ConfigList, name) && !this->ConfigList.empty()) {
return this->ConfigList[0];
}
diff --git a/Source/cmake.cxx b/Source/cmake.cxx
index 440a7b1..2500939 100644
--- a/Source/cmake.cxx
+++ b/Source/cmake.cxx
@@ -2738,7 +2738,7 @@ void cmake::WatchUnusedCli(const std::string& var)
{
#ifndef CMAKE_BOOTSTRAP
this->VariableWatch->AddWatch(var, cmWarnUnusedCliWarning, this);
- if (this->UsedCliVariables.find(var) == this->UsedCliVariables.end()) {
+ if (!cmContains(this->UsedCliVariables, var)) {
this->UsedCliVariables[var] = false;
}
#endif
diff --git a/Source/cmcmd.cxx b/Source/cmcmd.cxx
index ba2788e..30aaa9c 100644
--- a/Source/cmcmd.cxx
+++ b/Source/cmcmd.cxx
@@ -38,10 +38,8 @@
#include "cmsys/FStream.hxx"
#include "cmsys/Process.h"
#include "cmsys/Terminal.h"
-#include <algorithm>
#include <array>
#include <iostream>
-#include <iterator>
#include <memory>
#include <sstream>
#include <stdio.h>
@@ -1075,11 +1073,7 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string> const& args)
}
} else if (cmHasLiteralPrefix(arg, "--format=")) {
format = arg.substr(9);
- bool isKnown =
- std::find(cm::cbegin(knownFormats), cm::cend(knownFormats),
- format) != cm::cend(knownFormats);
-
- if (!isKnown) {
+ if (!cmContains(knownFormats, format)) {
cmSystemTools::Error("Unknown -E tar --format= argument: " +
format);
return 1;