summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
Diffstat (limited to 'Source')
-rw-r--r--Source/CMakeLists.txt1
-rw-r--r--Source/CMakeVersion.cmake2
-rw-r--r--Source/CPack/IFW/cmCPackIFWGenerator.cxx2
-rw-r--r--Source/CTest/cmCTestMemCheckHandler.cxx2
-rw-r--r--Source/CTest/cmCTestMultiProcessHandler.cxx173
-rw-r--r--Source/CTest/cmCTestMultiProcessHandler.h12
-rw-r--r--Source/CTest/cmCTestRunTest.cxx201
-rw-r--r--Source/CTest/cmCTestRunTest.h30
-rw-r--r--Source/CTest/cmParseMumpsCoverage.cxx2
-rw-r--r--Source/CTest/cmProcess.cxx708
-rw-r--r--Source/CTest/cmProcess.h79
-rw-r--r--Source/Checks/cm_cxx14_check.cmake36
-rw-r--r--Source/Checks/cm_cxx14_check.cpp (renamed from Source/Checks/cm_cxx14_cstdio.cpp)0
-rw-r--r--Source/Checks/cm_cxx14_cstdio.cmake33
-rw-r--r--Source/Checks/cm_cxx17_check.cmake36
-rw-r--r--Source/Checks/cm_cxx17_check.cpp7
-rw-r--r--Source/CursesDialog/CMakeLists.txt26
-rw-r--r--Source/QtDialog/CMakeLists.txt2
-rw-r--r--Source/cmCTest.cxx72
-rw-r--r--Source/cmCTest.h12
-rw-r--r--Source/cmCommands.cxx2
-rw-r--r--Source/cmDependsFortran.cxx2
-rw-r--r--Source/cmDependsFortran.h2
-rw-r--r--Source/cmExportInstallAndroidMKGenerator.h2
-rw-r--r--Source/cmExtraCodeBlocksGenerator.cxx4
-rw-r--r--Source/cmExtraCodeLiteGenerator.cxx4
-rw-r--r--Source/cmFilePathChecksum.h4
-rw-r--r--Source/cmGeneratorTarget.cxx15
-rw-r--r--Source/cmGlobalGenerator.cxx2
-rw-r--r--Source/cmGlobalNinjaGenerator.cxx3
-rw-r--r--Source/cmGlobalVisualStudio10Generator.cxx12
-rw-r--r--Source/cmGlobalVisualStudio11Generator.cxx14
-rw-r--r--Source/cmGlobalVisualStudio14Generator.cxx17
-rw-r--r--Source/cmGlobalVisualStudio71Generator.cxx35
-rw-r--r--Source/cmGlobalVisualStudio7Generator.cxx111
-rw-r--r--Source/cmGlobalVisualStudio8Generator.cxx59
-rw-r--r--Source/cmGlobalVisualStudio9Generator.cxx6
-rw-r--r--Source/cmGlobalVisualStudioGenerator.cxx105
-rw-r--r--Source/cmGlobalXCodeGenerator.cxx29
-rw-r--r--Source/cmGlobalXCodeGenerator.h2
-rw-r--r--Source/cmInstallTargetGenerator.cxx4
-rw-r--r--Source/cmLocalUnixMakefileGenerator3.cxx2
-rw-r--r--Source/cmLocalVisualStudio10Generator.cxx14
-rw-r--r--Source/cmLocalVisualStudio7Generator.cxx27
-rw-r--r--Source/cmLocalVisualStudioGenerator.cxx14
-rw-r--r--Source/cmMakefile.cxx64
-rw-r--r--Source/cmMakefile.h34
-rw-r--r--Source/cmMakefileTargetGenerator.cxx2
-rw-r--r--Source/cmOSXBundleGenerator.cxx4
-rw-r--r--Source/cmProcessOutput.cxx2
-rw-r--r--Source/cmProjectCommand.cxx2
-rw-r--r--Source/cmQtAutoGeneratorInitializer.cxx21
-rw-r--r--Source/cmQtAutoGeneratorMocUic.cxx2
-rw-r--r--Source/cmServerProtocol.cxx25
-rw-r--r--Source/cmSourceFile.cxx7
-rw-r--r--Source/cmSourceFile.h8
-rw-r--r--Source/cmSourceFileLocation.cxx10
-rw-r--r--Source/cmSourceFileLocation.h10
-rw-r--r--Source/cmSourceFileLocationKind.h15
-rw-r--r--Source/cmSystemTools.cxx3
-rw-r--r--Source/cmSystemTools.h7
-rw-r--r--Source/cmTarget.cxx7
-rw-r--r--Source/cmTargetLinkLibrariesCommand.cxx2
-rw-r--r--Source/cmVisualStudio10TargetGenerator.cxx405
-rw-r--r--Source/cmVisualStudioGeneratorOptions.cxx30
-rw-r--r--Source/cmXMLWriter.h2
-rw-r--r--Source/cmake.cxx1
67 files changed, 1545 insertions, 1045 deletions
diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt
index 7031d5a..1b46377 100644
--- a/Source/CMakeLists.txt
+++ b/Source/CMakeLists.txt
@@ -327,6 +327,7 @@ set(SRCS
cmSourceFile.h
cmSourceFileLocation.cxx
cmSourceFileLocation.h
+ cmSourceFileLocationKind.h
cmSourceGroup.cxx
cmSourceGroup.h
cmState.cxx
diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake
index b7e2d42..60bdf73 100644
--- a/Source/CMakeVersion.cmake
+++ b/Source/CMakeVersion.cmake
@@ -1,5 +1,5 @@
# CMake version number components.
set(CMake_VERSION_MAJOR 3)
set(CMake_VERSION_MINOR 10)
-set(CMake_VERSION_PATCH 20171222)
+set(CMake_VERSION_PATCH 20180112)
#set(CMake_VERSION_RC 1)
diff --git a/Source/CPack/IFW/cmCPackIFWGenerator.cxx b/Source/CPack/IFW/cmCPackIFWGenerator.cxx
index 825a888..86c6981 100644
--- a/Source/CPack/IFW/cmCPackIFWGenerator.cxx
+++ b/Source/CPack/IFW/cmCPackIFWGenerator.cxx
@@ -61,7 +61,7 @@ int cmCPackIFWGenerator::PackageFiles()
}
} else {
cmCPackIFWLogger(WARNING, "The \"CPACK_IFW_REPOSITORIES_DIRECTORIES\" "
- << "variable is set, but content will be skiped, "
+ << "variable is set, but content will be skipped, "
<< "because this feature available only since "
<< "QtIFW 3.1. Please update your QtIFW instance."
<< std::endl);
diff --git a/Source/CTest/cmCTestMemCheckHandler.cxx b/Source/CTest/cmCTestMemCheckHandler.cxx
index 57d2489..6b6c337 100644
--- a/Source/CTest/cmCTestMemCheckHandler.cxx
+++ b/Source/CTest/cmCTestMemCheckHandler.cxx
@@ -176,7 +176,7 @@ void cmCTestMemCheckHandler::GenerateTestCommand(
}
// Create a copy of the memory tester environment variable.
// This is used for memory testing programs that pass options
- // via environment varaibles.
+ // via environment variables.
std::string memTesterEnvironmentVariable =
this->MemoryTesterEnvironmentVariable;
for (std::string const& arg : this->MemoryTesterOptions) {
diff --git a/Source/CTest/cmCTestMultiProcessHandler.cxx b/Source/CTest/cmCTestMultiProcessHandler.cxx
index ae07feb..53c47a2 100644
--- a/Source/CTest/cmCTestMultiProcessHandler.cxx
+++ b/Source/CTest/cmCTestMultiProcessHandler.cxx
@@ -9,10 +9,14 @@
#include "cmSystemTools.h"
#include "cmWorkingDirectory.h"
+#include "cm_uv.h"
+
#include "cmsys/FStream.hxx"
#include "cmsys/String.hxx"
#include "cmsys/SystemInformation.hxx"
+
#include <algorithm>
+#include <chrono>
#include <iomanip>
#include <list>
#include <math.h>
@@ -21,6 +25,43 @@
#include <stdlib.h>
#include <utility>
+#if defined(CMAKE_USE_SYSTEM_LIBUV) && !defined(_WIN32) && \
+ UV_VERSION_MAJOR == 1 && UV_VERSION_MINOR < 19
+#define CMAKE_UV_SIGNAL_HACK
+/*
+ libuv does not use SA_RESTART on its signal handler, but C++ streams
+ depend on it for reliable i/o operations. This RAII helper convinces
+ libuv to install its handler, and then revises the handler to add the
+ SA_RESTART flag. We use a distinct uv loop that never runs to avoid
+ ever really getting a callback. libuv may fill the hack loop's signal
+ pipe and then stop writing, but that won't break any real loops.
+ */
+class cmUVSignalHackRAII
+{
+ uv_loop_t HackLoop;
+ cm::uv_signal_ptr HackSignal;
+ static void HackCB(uv_signal_t*, int) {}
+public:
+ cmUVSignalHackRAII()
+ {
+ uv_loop_init(&this->HackLoop);
+ this->HackSignal.init(this->HackLoop);
+ this->HackSignal.start(HackCB, SIGCHLD);
+ struct sigaction hack_sa;
+ sigaction(SIGCHLD, NULL, &hack_sa);
+ if (!(hack_sa.sa_flags & SA_RESTART)) {
+ hack_sa.sa_flags |= SA_RESTART;
+ sigaction(SIGCHLD, &hack_sa, NULL);
+ }
+ }
+ ~cmUVSignalHackRAII()
+ {
+ this->HackSignal.stop();
+ uv_loop_close(&this->HackLoop);
+ }
+};
+#endif
+
class TestComparator
{
public:
@@ -95,24 +136,32 @@ void cmCTestMultiProcessHandler::RunTests()
if (this->HasCycles) {
return;
}
+#ifdef CMAKE_UV_SIGNAL_HACK
+ cmUVSignalHackRAII hackRAII;
+#endif
this->TestHandler->SetMaxIndex(this->FindMaxIndex());
+
+ uv_loop_init(&this->Loop);
this->StartNextTests();
- while (!this->Tests.empty()) {
- if (this->StopTimePassed) {
- return;
- }
- this->CheckOutput();
- this->StartNextTests();
- }
- // let all running tests finish
- while (this->CheckOutput()) {
- }
+ uv_run(&this->Loop, UV_RUN_DEFAULT);
+ uv_loop_close(&this->Loop);
+
this->MarkFinished();
this->UpdateCostData();
}
-void cmCTestMultiProcessHandler::StartTestProcess(int test)
+bool cmCTestMultiProcessHandler::StartTestProcess(int test)
{
+ std::chrono::system_clock::time_point stop_time = this->CTest->GetStopTime();
+ if (stop_time != std::chrono::system_clock::time_point() &&
+ stop_time <= std::chrono::system_clock::now()) {
+ cmCTestLog(this->CTest, ERROR_MESSAGE, "The stop time has been passed. "
+ "Stopping all tests."
+ << std::endl);
+ this->StopTimePassed = true;
+ return false;
+ }
+
cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
"test " << test << "\n", this->Quiet);
this->TestRunningMap[test] = true; // mark the test as running
@@ -120,7 +169,7 @@ void cmCTestMultiProcessHandler::StartTestProcess(int test)
this->EraseTest(test);
this->RunningCount += GetProcessorsUsed(test);
- cmCTestRunTest* testRun = new cmCTestRunTest(this->TestHandler);
+ cmCTestRunTest* testRun = new cmCTestRunTest(*this);
if (this->CTest->GetRepeatUntilFail()) {
testRun->SetRunUntilFailOn();
testRun->SetNumberOfRuns(this->CTest->GetTestRepeat());
@@ -143,28 +192,11 @@ void cmCTestMultiProcessHandler::StartTestProcess(int test)
this->LockResources(test);
if (testRun->StartTest(this->Total)) {
- this->RunningTests.insert(testRun);
- } else if (testRun->IsStopTimePassed()) {
- this->StopTimePassed = true;
- delete testRun;
- return;
- } else {
-
- for (auto& j : this->Tests) {
- j.second.erase(test);
- }
-
- this->UnlockResources(test);
- this->Completed++;
- this->TestFinishMap[test] = true;
- this->TestRunningMap[test] = false;
- this->RunningCount -= GetProcessorsUsed(test);
- testRun->EndTest(this->Completed, this->Total, false);
- if (!this->Properties[test]->Disabled) {
- this->Failed->push_back(this->Properties[test]->Name);
- }
- delete testRun;
+ return true;
}
+
+ this->FinishTestProcess(testRun, false);
+ return false;
}
void cmCTestMultiProcessHandler::LockResources(int index)
@@ -222,8 +254,7 @@ bool cmCTestMultiProcessHandler::StartTest(int test)
// if there are no depends left then run this test
if (this->Tests[test].empty()) {
- this->StartTestProcess(test);
- return true;
+ return this->StartTestProcess(test);
}
// This test was not able to start because it is waiting
// on depends to run
@@ -233,6 +264,11 @@ bool cmCTestMultiProcessHandler::StartTest(int test)
void cmCTestMultiProcessHandler::StartNextTests()
{
size_t numToStart = 0;
+
+ if (this->Tests.empty()) {
+ return;
+ }
+
if (this->RunningCount < this->ParallelLevel) {
numToStart = this->ParallelLevel - this->RunningCount;
}
@@ -365,45 +401,42 @@ void cmCTestMultiProcessHandler::StartNextTests()
}
}
-bool cmCTestMultiProcessHandler::CheckOutput()
+void cmCTestMultiProcessHandler::FinishTestProcess(cmCTestRunTest* runner,
+ bool started)
{
- // no more output we are done
- if (this->RunningTests.empty()) {
- return false;
- }
- std::vector<cmCTestRunTest*> finished;
- std::string out, err;
- for (cmCTestRunTest* p : this->RunningTests) {
- if (!p->CheckOutput()) {
- finished.push_back(p);
- }
- }
- for (cmCTestRunTest* p : finished) {
- this->Completed++;
- int test = p->GetIndex();
+ this->Completed++;
+
+ int test = runner->GetIndex();
+ auto properties = runner->GetTestProperties();
- bool testResult = p->EndTest(this->Completed, this->Total, true);
- if (p->StartAgain()) {
+ bool testResult = runner->EndTest(this->Completed, this->Total, started);
+ if (started) {
+ if (runner->StartAgain()) {
this->Completed--; // remove the completed test because run again
- continue;
- }
- if (testResult) {
- this->Passed->push_back(p->GetTestProperties()->Name);
- } else {
- this->Failed->push_back(p->GetTestProperties()->Name);
- }
- for (auto& t : this->Tests) {
- t.second.erase(test);
+ return;
}
- this->TestFinishMap[test] = true;
- this->TestRunningMap[test] = false;
- this->RunningTests.erase(p);
- this->WriteCheckpoint(test);
- this->UnlockResources(test);
- this->RunningCount -= GetProcessorsUsed(test);
- delete p;
}
- return true;
+
+ if (testResult) {
+ this->Passed->push_back(properties->Name);
+ } else if (!properties->Disabled) {
+ this->Failed->push_back(properties->Name);
+ }
+
+ for (auto& t : this->Tests) {
+ t.second.erase(test);
+ }
+
+ this->TestFinishMap[test] = true;
+ this->TestRunningMap[test] = false;
+ this->WriteCheckpoint(test);
+ this->UnlockResources(test);
+ this->RunningCount -= GetProcessorsUsed(test);
+
+ delete runner;
+ if (started) {
+ this->StartNextTests();
+ }
}
void cmCTestMultiProcessHandler::UpdateCostData()
@@ -670,7 +703,7 @@ void cmCTestMultiProcessHandler::PrintTestList()
cmWorkingDirectory workdir(p.Directory);
- cmCTestRunTest testRun(this->TestHandler);
+ cmCTestRunTest testRun(*this);
testRun.SetIndex(p.Index);
testRun.SetTestProperties(&p);
testRun.ComputeArguments(); // logs the command in verbose mode
diff --git a/Source/CTest/cmCTestMultiProcessHandler.h b/Source/CTest/cmCTestMultiProcessHandler.h
index dccc2c8..7837ff9 100644
--- a/Source/CTest/cmCTestMultiProcessHandler.h
+++ b/Source/CTest/cmCTestMultiProcessHandler.h
@@ -12,6 +12,8 @@
#include <string>
#include <vector>
+#include "cm_uv.h"
+
class cmCTest;
class cmCTestRunTest;
@@ -23,6 +25,7 @@ class cmCTestRunTest;
class cmCTestMultiProcessHandler
{
friend class TestComparator;
+ friend class cmCTestRunTest;
public:
struct TestSet : public std::set<int>
@@ -75,7 +78,7 @@ protected:
// Start the next test or tests as many as are allowed by
// ParallelLevel
void StartNextTests();
- void StartTestProcess(int test);
+ bool StartTestProcess(int test);
bool StartTest(int test);
// Mark the checkpoint for the given test
void WriteCheckpoint(int index);
@@ -95,9 +98,8 @@ protected:
// Removes the checkpoint file
void MarkFinished();
void EraseTest(int index);
- // Return true if there are still tests running
- // check all running processes for output and exit case
- bool CheckOutput();
+ void FinishTestProcess(cmCTestRunTest* runner, bool started);
+
void RemoveTest(int index);
// Check if we need to resume an interrupted test set
void CheckResume();
@@ -130,7 +132,7 @@ protected:
std::vector<cmCTestTestHandler::cmCTestTestResult>* TestResults;
size_t ParallelLevel; // max number of process that can be run at once
unsigned long TestLoad;
- std::set<cmCTestRunTest*> RunningTests; // current running tests
+ uv_loop_t Loop;
cmCTestTestHandler* TestHandler;
cmCTest* CTest;
bool HasCycles;
diff --git a/Source/CTest/cmCTestRunTest.cxx b/Source/CTest/cmCTestRunTest.cxx
index dbdefae..baf894e 100644
--- a/Source/CTest/cmCTestRunTest.cxx
+++ b/Source/CTest/cmCTestRunTest.cxx
@@ -4,28 +4,27 @@
#include "cmCTest.h"
#include "cmCTestMemCheckHandler.h"
-#include "cmCTestTestHandler.h"
+#include "cmCTestMultiProcessHandler.h"
#include "cmProcess.h"
#include "cmSystemTools.h"
#include "cmWorkingDirectory.h"
-#include "cm_curl.h"
#include "cm_zlib.h"
#include "cmsys/Base64.h"
-#include "cmsys/Process.h"
#include "cmsys/RegularExpression.hxx"
#include <chrono>
+#include <cmAlgorithms.h>
#include <iomanip>
+#include <ratio>
#include <sstream>
#include <stdio.h>
-#include <time.h>
#include <utility>
-cmCTestRunTest::cmCTestRunTest(cmCTestTestHandler* handler)
+cmCTestRunTest::cmCTestRunTest(cmCTestMultiProcessHandler& multiHandler)
+ : MultiTestHandler(multiHandler)
{
- this->CTest = handler->CTest;
- this->TestHandler = handler;
- this->TestProcess = nullptr;
+ this->CTest = multiHandler.CTest;
+ this->TestHandler = multiHandler.TestHandler;
this->TestResult.ExecutionTime = std::chrono::duration<double>::zero();
this->TestResult.ReturnValue = 0;
this->TestResult.Status = cmCTestTestHandler::NOT_RUN;
@@ -34,60 +33,37 @@ cmCTestRunTest::cmCTestRunTest(cmCTestTestHandler* handler)
this->ProcessOutput.clear();
this->CompressedOutput.clear();
this->CompressionRatio = 2;
- this->StopTimePassed = false;
this->NumberOfRunsLeft = 1; // default to 1 run of the test
this->RunUntilFail = false; // default to run the test once
this->RunAgain = false; // default to not having to run again
}
-cmCTestRunTest::~cmCTestRunTest()
+void cmCTestRunTest::CheckOutput(std::string const& line)
{
-}
-
-bool cmCTestRunTest::CheckOutput()
-{
- // Read lines for up to 0.1 seconds of total time.
- std::chrono::duration<double> timeout = std::chrono::milliseconds(100);
- auto timeEnd = std::chrono::steady_clock::now() + timeout;
- std::string line;
- while ((timeout = timeEnd - std::chrono::steady_clock::now(),
- timeout > std::chrono::seconds(0))) {
- int p = this->TestProcess->GetNextOutputLine(line, timeout);
- if (p == cmsysProcess_Pipe_None) {
- // Process has terminated and all output read.
- return false;
- }
- if (p == cmsysProcess_Pipe_STDOUT) {
- // Store this line of output.
- cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, this->GetIndex()
- << ": " << line << std::endl);
- this->ProcessOutput += line;
- this->ProcessOutput += "\n";
-
- // Check for TIMEOUT_AFTER_MATCH property.
- if (!this->TestProperties->TimeoutRegularExpressions.empty()) {
- for (auto& reg : this->TestProperties->TimeoutRegularExpressions) {
- if (reg.first.find(this->ProcessOutput.c_str())) {
- cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, this->GetIndex()
- << ": "
- << "Test timeout changed to "
- << std::chrono::duration_cast<std::chrono::seconds>(
- this->TestProperties->AlternateTimeout)
- .count()
- << std::endl);
- this->TestProcess->ResetStartTime();
- this->TestProcess->ChangeTimeout(
- this->TestProperties->AlternateTimeout);
- this->TestProperties->TimeoutRegularExpressions.clear();
- break;
- }
- }
+ cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, this->GetIndex()
+ << ": " << line << std::endl);
+ this->ProcessOutput += line;
+ this->ProcessOutput += "\n";
+
+ // Check for TIMEOUT_AFTER_MATCH property.
+ if (!this->TestProperties->TimeoutRegularExpressions.empty()) {
+ for (auto& reg : this->TestProperties->TimeoutRegularExpressions) {
+ if (reg.first.find(this->ProcessOutput.c_str())) {
+ cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, this->GetIndex()
+ << ": "
+ << "Test timeout changed to "
+ << std::chrono::duration_cast<std::chrono::seconds>(
+ this->TestProperties->AlternateTimeout)
+ .count()
+ << std::endl);
+ this->TestProcess->ResetStartTime();
+ this->TestProcess->ChangeTimeout(
+ this->TestProperties->AlternateTimeout);
+ this->TestProperties->TimeoutRegularExpressions.clear();
+ break;
}
- } else { // if(p == cmsysProcess_Pipe_Timeout)
- break;
}
}
- return true;
}
// Streamed compression of test output. The compressed data
@@ -160,8 +136,8 @@ bool cmCTestRunTest::EndTest(size_t completed, size_t total, bool started)
this->WriteLogOutputTop(completed, total);
std::string reason;
bool passed = true;
- int res =
- started ? this->TestProcess->GetProcessStatus() : cmsysProcess_State_Error;
+ cmProcess::State res =
+ started ? this->TestProcess->GetProcessStatus() : cmProcess::State::Error;
int retVal = this->TestProcess->GetExitValue();
bool forceFail = false;
bool skipped = false;
@@ -200,7 +176,7 @@ bool cmCTestRunTest::EndTest(size_t completed, size_t total, bool started)
}
}
}
- if (res == cmsysProcess_State_Exited) {
+ if (res == cmProcess::State::Exited) {
bool success = !forceFail &&
(retVal == 0 ||
!this->TestProperties->RequiredRegularExpressions.empty());
@@ -221,29 +197,29 @@ bool cmCTestRunTest::EndTest(size_t completed, size_t total, bool started)
cmCTestLog(this->CTest, HANDLER_OUTPUT, "***Failed " << reason);
outputTestErrorsToConsole = this->CTest->OutputTestOutputOnTestFailure;
}
- } else if (res == cmsysProcess_State_Expired) {
+ } else if (res == cmProcess::State::Expired) {
cmCTestLog(this->CTest, HANDLER_OUTPUT, "***Timeout ");
this->TestResult.Status = cmCTestTestHandler::TIMEOUT;
outputTestErrorsToConsole = this->CTest->OutputTestOutputOnTestFailure;
- } else if (res == cmsysProcess_State_Exception) {
+ } else if (res == cmProcess::State::Exception) {
outputTestErrorsToConsole = this->CTest->OutputTestOutputOnTestFailure;
cmCTestLog(this->CTest, HANDLER_OUTPUT, "***Exception: ");
this->TestResult.ExceptionStatus =
this->TestProcess->GetExitExceptionString();
switch (this->TestProcess->GetExitException()) {
- case cmsysProcess_Exception_Fault:
+ case cmProcess::Exception::Fault:
cmCTestLog(this->CTest, HANDLER_OUTPUT, "SegFault");
this->TestResult.Status = cmCTestTestHandler::SEGFAULT;
break;
- case cmsysProcess_Exception_Illegal:
+ case cmProcess::Exception::Illegal:
cmCTestLog(this->CTest, HANDLER_OUTPUT, "Illegal");
this->TestResult.Status = cmCTestTestHandler::ILLEGAL;
break;
- case cmsysProcess_Exception_Interrupt:
+ case cmProcess::Exception::Interrupt:
cmCTestLog(this->CTest, HANDLER_OUTPUT, "Interrupt");
this->TestResult.Status = cmCTestTestHandler::INTERRUPT;
break;
- case cmsysProcess_Exception_Numerical:
+ case cmProcess::Exception::Numerical:
cmCTestLog(this->CTest, HANDLER_OUTPUT, "Numerical");
this->TestResult.Status = cmCTestTestHandler::NUMERICAL;
break;
@@ -254,7 +230,7 @@ bool cmCTestRunTest::EndTest(size_t completed, size_t total, bool started)
}
} else if ("Disabled" == this->TestResult.CompletionStatus) {
cmCTestLog(this->CTest, HANDLER_OUTPUT, "***Not Run (Disabled) ");
- } else // cmsysProcess_State_Error
+ } else // cmProcess::State::Error
{
cmCTestLog(this->CTest, HANDLER_OUTPUT, "***Not Run ");
}
@@ -350,7 +326,7 @@ bool cmCTestRunTest::EndTest(size_t completed, size_t total, bool started)
if (!this->NeedsToRerun()) {
this->TestHandler->TestResults.push_back(this->TestResult);
}
- delete this->TestProcess;
+ this->TestProcess.reset();
return passed || skipped;
}
@@ -432,7 +408,7 @@ bool cmCTestRunTest::StartTest(size_t total)
this->TestResult.TestCount = this->TestProperties->Index;
this->TestResult.Name = this->TestProperties->Name;
this->TestResult.Path = this->TestProperties->Directory;
- this->TestProcess = new cmProcess;
+ this->TestProcess = cm::make_unique<cmProcess>(*this);
this->TestResult.Output = "Disabled";
this->TestResult.FullCommandLine.clear();
return false;
@@ -453,7 +429,7 @@ bool cmCTestRunTest::StartTest(size_t total)
// its arguments are irrelevant. This matters for the case where a fixture
// dependency might be creating the executable we want to run.
if (!this->FailedDependencies.empty()) {
- this->TestProcess = new cmProcess;
+ this->TestProcess = cm::make_unique<cmProcess>(*this);
std::string msg = "Failed test dependencies:";
for (std::string const& failedDep : this->FailedDependencies) {
msg += " " + failedDep;
@@ -470,7 +446,7 @@ bool cmCTestRunTest::StartTest(size_t total)
this->ComputeArguments();
std::vector<std::string>& args = this->TestProperties->Args;
if (args.size() >= 2 && args[1] == "NOT_AVAILABLE") {
- this->TestProcess = new cmProcess;
+ this->TestProcess = cm::make_unique<cmProcess>(*this);
std::string msg;
if (this->CTest->GetConfigType().empty()) {
msg = "Test not available without configuration.";
@@ -493,7 +469,7 @@ bool cmCTestRunTest::StartTest(size_t total)
for (std::string const& file : this->TestProperties->RequiredFiles) {
if (!cmSystemTools::FileExists(file.c_str())) {
// Required file was not found
- this->TestProcess = new cmProcess;
+ this->TestProcess = cm::make_unique<cmProcess>(*this);
*this->TestHandler->LogFile << "Unable to find required file: " << file
<< std::endl;
cmCTestLog(this->CTest, ERROR_MESSAGE,
@@ -509,7 +485,7 @@ bool cmCTestRunTest::StartTest(size_t total)
if (this->ActualCommand.empty()) {
// if the command was not found create a TestResult object
// that has that information
- this->TestProcess = new cmProcess;
+ this->TestProcess = cm::make_unique<cmProcess>(*this);
*this->TestHandler->LogFile << "Unable to find executable: " << args[1]
<< std::endl;
cmCTestLog(this->CTest, ERROR_MESSAGE,
@@ -522,11 +498,22 @@ bool cmCTestRunTest::StartTest(size_t total)
}
this->StartTime = this->CTest->CurrentTime();
- auto timeout = this->ResolveTimeout();
+ auto timeout = this->TestProperties->Timeout;
- if (this->StopTimePassed) {
- return false;
+ std::chrono::system_clock::time_point stop_time = this->CTest->GetStopTime();
+ if (stop_time != std::chrono::system_clock::time_point()) {
+ std::chrono::duration<double> stop_timeout =
+ (stop_time - std::chrono::system_clock::now()) % std::chrono::hours(24);
+
+ if (stop_timeout <= std::chrono::duration<double>::zero()) {
+ stop_timeout = std::chrono::duration<double>::zero();
+ }
+ if (timeout == std::chrono::duration<double>::zero() ||
+ stop_timeout < timeout) {
+ timeout = stop_timeout;
+ }
}
+
return this->ForkProcess(timeout, this->TestProperties->ExplicitTimeout,
&this->TestProperties->Environment);
}
@@ -603,72 +590,11 @@ void cmCTestRunTest::DartProcessing()
}
}
-std::chrono::duration<double> cmCTestRunTest::ResolveTimeout()
-{
- auto timeout = this->TestProperties->Timeout;
-
- if (this->CTest->GetStopTime().empty()) {
- return timeout;
- }
- struct tm* lctime;
- time_t current_time = time(nullptr);
- lctime = gmtime(&current_time);
- int gm_hour = lctime->tm_hour;
- time_t gm_time = mktime(lctime);
- lctime = localtime(&current_time);
- int local_hour = lctime->tm_hour;
-
- int tzone_offset = local_hour - gm_hour;
- if (gm_time > current_time && gm_hour < local_hour) {
- // this means gm_time is on the next day
- tzone_offset -= 24;
- } else if (gm_time < current_time && gm_hour > local_hour) {
- // this means gm_time is on the previous day
- tzone_offset += 24;
- }
-
- tzone_offset *= 100;
- char buf[1024];
- // add todays year day and month to the time in str because
- // curl_getdate no longer assumes the day is today
- sprintf(buf, "%d%02d%02d %s %+05i", lctime->tm_year + 1900,
- lctime->tm_mon + 1, lctime->tm_mday,
- this->CTest->GetStopTime().c_str(), tzone_offset);
-
- time_t stop_time_t = curl_getdate(buf, &current_time);
- if (stop_time_t == -1) {
- return timeout;
- }
-
- auto stop_time = std::chrono::system_clock::from_time_t(stop_time_t);
-
- // the stop time refers to the next day
- if (this->CTest->NextDayStopTime) {
- stop_time += std::chrono::hours(24);
- }
- auto stop_timeout =
- (stop_time - std::chrono::system_clock::from_time_t(current_time)) %
- std::chrono::hours(24);
- this->CTest->LastStopTimeout = stop_timeout;
-
- if (stop_timeout <= std::chrono::duration<double>::zero() ||
- stop_timeout > this->CTest->LastStopTimeout) {
- cmCTestLog(this->CTest, ERROR_MESSAGE, "The stop time has been passed. "
- "Stopping all tests."
- << std::endl);
- this->StopTimePassed = true;
- return std::chrono::duration<double>::zero();
- }
- return timeout == std::chrono::duration<double>::zero()
- ? stop_timeout
- : (timeout < stop_timeout ? timeout : stop_timeout);
-}
-
bool cmCTestRunTest::ForkProcess(std::chrono::duration<double> testTimeOut,
bool explicitTimeout,
std::vector<std::string>* environment)
{
- this->TestProcess = new cmProcess;
+ this->TestProcess = cm::make_unique<cmProcess>(*this);
this->TestProcess->SetId(this->Index);
this->TestProcess->SetWorkingDirectory(
this->TestProperties->Directory.c_str());
@@ -720,7 +646,7 @@ bool cmCTestRunTest::ForkProcess(std::chrono::duration<double> testTimeOut,
cmSystemTools::AppendEnv(*environment);
}
- return this->TestProcess->StartProcess();
+ return this->TestProcess->StartProcess(this->MultiTestHandler.Loop);
}
void cmCTestRunTest::WriteLogOutputTop(size_t completed, size_t total)
@@ -794,3 +720,8 @@ void cmCTestRunTest::WriteLogOutputTop(size_t completed, size_t total)
cmCTestLog(this->CTest, DEBUG, "Testing " << this->TestProperties->Name
<< " ... ");
}
+
+void cmCTestRunTest::FinalizeTest()
+{
+ this->MultiTestHandler.FinishTestProcess(this, true);
+}
diff --git a/Source/CTest/cmCTestRunTest.h b/Source/CTest/cmCTestRunTest.h
index cd380ca..fbc202f 100644
--- a/Source/CTest/cmCTestRunTest.h
+++ b/Source/CTest/cmCTestRunTest.h
@@ -12,9 +12,10 @@
#include <vector>
#include "cmCTestTestHandler.h"
+#include "cmProcess.h" // IWYU pragma: keep (for unique_ptr)
class cmCTest;
-class cmProcess;
+class cmCTestMultiProcessHandler;
/** \class cmRunTest
* \brief represents a single test to be run
@@ -24,8 +25,9 @@ class cmProcess;
class cmCTestRunTest
{
public:
- cmCTestRunTest(cmCTestTestHandler* handler);
- ~cmCTestRunTest();
+ explicit cmCTestRunTest(cmCTestMultiProcessHandler& multiHandler);
+
+ ~cmCTestRunTest() = default;
void SetNumberOfRuns(int n) { this->NumberOfRunsLeft = n; }
void SetRunUntilFailOn() { this->RunUntilFail = true; }
@@ -50,15 +52,13 @@ public:
std::string GetProcessOutput() { return this->ProcessOutput; }
- bool IsStopTimePassed() { return this->StopTimePassed; }
-
cmCTestTestHandler::cmCTestTestResult GetTestResults()
{
return this->TestResult;
}
// Read and store output. Returns true if it must be called again.
- bool CheckOutput();
+ void CheckOutput(std::string const& line);
// Compresses the output, writing to CompressedOutput
void CompressOutput();
@@ -74,12 +74,14 @@ public:
bool StartAgain();
+ cmCTest* GetCTest() const { return this->CTest; }
+
+ void FinalizeTest();
+
private:
bool NeedsToRerun();
void DartProcessing();
void ExeNotFound(std::string exe);
- // Figures out a final timeout which is min(STOP_TIME, NOW+TIMEOUT)
- std::chrono::duration<double> ResolveTimeout();
bool ForkProcess(std::chrono::duration<double> testTimeOut,
bool explicitTimeout,
std::vector<std::string>* environment);
@@ -91,26 +93,18 @@ private:
// Pointer back to the "parent"; the handler that invoked this test run
cmCTestTestHandler* TestHandler;
cmCTest* CTest;
- cmProcess* TestProcess;
- // If the executable to run is ctest, don't create a new process;
- // just instantiate a new cmTest. (Can be disabled for a single test
- // if this option is set to false.)
- // bool OptimizeForCTest;
-
- bool UsePrefixCommand;
- std::string PrefixCommand;
-
+ std::unique_ptr<cmProcess> TestProcess;
std::string ProcessOutput;
std::string CompressedOutput;
double CompressionRatio;
// The test results
cmCTestTestHandler::cmCTestTestResult TestResult;
+ cmCTestMultiProcessHandler& MultiTestHandler;
int Index;
std::set<std::string> FailedDependencies;
std::string StartTime;
std::string ActualCommand;
std::vector<std::string> Arguments;
- bool StopTimePassed;
bool RunUntilFail;
int NumberOfRunsLeft;
bool RunAgain;
diff --git a/Source/CTest/cmParseMumpsCoverage.cxx b/Source/CTest/cmParseMumpsCoverage.cxx
index 1419743..18412ba 100644
--- a/Source/CTest/cmParseMumpsCoverage.cxx
+++ b/Source/CTest/cmParseMumpsCoverage.cxx
@@ -114,7 +114,7 @@ bool cmParseMumpsCoverage::LoadPackages(const char* d)
for (std::string& file : glob.GetFiles()) {
std::string name = cmSystemTools::GetFilenameName(file);
this->RoutineToDirectory[name.substr(0, name.size() - 2)] = file;
- // initialze each file, this is left out until CDash is fixed
+ // initialize each file, this is left out until CDash is fixed
// to handle large numbers of files
this->InitializeMumpsFile(file);
}
diff --git a/Source/CTest/cmProcess.cxx b/Source/CTest/cmProcess.cxx
index 0db66c3..c8806a7 100644
--- a/Source/CTest/cmProcess.cxx
+++ b/Source/CTest/cmProcess.cxx
@@ -2,12 +2,65 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmProcess.h"
+#include "cmCTest.h"
+#include "cmCTestRunTest.h"
+#include "cmCTestTestHandler.h"
#include "cmProcessOutput.h"
+#include "cmsys/Process.h"
+
+#include <algorithm>
+#include <fcntl.h>
#include <iostream>
+#include <signal.h>
+#include <stdint.h>
+#include <string>
+#if !defined(_WIN32)
+#include <unistd.h>
+#endif
+
+#if defined(_WIN32) && !defined(__CYGWIN__)
+#include <io.h>
+
+static int cmProcessGetPipes(int* fds)
+{
+ SECURITY_ATTRIBUTES attr;
+ HANDLE readh, writeh;
+ attr.nLength = sizeof(attr);
+ attr.lpSecurityDescriptor = nullptr;
+ attr.bInheritHandle = FALSE;
+ if (!CreatePipe(&readh, &writeh, &attr, 0))
+ return uv_translate_sys_error(GetLastError());
+ fds[0] = _open_osfhandle((intptr_t)readh, 0);
+ fds[1] = _open_osfhandle((intptr_t)writeh, 0);
+ if (fds[0] == -1 || fds[1] == -1) {
+ CloseHandle(readh);
+ CloseHandle(writeh);
+ return uv_translate_sys_error(GetLastError());
+ }
+ return 0;
+}
+#else
+#include <errno.h>
-cmProcess::cmProcess()
+static int cmProcessGetPipes(int* fds)
+{
+ if (pipe(fds) == -1) {
+ return uv_translate_sys_error(errno);
+ }
+
+ if (fcntl(fds[0], F_SETFD, FD_CLOEXEC) == -1 ||
+ fcntl(fds[1], F_SETFD, FD_CLOEXEC) == -1) {
+ close(fds[0]);
+ close(fds[1]);
+ return uv_translate_sys_error(errno);
+ }
+ return 0;
+}
+#endif
+
+cmProcess::cmProcess(cmCTestRunTest& runner)
+ : Runner(runner)
{
- this->Process = nullptr;
this->Timeout = std::chrono::duration<double>::zero();
this->TotalTime = std::chrono::duration<double>::zero();
this->ExitValue = 0;
@@ -17,8 +70,8 @@ cmProcess::cmProcess()
cmProcess::~cmProcess()
{
- cmsysProcess_Delete(this->Process);
}
+
void cmProcess::SetCommand(const char* command)
{
this->Command = command;
@@ -29,8 +82,9 @@ void cmProcess::SetCommandArguments(std::vector<std::string> const& args)
this->Arguments = args;
}
-bool cmProcess::StartProcess()
+bool cmProcess::StartProcess(uv_loop_t& loop)
{
+ this->ProcessState = cmProcess::State::Error;
if (this->Command.empty()) {
return false;
}
@@ -43,17 +97,83 @@ bool cmProcess::StartProcess()
this->ProcessArgs.push_back(arg.c_str());
}
this->ProcessArgs.push_back(nullptr); // null terminate the list
- this->Process = cmsysProcess_New();
- cmsysProcess_SetCommand(this->Process, &*this->ProcessArgs.begin());
- if (!this->WorkingDirectory.empty()) {
- cmsysProcess_SetWorkingDirectory(this->Process,
- this->WorkingDirectory.c_str());
+
+ cm::uv_timer_ptr timer;
+ int status = timer.init(loop, this);
+ if (status != 0) {
+ cmCTestLog(this->Runner.GetCTest(), ERROR_MESSAGE,
+ "Error initializing timer: " << uv_strerror(status)
+ << std::endl);
+ return false;
+ }
+
+ cm::uv_pipe_ptr pipe_writer;
+ cm::uv_pipe_ptr pipe_reader;
+
+ pipe_writer.init(loop, 0);
+ pipe_reader.init(loop, 0, this);
+
+ int fds[2] = { -1, -1 };
+ status = cmProcessGetPipes(fds);
+ if (status != 0) {
+ cmCTestLog(this->Runner.GetCTest(), ERROR_MESSAGE,
+ "Error initializing pipe: " << uv_strerror(status)
+ << std::endl);
+ return false;
+ }
+
+ uv_pipe_open(pipe_reader, fds[0]);
+ uv_pipe_open(pipe_writer, fds[1]);
+
+ uv_stdio_container_t stdio[3];
+ stdio[0].flags = UV_IGNORE;
+ stdio[1].flags = UV_INHERIT_STREAM;
+ stdio[1].data.stream = pipe_writer;
+ stdio[2] = stdio[1];
+
+ uv_process_options_t options = uv_process_options_t();
+ options.file = this->Command.data();
+ options.args = const_cast<char**>(this->ProcessArgs.data());
+ options.stdio_count = 3; // in, out and err
+ options.exit_cb = &cmProcess::OnExitCB;
+ options.stdio = stdio;
+
+ status =
+ uv_read_start(pipe_reader, &cmProcess::OnAllocateCB, &cmProcess::OnReadCB);
+
+ if (status != 0) {
+ cmCTestLog(this->Runner.GetCTest(), ERROR_MESSAGE,
+ "Error starting read events: " << uv_strerror(status)
+ << std::endl);
+ return false;
+ }
+
+ status = this->Process.spawn(loop, options, this);
+ if (status != 0) {
+ cmCTestLog(this->Runner.GetCTest(), ERROR_MESSAGE, "Process not started\n "
+ << this->Command << "\n[" << uv_strerror(status) << "]\n");
+ return false;
+ }
+
+ this->PipeReader = std::move(pipe_reader);
+ this->Timer = std::move(timer);
+
+ this->StartTimer();
+
+ this->ProcessState = cmProcess::State::Executing;
+ return true;
+}
+
+void cmProcess::StartTimer()
+{
+ auto properties = this->Runner.GetTestProperties();
+ auto msec =
+ std::chrono::duration_cast<std::chrono::milliseconds>(this->Timeout);
+
+ if (msec != std::chrono::milliseconds(0) || !properties->ExplicitTimeout) {
+ this->Timer.start(&cmProcess::OnTimeoutCB,
+ static_cast<uint64_t>(msec.count()), 0);
}
- cmsysProcess_SetTimeout(this->Process, this->Timeout.count());
- cmsysProcess_SetOption(this->Process, cmsysProcess_Option_MergeOutput, 1);
- cmsysProcess_Execute(this->Process);
- return (cmsysProcess_GetState(this->Process) ==
- cmsysProcess_State_Executing);
}
bool cmProcess::Buffer::GetLine(std::string& line)
@@ -100,51 +220,121 @@ bool cmProcess::Buffer::GetLast(std::string& line)
return false;
}
-int cmProcess::GetNextOutputLine(std::string& line,
- std::chrono::duration<double> timeout)
+void cmProcess::OnReadCB(uv_stream_t* stream, ssize_t nread,
+ const uv_buf_t* buf)
{
- cmProcessOutput processOutput(cmProcessOutput::UTF8);
- std::string strdata;
- double waitTimeout = timeout.count();
- for (;;) {
- // Look for lines already buffered.
- if (this->Output.GetLine(line)) {
- return cmsysProcess_Pipe_STDOUT;
- }
+ auto self = static_cast<cmProcess*>(stream->data);
+ self->OnRead(nread, buf);
+}
- // Check for more data from the process.
- char* data;
- int length;
- int p =
- cmsysProcess_WaitForData(this->Process, &data, &length, &waitTimeout);
- if (p == cmsysProcess_Pipe_Timeout) {
- return cmsysProcess_Pipe_Timeout;
- }
- if (p == cmsysProcess_Pipe_STDOUT) {
- processOutput.DecodeText(data, length, strdata);
- this->Output.insert(this->Output.end(), strdata.begin(), strdata.end());
- } else { // p == cmsysProcess_Pipe_None
- // The process will provide no more data.
- break;
+void cmProcess::OnRead(ssize_t nread, const uv_buf_t* buf)
+{
+ std::string line;
+ if (nread > 0) {
+ std::string strdata;
+ cmProcessOutput processOutput(cmProcessOutput::UTF8,
+ static_cast<unsigned int>(buf->len));
+ processOutput.DecodeText(buf->base, static_cast<size_t>(nread), strdata);
+ this->Output.insert(this->Output.end(), strdata.begin(), strdata.end());
+
+ while (this->Output.GetLine(line)) {
+ this->Runner.CheckOutput(line);
+ line.clear();
}
+
+ return;
}
- processOutput.DecodeText(std::string(), strdata);
- if (!strdata.empty()) {
- this->Output.insert(this->Output.end(), strdata.begin(), strdata.end());
+
+ // The process will provide no more data.
+ if (nread != UV_EOF) {
+ auto error = static_cast<int>(nread);
+ cmCTestLog(this->Runner.GetCTest(), ERROR_MESSAGE,
+ "Error reading stream: " << uv_strerror(error) << std::endl);
}
// Look for partial last lines.
if (this->Output.GetLast(line)) {
- return cmsysProcess_Pipe_STDOUT;
+ this->Runner.CheckOutput(line);
+ }
+
+ this->ReadHandleClosed = true;
+ if (this->ProcessHandleClosed) {
+ uv_timer_stop(this->Timer);
+ this->Runner.FinalizeTest();
+ }
+}
+
+void cmProcess::OnAllocateCB(uv_handle_t* handle, size_t suggested_size,
+ uv_buf_t* buf)
+{
+ auto self = static_cast<cmProcess*>(handle->data);
+ self->OnAllocate(suggested_size, buf);
+}
+
+void cmProcess::OnAllocate(size_t suggested_size, uv_buf_t* buf)
+{
+ if (this->Buf.size() < suggested_size) {
+ this->Buf.resize(suggested_size);
+ }
+
+ *buf =
+ uv_buf_init(this->Buf.data(), static_cast<unsigned int>(this->Buf.size()));
+}
+
+void cmProcess::OnTimeoutCB(uv_timer_t* timer)
+{
+ auto self = static_cast<cmProcess*>(timer->data);
+ self->OnTimeout();
+}
+
+void cmProcess::OnTimeout()
+{
+ if (this->ProcessState != cmProcess::State::Executing) {
+ return;
+ }
+ this->ProcessState = cmProcess::State::Expired;
+ bool const was_still_reading = !this->ReadHandleClosed;
+ if (!this->ReadHandleClosed) {
+ this->ReadHandleClosed = true;
+ this->PipeReader.reset();
+ }
+ if (!this->ProcessHandleClosed) {
+ // Kill the child and let our on-exit handler finish the test.
+ cmsysProcess_KillPID(static_cast<unsigned long>(this->Process->pid));
+ } else if (was_still_reading) {
+ // Our on-exit handler already ran but did not finish the test
+ // because we were still reading output. We've just dropped
+ // our read handler, so we need to finish the test now.
+ this->Runner.FinalizeTest();
}
+}
- // No more data. Wait for process exit.
- if (!cmsysProcess_WaitForExit(this->Process, &waitTimeout)) {
- return cmsysProcess_Pipe_Timeout;
+void cmProcess::OnExitCB(uv_process_t* process, int64_t exit_status,
+ int term_signal)
+{
+ auto self = static_cast<cmProcess*>(process->data);
+ self->OnExit(exit_status, term_signal);
+}
+
+void cmProcess::OnExit(int64_t exit_status, int term_signal)
+{
+ if (this->ProcessState != cmProcess::State::Expired) {
+ if (
+#if defined(_WIN32)
+ ((DWORD)exit_status & 0xF0000000) == 0xC0000000
+#else
+ term_signal != 0
+#endif
+ ) {
+ this->ProcessState = cmProcess::State::Exception;
+ } else {
+ this->ProcessState = cmProcess::State::Exited;
+ }
}
// Record exit information.
- this->ExitValue = cmsysProcess_GetExitValue(this->Process);
+ this->ExitValue = static_cast<int>(exit_status);
+ this->Signal = term_signal;
this->TotalTime = std::chrono::steady_clock::now() - this->StartTime;
// Because of a processor clock scew the runtime may become slightly
// negative. If someone changed the system clock while the process was
@@ -153,95 +343,373 @@ int cmProcess::GetNextOutputLine(std::string& line,
if (this->TotalTime <= std::chrono::duration<double>::zero()) {
this->TotalTime = std::chrono::duration<double>::zero();
}
- // std::cerr << "Time to run: " << this->TotalTime << "\n";
- return cmsysProcess_Pipe_None;
-}
-
-// return the process status
-int cmProcess::GetProcessStatus()
-{
- if (!this->Process) {
- return cmsysProcess_State_Exited;
- }
- return cmsysProcess_GetState(this->Process);
-}
-
-int cmProcess::ReportStatus()
-{
- int result = 1;
- switch (cmsysProcess_GetState(this->Process)) {
- case cmsysProcess_State_Starting: {
- std::cerr << "cmProcess: Never started " << this->Command
- << " process.\n";
- } break;
- case cmsysProcess_State_Error: {
- std::cerr << "cmProcess: Error executing " << this->Command
- << " process: " << cmsysProcess_GetErrorString(this->Process)
- << "\n";
- } break;
- case cmsysProcess_State_Exception: {
- std::cerr << "cmProcess: " << this->Command
- << " process exited with an exception: ";
- switch (cmsysProcess_GetExitException(this->Process)) {
- case cmsysProcess_Exception_None: {
- std::cerr << "None";
- } break;
- case cmsysProcess_Exception_Fault: {
- std::cerr << "Segmentation fault";
- } break;
- case cmsysProcess_Exception_Illegal: {
- std::cerr << "Illegal instruction";
- } break;
- case cmsysProcess_Exception_Interrupt: {
- std::cerr << "Interrupted by user";
- } break;
- case cmsysProcess_Exception_Numerical: {
- std::cerr << "Numerical exception";
- } break;
- case cmsysProcess_Exception_Other: {
- std::cerr << "Unknown";
- } break;
- }
- std::cerr << "\n";
- } break;
- case cmsysProcess_State_Executing: {
- std::cerr << "cmProcess: Never terminated " << this->Command
- << " process.\n";
- } break;
- case cmsysProcess_State_Exited: {
- result = cmsysProcess_GetExitValue(this->Process);
- std::cerr << "cmProcess: " << this->Command
- << " process exited with code " << result << "\n";
- } break;
- case cmsysProcess_State_Expired: {
- std::cerr << "cmProcess: killed " << this->Command
- << " process due to timeout.\n";
- } break;
- case cmsysProcess_State_Killed: {
- std::cerr << "cmProcess: killed " << this->Command << " process.\n";
- } break;
- }
- return result;
+
+ this->ProcessHandleClosed = true;
+ if (this->ReadHandleClosed) {
+ uv_timer_stop(this->Timer);
+ this->Runner.FinalizeTest();
+ }
+}
+
+cmProcess::State cmProcess::GetProcessStatus()
+{
+ return this->ProcessState;
}
void cmProcess::ChangeTimeout(std::chrono::duration<double> t)
{
this->Timeout = t;
- cmsysProcess_SetTimeout(this->Process, this->Timeout.count());
+ this->StartTimer();
}
void cmProcess::ResetStartTime()
{
- cmsysProcess_ResetStartTime(this->Process);
this->StartTime = std::chrono::steady_clock::now();
}
-int cmProcess::GetExitException()
+cmProcess::Exception cmProcess::GetExitException()
{
- return cmsysProcess_GetExitException(this->Process);
+ auto exception = Exception::None;
+#if defined(_WIN32) && !defined(__CYGWIN__)
+ auto exit_code = (DWORD) this->ExitValue;
+ if ((exit_code & 0xF0000000) != 0xC0000000) {
+ return exception;
+ }
+
+ if (exit_code) {
+ switch (exit_code) {
+ case STATUS_DATATYPE_MISALIGNMENT:
+ case STATUS_ACCESS_VIOLATION:
+ case STATUS_IN_PAGE_ERROR:
+ case STATUS_INVALID_HANDLE:
+ case STATUS_NONCONTINUABLE_EXCEPTION:
+ case STATUS_INVALID_DISPOSITION:
+ case STATUS_ARRAY_BOUNDS_EXCEEDED:
+ case STATUS_STACK_OVERFLOW:
+ exception = Exception::Fault;
+ break;
+ case STATUS_FLOAT_DENORMAL_OPERAND:
+ case STATUS_FLOAT_DIVIDE_BY_ZERO:
+ case STATUS_FLOAT_INEXACT_RESULT:
+ case STATUS_FLOAT_INVALID_OPERATION:
+ case STATUS_FLOAT_OVERFLOW:
+ case STATUS_FLOAT_STACK_CHECK:
+ case STATUS_FLOAT_UNDERFLOW:
+#ifdef STATUS_FLOAT_MULTIPLE_FAULTS
+ case STATUS_FLOAT_MULTIPLE_FAULTS:
+#endif
+#ifdef STATUS_FLOAT_MULTIPLE_TRAPS
+ case STATUS_FLOAT_MULTIPLE_TRAPS:
+#endif
+ case STATUS_INTEGER_DIVIDE_BY_ZERO:
+ case STATUS_INTEGER_OVERFLOW:
+ exception = Exception::Numerical;
+ break;
+ case STATUS_CONTROL_C_EXIT:
+ exception = Exception::Interrupt;
+ break;
+ case STATUS_ILLEGAL_INSTRUCTION:
+ case STATUS_PRIVILEGED_INSTRUCTION:
+ exception = Exception::Illegal;
+ break;
+ default:
+ exception = Exception::Other;
+ }
+ }
+#else
+ if (this->Signal) {
+ switch (this->Signal) {
+ case SIGSEGV:
+ exception = Exception::Fault;
+ break;
+ case SIGFPE:
+ exception = Exception::Numerical;
+ break;
+ case SIGINT:
+ exception = Exception::Interrupt;
+ break;
+ case SIGILL:
+ exception = Exception::Illegal;
+ break;
+ default:
+ exception = Exception::Other;
+ }
+ }
+#endif
+ return exception;
}
std::string cmProcess::GetExitExceptionString()
{
- return cmsysProcess_GetExceptionString(this->Process);
+ std::string exception_str;
+#if defined(_WIN32)
+ switch (this->ExitValue) {
+ case STATUS_CONTROL_C_EXIT:
+ exception_str = "User interrupt";
+ break;
+ case STATUS_FLOAT_DENORMAL_OPERAND:
+ exception_str = "Floating-point exception (denormal operand)";
+ break;
+ case STATUS_FLOAT_DIVIDE_BY_ZERO:
+ exception_str = "Divide-by-zero";
+ break;
+ case STATUS_FLOAT_INEXACT_RESULT:
+ exception_str = "Floating-point exception (inexact result)";
+ break;
+ case STATUS_FLOAT_INVALID_OPERATION:
+ exception_str = "Invalid floating-point operation";
+ break;
+ case STATUS_FLOAT_OVERFLOW:
+ exception_str = "Floating-point overflow";
+ break;
+ case STATUS_FLOAT_STACK_CHECK:
+ exception_str = "Floating-point stack check failed";
+ break;
+ case STATUS_FLOAT_UNDERFLOW:
+ exception_str = "Floating-point underflow";
+ break;
+#ifdef STATUS_FLOAT_MULTIPLE_FAULTS
+ case STATUS_FLOAT_MULTIPLE_FAULTS:
+ exception_str = "Floating-point exception (multiple faults)";
+ break;
+#endif
+#ifdef STATUS_FLOAT_MULTIPLE_TRAPS
+ case STATUS_FLOAT_MULTIPLE_TRAPS:
+ exception_str = "Floating-point exception (multiple traps)";
+ break;
+#endif
+ case STATUS_INTEGER_DIVIDE_BY_ZERO:
+ exception_str = "Integer divide-by-zero";
+ break;
+ case STATUS_INTEGER_OVERFLOW:
+ exception_str = "Integer overflow";
+ break;
+
+ case STATUS_DATATYPE_MISALIGNMENT:
+ exception_str = "Datatype misalignment";
+ break;
+ case STATUS_ACCESS_VIOLATION:
+ exception_str = "Access violation";
+ break;
+ case STATUS_IN_PAGE_ERROR:
+ exception_str = "In-page error";
+ break;
+ case STATUS_INVALID_HANDLE:
+ exception_str = "Invalid handle";
+ break;
+ case STATUS_NONCONTINUABLE_EXCEPTION:
+ exception_str = "Noncontinuable exception";
+ break;
+ case STATUS_INVALID_DISPOSITION:
+ exception_str = "Invalid disposition";
+ break;
+ case STATUS_ARRAY_BOUNDS_EXCEEDED:
+ exception_str = "Array bounds exceeded";
+ break;
+ case STATUS_STACK_OVERFLOW:
+ exception_str = "Stack overflow";
+ break;
+
+ case STATUS_ILLEGAL_INSTRUCTION:
+ exception_str = "Illegal instruction";
+ break;
+ case STATUS_PRIVILEGED_INSTRUCTION:
+ exception_str = "Privileged instruction";
+ break;
+ case STATUS_NO_MEMORY:
+ default:
+ char buf[1024];
+ _snprintf(buf, 1024, "Exit code 0x%x\n", this->ExitValue);
+ exception_str.assign(buf);
+ }
+#else
+ switch (this->Signal) {
+#ifdef SIGSEGV
+ case SIGSEGV:
+ exception_str = "Segmentation fault";
+ break;
+#endif
+#ifdef SIGBUS
+#if !defined(SIGSEGV) || SIGBUS != SIGSEGV
+ case SIGBUS:
+ exception_str = "Bus error";
+ break;
+#endif
+#endif
+#ifdef SIGFPE
+ case SIGFPE:
+ exception_str = "Floating-point exception";
+ break;
+#endif
+#ifdef SIGILL
+ case SIGILL:
+ exception_str = "Illegal instruction";
+ break;
+#endif
+#ifdef SIGINT
+ case SIGINT:
+ exception_str = "User interrupt";
+ break;
+#endif
+#ifdef SIGABRT
+ case SIGABRT:
+ exception_str = "Child aborted";
+ break;
+#endif
+#ifdef SIGKILL
+ case SIGKILL:
+ exception_str = "Child killed";
+ break;
+#endif
+#ifdef SIGTERM
+ case SIGTERM:
+ exception_str = "Child terminated";
+ break;
+#endif
+#ifdef SIGHUP
+ case SIGHUP:
+ exception_str = "SIGHUP";
+ break;
+#endif
+#ifdef SIGQUIT
+ case SIGQUIT:
+ exception_str = "SIGQUIT";
+ break;
+#endif
+#ifdef SIGTRAP
+ case SIGTRAP:
+ exception_str = "SIGTRAP";
+ break;
+#endif
+#ifdef SIGIOT
+#if !defined(SIGABRT) || SIGIOT != SIGABRT
+ case SIGIOT:
+ exception_str = "SIGIOT";
+ break;
+#endif
+#endif
+#ifdef SIGUSR1
+ case SIGUSR1:
+ exception_str = "SIGUSR1";
+ break;
+#endif
+#ifdef SIGUSR2
+ case SIGUSR2:
+ exception_str = "SIGUSR2";
+ break;
+#endif
+#ifdef SIGPIPE
+ case SIGPIPE:
+ exception_str = "SIGPIPE";
+ break;
+#endif
+#ifdef SIGALRM
+ case SIGALRM:
+ exception_str = "SIGALRM";
+ break;
+#endif
+#ifdef SIGSTKFLT
+ case SIGSTKFLT:
+ exception_str = "SIGSTKFLT";
+ break;
+#endif
+#ifdef SIGCHLD
+ case SIGCHLD:
+ exception_str = "SIGCHLD";
+ break;
+#elif defined(SIGCLD)
+ case SIGCLD:
+ exception_str = "SIGCLD";
+ break;
+#endif
+#ifdef SIGCONT
+ case SIGCONT:
+ exception_str = "SIGCONT";
+ break;
+#endif
+#ifdef SIGSTOP
+ case SIGSTOP:
+ exception_str = "SIGSTOP";
+ break;
+#endif
+#ifdef SIGTSTP
+ case SIGTSTP:
+ exception_str = "SIGTSTP";
+ break;
+#endif
+#ifdef SIGTTIN
+ case SIGTTIN:
+ exception_str = "SIGTTIN";
+ break;
+#endif
+#ifdef SIGTTOU
+ case SIGTTOU:
+ exception_str = "SIGTTOU";
+ break;
+#endif
+#ifdef SIGURG
+ case SIGURG:
+ exception_str = "SIGURG";
+ break;
+#endif
+#ifdef SIGXCPU
+ case SIGXCPU:
+ exception_str = "SIGXCPU";
+ break;
+#endif
+#ifdef SIGXFSZ
+ case SIGXFSZ:
+ exception_str = "SIGXFSZ";
+ break;
+#endif
+#ifdef SIGVTALRM
+ case SIGVTALRM:
+ exception_str = "SIGVTALRM";
+ break;
+#endif
+#ifdef SIGPROF
+ case SIGPROF:
+ exception_str = "SIGPROF";
+ break;
+#endif
+#ifdef SIGWINCH
+ case SIGWINCH:
+ exception_str = "SIGWINCH";
+ break;
+#endif
+#ifdef SIGPOLL
+ case SIGPOLL:
+ exception_str = "SIGPOLL";
+ break;
+#endif
+#ifdef SIGIO
+#if !defined(SIGPOLL) || SIGIO != SIGPOLL
+ case SIGIO:
+ exception_str = "SIGIO";
+ break;
+#endif
+#endif
+#ifdef SIGPWR
+ case SIGPWR:
+ exception_str = "SIGPWR";
+ break;
+#endif
+#ifdef SIGSYS
+ case SIGSYS:
+ exception_str = "SIGSYS";
+ break;
+#endif
+#ifdef SIGUNUSED
+#if !defined(SIGSYS) || SIGUNUSED != SIGSYS
+ case SIGUNUSED:
+ exception_str = "SIGUNUSED";
+ break;
+#endif
+#endif
+ default:
+ exception_str = "Signal ";
+ exception_str += std::to_string(this->Signal);
+ }
+#endif
+ return exception_str;
}
diff --git a/Source/CTest/cmProcess.h b/Source/CTest/cmProcess.h
index f3b0bd7..9250896 100644
--- a/Source/CTest/cmProcess.h
+++ b/Source/CTest/cmProcess.h
@@ -5,11 +5,17 @@
#include "cmConfigure.h" // IWYU pragma: keep
-#include "cmsys/Process.h"
+#include "cmUVHandlePtr.h"
+#include "cm_uv.h"
+
#include <chrono>
+#include <stddef.h>
#include <string>
+#include <sys/types.h>
#include <vector>
+class cmCTestRunTest;
+
/** \class cmProcess
* \brief run a process with c++
*
@@ -18,7 +24,7 @@
class cmProcess
{
public:
- cmProcess();
+ explicit cmProcess(cmCTestRunTest& runner);
~cmProcess();
const char* GetCommand() { return this->Command.c_str(); }
void SetCommand(const char* command);
@@ -28,33 +34,70 @@ public:
void ChangeTimeout(std::chrono::duration<double> t);
void ResetStartTime();
// Return true if the process starts
- bool StartProcess();
+ bool StartProcess(uv_loop_t& loop);
+
+ enum class State
+ {
+ Starting,
+ Error,
+ Exception,
+ Executing,
+ Exited,
+ Expired,
+ Killed,
+ Disowned
+ };
- // return the process status
- int GetProcessStatus();
- // Report the status of the program
- int ReportStatus();
+ State GetProcessStatus();
int GetId() { return this->Id; }
void SetId(int id) { this->Id = id; }
int GetExitValue() { return this->ExitValue; }
std::chrono::duration<double> GetTotalTime() { return this->TotalTime; }
- int GetExitException();
+
+ enum class Exception
+ {
+ None,
+ Fault,
+ Illegal,
+ Interrupt,
+ Numerical,
+ Other
+ };
+
+ Exception GetExitException();
std::string GetExitExceptionString();
- /**
- * Read one line of output but block for no more than timeout.
- * Returns:
- * cmsysProcess_Pipe_None = Process terminated and all output read
- * cmsysProcess_Pipe_STDOUT = Line came from stdout or stderr
- * cmsysProcess_Pipe_Timeout = Timeout expired while waiting
- */
- int GetNextOutputLine(std::string& line,
- std::chrono::duration<double> timeout);
private:
std::chrono::duration<double> Timeout;
std::chrono::steady_clock::time_point StartTime;
std::chrono::duration<double> TotalTime;
- cmsysProcess* Process;
+ bool ReadHandleClosed = false;
+ bool ProcessHandleClosed = false;
+
+ cm::uv_process_ptr Process;
+ cm::uv_pipe_ptr PipeReader;
+ cm::uv_timer_ptr Timer;
+ std::vector<char> Buf;
+
+ cmCTestRunTest& Runner;
+ int Signal = 0;
+ cmProcess::State ProcessState = cmProcess::State::Starting;
+
+ static void OnExitCB(uv_process_t* process, int64_t exit_status,
+ int term_signal);
+ static void OnTimeoutCB(uv_timer_t* timer);
+ static void OnReadCB(uv_stream_t* stream, ssize_t nread,
+ const uv_buf_t* buf);
+ static void OnAllocateCB(uv_handle_t* handle, size_t suggested_size,
+ uv_buf_t* buf);
+
+ void OnExit(int64_t exit_status, int term_signal);
+ void OnTimeout();
+ void OnRead(ssize_t nread, const uv_buf_t* buf);
+ void OnAllocate(size_t suggested_size, uv_buf_t* buf);
+
+ void StartTimer();
+
class Buffer : public std::vector<char>
{
// Half-open index range of partial line already scanned.
diff --git a/Source/Checks/cm_cxx14_check.cmake b/Source/Checks/cm_cxx14_check.cmake
new file mode 100644
index 0000000..a78ba35
--- /dev/null
+++ b/Source/Checks/cm_cxx14_check.cmake
@@ -0,0 +1,36 @@
+set(CMake_CXX14_BROKEN 0)
+if(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")
+ if(NOT CMAKE_CXX14_STANDARD_COMPILE_OPTION)
+ set(CMake_CXX14_WORKS 0)
+ endif()
+ if(NOT DEFINED CMake_CXX14_WORKS)
+ message(STATUS "Checking if compiler supports needed C++14 constructs")
+ try_compile(CMake_CXX14_WORKS
+ ${CMAKE_CURRENT_BINARY_DIR}
+ ${CMAKE_CURRENT_LIST_DIR}/cm_cxx14_check.cpp
+ CMAKE_FLAGS -DCMAKE_CXX_STANDARD=14
+ OUTPUT_VARIABLE OUTPUT
+ )
+ if(CMake_CXX14_WORKS AND "${OUTPUT}" MATCHES "error: no member named.*gets.*in the global namespace")
+ set_property(CACHE CMake_CXX14_WORKS PROPERTY VALUE 0)
+ endif()
+ if(CMake_CXX14_WORKS)
+ message(STATUS "Checking if compiler supports needed C++14 constructs - yes")
+ file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
+ "Determining if compiler supports needed C++14 constructs passed with the following output:\n"
+ "${OUTPUT}\n"
+ "\n"
+ )
+ else()
+ message(STATUS "Checking if compiler supports needed C++14 constructs - no")
+ file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
+ "Determining if compiler supports needed C++14 constructs failed with the following output:\n"
+ "${OUTPUT}\n"
+ "\n"
+ )
+ endif()
+ endif()
+ if(NOT CMake_CXX14_WORKS)
+ set(CMake_CXX14_BROKEN 1)
+ endif()
+endif()
diff --git a/Source/Checks/cm_cxx14_cstdio.cpp b/Source/Checks/cm_cxx14_check.cpp
index f5806a9..f5806a9 100644
--- a/Source/Checks/cm_cxx14_cstdio.cpp
+++ b/Source/Checks/cm_cxx14_check.cpp
diff --git a/Source/Checks/cm_cxx14_cstdio.cmake b/Source/Checks/cm_cxx14_cstdio.cmake
deleted file mode 100644
index 73f7e2e..0000000
--- a/Source/Checks/cm_cxx14_cstdio.cmake
+++ /dev/null
@@ -1,33 +0,0 @@
-set(CMake_CXX14_CSTDIO_BROKEN 0)
-if(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang" AND CMAKE_CXX14_STANDARD_COMPILE_OPTION)
- if(NOT DEFINED CMake_CXX14_CSTDIO_WORKS)
- message(STATUS "Checking if compiler supports C++14 cstdio")
- try_compile(CMake_CXX14_CSTDIO_WORKS
- ${CMAKE_CURRENT_BINARY_DIR}
- ${CMAKE_CURRENT_LIST_DIR}/cm_cxx14_cstdio.cpp
- CMAKE_FLAGS -DCMAKE_CXX_STANDARD=14
- OUTPUT_VARIABLE OUTPUT
- )
- if(CMake_CXX14_CSTDIO_WORKS AND "${OUTPUT}" MATCHES "error: no member named.*gets.*in the global namespace")
- set_property(CACHE CMake_CXX14_CSTDIO_WORKS PROPERTY VALUE 0)
- endif()
- if(CMake_CXX14_CSTDIO_WORKS)
- message(STATUS "Checking if compiler supports C++14 cstdio - yes")
- file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
- "Determining if compiler supports C++14 cstdio passed with the following output:\n"
- "${OUTPUT}\n"
- "\n"
- )
- else()
- message(STATUS "Checking if compiler supports C++14 cstdio - no")
- file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
- "Determining if compiler supports C++14 cstdio failed with the following output:\n"
- "${OUTPUT}\n"
- "\n"
- )
- endif()
- endif()
- if(NOT CMake_CXX14_CSTDIO_WORKS)
- set(CMake_CXX14_CSTDIO_BROKEN 1)
- endif()
-endif()
diff --git a/Source/Checks/cm_cxx17_check.cmake b/Source/Checks/cm_cxx17_check.cmake
new file mode 100644
index 0000000..83d3971
--- /dev/null
+++ b/Source/Checks/cm_cxx17_check.cmake
@@ -0,0 +1,36 @@
+set(CMake_CXX17_BROKEN 0)
+if(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")
+ if(NOT CMAKE_CXX17_STANDARD_COMPILE_OPTION)
+ set(CMake_CXX17_WORKS 0)
+ endif()
+ if(NOT DEFINED CMake_CXX17_WORKS)
+ message(STATUS "Checking if compiler supports needed C++17 constructs")
+ try_compile(CMake_CXX17_WORKS
+ ${CMAKE_CURRENT_BINARY_DIR}
+ ${CMAKE_CURRENT_LIST_DIR}/cm_cxx17_check.cpp
+ CMAKE_FLAGS -DCMAKE_CXX_STANDARD=17
+ OUTPUT_VARIABLE OUTPUT
+ )
+ if(CMake_CXX17_WORKS AND "${OUTPUT}" MATCHES "error: no member named.*gets.*in the global namespace")
+ set_property(CACHE CMake_CXX17_WORKS PROPERTY VALUE 0)
+ endif()
+ if(CMake_CXX17_WORKS)
+ message(STATUS "Checking if compiler supports needed C++17 constructs - yes")
+ file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
+ "Determining if compiler supports needed C++17 constructs passed with the following output:\n"
+ "${OUTPUT}\n"
+ "\n"
+ )
+ else()
+ message(STATUS "Checking if compiler supports needed C++17 constructs - no")
+ file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
+ "Determining if compiler supports needed C++17 constructs failed with the following output:\n"
+ "${OUTPUT}\n"
+ "\n"
+ )
+ endif()
+ endif()
+ if(NOT CMake_CXX17_WORKS)
+ set(CMake_CXX17_BROKEN 1)
+ endif()
+endif()
diff --git a/Source/Checks/cm_cxx17_check.cpp b/Source/Checks/cm_cxx17_check.cpp
new file mode 100644
index 0000000..2cbf1d5
--- /dev/null
+++ b/Source/Checks/cm_cxx17_check.cpp
@@ -0,0 +1,7 @@
+#include <cstdio>
+#include <unordered_map>
+
+int main()
+{
+ return 0;
+}
diff --git a/Source/CursesDialog/CMakeLists.txt b/Source/CursesDialog/CMakeLists.txt
index 6023c83..c51b0dd 100644
--- a/Source/CursesDialog/CMakeLists.txt
+++ b/Source/CursesDialog/CMakeLists.txt
@@ -2,19 +2,19 @@
# file Copyright.txt or https://cmake.org/licensing for details.
set( CURSES_SRCS
- CursesDialog/cmCursesOptionsWidget
- CursesDialog/cmCursesBoolWidget
- CursesDialog/cmCursesCacheEntryComposite
- CursesDialog/cmCursesDummyWidget
- CursesDialog/cmCursesFilePathWidget
- CursesDialog/cmCursesForm
- CursesDialog/cmCursesLabelWidget
- CursesDialog/cmCursesLongMessageForm
- CursesDialog/cmCursesMainForm
- CursesDialog/cmCursesPathWidget
- CursesDialog/cmCursesStringWidget
- CursesDialog/cmCursesWidget
- CursesDialog/ccmake
+ CursesDialog/cmCursesOptionsWidget.cxx
+ CursesDialog/cmCursesBoolWidget.cxx
+ CursesDialog/cmCursesCacheEntryComposite.cxx
+ CursesDialog/cmCursesDummyWidget.cxx
+ CursesDialog/cmCursesFilePathWidget.cxx
+ CursesDialog/cmCursesForm.cxx
+ CursesDialog/cmCursesLabelWidget.cxx
+ CursesDialog/cmCursesLongMessageForm.cxx
+ CursesDialog/cmCursesMainForm.cxx
+ CursesDialog/cmCursesPathWidget.cxx
+ CursesDialog/cmCursesStringWidget.cxx
+ CursesDialog/cmCursesWidget.cxx
+ CursesDialog/ccmake.cxx
)
include_directories(${CURSES_INCLUDE_PATH})
diff --git a/Source/QtDialog/CMakeLists.txt b/Source/QtDialog/CMakeLists.txt
index b38797b..06d13ba 100644
--- a/Source/QtDialog/CMakeLists.txt
+++ b/Source/QtDialog/CMakeLists.txt
@@ -40,7 +40,7 @@ if (Qt5Widgets_FOUND)
endif()
# We need to install platform plugin and add qt.conf for Qt5 on Mac and Windows.
- # FIXME: This should be part of Qt5 CMake scripts, but unfortunatelly
+ # FIXME: This should be part of Qt5 CMake scripts, but unfortunately
# Qt5 support is missing there.
if(CMake_INSTALL_DEPENDENCIES AND (APPLE OR WIN32))
macro(install_qt5_plugin _qt_plugin_name _qt_plugins_var)
diff --git a/Source/cmCTest.cxx b/Source/cmCTest.cxx
index 26e1dcb..fd7c5e8 100644
--- a/Source/cmCTest.cxx
+++ b/Source/cmCTest.cxx
@@ -279,11 +279,8 @@ cmCTest::cmCTest()
this->InteractiveDebugMode = true;
this->TimeOut = std::chrono::duration<double>::zero();
this->GlobalTimeout = std::chrono::duration<double>::zero();
- this->LastStopTimeout = std::chrono::hours(24);
this->CompressXMLFiles = false;
this->ScheduleType.clear();
- this->StopTime.clear();
- this->NextDayStopTime = false;
this->OutputLogFile = nullptr;
this->OutputLogFileLastTag = -1;
this->SuppressUpdatingCTestConfiguration = false;
@@ -2269,10 +2266,41 @@ void cmCTest::SetNotesFiles(const char* notes)
this->NotesFiles = notes;
}
-void cmCTest::SetStopTime(std::string const& time)
+void cmCTest::SetStopTime(std::string const& time_str)
{
- this->StopTime = time;
- this->DetermineNextDayStop();
+
+ struct tm* lctime;
+ time_t current_time = time(nullptr);
+ lctime = gmtime(&current_time);
+ int gm_hour = lctime->tm_hour;
+ time_t gm_time = mktime(lctime);
+ lctime = localtime(&current_time);
+ int local_hour = lctime->tm_hour;
+
+ int tzone_offset = local_hour - gm_hour;
+ if (gm_time > current_time && gm_hour < local_hour) {
+ // this means gm_time is on the next day
+ tzone_offset -= 24;
+ } else if (gm_time < current_time && gm_hour > local_hour) {
+ // this means gm_time is on the previous day
+ tzone_offset += 24;
+ }
+
+ tzone_offset *= 100;
+ char buf[1024];
+ sprintf(buf, "%d%02d%02d %s %+05i", lctime->tm_year + 1900,
+ lctime->tm_mon + 1, lctime->tm_mday, time_str.c_str(), tzone_offset);
+
+ time_t stop_time = curl_getdate(buf, &current_time);
+ if (stop_time == -1) {
+ this->StopTime = std::chrono::system_clock::time_point();
+ return;
+ }
+ this->StopTime = std::chrono::system_clock::from_time_t(stop_time);
+
+ if (stop_time < current_time) {
+ this->StopTime += std::chrono::hours(24);
+ }
}
int cmCTest::ReadCustomConfigurationFileTree(const char* dir, cmMakefile* mf)
@@ -2430,38 +2458,6 @@ void cmCTest::EmptyCTestConfiguration()
this->CTestConfiguration.clear();
}
-void cmCTest::DetermineNextDayStop()
-{
- struct tm* lctime;
- time_t current_time = time(nullptr);
- lctime = gmtime(&current_time);
- int gm_hour = lctime->tm_hour;
- time_t gm_time = mktime(lctime);
- lctime = localtime(&current_time);
- int local_hour = lctime->tm_hour;
-
- int tzone_offset = local_hour - gm_hour;
- if (gm_time > current_time && gm_hour < local_hour) {
- // this means gm_time is on the next day
- tzone_offset -= 24;
- } else if (gm_time < current_time && gm_hour > local_hour) {
- // this means gm_time is on the previous day
- tzone_offset += 24;
- }
-
- tzone_offset *= 100;
- char buf[1024];
- sprintf(buf, "%d%02d%02d %s %+05i", lctime->tm_year + 1900,
- lctime->tm_mon + 1, lctime->tm_mday, this->StopTime.c_str(),
- tzone_offset);
-
- time_t stop_time = curl_getdate(buf, &current_time);
-
- if (stop_time < current_time) {
- this->NextDayStopTime = true;
- }
-}
-
void cmCTest::SetCTestConfiguration(const char* name, const char* value,
bool suppress)
{
diff --git a/Source/cmCTest.h b/Source/cmCTest.h
index 23d71cb..61487f1 100644
--- a/Source/cmCTest.h
+++ b/Source/cmCTest.h
@@ -226,7 +226,10 @@ public:
bool ShouldCompressTestOutput();
bool CompressString(std::string& str);
- std::string GetStopTime() { return this->StopTime; }
+ std::chrono::system_clock::time_point GetStopTime()
+ {
+ return this->StopTime;
+ }
void SetStopTime(std::string const& time);
/** Used for parallel ctest job scheduling */
@@ -464,8 +467,7 @@ private:
bool RepeatUntilFail;
std::string ConfigType;
std::string ScheduleType;
- std::string StopTime;
- bool NextDayStopTime;
+ std::chrono::system_clock::time_point StopTime;
bool Verbose;
bool ExtraVerbose;
bool ProduceXML;
@@ -481,8 +483,6 @@ private:
int GenerateNotesFile(const char* files);
- void DetermineNextDayStop();
-
// these are helper classes
typedef std::map<std::string, cmCTestGenericHandler*> t_TestingHandlers;
t_TestingHandlers TestingHandlers;
@@ -512,8 +512,6 @@ private:
std::chrono::duration<double> GlobalTimeout;
- std::chrono::duration<double> LastStopTimeout;
-
int MaxTestNameWidth;
int ParallelLevel;
diff --git a/Source/cmCommands.cxx b/Source/cmCommands.cxx
index 8a7d9bd..a1de8b1 100644
--- a/Source/cmCommands.cxx
+++ b/Source/cmCommands.cxx
@@ -343,7 +343,7 @@ void GetProjectCommandsInScriptMode(cmState* state)
CM_UNEXPECTED_PROJECT_COMMAND("try_compile");
CM_UNEXPECTED_PROJECT_COMMAND("try_run");
- // deprected commands
+ // deprecated commands
CM_UNEXPECTED_PROJECT_COMMAND("export_library_dependencies");
CM_UNEXPECTED_PROJECT_COMMAND("load_command");
CM_UNEXPECTED_PROJECT_COMMAND("output_required_files");
diff --git a/Source/cmDependsFortran.cxx b/Source/cmDependsFortran.cxx
index 23f622b..25d78c4 100644
--- a/Source/cmDependsFortran.cxx
+++ b/Source/cmDependsFortran.cxx
@@ -583,7 +583,7 @@ bool cmDependsFortran::ModulesDiffer(const char* modFile,
A mod file is a binary file.
However, looking into both generated bar.mod files with a hex editor
shows that they differ only before a sequence linefeed-zero (0x0A 0x00)
- which is located some bytes in front of the absoulte path to the source
+ which is located some bytes in front of the absolute path to the source
file.
sun:
diff --git a/Source/cmDependsFortran.h b/Source/cmDependsFortran.h
index ccf267b..bee9804 100644
--- a/Source/cmDependsFortran.h
+++ b/Source/cmDependsFortran.h
@@ -64,7 +64,7 @@ protected:
const std::string& file, std::ostream& makeDepends,
std::ostream& internalDepends) override;
- // Actually write the depenencies to the streams.
+ // Actually write the dependencies to the streams.
bool WriteDependenciesReal(const char* obj, cmFortranSourceInfo const& info,
std::string const& mod_dir, const char* stamp_dir,
std::ostream& makeDepends,
diff --git a/Source/cmExportInstallAndroidMKGenerator.h b/Source/cmExportInstallAndroidMKGenerator.h
index 3165982..91554ee 100644
--- a/Source/cmExportInstallAndroidMKGenerator.h
+++ b/Source/cmExportInstallAndroidMKGenerator.h
@@ -22,7 +22,7 @@ class cmInstallExportGenerator;
* cmExportInstallAndroidMKGenerator generates files exporting targets from
* install an installation tree. The files are placed in a temporary
* location for installation by cmInstallExportGenerator. The file format
- * is for the ndk build system and is a makefile fragment specifing prebuilt
+ * is for the ndk build system and is a makefile fragment specifying prebuilt
* libraries to the ndk build system.
*
* This is used to implement the INSTALL(EXPORT_ANDROID_MK) command.
diff --git a/Source/cmExtraCodeBlocksGenerator.cxx b/Source/cmExtraCodeBlocksGenerator.cxx
index edce330..31c8bca 100644
--- a/Source/cmExtraCodeBlocksGenerator.cxx
+++ b/Source/cmExtraCodeBlocksGenerator.cxx
@@ -371,10 +371,10 @@ void cmExtraCodeBlocksGenerator::CreateNewProjectFile(
continue;
}
- // check whether it is a C/C++ implementation file
+ // check whether it is a C/C++/CUDA implementation file
bool isCFile = false;
std::string lang = s->GetLanguage();
- if (lang == "C" || lang == "CXX") {
+ if (lang == "C" || lang == "CXX" || lang == "CUDA") {
std::string const& srcext = s->GetExtension();
isCFile = cm->IsSourceExtension(srcext);
}
diff --git a/Source/cmExtraCodeLiteGenerator.cxx b/Source/cmExtraCodeLiteGenerator.cxx
index 383942b..4958007 100644
--- a/Source/cmExtraCodeLiteGenerator.cxx
+++ b/Source/cmExtraCodeLiteGenerator.cxx
@@ -227,10 +227,10 @@ std::string cmExtraCodeLiteGenerator::CollectSourceFiles(
gt->GetSourceFiles(sources,
makefile->GetSafeDefinition("CMAKE_BUILD_TYPE"));
for (cmSourceFile* s : sources) {
- // check whether it is a C/C++ implementation file
+ // check whether it is a C/C++/CUDA implementation file
bool isCFile = false;
std::string lang = s->GetLanguage();
- if (lang == "C" || lang == "CXX") {
+ if (lang == "C" || lang == "CXX" || lang == "CUDA") {
std::string const& srcext = s->GetExtension();
isCFile = cm->IsSourceExtension(srcext);
}
diff --git a/Source/cmFilePathChecksum.h b/Source/cmFilePathChecksum.h
index 48b5da0..30881ce 100644
--- a/Source/cmFilePathChecksum.h
+++ b/Source/cmFilePathChecksum.h
@@ -29,13 +29,13 @@ public:
/// @brief Parent directories are empty
cmFilePathChecksum();
- /// @brief Initilizes the parent directories manually
+ /// @brief Initializes the parent directories manually
cmFilePathChecksum(std::string const& currentSrcDir,
std::string const& currentBinDir,
std::string const& projectSrcDir,
std::string const& projectBinDir);
- /// @brief Initilizes the parent directories from a makefile
+ /// @brief Initializes the parent directories from a makefile
cmFilePathChecksum(cmMakefile* makefile);
/// @brief Allows parent directories setup after construction
diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx
index 2cf53cc..4eddd15 100644
--- a/Source/cmGeneratorTarget.cxx
+++ b/Source/cmGeneratorTarget.cxx
@@ -1529,7 +1529,8 @@ std::string cmGeneratorTarget::GetAppBundleDirectory(
ext = "app";
}
fpath += ext;
- if (shouldAddContentLevel(level) && !this->Makefile->PlatformIsAppleIos()) {
+ if (shouldAddContentLevel(level) &&
+ !this->Makefile->PlatformIsAppleEmbedded()) {
fpath += "/Contents";
if (shouldAddFullLevel(level)) {
fpath += "/MacOS";
@@ -1559,7 +1560,8 @@ std::string cmGeneratorTarget::GetCFBundleDirectory(
}
}
fpath += ext;
- if (shouldAddContentLevel(level) && !this->Makefile->PlatformIsAppleIos()) {
+ if (shouldAddContentLevel(level) &&
+ !this->Makefile->PlatformIsAppleEmbedded()) {
fpath += "/Contents";
if (shouldAddFullLevel(level)) {
fpath += "/MacOS";
@@ -1579,7 +1581,8 @@ std::string cmGeneratorTarget::GetFrameworkDirectory(
ext = "framework";
}
fpath += ext;
- if (shouldAddFullLevel(level) && !this->Makefile->PlatformIsAppleIos()) {
+ if (shouldAddFullLevel(level) &&
+ !this->Makefile->PlatformIsAppleEmbedded()) {
fpath += "/Versions/";
fpath += this->GetFrameworkVersion();
}
@@ -2166,7 +2169,7 @@ void cmTargetTraceDependencies::Trace()
// Queue the source needed to generate this file, if any.
this->FollowName(sf->GetFullPath());
- // Queue dependencies added programatically by commands.
+ // Queue dependencies added programmatically by commands.
this->FollowNames(sf->GetDepends());
// Queue custom command dependencies.
@@ -3004,7 +3007,7 @@ void cmGeneratorTarget::GetLibraryNames(std::string& name, std::string& soName,
if (this->IsFrameworkOnApple()) {
realName = prefix;
- if (!this->Makefile->PlatformIsAppleIos()) {
+ if (!this->Makefile->PlatformIsAppleEmbedded()) {
realName += "Versions/";
realName += this->GetFrameworkVersion();
realName += "/";
@@ -5154,7 +5157,7 @@ void cmGeneratorTarget::ComputeLinkImplementationLanguages(
std::set<std::string> languages;
// Get languages used in our source files.
this->GetLanguages(languages, config);
- // Copy the set of langauges to the link implementation.
+ // Copy the set of languages to the link implementation.
impl.Languages.insert(impl.Languages.begin(), languages.begin(),
languages.end());
}
diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx
index 6e903fb..fd9b488 100644
--- a/Source/cmGlobalGenerator.cxx
+++ b/Source/cmGlobalGenerator.cxx
@@ -2609,7 +2609,7 @@ std::string cmGlobalGenerator::GenerateRuleFile(
bool cmGlobalGenerator::ShouldStripResourcePath(cmMakefile* mf) const
{
- return mf->PlatformIsAppleIos();
+ return mf->PlatformIsAppleEmbedded();
}
std::string cmGlobalGenerator::GetSharedLibFlagsForLanguage(
diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx
index d5531cb..4f546bb 100644
--- a/Source/cmGlobalNinjaGenerator.cxx
+++ b/Source/cmGlobalNinjaGenerator.cxx
@@ -8,7 +8,6 @@
#include "cmsys/FStream.hxx"
#include <algorithm>
#include <ctype.h>
-#include <functional>
#include <iterator>
#include <memory> // IWYU pragma: keep
#include <sstream>
@@ -114,7 +113,7 @@ std::string cmGlobalNinjaGenerator::EncodeIdent(const std::string& ident,
std::ostream& vars)
{
if (std::find_if(ident.begin(), ident.end(),
- std::not1(std::ptr_fun(IsIdentChar))) != ident.end()) {
+ [](char c) { return !IsIdentChar(c); }) != ident.end()) {
static unsigned VarNum = 0;
std::ostringstream names;
names << "ident" << VarNum++;
diff --git a/Source/cmGlobalVisualStudio10Generator.cxx b/Source/cmGlobalVisualStudio10Generator.cxx
index 4c4c62c..73a5dae 100644
--- a/Source/cmGlobalVisualStudio10Generator.cxx
+++ b/Source/cmGlobalVisualStudio10Generator.cxx
@@ -478,12 +478,11 @@ void cmGlobalVisualStudio10Generator::Generate()
void cmGlobalVisualStudio10Generator::EnableLanguage(
std::vector<std::string> const& lang, cmMakefile* mf, bool optional)
{
- for (std::vector<std::string>::const_iterator it = lang.begin();
- it != lang.end(); ++it) {
- if (*it == "ASM_NASM") {
+ for (std::string const& it : lang) {
+ if (it == "ASM_NASM") {
this->NasmEnabled = true;
}
- if (*it == "CUDA") {
+ if (it == "CUDA") {
this->CudaEnabled = true;
}
}
@@ -829,8 +828,9 @@ void cmGlobalVisualStudio10Generator::GenerateBuildCommand(
if (parser.ParseFile(slnFile, slnData,
cmVisualStudioSlnParser::DataGroupProjects)) {
std::vector<cmSlnProjectEntry> slnProjects = slnData.GetProjects();
- for (std::vector<cmSlnProjectEntry>::iterator i = slnProjects.begin();
- !useDevEnv && i != slnProjects.end(); ++i) {
+ for (std::vector<cmSlnProjectEntry>::const_iterator i =
+ slnProjects.cbegin();
+ !useDevEnv && i != slnProjects.cend(); ++i) {
std::string proj = i->GetRelativePath();
if (proj.size() > 7 && proj.substr(proj.size() - 7) == ".vfproj") {
useDevEnv = true;
diff --git a/Source/cmGlobalVisualStudio11Generator.cxx b/Source/cmGlobalVisualStudio11Generator.cxx
index cb3b047..f1d5a8c 100644
--- a/Source/cmGlobalVisualStudio11Generator.cxx
+++ b/Source/cmGlobalVisualStudio11Generator.cxx
@@ -83,9 +83,8 @@ public:
std::set<std::string> installedSDKs =
cmGlobalVisualStudio11Generator::GetInstalledWindowsCESDKs();
- for (std::set<std::string>::const_iterator i = installedSDKs.begin();
- i != installedSDKs.end(); ++i) {
- names.push_back(std::string(vs11generatorName) + " " + *i);
+ for (std::string const& i : installedSDKs) {
+ names.push_back(std::string(vs11generatorName) + " " + i);
}
}
@@ -224,18 +223,17 @@ cmGlobalVisualStudio11Generator::GetInstalledWindowsCESDKs()
cmSystemTools::KeyWOW64_32);
std::set<std::string> ret;
- for (std::vector<std::string>::const_iterator i = subkeys.begin();
- i != subkeys.end(); ++i) {
+ for (std::string const& i : subkeys) {
std::string key = sdksKey;
key += '\\';
- key += *i;
+ key += i;
key += ';';
std::string path;
- if (cmSystemTools::ReadRegistryValue(key.c_str(), path,
+ if (cmSystemTools::ReadRegistryValue(key, path,
cmSystemTools::KeyWOW64_32) &&
!path.empty()) {
- ret.insert(*i);
+ ret.insert(i);
}
}
diff --git a/Source/cmGlobalVisualStudio14Generator.cxx b/Source/cmGlobalVisualStudio14Generator.cxx
index 97d5313..c440e0d 100644
--- a/Source/cmGlobalVisualStudio14Generator.cxx
+++ b/Source/cmGlobalVisualStudio14Generator.cxx
@@ -257,9 +257,8 @@ std::string cmGlobalVisualStudio14Generator::GetWindows10SDKVersion()
std::vector<std::string> sdks;
// Grab the paths of the different SDKs that are installed
- for (std::vector<std::string>::iterator i = win10Roots.begin();
- i != win10Roots.end(); ++i) {
- std::string path = *i + "/Include/*";
+ for (std::string const& i : win10Roots) {
+ std::string path = i + "/Include/*";
cmSystemTools::GlobDirs(path, sdks);
}
@@ -269,19 +268,17 @@ std::string cmGlobalVisualStudio14Generator::GetWindows10SDKVersion()
if (!sdks.empty()) {
// Only use the filename, which will be the SDK version.
- for (std::vector<std::string>::iterator i = sdks.begin(); i != sdks.end();
- ++i) {
- *i = cmSystemTools::GetFilenameName(*i);
+ for (std::string& i : sdks) {
+ i = cmSystemTools::GetFilenameName(i);
}
// Sort the results to make sure we select the most recent one.
std::sort(sdks.begin(), sdks.end(), cmSystemTools::VersionCompareGreater);
// Look for a SDK exactly matching the requested target version.
- for (std::vector<std::string>::iterator i = sdks.begin(); i != sdks.end();
- ++i) {
- if (cmSystemTools::VersionCompareEqual(*i, this->SystemVersion)) {
- return *i;
+ for (std::string const& i : sdks) {
+ if (cmSystemTools::VersionCompareEqual(i, this->SystemVersion)) {
+ return i;
}
}
diff --git a/Source/cmGlobalVisualStudio71Generator.cxx b/Source/cmGlobalVisualStudio71Generator.cxx
index 8a9a3fb..45cc583 100644
--- a/Source/cmGlobalVisualStudio71Generator.cxx
+++ b/Source/cmGlobalVisualStudio71Generator.cxx
@@ -76,9 +76,8 @@ void cmGlobalVisualStudio71Generator::WriteSolutionConfigurations(
std::ostream& fout, std::vector<std::string> const& configs)
{
fout << "\tGlobalSection(SolutionConfiguration) = preSolution\n";
- for (std::vector<std::string>::const_iterator i = configs.begin();
- i != configs.end(); ++i) {
- fout << "\t\t" << *i << " = " << *i << "\n";
+ for (std::string const& i : configs) {
+ fout << "\t\t" << i << " = " << i << "\n";
}
fout << "\tEndGlobalSection\n";
}
@@ -143,9 +142,7 @@ void cmGlobalVisualStudio71Generator::WriteProjectDepends(
cmGeneratorTarget const* target)
{
VSDependSet const& depends = this->VSTargetDepends[target];
- for (VSDependSet::const_iterator di = depends.begin(); di != depends.end();
- ++di) {
- const char* name = di->c_str();
+ for (std::string const& name : depends) {
std::string guid = this->GetGUID(name);
if (guid.empty()) {
std::string m = "Target: ";
@@ -174,11 +171,10 @@ void cmGlobalVisualStudio71Generator::WriteExternalProject(
// project instead of in the global section
if (!depends.empty()) {
fout << "\tProjectSection(ProjectDependencies) = postProject\n";
- std::set<std::string>::const_iterator it;
- for (it = depends.begin(); it != depends.end(); ++it) {
- if (!it->empty()) {
- fout << "\t\t{" << this->GetGUID(it->c_str()) << "} = {"
- << this->GetGUID(it->c_str()) << "}\n";
+ for (std::string const& it : depends) {
+ if (!it.empty()) {
+ fout << "\t\t{" << this->GetGUID(it) << "} = {" << this->GetGUID(it)
+ << "}\n";
}
}
fout << "\tEndProjectSection\n";
@@ -198,26 +194,25 @@ void cmGlobalVisualStudio71Generator::WriteProjectConfigurations(
const std::string& platformName =
!platformMapping.empty() ? platformMapping : this->GetPlatformName();
std::string guid = this->GetGUID(name);
- for (std::vector<std::string>::const_iterator i = configs.begin();
- i != configs.end(); ++i) {
+ for (std::string const& i : configs) {
std::vector<std::string> mapConfig;
- const char* dstConfig = i->c_str();
+ const char* dstConfig = i.c_str();
if (target.GetProperty("EXTERNAL_MSPROJECT")) {
if (const char* m = target.GetProperty("MAP_IMPORTED_CONFIG_" +
- cmSystemTools::UpperCase(*i))) {
+ cmSystemTools::UpperCase(i))) {
cmSystemTools::ExpandListArgument(m, mapConfig);
if (!mapConfig.empty()) {
dstConfig = mapConfig[0].c_str();
}
}
}
- fout << "\t\t{" << guid << "}." << *i << ".ActiveCfg = " << dstConfig
- << "|" << platformName << std::endl;
+ fout << "\t\t{" << guid << "}." << i << ".ActiveCfg = " << dstConfig << "|"
+ << platformName << std::endl;
std::set<std::string>::const_iterator ci =
- configsPartOfDefaultBuild.find(*i);
+ configsPartOfDefaultBuild.find(i);
if (!(ci == configsPartOfDefaultBuild.end())) {
- fout << "\t\t{" << guid << "}." << *i << ".Build.0 = " << dstConfig
- << "|" << platformName << std::endl;
+ fout << "\t\t{" << guid << "}." << i << ".Build.0 = " << dstConfig << "|"
+ << platformName << std::endl;
}
}
}
diff --git a/Source/cmGlobalVisualStudio7Generator.cxx b/Source/cmGlobalVisualStudio7Generator.cxx
index a14b5f7..c915dc5 100644
--- a/Source/cmGlobalVisualStudio7Generator.cxx
+++ b/Source/cmGlobalVisualStudio7Generator.cxx
@@ -334,9 +334,8 @@ void cmGlobalVisualStudio7Generator::OutputSLNFile(
// output the SLN file
void cmGlobalVisualStudio7Generator::OutputSLNFile()
{
- std::map<std::string, std::vector<cmLocalGenerator*>>::iterator it;
- for (it = this->ProjectMap.begin(); it != this->ProjectMap.end(); ++it) {
- this->OutputSLNFile(it->second[0], it->second);
+ for (auto& it : this->ProjectMap) {
+ this->OutputSLNFile(it.second[0], it.second);
}
}
@@ -346,9 +345,7 @@ void cmGlobalVisualStudio7Generator::WriteTargetConfigurations(
{
// loop over again and write out configurations for each target
// in the solution
- for (OrderedTargetDependSet::const_iterator tt = projectTargets.begin();
- tt != projectTargets.end(); ++tt) {
- cmGeneratorTarget const* target = *tt;
+ for (cmGeneratorTarget const* target : projectTargets) {
if (target->GetType() == cmStateEnums::INTERFACE_LIBRARY) {
continue;
}
@@ -378,9 +375,7 @@ void cmGlobalVisualStudio7Generator::WriteTargetsToSolution(
VisualStudioFolders.clear();
std::string rootBinaryDir = root->GetCurrentBinaryDirectory();
- for (OrderedTargetDependSet::const_iterator tt = projectTargets.begin();
- tt != projectTargets.end(); ++tt) {
- cmGeneratorTarget const* target = *tt;
+ for (cmGeneratorTarget const* target : projectTargets) {
if (target->GetType() == cmStateEnums::INTERFACE_LIBRARY) {
continue;
}
@@ -420,19 +415,18 @@ void cmGlobalVisualStudio7Generator::WriteTargetsToSolution(
std::string cumulativePath;
- for (std::vector<cmsys::String>::iterator iter = tokens.begin();
- iter != tokens.end(); ++iter) {
- if (!iter->size()) {
+ for (cmsys::String const& iter : tokens) {
+ if (!iter.size()) {
continue;
}
if (cumulativePath.empty()) {
- cumulativePath = "CMAKE_FOLDER_GUID_" + *iter;
+ cumulativePath = "CMAKE_FOLDER_GUID_" + iter;
} else {
VisualStudioFolders[cumulativePath].insert(cumulativePath + "/" +
- *iter);
+ iter);
- cumulativePath = cumulativePath + "/" + *iter;
+ cumulativePath = cumulativePath + "/" + iter;
}
}
@@ -447,9 +441,7 @@ void cmGlobalVisualStudio7Generator::WriteTargetsToSolution(
void cmGlobalVisualStudio7Generator::WriteTargetDepends(
std::ostream& fout, OrderedTargetDependSet const& projectTargets)
{
- for (OrderedTargetDependSet::const_iterator tt = projectTargets.begin();
- tt != projectTargets.end(); ++tt) {
- cmGeneratorTarget const* target = *tt;
+ for (cmGeneratorTarget const* target : projectTargets) {
if (target->GetType() == cmStateEnums::INTERFACE_LIBRARY) {
continue;
}
@@ -467,11 +459,9 @@ void cmGlobalVisualStudio7Generator::WriteFolders(std::ostream& fout)
const char* prefix = "CMAKE_FOLDER_GUID_";
const std::string::size_type skip_prefix = strlen(prefix);
std::string guidProjectTypeFolder = "2150E333-8FDC-42A3-9474-1A3956D46DE8";
- for (std::map<std::string, std::set<std::string>>::iterator iter =
- VisualStudioFolders.begin();
- iter != VisualStudioFolders.end(); ++iter) {
- std::string fullName = iter->first;
- std::string guid = this->GetGUID(fullName.c_str());
+ for (auto const& iter : VisualStudioFolders) {
+ std::string fullName = iter.first;
+ std::string guid = this->GetGUID(fullName);
std::replace(fullName.begin(), fullName.end(), '/', '\\');
if (cmSystemTools::StringStartsWith(fullName.c_str(), prefix)) {
@@ -487,16 +477,13 @@ void cmGlobalVisualStudio7Generator::WriteFolders(std::ostream& fout)
void cmGlobalVisualStudio7Generator::WriteFoldersContent(std::ostream& fout)
{
- for (std::map<std::string, std::set<std::string>>::iterator iter =
- VisualStudioFolders.begin();
- iter != VisualStudioFolders.end(); ++iter) {
- std::string key(iter->first);
- std::string guidParent(this->GetGUID(key.c_str()));
+ for (auto const& iter : VisualStudioFolders) {
+ std::string key(iter.first);
+ std::string guidParent(this->GetGUID(key));
- for (std::set<std::string>::iterator it = iter->second.begin();
- it != iter->second.end(); ++it) {
- std::string value(*it);
- std::string guid(this->GetGUID(value.c_str()));
+ for (std::string const& it : iter.second) {
+ std::string value(it);
+ std::string guid(this->GetGUID(value));
fout << "\t\t{" << guid << "} = {" << guidParent << "}\n";
}
@@ -525,11 +512,10 @@ void cmGlobalVisualStudio7Generator::WriteSLNGlobalSections(
bool extensibilityAddInsOverridden = false;
const std::vector<std::string> propKeys =
root->GetMakefile()->GetPropertyKeys();
- for (std::vector<std::string>::const_iterator it = propKeys.begin();
- it != propKeys.end(); ++it) {
- if (it->find("VS_GLOBAL_SECTION_") == 0) {
+ for (std::string const& it : propKeys) {
+ if (it.find("VS_GLOBAL_SECTION_") == 0) {
std::string sectionType;
- std::string name = it->substr(18);
+ std::string name = it.substr(18);
if (name.find("PRE_") == 0) {
name = name.substr(4);
sectionType = "preSolution";
@@ -549,17 +535,15 @@ void cmGlobalVisualStudio7Generator::WriteSLNGlobalSections(
}
fout << "\tGlobalSection(" << name << ") = " << sectionType << "\n";
std::vector<std::string> keyValuePairs;
- cmSystemTools::ExpandListArgument(
- root->GetMakefile()->GetProperty(it->c_str()), keyValuePairs);
- for (std::vector<std::string>::const_iterator itPair =
- keyValuePairs.begin();
- itPair != keyValuePairs.end(); ++itPair) {
- const std::string::size_type posEqual = itPair->find('=');
+ cmSystemTools::ExpandListArgument(root->GetMakefile()->GetProperty(it),
+ keyValuePairs);
+ for (std::string const& itPair : keyValuePairs) {
+ const std::string::size_type posEqual = itPair.find('=');
if (posEqual != std::string::npos) {
const std::string key =
- cmSystemTools::TrimWhitespace(itPair->substr(0, posEqual));
+ cmSystemTools::TrimWhitespace(itPair.substr(0, posEqual));
const std::string value =
- cmSystemTools::TrimWhitespace(itPair->substr(posEqual + 1));
+ cmSystemTools::TrimWhitespace(itPair.substr(posEqual + 1));
fout << "\t\t" << key << " = " << value << "\n";
if (key == "SolutionGuid") {
addGuid = false;
@@ -618,14 +602,13 @@ std::string cmGlobalVisualStudio7Generator::WriteUtilityDepend(
"\t<Configurations>\n"
;
/* clang-format on */
- for (std::vector<std::string>::iterator i = configs.begin();
- i != configs.end(); ++i) {
+ for (std::string const& i : configs) {
/* clang-format off */
fout <<
"\t\t<Configuration\n"
- "\t\t\tName=\"" << *i << "|Win32\"\n"
- "\t\t\tOutputDirectory=\"" << *i << "\"\n"
- "\t\t\tIntermediateDirectory=\"" << pname << ".dir\\" << *i << "\"\n"
+ "\t\t\tName=\"" << i << "|Win32\"\n"
+ "\t\t\tOutputDirectory=\"" << i << "\"\n"
+ "\t\t\tIntermediateDirectory=\"" << pname << ".dir\\" << i << "\"\n"
"\t\t\tConfigurationType=\"10\"\n"
"\t\t\tUseOfMFC=\"0\"\n"
"\t\t\tATLMinimizesCRunTimeLibraryUsage=\"FALSE\"\n"
@@ -696,23 +679,21 @@ std::set<std::string> cmGlobalVisualStudio7Generator::IsPartOfDefaultBuild(
std::vector<std::string> targetNames;
targetNames.push_back("INSTALL");
targetNames.push_back("PACKAGE");
- for (std::vector<std::string>::const_iterator t = targetNames.begin();
- t != targetNames.end(); ++t) {
- // check if target <*t> is part of default build
- if (target->GetName() == *t) {
+ for (std::string const& t : targetNames) {
+ // check if target <t> is part of default build
+ if (target->GetName() == t) {
const std::string propertyName =
- "CMAKE_VS_INCLUDE_" + *t + "_TO_DEFAULT_BUILD";
- // inspect CMAKE_VS_INCLUDE_<*t>_TO_DEFAULT_BUILD properties
- for (std::vector<std::string>::const_iterator i = configs.begin();
- i != configs.end(); ++i) {
+ "CMAKE_VS_INCLUDE_" + t + "_TO_DEFAULT_BUILD";
+ // inspect CMAKE_VS_INCLUDE_<t>_TO_DEFAULT_BUILD properties
+ for (std::string const& i : configs) {
const char* propertyValue =
target->Target->GetMakefile()->GetDefinition(propertyName);
cmGeneratorExpression ge;
std::unique_ptr<cmCompiledGeneratorExpression> cge =
ge.Parse(propertyValue);
if (cmSystemTools::IsOn(
- cge->Evaluate(target->GetLocalGenerator(), *i))) {
- activeConfigs.insert(*i);
+ cge->Evaluate(target->GetLocalGenerator(), i))) {
+ activeConfigs.insert(i);
}
}
}
@@ -724,12 +705,11 @@ std::set<std::string> cmGlobalVisualStudio7Generator::IsPartOfDefaultBuild(
return activeConfigs;
}
// inspect EXCLUDE_FROM_DEFAULT_BUILD[_<CONFIG>] properties
- for (std::vector<std::string>::const_iterator i = configs.begin();
- i != configs.end(); ++i) {
+ for (std::string const& i : configs) {
const char* propertyValue =
- target->GetFeature("EXCLUDE_FROM_DEFAULT_BUILD", i->c_str());
+ target->GetFeature("EXCLUDE_FROM_DEFAULT_BUILD", i);
if (cmSystemTools::IsOff(propertyValue)) {
- activeConfigs.insert(*i);
+ activeConfigs.insert(i);
}
}
return activeConfigs;
@@ -738,9 +718,8 @@ std::set<std::string> cmGlobalVisualStudio7Generator::IsPartOfDefaultBuild(
bool cmGlobalVisualStudio7Generator::IsDependedOn(
OrderedTargetDependSet const& projectTargets, cmGeneratorTarget const* gtIn)
{
- for (OrderedTargetDependSet::const_iterator l = projectTargets.begin();
- l != projectTargets.end(); ++l) {
- TargetDependSet const& tgtdeps = this->GetTargetDirectDepends(*l);
+ for (cmTargetDepend const& l : projectTargets) {
+ TargetDependSet const& tgtdeps = this->GetTargetDirectDepends(l);
if (tgtdeps.count(gtIn)) {
return true;
}
diff --git a/Source/cmGlobalVisualStudio8Generator.cxx b/Source/cmGlobalVisualStudio8Generator.cxx
index 1743b18..ab8ad70 100644
--- a/Source/cmGlobalVisualStudio8Generator.cxx
+++ b/Source/cmGlobalVisualStudio8Generator.cxx
@@ -66,10 +66,8 @@ public:
parser.ParseVersion("8.0");
const std::vector<std::string>& availablePlatforms =
parser.GetAvailablePlatforms();
- for (std::vector<std::string>::const_iterator i =
- availablePlatforms.begin();
- i != availablePlatforms.end(); ++i) {
- names.push_back("Visual Studio 8 2005 " + *i);
+ for (std::string const& i : availablePlatforms) {
+ names.push_back("Visual Studio 8 2005 " + i);
}
}
@@ -117,9 +115,8 @@ std::string cmGlobalVisualStudio8Generator::FindDevEnvCommand()
void cmGlobalVisualStudio8Generator::EnableLanguage(
std::vector<std::string> const& lang, cmMakefile* mf, bool optional)
{
- for (std::vector<std::string>::const_iterator it = lang.begin();
- it != lang.end(); ++it) {
- if (*it == "ASM_MASM") {
+ for (std::string const& it : lang) {
+ if (it == "ASM_MASM") {
this->MasmEnabled = true;
}
}
@@ -249,10 +246,8 @@ bool cmGlobalVisualStudio8Generator::AddCheckTarget()
stampListFile += stampList;
std::string stampFile;
cmGeneratedFileStream fout(stampListFile.c_str());
- for (std::vector<cmLocalGenerator*>::const_iterator gi =
- generators.begin();
- gi != generators.end(); ++gi) {
- stampFile = (*gi)->GetMakefile()->GetCurrentBinaryDirectory();
+ for (cmLocalGenerator const* gi : generators) {
+ stampFile = gi->GetMakefile()->GetCurrentBinaryDirectory();
stampFile += "/";
stampFile += cmake::GetCMakeFilesDirectoryPostSlash();
stampFile += "generate.stamp";
@@ -323,10 +318,9 @@ void cmGlobalVisualStudio8Generator::AddExtraIDETargets()
const std::vector<cmGeneratorTarget*>& tgts =
this->LocalGenerators[i]->GetGeneratorTargets();
// All targets depend on the build-system check target.
- for (std::vector<cmGeneratorTarget*>::const_iterator ti = tgts.begin();
- ti != tgts.end(); ++ti) {
- if ((*ti)->GetName() != CMAKE_CHECK_BUILD_SYSTEM_TARGET) {
- (*ti)->Target->AddUtility(CMAKE_CHECK_BUILD_SYSTEM_TARGET);
+ for (cmGeneratorTarget const* ti : tgts) {
+ if (ti->GetName() != CMAKE_CHECK_BUILD_SYSTEM_TARGET) {
+ ti->Target->AddUtility(CMAKE_CHECK_BUILD_SYSTEM_TARGET);
}
}
}
@@ -337,10 +331,9 @@ void cmGlobalVisualStudio8Generator::WriteSolutionConfigurations(
std::ostream& fout, std::vector<std::string> const& configs)
{
fout << "\tGlobalSection(SolutionConfigurationPlatforms) = preSolution\n";
- for (std::vector<std::string>::const_iterator i = configs.begin();
- i != configs.end(); ++i) {
- fout << "\t\t" << *i << "|" << this->GetPlatformName() << " = " << *i
- << "|" << this->GetPlatformName() << "\n";
+ for (std::string const& i : configs) {
+ fout << "\t\t" << i << "|" << this->GetPlatformName() << " = " << i << "|"
+ << this->GetPlatformName() << "\n";
}
fout << "\tEndGlobalSection\n";
}
@@ -352,35 +345,34 @@ void cmGlobalVisualStudio8Generator::WriteProjectConfigurations(
std::string const& platformMapping)
{
std::string guid = this->GetGUID(name);
- for (std::vector<std::string>::const_iterator i = configs.begin();
- i != configs.end(); ++i) {
+ for (std::string const& i : configs) {
std::vector<std::string> mapConfig;
- const char* dstConfig = i->c_str();
+ const char* dstConfig = i.c_str();
if (target.GetProperty("EXTERNAL_MSPROJECT")) {
if (const char* m = target.GetProperty("MAP_IMPORTED_CONFIG_" +
- cmSystemTools::UpperCase(*i))) {
+ cmSystemTools::UpperCase(i))) {
cmSystemTools::ExpandListArgument(m, mapConfig);
if (!mapConfig.empty()) {
dstConfig = mapConfig[0].c_str();
}
}
}
- fout << "\t\t{" << guid << "}." << *i << "|" << this->GetPlatformName()
+ fout << "\t\t{" << guid << "}." << i << "|" << this->GetPlatformName()
<< ".ActiveCfg = " << dstConfig << "|"
<< (!platformMapping.empty() ? platformMapping
: this->GetPlatformName())
<< "\n";
std::set<std::string>::const_iterator ci =
- configsPartOfDefaultBuild.find(*i);
+ configsPartOfDefaultBuild.find(i);
if (!(ci == configsPartOfDefaultBuild.end())) {
- fout << "\t\t{" << guid << "}." << *i << "|" << this->GetPlatformName()
+ fout << "\t\t{" << guid << "}." << i << "|" << this->GetPlatformName()
<< ".Build.0 = " << dstConfig << "|"
<< (!platformMapping.empty() ? platformMapping
: this->GetPlatformName())
<< "\n";
}
if (this->NeedsDeploy(target.GetType())) {
- fout << "\t\t{" << guid << "}." << *i << "|" << this->GetPlatformName()
+ fout << "\t\t{" << guid << "}." << i << "|" << this->GetPlatformName()
<< ".Deploy.0 = " << dstConfig << "|"
<< (!platformMapping.empty() ? platformMapping
: this->GetPlatformName())
@@ -410,12 +402,11 @@ void cmGlobalVisualStudio8Generator::WriteProjectDepends(
{
TargetDependSet const& unordered = this->GetTargetDirectDepends(gt);
OrderedTargetDependSet depends(unordered, std::string());
- for (OrderedTargetDependSet::const_iterator i = depends.begin();
- i != depends.end(); ++i) {
- if ((*i)->GetType() == cmStateEnums::INTERFACE_LIBRARY) {
+ for (cmTargetDepend const& i : depends) {
+ if (i->GetType() == cmStateEnums::INTERFACE_LIBRARY) {
continue;
}
- std::string guid = this->GetGUID((*i)->GetName().c_str());
+ std::string guid = this->GetGUID(i->GetName());
fout << "\t\t{" << guid << "} = {" << guid << "}\n";
}
}
@@ -424,11 +415,9 @@ bool cmGlobalVisualStudio8Generator::NeedLinkLibraryDependencies(
cmGeneratorTarget* target)
{
// Look for utility dependencies that magically link.
- for (std::set<std::string>::const_iterator ui =
- target->GetUtilities().begin();
- ui != target->GetUtilities().end(); ++ui) {
+ for (std::string const& ui : target->GetUtilities()) {
if (cmGeneratorTarget* depTarget =
- target->GetLocalGenerator()->FindGeneratorTargetToUse(ui->c_str())) {
+ target->GetLocalGenerator()->FindGeneratorTargetToUse(ui)) {
if (depTarget->GetType() != cmStateEnums::INTERFACE_LIBRARY &&
depTarget->GetProperty("EXTERNAL_MSPROJECT")) {
// This utility dependency names an external .vcproj target.
diff --git a/Source/cmGlobalVisualStudio9Generator.cxx b/Source/cmGlobalVisualStudio9Generator.cxx
index 0abb348..7ac3a6f 100644
--- a/Source/cmGlobalVisualStudio9Generator.cxx
+++ b/Source/cmGlobalVisualStudio9Generator.cxx
@@ -68,10 +68,8 @@ public:
parser.ParseVersion("9.0");
const std::vector<std::string>& availablePlatforms =
parser.GetAvailablePlatforms();
- for (std::vector<std::string>::const_iterator i =
- availablePlatforms.begin();
- i != availablePlatforms.end(); ++i) {
- names.push_back("Visual Studio 9 2008 " + *i);
+ for (std::string const& i : availablePlatforms) {
+ names.push_back("Visual Studio 9 2008 " + i);
}
}
diff --git a/Source/cmGlobalVisualStudioGenerator.cxx b/Source/cmGlobalVisualStudioGenerator.cxx
index c89c2c4..d7ebcac 100644
--- a/Source/cmGlobalVisualStudioGenerator.cxx
+++ b/Source/cmGlobalVisualStudioGenerator.cxx
@@ -61,9 +61,8 @@ void cmGlobalVisualStudioGenerator::AddExtraIDETargets()
const char* no_working_dir = 0;
std::vector<std::string> no_depends;
cmCustomCommandLines no_commands;
- std::map<std::string, std::vector<cmLocalGenerator*>>::iterator it;
- for (it = this->ProjectMap.begin(); it != this->ProjectMap.end(); ++it) {
- std::vector<cmLocalGenerator*>& gen = it->second;
+ for (auto const& it : this->ProjectMap) {
+ std::vector<cmLocalGenerator*> const& gen = it.second;
// add the ALL_BUILD to the first local generator of each project
if (!gen.empty()) {
// Use no actual command lines so that the target itself is not
@@ -83,14 +82,10 @@ void cmGlobalVisualStudioGenerator::AddExtraIDETargets()
}
// Now make all targets depend on the ALL_BUILD target
- for (std::vector<cmLocalGenerator*>::iterator i = gen.begin();
- i != gen.end(); ++i) {
- const std::vector<cmGeneratorTarget*>& targets =
- (*i)->GetGeneratorTargets();
- for (std::vector<cmGeneratorTarget*>::const_iterator t =
- targets.begin();
- t != targets.end(); ++t) {
- cmGeneratorTarget* tgt = *t;
+ for (cmLocalGenerator const* i : gen) {
+ std::vector<cmGeneratorTarget*> const& targets =
+ i->GetGeneratorTargets();
+ for (cmGeneratorTarget* tgt : targets) {
if (tgt->GetType() == cmStateEnums::GLOBAL_TARGET ||
tgt->IsImported()) {
continue;
@@ -243,10 +238,9 @@ void cmGlobalVisualStudioGenerator::FillLinkClosure(
{
if (linked.insert(target).second) {
TargetDependSet const& depends = this->GetTargetDirectDepends(target);
- for (TargetDependSet::const_iterator di = depends.begin();
- di != depends.end(); ++di) {
- if (di->IsLink()) {
- this->FillLinkClosure(*di, linked);
+ for (cmTargetDepend const& di : depends) {
+ if (di.IsLink()) {
+ this->FillLinkClosure(di, linked);
}
}
}
@@ -275,10 +269,9 @@ void cmGlobalVisualStudioGenerator::FollowLinkDepends(
// Static library targets do not list their link dependencies so
// we must follow them transitively now.
TargetDependSet const& depends = this->GetTargetDirectDepends(target);
- for (TargetDependSet::const_iterator di = depends.begin();
- di != depends.end(); ++di) {
- if (di->IsLink()) {
- this->FollowLinkDepends(*di, linked);
+ for (cmTargetDepend const& di : depends) {
+ if (di.IsLink()) {
+ this->FollowLinkDepends(di, linked);
}
}
}
@@ -289,17 +282,13 @@ bool cmGlobalVisualStudioGenerator::ComputeTargetDepends()
if (!this->cmGlobalGenerator::ComputeTargetDepends()) {
return false;
}
- std::map<std::string, std::vector<cmLocalGenerator*>>::iterator it;
- for (it = this->ProjectMap.begin(); it != this->ProjectMap.end(); ++it) {
- std::vector<cmLocalGenerator*>& gen = it->second;
- for (std::vector<cmLocalGenerator*>::iterator i = gen.begin();
- i != gen.end(); ++i) {
- const std::vector<cmGeneratorTarget*>& targets =
- (*i)->GetGeneratorTargets();
- for (std::vector<cmGeneratorTarget*>::const_iterator ti =
- targets.begin();
- ti != targets.end(); ++ti) {
- this->ComputeVSTargetDepends(*ti);
+ for (auto const& it : this->ProjectMap) {
+ std::vector<cmLocalGenerator*> const& gen = it.second;
+ for (const cmLocalGenerator* i : gen) {
+ std::vector<cmGeneratorTarget*> const& targets =
+ i->GetGeneratorTargets();
+ for (cmGeneratorTarget* ti : targets) {
+ this->ComputeVSTargetDepends(ti);
}
}
}
@@ -349,22 +338,20 @@ void cmGlobalVisualStudioGenerator::ComputeVSTargetDepends(
// due to behavior (2), but they do not really need to.
std::set<cmGeneratorTarget const*> linkDepends;
if (target->GetType() != cmStateEnums::STATIC_LIBRARY) {
- for (TargetDependSet::const_iterator di = depends.begin();
- di != depends.end(); ++di) {
- cmTargetDepend dep = *di;
+ for (cmTargetDepend const& di : depends) {
+ cmTargetDepend dep = di;
if (dep.IsLink()) {
- this->FollowLinkDepends(*di, linkDepends);
+ this->FollowLinkDepends(di, linkDepends);
}
}
}
// Collect explicit util dependencies (add_dependencies).
std::set<cmGeneratorTarget const*> utilDepends;
- for (TargetDependSet::const_iterator di = depends.begin();
- di != depends.end(); ++di) {
- cmTargetDepend dep = *di;
+ for (cmTargetDepend const& di : depends) {
+ cmTargetDepend dep = di;
if (dep.IsUtil()) {
- this->FollowLinkDepends(*di, utilDepends);
+ this->FollowLinkDepends(di, utilDepends);
}
}
@@ -376,16 +363,12 @@ void cmGlobalVisualStudioGenerator::ComputeVSTargetDepends(
}
// Emit link dependencies.
- for (std::set<cmGeneratorTarget const*>::iterator di = linkDepends.begin();
- di != linkDepends.end(); ++di) {
- cmGeneratorTarget const* dep = *di;
+ for (cmGeneratorTarget const* dep : linkDepends) {
vsTargetDepend.insert(dep->GetName());
}
// Emit util dependencies. Possibly use intermediate targets.
- for (std::set<cmGeneratorTarget const*>::iterator di = utilDepends.begin();
- di != utilDepends.end(); ++di) {
- cmGeneratorTarget const* dgt = *di;
+ for (cmGeneratorTarget const* dgt : utilDepends) {
if (allowLinkable || !VSLinkable(dgt) || linked.count(dgt)) {
// Direct dependency allowed.
vsTargetDepend.insert(dgt->GetName());
@@ -815,9 +798,8 @@ cmGlobalVisualStudioGenerator::OrderedTargetDependSet::OrderedTargetDependSet(
TargetSet const& targets, std::string const& first)
: derived(TargetCompare(first))
{
- for (TargetSet::const_iterator it = targets.begin(); it != targets.end();
- ++it) {
- this->insert(*it);
+ for (cmGeneratorTarget const* it : targets) {
+ this->insert(it);
}
}
@@ -851,10 +833,8 @@ void cmGlobalVisualStudioGenerator::AddSymbolExportCommand(
std::vector<cmSourceFile const*> objectSources;
gt->GetObjectSources(objectSources, configName);
std::map<cmSourceFile const*, std::string> mapping;
- for (std::vector<cmSourceFile const*>::const_iterator it =
- objectSources.begin();
- it != objectSources.end(); ++it) {
- mapping[*it];
+ for (cmSourceFile const* it : objectSources) {
+ mapping[it];
}
gt->LocalGenerator->ComputeObjectFilenames(mapping, gt);
std::string obj_dir = gt->ObjectDirectory;
@@ -879,12 +859,10 @@ void cmGlobalVisualStudioGenerator::AddSymbolExportCommand(
if (mdi->WindowsExportAllSymbols) {
std::vector<std::string> objs;
- for (std::vector<cmSourceFile const*>::const_iterator it =
- objectSources.begin();
- it != objectSources.end(); ++it) {
+ for (cmSourceFile const* it : objectSources) {
// Find the object file name corresponding to this source file.
std::map<cmSourceFile const*, std::string>::const_iterator map_it =
- mapping.find(*it);
+ mapping.find(it);
// It must exist because we populated the mapping just above.
assert(!map_it->second.empty());
std::string objFile = obj_dir + map_it->second;
@@ -892,15 +870,12 @@ void cmGlobalVisualStudioGenerator::AddSymbolExportCommand(
}
std::vector<cmSourceFile const*> externalObjectSources;
gt->GetExternalObjects(externalObjectSources, configName);
- for (std::vector<cmSourceFile const*>::const_iterator it =
- externalObjectSources.begin();
- it != externalObjectSources.end(); ++it) {
- objs.push_back((*it)->GetFullPath());
+ for (cmSourceFile const* it : externalObjectSources) {
+ objs.push_back(it->GetFullPath());
}
- for (std::vector<std::string>::iterator it = objs.begin();
- it != objs.end(); ++it) {
- std::string objFile = *it;
+ for (std::string const& it : objs) {
+ std::string objFile = it;
// replace $(ConfigurationName) in the object names
cmSystemTools::ReplaceString(objFile, this->GetCMakeCFGIntDir(),
configName.c_str());
@@ -910,10 +885,8 @@ void cmGlobalVisualStudioGenerator::AddSymbolExportCommand(
}
}
- for (std::vector<cmSourceFile const*>::const_iterator i =
- mdi->Sources.begin();
- i != mdi->Sources.end(); ++i) {
- fout << (*i)->GetFullPath() << "\n";
+ for (cmSourceFile const* i : mdi->Sources) {
+ fout << i->GetFullPath() << "\n";
}
cmCustomCommandLines commandLines;
diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx
index 6223be8..338c2b4 100644
--- a/Source/cmGlobalXCodeGenerator.cxx
+++ b/Source/cmGlobalXCodeGenerator.cxx
@@ -1172,7 +1172,7 @@ bool cmGlobalXCodeGenerator::CreateXCodeTargets(
// dstPath in frameworks is relative to Versions/<version>
ostr << keySources.first;
} else if (keySources.first != "MacOS") {
- if (gtgt->Target->GetMakefile()->PlatformIsAppleIos()) {
+ if (gtgt->Target->GetMakefile()->PlatformIsAppleEmbedded()) {
ostr << keySources.first;
} else {
// dstPath in bundles is relative to Contents/MacOS
@@ -2992,7 +2992,7 @@ bool cmGlobalXCodeGenerator::CreateXCodeObjects(
buildSettings->AddAttribute("ARCHS", this->CreateString(archs));
}
if (deploymentTarget && *deploymentTarget) {
- buildSettings->AddAttribute("MACOSX_DEPLOYMENT_TARGET",
+ buildSettings->AddAttribute(GetDeploymentPlatform(root->GetMakefile()),
this->CreateString(deploymentTarget));
}
if (!this->GeneratorToolset.empty()) {
@@ -3218,7 +3218,7 @@ void cmGlobalXCodeGenerator::CreateXCodeDependHackTarget(
<< this->ConvertToRelativeForMake(tfull.c_str())
<< "\n";
// if building for more than one architecture
- // then remove those exectuables as well
+ // then remove those executables as well
if (this->Architectures.size() > 1) {
std::string universal = this->GetObjectsNormalDirectory(
this->CurrentProject, configName, gt);
@@ -3605,7 +3605,7 @@ bool cmGlobalXCodeGenerator::UseEffectivePlatformName(cmMakefile* mf) const
"XCODE_EMIT_EFFECTIVE_PLATFORM_NAME");
if (!epnValue) {
- return mf->PlatformIsAppleIos();
+ return mf->PlatformIsAppleEmbedded();
}
return cmSystemTools::IsOn(epnValue);
@@ -3627,3 +3627,24 @@ void cmGlobalXCodeGenerator::ComputeTargetObjectDirectory(
dir += "/";
gt->ObjectDirectory = dir;
}
+
+std::string cmGlobalXCodeGenerator::GetDeploymentPlatform(const cmMakefile* mf)
+{
+ switch (mf->GetAppleSDKType()) {
+ case cmMakefile::AppleSDK::AppleTVOS:
+ case cmMakefile::AppleSDK::AppleTVSimulator:
+ return "TVOS_DEPLOYMENT_TARGET";
+
+ case cmMakefile::AppleSDK::IPhoneOS:
+ case cmMakefile::AppleSDK::IPhoneSimulator:
+ return "IPHONEOS_DEPLOYMENT_TARGET";
+
+ case cmMakefile::AppleSDK::WatchOS:
+ case cmMakefile::AppleSDK::WatchSimulator:
+ return "WATCHOS_DEPLOYMENT_TARGET";
+
+ case cmMakefile::AppleSDK::MacOS:
+ default:
+ return "MACOSX_DEPLOYMENT_TARGET";
+ }
+}
diff --git a/Source/cmGlobalXCodeGenerator.h b/Source/cmGlobalXCodeGenerator.h
index b758e97..2269b25 100644
--- a/Source/cmGlobalXCodeGenerator.h
+++ b/Source/cmGlobalXCodeGenerator.h
@@ -254,6 +254,8 @@ private:
const std::string& configName,
const cmGeneratorTarget* t) const;
+ static std::string GetDeploymentPlatform(const cmMakefile* mf);
+
void ComputeArchitectures(cmMakefile* mf);
void ComputeObjectDirArch(cmMakefile* mf);
diff --git a/Source/cmInstallTargetGenerator.cxx b/Source/cmInstallTargetGenerator.cxx
index b964794..814dc4f 100644
--- a/Source/cmInstallTargetGenerator.cxx
+++ b/Source/cmInstallTargetGenerator.cxx
@@ -167,7 +167,7 @@ void cmInstallTargetGenerator::GenerateScriptForConfig(
to1 += ".";
to1 += ext;
to1 += "/";
- if (!mf->PlatformIsAppleIos()) {
+ if (!mf->PlatformIsAppleEmbedded()) {
to1 += "Contents/MacOS/";
}
to1 += targetName;
@@ -796,7 +796,7 @@ void cmInstallTargetGenerator::AddUniversalInstallRule(
{
cmMakefile const* mf = this->Target->Target->GetMakefile();
- if (!mf->PlatformIsAppleIos() || !mf->IsOn("XCODE")) {
+ if (!mf->PlatformIsAppleEmbedded() || !mf->IsOn("XCODE")) {
return;
}
diff --git a/Source/cmLocalUnixMakefileGenerator3.cxx b/Source/cmLocalUnixMakefileGenerator3.cxx
index a389ad0..28890f0 100644
--- a/Source/cmLocalUnixMakefileGenerator3.cxx
+++ b/Source/cmLocalUnixMakefileGenerator3.cxx
@@ -1161,7 +1161,7 @@ void cmLocalUnixMakefileGenerator3::AppendEcho(
commands.push_back(cmd);
}
- // Reset the line to emtpy.
+ // Reset the line to empty.
line.clear();
// Progress appears only on first line.
diff --git a/Source/cmLocalVisualStudio10Generator.cxx b/Source/cmLocalVisualStudio10Generator.cxx
index 5e81514..2803d4a 100644
--- a/Source/cmLocalVisualStudio10Generator.cxx
+++ b/Source/cmLocalVisualStudio10Generator.cxx
@@ -64,20 +64,18 @@ cmLocalVisualStudio10Generator::~cmLocalVisualStudio10Generator()
void cmLocalVisualStudio10Generator::Generate()
{
-
const std::vector<cmGeneratorTarget*>& tgts = this->GetGeneratorTargets();
- for (std::vector<cmGeneratorTarget*>::const_iterator l = tgts.begin();
- l != tgts.end(); ++l) {
- if ((*l)->GetType() == cmStateEnums::INTERFACE_LIBRARY) {
+ for (cmGeneratorTarget* l : tgts) {
+ if (l->GetType() == cmStateEnums::INTERFACE_LIBRARY) {
continue;
}
if (static_cast<cmGlobalVisualStudioGenerator*>(this->GlobalGenerator)
- ->TargetIsFortranOnly(*l)) {
- this->CreateSingleVCProj((*l)->GetName().c_str(), *l);
+ ->TargetIsFortranOnly(l)) {
+ this->CreateSingleVCProj(l->GetName(), l);
} else {
cmVisualStudio10TargetGenerator tg(
- *l, static_cast<cmGlobalVisualStudio10Generator*>(
- this->GetGlobalGenerator()));
+ l, static_cast<cmGlobalVisualStudio10Generator*>(
+ this->GetGlobalGenerator()));
tg.Generate();
}
}
diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx
index 1b96ef4..eccd4d0 100644
--- a/Source/cmLocalVisualStudio7Generator.cxx
+++ b/Source/cmLocalVisualStudio7Generator.cxx
@@ -70,14 +70,13 @@ void cmLocalVisualStudio7Generator::AddHelperCommands()
{
// Now create GUIDs for targets
const std::vector<cmGeneratorTarget*>& tgts = this->GetGeneratorTargets();
- for (std::vector<cmGeneratorTarget*>::const_iterator l = tgts.begin();
- l != tgts.end(); ++l) {
- if ((*l)->GetType() == cmStateEnums::INTERFACE_LIBRARY) {
+ for (cmGeneratorTarget const* l : tgts) {
+ if (l->GetType() == cmStateEnums::INTERFACE_LIBRARY) {
continue;
}
- const char* path = (*l)->GetProperty("EXTERNAL_MSPROJECT");
+ const char* path = l->GetProperty("EXTERNAL_MSPROJECT");
if (path) {
- this->ReadAndStoreExternalGUID((*l)->GetName().c_str(), path);
+ this->ReadAndStoreExternalGUID(l->GetName(), path);
}
}
@@ -96,9 +95,8 @@ void cmLocalVisualStudio7Generator::FixGlobalTargets()
// commands for targets in which no sources are built. Add dummy
// rules to force these targets to build.
const std::vector<cmGeneratorTarget*>& tgts = this->GetGeneratorTargets();
- for (std::vector<cmGeneratorTarget*>::const_iterator l = tgts.begin();
- l != tgts.end(); l++) {
- if ((*l)->GetType() == cmStateEnums::GLOBAL_TARGET) {
+ for (cmGeneratorTarget* l : tgts) {
+ if (l->GetType() == cmStateEnums::GLOBAL_TARGET) {
std::vector<std::string> no_depends;
cmCustomCommandLine force_command;
force_command.push_back("cd");
@@ -109,12 +107,12 @@ void cmLocalVisualStudio7Generator::FixGlobalTargets()
std::string force = this->GetCurrentBinaryDirectory();
force += cmake::GetCMakeFilesDirectory();
force += "/";
- force += (*l)->GetName();
+ force += l->GetName();
force += "_force";
if (cmSourceFile* file = this->Makefile->AddCustomCommandToOutput(
force.c_str(), no_depends, no_main_dependency, force_commands, " ",
0, true)) {
- (*l)->AddSource(file->GetFullPath());
+ l->AddSource(file->GetFullPath());
}
}
}
@@ -138,15 +136,14 @@ void cmLocalVisualStudio7Generator::WriteProjectFiles()
const std::vector<cmGeneratorTarget*>& tgts = this->GetGeneratorTargets();
// Create the project file for each target.
- for (std::vector<cmGeneratorTarget*>::const_iterator l = tgts.begin();
- l != tgts.end(); l++) {
- if ((*l)->GetType() == cmStateEnums::INTERFACE_LIBRARY) {
+ for (cmGeneratorTarget* l : tgts) {
+ if (l->GetType() == cmStateEnums::INTERFACE_LIBRARY) {
continue;
}
// INCLUDE_EXTERNAL_MSPROJECT command only affects the workspace
// so don't build a projectfile for it
- if (!(*l)->GetProperty("EXTERNAL_MSPROJECT")) {
- this->CreateSingleVCProj((*l)->GetName().c_str(), *l);
+ if (!l->GetProperty("EXTERNAL_MSPROJECT")) {
+ this->CreateSingleVCProj(l->GetName(), l);
}
}
}
diff --git a/Source/cmLocalVisualStudioGenerator.cxx b/Source/cmLocalVisualStudioGenerator.cxx
index bbb91e0..2237da7 100644
--- a/Source/cmLocalVisualStudioGenerator.cxx
+++ b/Source/cmLocalVisualStudioGenerator.cxx
@@ -39,10 +39,8 @@ void cmLocalVisualStudioGenerator::ComputeObjectFilenames(
// windows file names are not case sensitive.
std::map<std::string, int> counts;
- for (std::map<cmSourceFile const*, std::string>::iterator si =
- mapping.begin();
- si != mapping.end(); ++si) {
- cmSourceFile const* sf = si->first;
+ for (auto const& si : mapping) {
+ cmSourceFile const* sf = si.first;
std::string objectNameLower = cmSystemTools::LowerCase(
cmSystemTools::GetFilenameWithoutLastExtension(sf->GetFullPath()));
if (custom_ext) {
@@ -57,10 +55,8 @@ void cmLocalVisualStudioGenerator::ComputeObjectFilenames(
// For all source files producing duplicate names we need unique
// object name computation.
- for (std::map<cmSourceFile const*, std::string>::iterator si =
- mapping.begin();
- si != mapping.end(); ++si) {
- cmSourceFile const* sf = si->first;
+ for (auto& si : mapping) {
+ cmSourceFile const* sf = si.first;
std::string objectName =
cmSystemTools::GetFilenameWithoutLastExtension(sf->GetFullPath());
if (custom_ext) {
@@ -74,7 +70,7 @@ void cmLocalVisualStudioGenerator::ComputeObjectFilenames(
objectName = this->GetObjectFileNameWithoutTarget(
*sf, dir_max, &keptSourceExtension, custom_ext);
}
- si->second = objectName;
+ si.second = objectName;
}
}
diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx
index a1e2f63..b42495c 100644
--- a/Source/cmMakefile.cxx
+++ b/Source/cmMakefile.cxx
@@ -855,7 +855,7 @@ cmSourceFile* cmMakefile::AddCustomCommandToOutput(
std::string outName = gg->GenerateRuleFile(outputs[0]);
// Check if the rule file already exists.
- file = this->GetSource(outName);
+ file = this->GetSource(outName, cmSourceFileLocationKind::Known);
if (file && file->GetCustomCommand() && !replace) {
// The rule file already exists.
if (commandLines != file->GetCustomCommand()->GetCommandLines()) {
@@ -868,19 +868,22 @@ cmSourceFile* cmMakefile::AddCustomCommandToOutput(
// Create a cmSourceFile for the rule file.
if (!file) {
- file = this->CreateSource(outName, true);
+ file =
+ this->CreateSource(outName, true, cmSourceFileLocationKind::Known);
}
file->SetProperty("__CMAKE_RULE", "1");
}
// Always create the output sources and mark them generated.
for (std::string const& o : outputs) {
- if (cmSourceFile* out = this->GetOrCreateSource(o, true)) {
+ if (cmSourceFile* out =
+ this->GetOrCreateSource(o, true, cmSourceFileLocationKind::Known)) {
out->SetProperty("GENERATED", "1");
}
}
for (std::string const& o : byproducts) {
- if (cmSourceFile* out = this->GetOrCreateSource(o, true)) {
+ if (cmSourceFile* out =
+ this->GetOrCreateSource(o, true, cmSourceFileLocationKind::Known)) {
out->SetProperty("GENERATED", "1");
}
}
@@ -967,7 +970,7 @@ void cmMakefile::AddCustomCommandOldStyle(
}
// Each output must get its own copy of this rule.
- cmsys::RegularExpression sourceFiles("\\.(C|M|c|c\\+\\+|cc|cpp|cxx|m|mm|"
+ cmsys::RegularExpression sourceFiles("\\.(C|M|c|c\\+\\+|cc|cpp|cxx|cu|m|mm|"
"rc|def|r|odl|idl|hpj|bat|h|h\\+\\+|"
"hm|hpp|hxx|in|txx|inl)$");
for (std::string const& oi : outputs) {
@@ -1092,7 +1095,8 @@ cmTarget* cmMakefile::AddUtilityCommand(
// Always create the byproduct sources and mark them generated.
for (std::string const& byproduct : byproducts) {
- if (cmSourceFile* out = this->GetOrCreateSource(byproduct, true)) {
+ if (cmSourceFile* out = this->GetOrCreateSource(
+ byproduct, true, cmSourceFileLocationKind::Known)) {
out->SetProperty("GENERATED", "1");
}
}
@@ -2244,25 +2248,38 @@ bool cmMakefile::PlatformIsx32() const
return false;
}
-bool cmMakefile::PlatformIsAppleIos() const
+cmMakefile::AppleSDK cmMakefile::GetAppleSDKType() const
{
std::string sdkRoot;
sdkRoot = this->GetSafeDefinition("CMAKE_OSX_SYSROOT");
sdkRoot = cmSystemTools::LowerCase(sdkRoot);
- const std::string embedded[] = {
- "appletvos", "appletvsimulator", "iphoneos",
- "iphonesimulator", "watchos", "watchsimulator",
+ struct
+ {
+ std::string name;
+ AppleSDK sdk;
+ } const sdkDatabase[]{
+ { "appletvos", AppleSDK::AppleTVOS },
+ { "appletvsimulator", AppleSDK::AppleTVSimulator },
+ { "iphoneos", AppleSDK::IPhoneOS },
+ { "iphonesimulator", AppleSDK::IPhoneSimulator },
+ { "watchos", AppleSDK::WatchOS },
+ { "watchsimulator", AppleSDK::WatchSimulator },
};
- for (std::string const& i : embedded) {
- if (sdkRoot.find(i) == 0 ||
- sdkRoot.find(std::string("/") + i) != std::string::npos) {
- return true;
+ for (auto entry : sdkDatabase) {
+ if (sdkRoot.find(entry.name) == 0 ||
+ sdkRoot.find(std::string("/") + entry.name) != std::string::npos) {
+ return entry.sdk;
}
}
- return false;
+ return AppleSDK::MacOS;
+}
+
+bool cmMakefile::PlatformIsAppleEmbedded() const
+{
+ return GetAppleSDKType() != AppleSDK::MacOS;
}
const char* cmMakefile::GetSONameFlag(const std::string& language) const
@@ -3119,9 +3136,10 @@ void cmMakefile::SetArgcArgv(const std::vector<std::string>& args)
}
}
-cmSourceFile* cmMakefile::GetSource(const std::string& sourceName) const
+cmSourceFile* cmMakefile::GetSource(const std::string& sourceName,
+ cmSourceFileLocationKind kind) const
{
- cmSourceFileLocation sfl(this, sourceName);
+ cmSourceFileLocation sfl(this, sourceName, kind);
auto name = this->GetCMakeInstance()->StripExtension(sfl.GetName());
#if defined(_WIN32) || defined(__APPLE__)
name = cmSystemTools::LowerCase(name);
@@ -3138,9 +3156,10 @@ cmSourceFile* cmMakefile::GetSource(const std::string& sourceName) const
}
cmSourceFile* cmMakefile::CreateSource(const std::string& sourceName,
- bool generated)
+ bool generated,
+ cmSourceFileLocationKind kind)
{
- cmSourceFile* sf = new cmSourceFile(this, sourceName);
+ cmSourceFile* sf = new cmSourceFile(this, sourceName, kind);
if (generated) {
sf->SetProperty("GENERATED", "1");
}
@@ -3157,12 +3176,13 @@ cmSourceFile* cmMakefile::CreateSource(const std::string& sourceName,
}
cmSourceFile* cmMakefile::GetOrCreateSource(const std::string& sourceName,
- bool generated)
+ bool generated,
+ cmSourceFileLocationKind kind)
{
- if (cmSourceFile* esf = this->GetSource(sourceName)) {
+ if (cmSourceFile* esf = this->GetSource(sourceName, kind)) {
return esf;
}
- return this->CreateSource(sourceName, generated);
+ return this->CreateSource(sourceName, generated, kind);
}
void cmMakefile::AddTargetObject(std::string const& tgtName,
diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h
index 737cab9..f06e2ff 100644
--- a/Source/cmMakefile.h
+++ b/Source/cmMakefile.h
@@ -20,6 +20,7 @@
#include "cmListFileCache.h"
#include "cmNewLineStyle.h"
#include "cmPolicies.h"
+#include "cmSourceFileLocationKind.h"
#include "cmStateSnapshot.h"
#include "cmStateTypes.h"
#include "cmTarget.h"
@@ -191,7 +192,7 @@ public:
};
/**
- * Add a utility to the build. A utiltity target is a command that
+ * Add a utility to the build. A utility target is a command that
* is run every time the target is built.
*/
cmTarget* AddUtilityCommand(const std::string& utilityName,
@@ -387,22 +388,26 @@ public:
/** Get a cmSourceFile pointer for a given source name, if the name is
* not found, then a null pointer is returned.
*/
- cmSourceFile* GetSource(const std::string& sourceName) const;
+ cmSourceFile* GetSource(
+ const std::string& sourceName,
+ cmSourceFileLocationKind kind = cmSourceFileLocationKind::Ambiguous) const;
/** Create the source file and return it. generated
* indicates if it is a generated file, this is used in determining
* how to create the source file instance e.g. name
*/
- cmSourceFile* CreateSource(const std::string& sourceName,
- bool generated = false);
+ cmSourceFile* CreateSource(
+ const std::string& sourceName, bool generated = false,
+ cmSourceFileLocationKind kind = cmSourceFileLocationKind::Ambiguous);
/** Get a cmSourceFile pointer for a given source name, if the name is
* not found, then create the source file and return it. generated
* indicates if it is a generated file, this is used in determining
* how to create the source file instance e.g. name
*/
- cmSourceFile* GetOrCreateSource(const std::string& sourceName,
- bool generated = false);
+ cmSourceFile* GetOrCreateSource(
+ const std::string& sourceName, bool generated = false,
+ cmSourceFileLocationKind kind = cmSourceFileLocationKind::Ambiguous);
void AddTargetObject(std::string const& tgtName, std::string const& objFile);
@@ -439,8 +444,23 @@ public:
/** Return whether the target platform is x32. */
bool PlatformIsx32() const;
+ /** Apple SDK Type */
+ enum class AppleSDK
+ {
+ MacOS,
+ IPhoneOS,
+ IPhoneSimulator,
+ AppleTVOS,
+ AppleTVSimulator,
+ WatchOS,
+ WatchSimulator,
+ };
+
+ /** What SDK type points CMAKE_OSX_SYSROOT to? */
+ AppleSDK GetAppleSDKType() const;
+
/** Return whether the target platform is Apple iOS. */
- bool PlatformIsAppleIos() const;
+ bool PlatformIsAppleEmbedded() const;
/** Retrieve soname flag for the specified language if supported */
const char* GetSONameFlag(const std::string& language) const;
diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx
index 850b8b2..002cc0f 100644
--- a/Source/cmMakefileTargetGenerator.cxx
+++ b/Source/cmMakefileTargetGenerator.cxx
@@ -884,7 +884,7 @@ bool cmMakefileTargetGenerator::WriteMakeRule(
for (std::vector<std::string>::const_iterator o = outputs.begin() + 1;
o != outputs.end(); ++o) {
// Touch the extra output so "make" knows that it was updated,
- // but only if the output was acually created.
+ // but only if the output was actually created.
std::string const out = this->LocalGenerator->ConvertToOutputFormat(
this->LocalGenerator->MaybeConvertToRelativePath(binDir, *o),
cmOutputConverter::SHELL);
diff --git a/Source/cmOSXBundleGenerator.cxx b/Source/cmOSXBundleGenerator.cxx
index c85c82d..e658e2c 100644
--- a/Source/cmOSXBundleGenerator.cxx
+++ b/Source/cmOSXBundleGenerator.cxx
@@ -82,7 +82,7 @@ void cmOSXBundleGenerator::CreateFramework(const std::string& targetName,
// Configure the Info.plist file
std::string plist = newoutpath;
- if (!this->Makefile->PlatformIsAppleIos()) {
+ if (!this->Makefile->PlatformIsAppleEmbedded()) {
// Put the Info.plist file into the Resources directory.
this->MacContentFolders->insert("Resources");
plist += "/Resources";
@@ -93,7 +93,7 @@ void cmOSXBundleGenerator::CreateFramework(const std::string& targetName,
plist.c_str());
// Generate Versions directory only for MacOSX frameworks
- if (this->Makefile->PlatformIsAppleIos()) {
+ if (this->Makefile->PlatformIsAppleEmbedded()) {
return;
}
diff --git a/Source/cmProcessOutput.cxx b/Source/cmProcessOutput.cxx
index 617e1ca..8371706 100644
--- a/Source/cmProcessOutput.cxx
+++ b/Source/cmProcessOutput.cxx
@@ -13,7 +13,7 @@ cmProcessOutput::Encoding cmProcessOutput::FindEncoding(
std::string const& name)
{
Encoding encoding = Auto;
- if (name == "UTF8") {
+ if ((name == "UTF8") || (name == "UTF-8")) {
encoding = UTF8;
} else if (name == "NONE") {
encoding = None;
diff --git a/Source/cmProjectCommand.cxx b/Source/cmProjectCommand.cxx
index fea8a9d..dfa1858 100644
--- a/Source/cmProjectCommand.cxx
+++ b/Source/cmProjectCommand.cxx
@@ -98,7 +98,7 @@ bool cmProjectCommand::InitialPass(std::vector<std::string> const& args,
} else if (args[i] == "DESCRIPTION") {
if (haveDescription) {
this->Makefile->IssueMessage(
- cmake::FATAL_ERROR, "DESCRITPION may be specified at most once.");
+ cmake::FATAL_ERROR, "DESCRIPTION may be specified at most once.");
cmSystemTools::SetFatalErrorOccured();
return true;
}
diff --git a/Source/cmQtAutoGeneratorInitializer.cxx b/Source/cmQtAutoGeneratorInitializer.cxx
index 14743de..de0ba4f 100644
--- a/Source/cmQtAutoGeneratorInitializer.cxx
+++ b/Source/cmQtAutoGeneratorInitializer.cxx
@@ -475,10 +475,16 @@ void cmQtAutoGeneratorInitializer::InitCustomTargets()
}
// Read skip files from makefile sources
if (this->MocEnabled || this->UicEnabled) {
- const std::vector<cmSourceFile*>& allSources = makefile->GetSourceFiles();
- for (cmSourceFile* sf : allSources) {
+ std::string pathError;
+ for (cmSourceFile* sf : makefile->GetSourceFiles()) {
// sf->GetExtension() is only valid after sf->GetFullPath() ...
- std::string const& fPath = sf->GetFullPath();
+ // Since we're iterating over source files that might be not in the
+ // target we need to check for path errors (not existing files).
+ std::string const& fPath = sf->GetFullPath(&pathError);
+ if (!pathError.empty()) {
+ pathError.clear();
+ continue;
+ }
cmSystemTools::FileFormat const fileType =
cmSystemTools::GetFileFormat(sf->GetExtension().c_str());
if (!(fileType == cmSystemTools::CXX_FILE_FORMAT) &&
@@ -1188,9 +1194,16 @@ void cmQtAutoGeneratorInitializer::SetupCustomTargetsUic()
std::vector<std::vector<std::string>> uiFileOptions;
{
std::string const uiExt = "ui";
+ std::string pathError;
for (cmSourceFile* sf : makefile->GetSourceFiles()) {
// sf->GetExtension() is only valid after sf->GetFullPath() ...
- std::string const& fPath = sf->GetFullPath();
+ // Since we're iterating over source files that might be not in the
+ // target we need to check for path errors (not existing files).
+ std::string const& fPath = sf->GetFullPath(&pathError);
+ if (!pathError.empty()) {
+ pathError.clear();
+ continue;
+ }
if (sf->GetExtension() == uiExt) {
std::string const absFile = cmSystemTools::GetRealPath(fPath);
// Check if the .ui file should be skipped
diff --git a/Source/cmQtAutoGeneratorMocUic.cxx b/Source/cmQtAutoGeneratorMocUic.cxx
index 0de02b5..bce148e 100644
--- a/Source/cmQtAutoGeneratorMocUic.cxx
+++ b/Source/cmQtAutoGeneratorMocUic.cxx
@@ -234,7 +234,7 @@ bool cmQtAutoGeneratorMocUic::InitInfoFile(cmMakefile* makefile)
// Compare list sizes
if (sources.size() != options.size()) {
std::ostringstream ost;
- ost << "files/options lists sizes missmatch (" << sources.size() << "/"
+ ost << "files/options lists sizes mismatch (" << sources.size() << "/"
<< options.size() << ")";
this->LogFileError(cmQtAutoGen::UIC, this->GetInfoFile(), ost.str());
return false;
diff --git a/Source/cmServerProtocol.cxx b/Source/cmServerProtocol.cxx
index d745c49..6b7143b 100644
--- a/Source/cmServerProtocol.cxx
+++ b/Source/cmServerProtocol.cxx
@@ -748,7 +748,8 @@ static Json::Value DumpSourceFilesList(
return result;
}
-static Json::Value DumpCTestInfo(cmTest* testInfo)
+static Json::Value DumpCTestInfo(cmLocalGenerator* lg, cmTest* testInfo,
+ const std::string& config)
{
Json::Value result = Json::objectValue;
result[kCTEST_NAME] = testInfo->GetName();
@@ -760,14 +761,24 @@ static Json::Value DumpCTestInfo(cmTest* testInfo)
command.append(cmd);
command.append(" ");
}
- result[kCTEST_COMMAND] = command;
+
+ // Remove any config specific variables from the output.
+ cmGeneratorExpression ge;
+ auto cge = ge.Parse(command.c_str());
+ const char* processed = cge->Evaluate(lg, config);
+
+ result[kCTEST_COMMAND] = processed;
// Build up the list of properties that may have been specified
Json::Value properties = Json::arrayValue;
for (auto& prop : testInfo->GetProperties()) {
Json::Value entry = Json::objectValue;
entry[kKEY_KEY] = prop.first;
- entry[kVALUE_KEY] = prop.second.GetValue();
+
+ // Remove config variables from the value too.
+ auto cge_value = ge.Parse(prop.second.GetValue());
+ const char* processed_value = cge_value->Evaluate(lg, config);
+ entry[kVALUE_KEY] = processed_value;
properties.append(entry);
}
result[kPROPERTIES_KEY] = properties;
@@ -775,13 +786,14 @@ static Json::Value DumpCTestInfo(cmTest* testInfo)
return result;
}
-static void DumpMakefileTests(cmMakefile* mf, const std::string& config,
+static void DumpMakefileTests(cmLocalGenerator* lg, const std::string& config,
Json::Value* result)
{
+ auto mf = lg->GetMakefile();
std::vector<cmTest*> tests;
mf->GetTests(config, tests);
for (auto test : tests) {
- Json::Value tmp = DumpCTestInfo(test);
+ Json::Value tmp = DumpCTestInfo(lg, test, config);
if (!tmp.isNull()) {
result->append(tmp);
}
@@ -805,8 +817,7 @@ static Json::Value DumpCTestProjectList(const cmake* cm,
for (const auto& lg : projectIt.second) {
// Make sure they're generated.
lg->GenerateTestFiles();
- cmMakefile* mf = lg->GetMakefile();
- DumpMakefileTests(mf, config, &tests);
+ DumpMakefileTests(lg, config, &tests);
}
pObj[kCTEST_INFO] = tests;
diff --git a/Source/cmSourceFile.cxx b/Source/cmSourceFile.cxx
index 0964bea..215f974 100644
--- a/Source/cmSourceFile.cxx
+++ b/Source/cmSourceFile.cxx
@@ -12,8 +12,9 @@
#include "cmSystemTools.h"
#include "cmake.h"
-cmSourceFile::cmSourceFile(cmMakefile* mf, const std::string& name)
- : Location(mf, name)
+cmSourceFile::cmSourceFile(cmMakefile* mf, const std::string& name,
+ cmSourceFileLocationKind kind)
+ : Location(mf, name, kind)
{
this->CustomCommand = nullptr;
this->FindFullPathFailed = false;
@@ -110,7 +111,7 @@ std::string const& cmSourceFile::GetFullPath() const
bool cmSourceFile::FindFullPath(std::string* error)
{
- // If thie method has already failed once do not try again.
+ // If this method has already failed once do not try again.
if (this->FindFullPathFailed) {
return false;
}
diff --git a/Source/cmSourceFile.h b/Source/cmSourceFile.h
index c2105d2..1516d98 100644
--- a/Source/cmSourceFile.h
+++ b/Source/cmSourceFile.h
@@ -7,6 +7,7 @@
#include "cmPropertyMap.h"
#include "cmSourceFileLocation.h"
+#include "cmSourceFileLocationKind.h"
#include <string>
#include <vector>
@@ -27,7 +28,9 @@ public:
* Construct with the makefile storing the source and the initial
* name referencing it.
*/
- cmSourceFile(cmMakefile* mf, const std::string& name);
+ cmSourceFile(
+ cmMakefile* mf, const std::string& name,
+ cmSourceFileLocationKind kind = cmSourceFileLocationKind::Ambiguous);
~cmSourceFile();
@@ -120,7 +123,8 @@ private:
#define CM_HEADER_REGEX "\\.(h|hh|h\\+\\+|hm|hpp|hxx|in|txx|inl)$"
#define CM_SOURCE_REGEX \
- "\\.(C|M|c|c\\+\\+|cc|cpp|cxx|f|f90|for|fpp|ftn|m|mm|rc|def|r|odl|idl|hpj" \
+ "\\.(C|M|c|c\\+\\+|cc|cpp|cxx|cu|f|f90|for|fpp|ftn|m|mm|rc|def|r|odl|idl|" \
+ "hpj" \
"|bat)$"
#define CM_RESOURCE_REGEX "\\.(pdf|plist|png|jpeg|jpg|storyboard|xcassets)$"
diff --git a/Source/cmSourceFileLocation.cxx b/Source/cmSourceFileLocation.cxx
index 6add7b3..5558ef3 100644
--- a/Source/cmSourceFileLocation.cxx
+++ b/Source/cmSourceFileLocation.cxx
@@ -27,7 +27,8 @@ cmSourceFileLocation::cmSourceFileLocation(const cmSourceFileLocation& loc)
}
cmSourceFileLocation::cmSourceFileLocation(cmMakefile const* mf,
- const std::string& name)
+ const std::string& name,
+ cmSourceFileLocationKind kind)
: Makefile(mf)
{
this->AmbiguousDirectory = !cmSystemTools::FileIsFullPath(name.c_str());
@@ -37,7 +38,12 @@ cmSourceFileLocation::cmSourceFileLocation(cmMakefile const* mf,
this->Directory = cmSystemTools::CollapseFullPath(this->Directory);
}
this->Name = cmSystemTools::GetFilenameName(name);
- this->UpdateExtension(name);
+ if (kind == cmSourceFileLocationKind::Known) {
+ this->DirectoryUseSource();
+ this->AmbiguousExtension = false;
+ } else {
+ this->UpdateExtension(name);
+ }
}
void cmSourceFileLocation::Update(cmSourceFileLocation const& loc)
diff --git a/Source/cmSourceFileLocation.h b/Source/cmSourceFileLocation.h
index 467682d..f325e54 100644
--- a/Source/cmSourceFileLocation.h
+++ b/Source/cmSourceFileLocation.h
@@ -7,6 +7,8 @@
#include <string>
+#include "cmSourceFileLocationKind.h"
+
class cmMakefile;
/** \class cmSourceFileLocation
@@ -26,7 +28,9 @@ public:
* Construct for a source file created in a given cmMakefile
* instance with an initial name.
*/
- cmSourceFileLocation(cmMakefile const* mf, const std::string& name);
+ cmSourceFileLocation(
+ cmMakefile const* mf, const std::string& name,
+ cmSourceFileLocationKind kind = cmSourceFileLocationKind::Ambiguous);
cmSourceFileLocation();
cmSourceFileLocation(const cmSourceFileLocation& loc);
@@ -38,12 +42,12 @@ public:
bool Matches(cmSourceFileLocation const& loc);
/**
- * Explicity state that the source file is located in the source tree.
+ * Explicitly state that the source file is located in the source tree.
*/
void DirectoryUseSource();
/**
- * Explicity state that the source file is located in the build tree.
+ * Explicitly state that the source file is located in the build tree.
*/
void DirectoryUseBinary();
diff --git a/Source/cmSourceFileLocationKind.h b/Source/cmSourceFileLocationKind.h
new file mode 100644
index 0000000..dd4c6dd
--- /dev/null
+++ b/Source/cmSourceFileLocationKind.h
@@ -0,0 +1,15 @@
+/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+ file Copyright.txt or https://cmake.org/licensing for details. */
+#ifndef cmSourceFileLocationKind_h
+#define cmSourceFileLocationKind_h
+
+enum class cmSourceFileLocationKind
+{
+ // The location is user-specified and may be ambiguous.
+ Ambiguous,
+ // The location is known to be at the given location; do not try to guess at
+ // extensions or absolute path.
+ Known
+};
+
+#endif
diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx
index 5d1f5f7..c321236 100644
--- a/Source/cmSystemTools.cxx
+++ b/Source/cmSystemTools.cxx
@@ -1308,6 +1308,9 @@ cmSystemTools::FileFormat cmSystemTools::GetFileFormat(const char* cext)
if (ext == "java" || ext == ".java") {
return cmSystemTools::JAVA_FILE_FORMAT;
}
+ if (ext == "cu" || ext == ".cu") {
+ return cmSystemTools::CUDA_FILE_FORMAT;
+ }
if (ext == "H" || ext == ".H" || ext == "h" || ext == ".h" || ext == "h++" ||
ext == ".h++" || ext == "hm" || ext == ".hm" || ext == "hpp" ||
ext == ".hpp" || ext == "hxx" || ext == ".hxx" || ext == "in" ||
diff --git a/Source/cmSystemTools.h b/Source/cmSystemTools.h
index 2646df9..d29ba56 100644
--- a/Source/cmSystemTools.h
+++ b/Source/cmSystemTools.h
@@ -59,7 +59,7 @@ public:
* Set the function used by GUIs to display error messages
* Function gets passed: message as a const char*,
* title as a const char*, and a reference to bool that when
- * set to false, will disable furthur messages (cancel).
+ * set to false, will disable further messages (cancel).
*/
static void SetMessageCallback(MessageCallback f,
void* clientData = nullptr);
@@ -167,7 +167,7 @@ public:
* to be at the end of the string and it does not support ?
* []... The optional argument type specifies what kind of files you
* want to find. 0 means all files, -1 means directories, 1 means
- * files only. This method returns true if search was succesfull.
+ * files only. This method returns true if search was successful.
*/
static bool SimpleGlob(const std::string& glob,
std::vector<std::string>& files, int type = 0);
@@ -229,7 +229,7 @@ public:
/**
* In this version of RunSingleCommand, command[0] should be
* the command to run, and each argument to the command should
- * be in comand[1]...command[command.size()]
+ * be in command[1]...command[command.size()]
*/
static bool RunSingleCommand(std::vector<std::string> const& command,
std::string* captureStdOut = nullptr,
@@ -285,6 +285,7 @@ public:
CXX_FILE_FORMAT,
FORTRAN_FILE_FORMAT,
JAVA_FILE_FORMAT,
+ CUDA_FILE_FORMAT,
HEADER_FILE_FORMAT,
RESOURCE_FILE_FORMAT,
DEFINITION_FILE_FORMAT,
diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx
index de23b08..1974be3 100644
--- a/Source/cmTarget.cxx
+++ b/Source/cmTarget.cxx
@@ -23,6 +23,7 @@
#include "cmProperty.h"
#include "cmSourceFile.h"
#include "cmSourceFileLocation.h"
+#include "cmSourceFileLocationKind.h"
#include "cmState.h"
#include "cmStateDirectory.h"
#include "cmStateSnapshot.h"
@@ -606,7 +607,8 @@ public:
cmSourceFile* cmTarget::AddSource(const std::string& src)
{
- cmSourceFileLocation sfl(this->Makefile, src);
+ cmSourceFileLocation sfl(this->Makefile, src,
+ cmSourceFileLocationKind::Known);
if (std::find_if(this->Internal->SourceEntries.begin(),
this->Internal->SourceEntries.end(),
TargetPropertyEntryFinder(sfl)) ==
@@ -618,7 +620,8 @@ cmSourceFile* cmTarget::AddSource(const std::string& src)
if (cmGeneratorExpression::Find(src) != std::string::npos) {
return nullptr;
}
- return this->Makefile->GetOrCreateSource(src);
+ return this->Makefile->GetOrCreateSource(src, false,
+ cmSourceFileLocationKind::Known);
}
void cmTarget::AddLinkDirectory(const std::string& d)
diff --git a/Source/cmTargetLinkLibrariesCommand.cxx b/Source/cmTargetLinkLibrariesCommand.cxx
index 97bb0a2..9e4575a 100644
--- a/Source/cmTargetLinkLibrariesCommand.cxx
+++ b/Source/cmTargetLinkLibrariesCommand.cxx
@@ -242,7 +242,7 @@ bool cmTargetLinkLibrariesCommand::InitialPass(
// Lookup old-style cache entry if type is unspecified. So if you
// do a target_link_libraries(foo optimized bar) it will stay optimized
// and not use the lookup. As there may be the case where someone has
- // specifed that a library is both debug and optimized. (this check is
+ // specified that a library is both debug and optimized. (this check is
// only there for backwards compatibility when mixing projects built
// with old versions of CMake and new)
llt = GENERAL_LibraryType;
diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx
index 1faff4e..ee9db43 100644
--- a/Source/cmVisualStudio10TargetGenerator.cxx
+++ b/Source/cmVisualStudio10TargetGenerator.cxx
@@ -38,8 +38,8 @@ static std::string cmVS10EscapeComment(std::string comment)
// does "echo $CDATA" with no escapes. We must encode the string.
// http://technet.microsoft.com/en-us/library/cc772462%28WS.10%29.aspx
std::string echoable;
- for (std::string::iterator c = comment.begin(); c != comment.end(); ++c) {
- switch (*c) {
+ for (char c : comment) {
+ switch (c) {
case '\r':
break;
case '\n':
@@ -54,7 +54,7 @@ static std::string cmVS10EscapeComment(std::string comment)
echoable += '^'; /* no break */
CM_FALLTHROUGH;
default:
- echoable += *c;
+ echoable += c;
break;
}
}
@@ -405,18 +405,17 @@ void cmVisualStudio10TargetGenerator::Generate()
}
std::vector<std::string> keys = this->GeneratorTarget->GetPropertyKeys();
- for (std::vector<std::string>::const_iterator keyIt = keys.begin();
- keyIt != keys.end(); ++keyIt) {
+ for (std::string const& keyIt : keys) {
static const char* prefix = "VS_GLOBAL_";
- if (keyIt->find(prefix) != 0)
+ if (keyIt.find(prefix) != 0)
continue;
- std::string globalKey = keyIt->substr(strlen(prefix));
+ std::string globalKey = keyIt.substr(strlen(prefix));
// Skip invalid or separately-handled properties.
if (globalKey.empty() || globalKey == "PROJECT_TYPES" ||
globalKey == "ROOTNAMESPACE" || globalKey == "KEYWORD") {
continue;
}
- const char* value = this->GeneratorTarget->GetProperty(*keyIt);
+ const char* value = this->GeneratorTarget->GetProperty(keyIt);
if (!value)
continue;
this->WriteString("<", 2);
@@ -578,22 +577,18 @@ void cmVisualStudio10TargetGenerator::Generate()
}
this->WriteString("</ImportGroup>\n", 1);
if (this->ProjectType == csproj) {
- for (std::vector<std::string>::const_iterator i =
- this->Configurations.begin();
- i != this->Configurations.end(); ++i) {
+ for (std::string const& i : this->Configurations) {
this->WriteString("<PropertyGroup Condition=\"'$(Configuration)' == '",
1);
- (*this->BuildFileStream) << *i << "'\">\n";
- this->WriteEvents(*i);
+ (*this->BuildFileStream) << i << "'\">\n";
+ this->WriteEvents(i);
this->WriteString("</PropertyGroup>\n", 1);
}
// make sure custom commands are executed before build (if necessary)
this->WriteString("<PropertyGroup>\n", 1);
this->WriteString("<BuildDependsOn>\n", 2);
- for (std::set<std::string>::const_iterator i =
- this->CSharpCustomCommandNames.begin();
- i != this->CSharpCustomCommandNames.end(); ++i) {
- this->WriteString(i->c_str(), 3);
+ for (std::string const& i : this->CSharpCustomCommandNames) {
+ this->WriteString(i.c_str(), 3);
(*this->BuildFileStream) << ";\n";
}
this->WriteString("$(BuildDependsOn)\n", 3);
@@ -615,12 +610,11 @@ void cmVisualStudio10TargetGenerator::WriteDotNetReferences()
cmSystemTools::ExpandListArgument(vsDotNetReferences, references);
}
cmPropertyMap const& props = this->GeneratorTarget->Target->GetProperties();
- for (cmPropertyMap::const_iterator i = props.begin(); i != props.end();
- ++i) {
- if (i->first.find("VS_DOTNET_REFERENCE_") == 0) {
- std::string name = i->first.substr(20);
+ for (auto const& i : props) {
+ 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.GetValue();
if (!cmsys::SystemTools::FileIsFullPath(path)) {
path = std::string(this->GeneratorTarget->Target->GetMakefile()
->GetCurrentSourceDirectory()) +
@@ -633,24 +627,20 @@ void cmVisualStudio10TargetGenerator::WriteDotNetReferences()
}
if (!references.empty() || !hintReferences.empty()) {
this->WriteString("<ItemGroup>\n", 1);
- for (std::vector<std::string>::iterator ri = references.begin();
- ri != references.end(); ++ri) {
+ for (std::string const& ri : references) {
// if the entry from VS_DOTNET_REFERENCES is an existing file, generate
// a new hint-reference and name it from the filename
- if (cmsys::SystemTools::FileExists(*ri, true)) {
- std::string name =
- cmsys::SystemTools::GetFilenameWithoutExtension(*ri);
- std::string path = *ri;
+ if (cmsys::SystemTools::FileExists(ri, true)) {
+ std::string name = cmsys::SystemTools::GetFilenameWithoutExtension(ri);
+ std::string path = ri;
this->ConvertToWindowsSlash(path);
hintReferences.push_back(HintReference(name, path));
} else {
- this->WriteDotNetReference(*ri, "");
+ this->WriteDotNetReference(ri, "");
}
}
- for (std::vector<std::pair<std::string, std::string>>::const_iterator i =
- hintReferences.begin();
- i != hintReferences.end(); ++i) {
- this->WriteDotNetReference(i->first, i->second);
+ for (const auto& i : hintReferences) {
+ this->WriteDotNetReference(i.first, i.second);
}
this->WriteString("</ItemGroup>\n", 1);
}
@@ -694,22 +684,19 @@ void cmVisualStudio10TargetGenerator::WriteDotNetReferenceCustomTags(
typedef std::map<std::string, std::string> CustomTags;
CustomTags tags;
cmPropertyMap const& props = this->GeneratorTarget->Target->GetProperties();
- for (cmPropertyMap::const_iterator i = props.begin(); i != props.end();
- ++i) {
- if (i->first.find(refPropFullPrefix) == 0) {
- std::string refTag = i->first.substr(refPropFullPrefix.length());
- std::string refVal = i->second.GetValue();
+ for (const auto& i : props) {
+ if (i.first.find(refPropFullPrefix) == 0) {
+ std::string refTag = i.first.substr(refPropFullPrefix.length());
+ std::string refVal = i.second.GetValue();
if (!refTag.empty() && !refVal.empty()) {
tags[refTag] = refVal;
}
}
}
- for (CustomTags::const_iterator tag = tags.begin(); tag != tags.end();
- ++tag) {
+ for (auto const& tag : tags) {
this->WriteString("<", 3);
- (*this->BuildFileStream) << tag->first << ">"
- << cmVS10EscapeXML(tag->second) << "</"
- << tag->first << ">\n";
+ (*this->BuildFileStream) << tag.first << ">" << cmVS10EscapeXML(tag.second)
+ << "</" << tag.first << ">\n";
}
}
@@ -721,10 +708,8 @@ void cmVisualStudio10TargetGenerator::WriteEmbeddedResourceGroup()
this->WriteString("<ItemGroup>\n", 1);
std::string srcDir = this->Makefile->GetCurrentSourceDirectory();
this->ConvertToWindowsSlash(srcDir);
- for (std::vector<cmSourceFile const*>::const_iterator oi =
- resxObjs.begin();
- oi != resxObjs.end(); ++oi) {
- std::string obj = (*oi)->GetFullPath();
+ for (cmSourceFile const* oi : resxObjs) {
+ std::string obj = oi->GetFullPath();
this->WriteString("<EmbeddedResource Include=\"", 2);
this->ConvertToWindowsSlash(obj);
bool useRelativePath = false;
@@ -746,10 +731,8 @@ void cmVisualStudio10TargetGenerator::WriteEmbeddedResourceGroup()
std::string hFileName = obj.substr(0, obj.find_last_of(".")) + ".h";
(*this->BuildFileStream) << hFileName << "</DependentUpon>\n";
- for (std::vector<std::string>::const_iterator i =
- this->Configurations.begin();
- i != this->Configurations.end(); ++i) {
- this->WritePlatformConfigTag("LogicalName", *i, 3);
+ for (std::string const& i : this->Configurations) {
+ this->WritePlatformConfigTag("LogicalName", i, 3);
if (this->GeneratorTarget->GetProperty("VS_GLOBAL_ROOTNAMESPACE") ||
// Handle variant of VS_GLOBAL_<variable> for RootNamespace.
this->GeneratorTarget->GetProperty("VS_GLOBAL_RootNamespace")) {
@@ -780,13 +763,12 @@ void cmVisualStudio10TargetGenerator::WriteEmbeddedResourceGroup()
}
// Determine if this is a generated resource from a .Designer.cs file
std::string designerResource =
- cmSystemTools::GetFilenamePath((*oi)->GetFullPath()) + "/" +
- cmSystemTools::GetFilenameWithoutLastExtension(
- (*oi)->GetFullPath()) +
+ cmSystemTools::GetFilenamePath(oi->GetFullPath()) + "/" +
+ cmSystemTools::GetFilenameWithoutLastExtension(oi->GetFullPath()) +
".Designer.cs";
if (cmsys::SystemTools::FileExists(designerResource)) {
std::string generator = "PublicResXFileCodeGenerator";
- if (const char* g = (*oi)->GetProperty("VS_RESOURCE_GENERATOR")) {
+ if (const char* g = oi->GetProperty("VS_RESOURCE_GENERATOR")) {
generator = g;
}
if (!generator.empty()) {
@@ -807,14 +789,13 @@ void cmVisualStudio10TargetGenerator::WriteEmbeddedResourceGroup()
<< "</LastGenOutput>\n";
}
}
- const cmPropertyMap& props = (*oi)->GetProperties();
- for (cmPropertyMap::const_iterator p = props.begin(); p != props.end();
- ++p) {
+ const cmPropertyMap& props = oi->GetProperties();
+ for (const auto& p : props) {
static const std::string propNamePrefix = "VS_CSHARP_";
- if (p->first.find(propNamePrefix) == 0) {
- std::string tagName = p->first.substr(propNamePrefix.length());
+ if (p.first.find(propNamePrefix) == 0) {
+ std::string tagName = p.first.substr(propNamePrefix.length());
if (!tagName.empty()) {
- std::string value = props.GetPropertyValue(p->first);
+ std::string value = props.GetPropertyValue(p.first);
if (!value.empty()) {
this->WriteString("<", 3);
(*this->BuildFileStream) << tagName << ">";
@@ -838,19 +819,17 @@ void cmVisualStudio10TargetGenerator::WriteXamlFilesGroup()
this->GeneratorTarget->GetXamlSources(xamlObjs, "");
if (!xamlObjs.empty()) {
this->WriteString("<ItemGroup>\n", 1);
- for (std::vector<cmSourceFile const*>::const_iterator oi =
- xamlObjs.begin();
- oi != xamlObjs.end(); ++oi) {
- std::string obj = (*oi)->GetFullPath();
+ for (cmSourceFile const* oi : xamlObjs) {
+ std::string obj = oi->GetFullPath();
std::string xamlType;
- const char* xamlTypeProperty = (*oi)->GetProperty("VS_XAML_TYPE");
+ const char* xamlTypeProperty = oi->GetProperty("VS_XAML_TYPE");
if (xamlTypeProperty) {
xamlType = xamlTypeProperty;
} else {
xamlType = "Page";
}
- this->WriteSource(xamlType, *oi, ">\n");
+ this->WriteSource(xamlType, oi, ">\n");
if (this->ProjectType == csproj && !this->InSourceBuild) {
// add <Link> tag to written XAML source if necessary
const std::string srcDir = this->Makefile->GetCurrentSourceDirectory();
@@ -1425,30 +1404,28 @@ void cmVisualStudio10TargetGenerator::WriteGroups()
// Added files are images and the manifest.
if (!this->AddedFiles.empty()) {
this->WriteString("<ItemGroup>\n", 1);
- for (std::vector<std::string>::const_iterator oi =
- this->AddedFiles.begin();
- oi != this->AddedFiles.end(); ++oi) {
+ for (std::string const& oi : this->AddedFiles) {
std::string fileName =
- cmSystemTools::LowerCase(cmSystemTools::GetFilenameName(*oi));
+ cmSystemTools::LowerCase(cmSystemTools::GetFilenameName(oi));
if (fileName == "wmappmanifest.xml") {
this->WriteString("<XML Include=\"", 2);
- (*this->BuildFileStream) << *oi << "\">\n";
+ (*this->BuildFileStream) << oi << "\">\n";
this->WriteString("<Filter>Resource Files</Filter>\n", 3);
this->WriteString("</XML>\n", 2);
} else if (cmSystemTools::GetFilenameExtension(fileName) ==
".appxmanifest") {
this->WriteString("<AppxManifest Include=\"", 2);
- (*this->BuildFileStream) << *oi << "\">\n";
+ (*this->BuildFileStream) << oi << "\">\n";
this->WriteString("<Filter>Resource Files</Filter>\n", 3);
this->WriteString("</AppxManifest>\n", 2);
} else if (cmSystemTools::GetFilenameExtension(fileName) == ".pfx") {
this->WriteString("<None Include=\"", 2);
- (*this->BuildFileStream) << *oi << "\">\n";
+ (*this->BuildFileStream) << oi << "\">\n";
this->WriteString("<Filter>Resource Files</Filter>\n", 3);
this->WriteString("</None>\n", 2);
} else {
this->WriteString("<Image Include=\"", 2);
- (*this->BuildFileStream) << *oi << "\">\n";
+ (*this->BuildFileStream) << oi << "\">\n";
this->WriteString("<Filter>Resource Files</Filter>\n", 3);
this->WriteString("</Image>\n", 2);
}
@@ -1460,10 +1437,8 @@ void cmVisualStudio10TargetGenerator::WriteGroups()
this->GeneratorTarget->GetResxSources(resxObjs, "");
if (!resxObjs.empty()) {
this->WriteString("<ItemGroup>\n", 1);
- for (std::vector<cmSourceFile const*>::const_iterator oi =
- resxObjs.begin();
- oi != resxObjs.end(); ++oi) {
- std::string obj = (*oi)->GetFullPath();
+ for (cmSourceFile const* oi : resxObjs) {
+ std::string obj = oi->GetFullPath();
this->WriteString("<EmbeddedResource Include=\"", 2);
this->ConvertToWindowsSlash(obj);
(*this->BuildFileStream) << cmVS10EscapeXML(obj) << "\">\n";
@@ -1522,16 +1497,15 @@ void cmVisualStudio10TargetGenerator::AddMissingSourceGroups(
std::set<cmSourceGroup*>& groupsUsed,
const std::vector<cmSourceGroup>& allGroups)
{
- for (std::vector<cmSourceGroup>::const_iterator current = allGroups.begin();
- current != allGroups.end(); ++current) {
- std::vector<cmSourceGroup> const& children = current->GetGroupChildren();
+ for (cmSourceGroup const& current : allGroups) {
+ std::vector<cmSourceGroup> const& children = current.GetGroupChildren();
if (children.empty()) {
continue; // the group is really empty
}
this->AddMissingSourceGroups(groupsUsed, children);
- cmSourceGroup* current_ptr = const_cast<cmSourceGroup*>(&(*current));
+ cmSourceGroup* current_ptr = const_cast<cmSourceGroup*>(&current);
if (groupsUsed.find(current_ptr) != groupsUsed.end()) {
continue; // group has already been added to set
}
@@ -1560,15 +1534,14 @@ void cmVisualStudio10TargetGenerator::WriteGroupSources(
std::vector<cmSourceGroup>& sourceGroups)
{
this->WriteString("<ItemGroup>\n", 1);
- for (ToolSources::const_iterator s = sources.begin(); s != sources.end();
- ++s) {
- cmSourceFile const* sf = s->SourceFile;
+ for (ToolSource const& s : sources) {
+ cmSourceFile const* sf = s.SourceFile;
std::string const& source = sf->GetFullPath();
cmSourceGroup* sourceGroup =
this->Makefile->FindSourceGroup(source.c_str(), sourceGroups);
std::string const& filter = sourceGroup->GetFullName();
this->WriteString("<", 2);
- std::string path = this->ConvertPath(source, s->RelativePath);
+ std::string path = this->ConvertPath(source, s.RelativePath);
this->ConvertToWindowsSlash(path);
(*this->BuildFileStream) << name << " Include=\"" << cmVS10EscapeXML(path);
if (!filter.empty()) {
@@ -1939,11 +1912,9 @@ void cmVisualStudio10TargetGenerator::WriteAllSources()
std::vector<cmGeneratorTarget::AllConfigSource> const& sources =
this->GeneratorTarget->GetAllConfigSources();
- for (std::vector<cmGeneratorTarget::AllConfigSource>::const_iterator si =
- sources.begin();
- si != sources.end(); ++si) {
+ for (cmGeneratorTarget::AllConfigSource const& si : sources) {
std::string tool;
- switch (si->Kind) {
+ switch (si.Kind) {
case cmGeneratorTarget::SourceKindAppManifest:
tool = "AppxManifest";
break;
@@ -1962,17 +1933,17 @@ void cmVisualStudio10TargetGenerator::WriteAllSources()
// then vs10 will use it in the build, and we have to list it as
// None instead of Object.
std::vector<cmSourceFile*> const* d =
- this->GeneratorTarget->GetSourceDepends(si->Source);
+ this->GeneratorTarget->GetSourceDepends(si.Source);
if (d && !d->empty()) {
tool = "None";
}
}
break;
case cmGeneratorTarget::SourceKindExtra:
- this->WriteExtraSource(si->Source);
+ this->WriteExtraSource(si.Source);
break;
case cmGeneratorTarget::SourceKindHeader:
- this->WriteHeaderSource(si->Source);
+ this->WriteHeaderSource(si.Source);
break;
case cmGeneratorTarget::SourceKindIDL:
tool = "Midl";
@@ -1984,7 +1955,7 @@ void cmVisualStudio10TargetGenerator::WriteAllSources()
tool = "None";
break;
case cmGeneratorTarget::SourceKindObjectSource: {
- const std::string& lang = si->Source->GetLanguage();
+ const std::string& lang = si.Source->GetLanguage();
if (lang == "C" || lang == "CXX") {
tool = "ClCompile";
} else if (lang == "ASM_MASM" &&
@@ -2013,16 +1984,16 @@ void cmVisualStudio10TargetGenerator::WriteAllSources()
if (!tool.empty()) {
// Compute set of configurations to exclude, if any.
- std::vector<size_t> const& include_configs = si->Configs;
+ std::vector<size_t> const& include_configs = si.Configs;
std::vector<size_t> exclude_configs;
std::set_difference(all_configs.begin(), all_configs.end(),
include_configs.begin(), include_configs.end(),
std::back_inserter(exclude_configs));
- if (si->Kind == cmGeneratorTarget::SourceKindObjectSource) {
+ if (si.Kind == cmGeneratorTarget::SourceKindObjectSource) {
// FIXME: refactor generation to avoid tracking XML syntax state.
- this->WriteSource(tool, si->Source, " ");
- bool have_nested = this->OutputSourceSpecificFlags(si->Source);
+ this->WriteSource(tool, si.Source, " ");
+ bool have_nested = this->OutputSourceSpecificFlags(si.Source);
if (!exclude_configs.empty()) {
if (!have_nested) {
(*this->BuildFileStream) << ">\n";
@@ -2037,12 +2008,12 @@ void cmVisualStudio10TargetGenerator::WriteAllSources()
(*this->BuildFileStream) << " />\n";
}
} else if (!exclude_configs.empty()) {
- this->WriteSource(tool, si->Source, ">\n");
+ this->WriteSource(tool, si.Source, ">\n");
this->WriteExcludeFromBuild(exclude_configs);
this->WriteString("</", 2);
(*this->BuildFileStream) << tool << ">\n";
} else {
- this->WriteSource(tool, si->Source);
+ this->WriteSource(tool, si.Source);
}
}
}
@@ -2113,10 +2084,8 @@ bool cmVisualStudio10TargetGenerator::OutputSourceSpecificFlags(
(*this->BuildFileStream) << "$(IntDir)/" << objectName
<< "</ObjectFileName>\n";
}
- for (std::vector<std::string>::const_iterator config =
- this->Configurations.begin();
- config != this->Configurations.end(); ++config) {
- std::string configUpper = cmSystemTools::UpperCase(*config);
+ for (std::string const& config : this->Configurations) {
+ std::string configUpper = cmSystemTools::UpperCase(config);
std::string configDefines = defines;
std::string defPropName = "COMPILE_DEFINITIONS_";
defPropName += configUpper;
@@ -2152,7 +2121,7 @@ bool cmVisualStudio10TargetGenerator::OutputSourceSpecificFlags(
flagtable = gg->GetCSharpFlagTable();
}
cmGeneratorExpressionInterpreter genexInterpreter(
- this->LocalGenerator, this->GeneratorTarget, *config,
+ this->LocalGenerator, this->GeneratorTarget, config,
this->GeneratorTarget->GetName(), lang);
cmVisualStudioGeneratorOptions clOptions(
this->LocalGenerator, cmVisualStudioGeneratorOptions::Compiler,
@@ -2182,7 +2151,7 @@ bool cmVisualStudio10TargetGenerator::OutputSourceSpecificFlags(
} else {
clOptions.AddDefines(configDefines.c_str());
}
- clOptions.SetConfiguration((*config).c_str());
+ clOptions.SetConfiguration(config.c_str());
clOptions.PrependInheritedString("AdditionalOptions");
clOptions.OutputFlagMap(*this->BuildFileStream, " ");
clOptions.OutputPreprocessorDefinitions(*this->BuildFileStream, " ",
@@ -2224,12 +2193,11 @@ bool cmVisualStudio10TargetGenerator::OutputSourceSpecificFlags(
void cmVisualStudio10TargetGenerator::WriteExcludeFromBuild(
std::vector<size_t> const& exclude_configs)
{
- for (std::vector<size_t>::const_iterator ci = exclude_configs.begin();
- ci != exclude_configs.end(); ++ci) {
+ for (size_t ci : exclude_configs) {
this->WriteString("", 3);
(*this->BuildFileStream)
<< "<ExcludedFromBuild Condition=\"'$(Configuration)|$(Platform)'=='"
- << cmVS10EscapeXML(this->Configurations[*ci]) << "|"
+ << cmVS10EscapeXML(this->Configurations[ci]) << "|"
<< cmVS10EscapeXML(this->Platform) << "'\">true</ExcludedFromBuild>\n";
}
}
@@ -2248,11 +2216,9 @@ void cmVisualStudio10TargetGenerator::WritePathAndIncrementalLinkOptions()
this->WriteString("<_ProjectFileVersion>10.0.20506.1"
"</_ProjectFileVersion>\n",
2);
- for (std::vector<std::string>::const_iterator config =
- this->Configurations.begin();
- config != this->Configurations.end(); ++config) {
+ for (std::string const& config : this->Configurations) {
if (ttype >= cmStateEnums::UTILITY) {
- this->WritePlatformConfigTag("IntDir", *config, 2);
+ this->WritePlatformConfigTag("IntDir", config, 2);
*this->BuildFileStream
<< "$(Platform)\\$(Configuration)\\$(ProjectName)\\"
<< "</IntDir>\n";
@@ -2260,7 +2226,7 @@ void cmVisualStudio10TargetGenerator::WritePathAndIncrementalLinkOptions()
std::string intermediateDir =
this->LocalGenerator->GetTargetDirectory(this->GeneratorTarget);
intermediateDir += "/";
- intermediateDir += *config;
+ intermediateDir += config;
intermediateDir += "/";
std::string outDir;
std::string targetNameFull;
@@ -2269,22 +2235,22 @@ void cmVisualStudio10TargetGenerator::WritePathAndIncrementalLinkOptions()
targetNameFull = this->GeneratorTarget->GetName();
targetNameFull += ".lib";
} else {
- outDir = this->GeneratorTarget->GetDirectory(*config) + "/";
- targetNameFull = this->GeneratorTarget->GetFullName(*config);
+ outDir = this->GeneratorTarget->GetDirectory(config) + "/";
+ targetNameFull = this->GeneratorTarget->GetFullName(config);
}
this->ConvertToWindowsSlash(intermediateDir);
this->ConvertToWindowsSlash(outDir);
- this->WritePlatformConfigTag("OutDir", *config, 2);
+ this->WritePlatformConfigTag("OutDir", config, 2);
*this->BuildFileStream << cmVS10EscapeXML(outDir) << "</OutDir>\n";
- this->WritePlatformConfigTag("IntDir", *config, 2);
+ this->WritePlatformConfigTag("IntDir", config, 2);
*this->BuildFileStream << cmVS10EscapeXML(intermediateDir)
<< "</IntDir>\n";
if (const char* workingDir = this->GeneratorTarget->GetProperty(
"VS_DEBUGGER_WORKING_DIRECTORY")) {
- this->WritePlatformConfigTag("LocalDebuggerWorkingDirectory", *config,
+ this->WritePlatformConfigTag("LocalDebuggerWorkingDirectory", config,
2);
*this->BuildFileStream << cmVS10EscapeXML(workingDir)
<< "</LocalDebuggerWorkingDirectory>\n";
@@ -2292,7 +2258,7 @@ void cmVisualStudio10TargetGenerator::WritePathAndIncrementalLinkOptions()
std::string name =
cmSystemTools::GetFilenameWithoutLastExtension(targetNameFull);
- this->WritePlatformConfigTag("TargetName", *config, 2);
+ this->WritePlatformConfigTag("TargetName", config, 2);
*this->BuildFileStream << cmVS10EscapeXML(name) << "</TargetName>\n";
std::string ext =
@@ -2302,10 +2268,10 @@ void cmVisualStudio10TargetGenerator::WritePathAndIncrementalLinkOptions()
// A single "." appears to be treated as an empty extension.
ext = ".";
}
- this->WritePlatformConfigTag("TargetExt", *config, 2);
+ this->WritePlatformConfigTag("TargetExt", config, 2);
*this->BuildFileStream << cmVS10EscapeXML(ext) << "</TargetExt>\n";
- this->OutputLinkIncremental(*config);
+ this->OutputLinkIncremental(config);
}
}
this->WriteString("</PropertyGroup>\n", 1);
@@ -2355,10 +2321,8 @@ void cmVisualStudio10TargetGenerator::OutputLinkIncremental(
bool cmVisualStudio10TargetGenerator::ComputeClOptions()
{
- for (std::vector<std::string>::const_iterator i =
- this->Configurations.begin();
- i != this->Configurations.end(); ++i) {
- if (!this->ComputeClOptions(*i)) {
+ for (std::string const& i : this->Configurations) {
+ if (!this->ComputeClOptions(i)) {
return false;
}
}
@@ -2582,10 +2546,8 @@ void cmVisualStudio10TargetGenerator::WriteClOptions(
bool cmVisualStudio10TargetGenerator::ComputeRcOptions()
{
- for (std::vector<std::string>::const_iterator i =
- this->Configurations.begin();
- i != this->Configurations.end(); ++i) {
- if (!this->ComputeRcOptions(*i)) {
+ for (std::string const& i : this->Configurations) {
+ if (!this->ComputeRcOptions(i)) {
return false;
}
}
@@ -2643,10 +2605,8 @@ bool cmVisualStudio10TargetGenerator::ComputeCudaOptions()
if (!this->GlobalGenerator->IsCudaEnabled()) {
return true;
}
- for (std::vector<std::string>::const_iterator i =
- this->Configurations.begin();
- i != this->Configurations.end(); ++i) {
- if (!this->ComputeCudaOptions(*i)) {
+ for (std::string const& i : this->Configurations) {
+ if (!this->ComputeCudaOptions(i)) {
return false;
}
}
@@ -2764,10 +2724,8 @@ bool cmVisualStudio10TargetGenerator::ComputeCudaLinkOptions()
if (!this->GlobalGenerator->IsCudaEnabled()) {
return true;
}
- for (std::vector<std::string>::const_iterator i =
- this->Configurations.begin();
- i != this->Configurations.end(); ++i) {
- if (!this->ComputeCudaLinkOptions(*i)) {
+ for (std::string const& i : this->Configurations) {
+ if (!this->ComputeCudaLinkOptions(i)) {
return false;
}
}
@@ -2835,10 +2793,8 @@ bool cmVisualStudio10TargetGenerator::ComputeMasmOptions()
if (!this->GlobalGenerator->IsMasmEnabled()) {
return true;
}
- for (std::vector<std::string>::const_iterator i =
- this->Configurations.begin();
- i != this->Configurations.end(); ++i) {
- if (!this->ComputeMasmOptions(*i)) {
+ for (std::string const& i : this->Configurations) {
+ if (!this->ComputeMasmOptions(i)) {
return false;
}
}
@@ -2893,10 +2849,8 @@ bool cmVisualStudio10TargetGenerator::ComputeNasmOptions()
if (!this->GlobalGenerator->IsNasmEnabled()) {
return true;
}
- for (std::vector<std::string>::const_iterator i =
- this->Configurations.begin();
- i != this->Configurations.end(); ++i) {
- if (!this->ComputeNasmOptions(*i)) {
+ for (std::string const& i : this->Configurations) {
+ if (!this->ComputeNasmOptions(i)) {
return false;
}
}
@@ -3003,10 +2957,8 @@ void cmVisualStudio10TargetGenerator::WriteManifestOptions(
if (!manifest_srcs.empty()) {
this->WriteString("<Manifest>\n", 2);
this->WriteString("<AdditionalManifestFiles>", 3);
- for (std::vector<cmSourceFile const*>::const_iterator mi =
- manifest_srcs.begin();
- mi != manifest_srcs.end(); ++mi) {
- std::string m = this->ConvertPath((*mi)->GetFullPath(), false);
+ for (cmSourceFile const* mi : manifest_srcs) {
+ std::string m = this->ConvertPath(mi->GetFullPath(), false);
this->ConvertToWindowsSlash(m);
(*this->BuildFileStream) << m << ";";
}
@@ -3024,12 +2976,10 @@ void cmVisualStudio10TargetGenerator::WriteAntBuildOptions(
{
std::vector<cmSourceFile const*> extraSources;
this->GeneratorTarget->GetExtraSources(extraSources, "");
- for (std::vector<cmSourceFile const*>::const_iterator si =
- extraSources.begin();
- si != extraSources.end(); ++si) {
+ for (cmSourceFile const* si : extraSources) {
if ("androidmanifest.xml" ==
- cmSystemTools::LowerCase((*si)->GetLocation().GetName())) {
- rootDir = (*si)->GetLocation().GetDirectory();
+ cmSystemTools::LowerCase(si->GetLocation().GetName())) {
+ rootDir = si->GetLocation().GetDirectory();
break;
}
}
@@ -3148,10 +3098,8 @@ bool cmVisualStudio10TargetGenerator::ComputeLinkOptions()
if (this->GeneratorTarget->GetType() == cmStateEnums::EXECUTABLE ||
this->GeneratorTarget->GetType() == cmStateEnums::SHARED_LIBRARY ||
this->GeneratorTarget->GetType() == cmStateEnums::MODULE_LIBRARY) {
- for (std::vector<std::string>::const_iterator i =
- this->Configurations.begin();
- i != this->Configurations.end(); ++i) {
- if (!this->ComputeLinkOptions(*i)) {
+ for (std::string const& i : this->Configurations) {
+ if (!this->ComputeLinkOptions(i)) {
return false;
}
}
@@ -3248,19 +3196,17 @@ bool cmVisualStudio10TargetGenerator::ComputeLinkOptions(
linkOptions.AddFlag("AdditionalDependencies", libVec);
// Populate TargetsFileAndConfigsVec
- for (std::vector<std::string>::iterator ti = vsTargetVec.begin();
- ti != vsTargetVec.end(); ++ti) {
- this->AddTargetsFileAndConfigPair(*ti, config);
+ for (std::string const& ti : vsTargetVec) {
+ this->AddTargetsFileAndConfigPair(ti, config);
}
std::vector<std::string> const& ldirs = cli.GetDirectories();
std::vector<std::string> linkDirs;
- for (std::vector<std::string>::const_iterator d = ldirs.begin();
- d != ldirs.end(); ++d) {
+ for (std::string const& d : ldirs) {
// first just full path
- linkDirs.push_back(*d);
+ linkDirs.push_back(d);
// next path with configuration type Debug, Release, etc
- linkDirs.push_back(*d + "/$(Configuration)");
+ linkDirs.push_back(d + "/$(Configuration)");
}
linkDirs.push_back("%(AdditionalLibraryDirectories)");
linkOptions.AddFlag("AdditionalLibraryDirectories", linkDirs);
@@ -3380,10 +3326,8 @@ bool cmVisualStudio10TargetGenerator::ComputeLinkOptions(
bool cmVisualStudio10TargetGenerator::ComputeLibOptions()
{
if (this->GeneratorTarget->GetType() == cmStateEnums::STATIC_LIBRARY) {
- for (std::vector<std::string>::const_iterator i =
- this->Configurations.begin();
- i != this->Configurations.end(); ++i) {
- if (!this->ComputeLibOptions(*i)) {
+ for (std::string const& i : this->Configurations) {
+ if (!this->ComputeLibOptions(i)) {
return false;
}
}
@@ -3408,10 +3352,10 @@ bool cmVisualStudio10TargetGenerator::ComputeLibOptions(
const ItemVector& libs = cli.GetItems();
std::string currentBinDir =
this->LocalGenerator->GetCurrentBinaryDirectory();
- for (ItemVector::const_iterator l = libs.begin(); l != libs.end(); ++l) {
- if (l->IsPath && cmVS10IsTargetsFile(l->Value)) {
+ for (cmComputeLinkInformation::Item const& l : libs) {
+ if (l.IsPath && cmVS10IsTargetsFile(l.Value)) {
std::string path =
- this->LocalGenerator->ConvertToRelativePath(currentBinDir, l->Value);
+ this->LocalGenerator->ConvertToRelativePath(currentBinDir, l.Value);
this->ConvertToWindowsSlash(path);
this->AddTargetsFileAndConfigPair(path, config);
}
@@ -3454,19 +3398,19 @@ void cmVisualStudio10TargetGenerator::AddLibraries(
ItemVector const& libs = cli.GetItems();
std::string currentBinDir =
this->LocalGenerator->GetCurrentBinaryDirectory();
- for (ItemVector::const_iterator l = libs.begin(); l != libs.end(); ++l) {
- if (l->IsPath) {
+ for (cmComputeLinkInformation::Item const& l : libs) {
+ if (l.IsPath) {
std::string path =
- this->LocalGenerator->ConvertToRelativePath(currentBinDir, l->Value);
+ this->LocalGenerator->ConvertToRelativePath(currentBinDir, l.Value);
this->ConvertToWindowsSlash(path);
- if (cmVS10IsTargetsFile(l->Value)) {
+ if (cmVS10IsTargetsFile(l.Value)) {
vsTargetVec.push_back(path);
} else {
libVec.push_back(path);
}
- } else if (!l->Target ||
- l->Target->GetType() != cmStateEnums::INTERFACE_LIBRARY) {
- libVec.push_back(l->Value);
+ } else if (!l.Target ||
+ l.Target->GetType() != cmStateEnums::INTERFACE_LIBRARY) {
+ libVec.push_back(l.Value);
}
}
}
@@ -3474,13 +3418,11 @@ void cmVisualStudio10TargetGenerator::AddLibraries(
void cmVisualStudio10TargetGenerator::AddTargetsFileAndConfigPair(
std::string const& targetsFile, std::string const& config)
{
- for (std::vector<TargetsFileAndConfigs>::iterator i =
- this->TargetsFileAndConfigsVec.begin();
- i != this->TargetsFileAndConfigsVec.end(); ++i) {
- if (cmSystemTools::ComparePath(targetsFile, i->File)) {
- if (std::find(i->Configs.begin(), i->Configs.end(), config) ==
- i->Configs.end()) {
- i->Configs.push_back(config);
+ for (TargetsFileAndConfigs& i : this->TargetsFileAndConfigsVec) {
+ if (cmSystemTools::ComparePath(targetsFile, i.File)) {
+ if (std::find(i.Configs.begin(), i.Configs.end(), config) ==
+ i.Configs.end()) {
+ i.Configs.push_back(config);
}
return;
}
@@ -3518,9 +3460,8 @@ void cmVisualStudio10TargetGenerator::WriteMidlOptions(
// on the CMake side?
this->WriteString("<Midl>\n", 2);
this->WriteString("<AdditionalIncludeDirectories>", 3);
- for (std::vector<std::string>::const_iterator i = includes.begin();
- i != includes.end(); ++i) {
- *this->BuildFileStream << cmVS10EscapeXML(*i) << ";";
+ for (std::string const& i : includes) {
+ *this->BuildFileStream << cmVS10EscapeXML(i) << ";";
}
this->WriteString("%(AdditionalIncludeDirectories)"
"</AdditionalIncludeDirectories>\n",
@@ -3542,44 +3483,41 @@ void cmVisualStudio10TargetGenerator::WriteItemDefinitionGroups()
if (this->ProjectType == csproj) {
return;
}
- for (std::vector<std::string>::const_iterator i =
- this->Configurations.begin();
- i != this->Configurations.end(); ++i) {
+ for (std::string const& i : this->Configurations) {
std::vector<std::string> includes;
- this->LocalGenerator->GetIncludeDirectories(
- includes, this->GeneratorTarget, "C", *i);
- for (std::vector<std::string>::iterator ii = includes.begin();
- ii != includes.end(); ++ii) {
- this->ConvertToWindowsSlash(*ii);
+ this->LocalGenerator->GetIncludeDirectories(includes,
+ this->GeneratorTarget, "C", i);
+ for (std::string& ii : includes) {
+ this->ConvertToWindowsSlash(ii);
}
- this->WritePlatformConfigTag("ItemDefinitionGroup", *i, 1);
+ this->WritePlatformConfigTag("ItemDefinitionGroup", i, 1);
*this->BuildFileStream << "\n";
// output cl compile flags <ClCompile></ClCompile>
if (this->GeneratorTarget->GetType() <= cmStateEnums::OBJECT_LIBRARY) {
- this->WriteClOptions(*i, includes);
+ this->WriteClOptions(i, includes);
// output rc compile flags <ResourceCompile></ResourceCompile>
- this->WriteRCOptions(*i, includes);
- this->WriteCudaOptions(*i, includes);
- this->WriteMasmOptions(*i, includes);
- this->WriteNasmOptions(*i, includes);
+ this->WriteRCOptions(i, includes);
+ this->WriteCudaOptions(i, includes);
+ this->WriteMasmOptions(i, includes);
+ this->WriteNasmOptions(i, includes);
}
// output midl flags <Midl></Midl>
- this->WriteMidlOptions(*i, includes);
+ this->WriteMidlOptions(i, includes);
// write events
if (this->ProjectType != csproj) {
- this->WriteEvents(*i);
+ this->WriteEvents(i);
}
// output link flags <Link></Link>
- this->WriteLinkOptions(*i);
- this->WriteCudaLinkOptions(*i);
+ this->WriteLinkOptions(i);
+ this->WriteCudaLinkOptions(i);
// output lib flags <Lib></Lib>
- this->WriteLibOptions(*i);
+ this->WriteLibOptions(i);
// output manifest flags <Manifest></Manifest>
- this->WriteManifestOptions(*i);
+ this->WriteManifestOptions(i);
if (this->NsightTegra &&
this->GeneratorTarget->GetType() == cmStateEnums::EXECUTABLE &&
this->GeneratorTarget->GetPropertyAsBool("ANDROID_GUI")) {
- this->WriteAntBuildOptions(*i);
+ this->WriteAntBuildOptions(i);
}
this->WriteString("</ItemDefinitionGroup>\n", 1);
}
@@ -3622,9 +3560,8 @@ void cmVisualStudio10TargetGenerator::WriteEvent(
std::string script;
const char* pre = "";
std::string comment;
- for (std::vector<cmCustomCommand>::const_iterator i = commands.begin();
- i != commands.end(); ++i) {
- cmCustomCommandGenerator ccg(*i, configName, this->LocalGenerator);
+ for (cmCustomCommand const& i : commands) {
+ cmCustomCommandGenerator ccg(i, configName, this->LocalGenerator);
if (!ccg.HasOnlyEmptyCommandLines()) {
comment += pre;
comment += lg->ConstructComment(ccg);
@@ -3664,9 +3601,8 @@ void cmVisualStudio10TargetGenerator::WriteProjectReferences()
OrderedTargetDependSet;
OrderedTargetDependSet depends(unordered, CMAKE_CHECK_BUILD_SYSTEM_TARGET);
this->WriteString("<ItemGroup>\n", 1);
- for (OrderedTargetDependSet::const_iterator i = depends.begin();
- i != depends.end(); ++i) {
- cmGeneratorTarget const* dt = *i;
+ for (cmTargetDepend const& i : depends) {
+ cmGeneratorTarget const* dt = i;
if (dt->GetType() == cmStateEnums::INTERFACE_LIBRARY) {
continue;
}
@@ -3761,10 +3697,9 @@ void cmVisualStudio10TargetGenerator::WriteSDKReferences()
cmSystemTools::ExpandListArgument(vsSDKReferences, sdkReferences);
this->WriteString("<ItemGroup>\n", 1);
hasWrittenItemGroup = true;
- for (std::vector<std::string>::iterator ri = sdkReferences.begin();
- ri != sdkReferences.end(); ++ri) {
+ for (std::string const& ri : sdkReferences) {
this->WriteString("<SDKReference Include=\"", 2);
- (*this->BuildFileStream) << cmVS10EscapeXML(*ri) << "\"/>\n";
+ (*this->BuildFileStream) << cmVS10EscapeXML(ri) << "\"/>\n";
}
}
@@ -3819,10 +3754,8 @@ void cmVisualStudio10TargetGenerator::WriteWinRTPackageCertificateKeyFile()
std::string pfxFile;
std::vector<cmSourceFile const*> certificates;
this->GeneratorTarget->GetCertificates(certificates, "");
- for (std::vector<cmSourceFile const*>::const_iterator si =
- certificates.begin();
- si != certificates.end(); ++si) {
- pfxFile = this->ConvertPath((*si)->GetFullPath(), false);
+ for (cmSourceFile const* si : certificates) {
+ pfxFile = this->ConvertPath(si->GetFullPath(), false);
this->ConvertToWindowsSlash(pfxFile);
break;
}
@@ -4034,12 +3967,10 @@ void cmVisualStudio10TargetGenerator::VerifyNecessaryFiles()
std::vector<cmSourceFile const*> extraSources;
this->GeneratorTarget->GetExtraSources(extraSources, "");
bool foundManifest = false;
- for (std::vector<cmSourceFile const*>::const_iterator si =
- extraSources.begin();
- si != extraSources.end(); ++si) {
+ for (cmSourceFile const* si : extraSources) {
// Need to do a lowercase comparison on the filename
if ("wmappmanifest.xml" ==
- cmSystemTools::LowerCase((*si)->GetLocation().GetName())) {
+ cmSystemTools::LowerCase(si->GetLocation().GetName())) {
foundManifest = true;
break;
}
@@ -4501,13 +4432,12 @@ void cmVisualStudio10TargetGenerator::GetCSharpSourceProperties(
{
if (this->ProjectType == csproj) {
const cmPropertyMap& props = sf->GetProperties();
- for (cmPropertyMap::const_iterator p = props.begin(); p != props.end();
- ++p) {
+ for (auto const& p : props) {
static const std::string propNamePrefix = "VS_CSHARP_";
- if (p->first.find(propNamePrefix) == 0) {
- std::string tagName = p->first.substr(propNamePrefix.length());
+ if (p.first.find(propNamePrefix) == 0) {
+ std::string tagName = p.first.substr(propNamePrefix.length());
if (!tagName.empty()) {
- const std::string val = props.GetPropertyValue(p->first);
+ const std::string val = props.GetPropertyValue(p.first);
if (!val.empty()) {
tags[tagName] = val;
} else {
@@ -4523,11 +4453,10 @@ void cmVisualStudio10TargetGenerator::WriteCSharpSourceProperties(
const std::map<std::string, std::string>& tags)
{
if (!tags.empty()) {
- for (std::map<std::string, std::string>::const_iterator i = tags.begin();
- i != tags.end(); ++i) {
+ for (const auto& i : tags) {
this->WriteString("<", 3);
- (*this->BuildFileStream) << i->first << ">" << cmVS10EscapeXML(i->second)
- << "</" << i->first << ">\n";
+ (*this->BuildFileStream) << i.first << ">" << cmVS10EscapeXML(i.second)
+ << "</" << i.first << ">\n";
}
}
}
diff --git a/Source/cmVisualStudioGeneratorOptions.cxx b/Source/cmVisualStudioGeneratorOptions.cxx
index 4f3d737..106bdff 100644
--- a/Source/cmVisualStudioGeneratorOptions.cxx
+++ b/Source/cmVisualStudioGeneratorOptions.cxx
@@ -239,20 +239,32 @@ void cmVisualStudioGeneratorOptions::FixCudaCodeGeneration()
// It translates to -arch=<virtual> -code=<real>.
cmSystemTools::ReplaceString(arch_name, "sm_", "compute_");
}
- for (std::vector<std::string>::iterator ci = codes.begin();
- ci != codes.end(); ++ci) {
- std::string entry = arch_name + "," + *ci;
+ for (auto const& c : codes) {
+ std::string entry = arch_name + "," + c;
result.push_back(entry);
}
}
- // Now add entries for the -gencode=<arch>,<code> pairs.
- for (std::vector<std::string>::iterator ei = gencode.begin();
- ei != gencode.end(); ++ei) {
- std::string entry = *ei;
+ // Now add entries for the following signatures:
+ // -gencode=<arch>,<code>
+ // -gencode=<arch>,[<code1>,<code2>]
+ // -gencode=<arch>,"<code1>,<code2>"
+ for (auto const& e : gencode) {
+ std::string entry = e;
cmSystemTools::ReplaceString(entry, "arch=", "");
cmSystemTools::ReplaceString(entry, "code=", "");
- result.push_back(entry);
+ cmSystemTools::ReplaceString(entry, "[", "");
+ cmSystemTools::ReplaceString(entry, "]", "");
+ cmSystemTools::ReplaceString(entry, "\"", "");
+
+ std::vector<std::string> codes = cmSystemTools::tokenize(entry, ",");
+ if (codes.size() >= 2) {
+ auto gencode_arch = cm::cbegin(codes);
+ for (auto ci = gencode_arch + 1; ci != cm::cend(codes); ++ci) {
+ std::string code_entry = *gencode_arch + "," + *ci;
+ result.push_back(code_entry);
+ }
+ }
}
}
@@ -317,7 +329,7 @@ void cmVisualStudioGeneratorOptions::FixManifestUACFlags()
continue;
}
- // unknwon sub option
+ // unknown sub option
}
AddFlag(ENABLE_UAC, "true");
diff --git a/Source/cmXMLWriter.h b/Source/cmXMLWriter.h
index c890acf..7bae21e 100644
--- a/Source/cmXMLWriter.h
+++ b/Source/cmXMLWriter.h
@@ -108,7 +108,7 @@ private:
* It would be tempting to convert a time_point to number of seconds by
* using time_since_epoch(). Unfortunately the C++11 standard does not
* specify what the epoch of the system_clock must be.
- * Therefore we must assume it is an arbitary point in time. Instead of this
+ * Therefore we must assume it is an arbitrary point in time. Instead of this
* method, it is recommended to convert it by means of the to_time_t method.
*/
static std::time_t SafeContent(
diff --git a/Source/cmake.cxx b/Source/cmake.cxx
index 2a5bb6c..2341dd6 100644
--- a/Source/cmake.cxx
+++ b/Source/cmake.cxx
@@ -196,6 +196,7 @@ cmake::cmake(Role role)
this->SourceFileExtensions.push_back("cc");
this->SourceFileExtensions.push_back("cpp");
this->SourceFileExtensions.push_back("cxx");
+ this->SourceFileExtensions.push_back("cu");
this->SourceFileExtensions.push_back("m");
this->SourceFileExtensions.push_back("M");
this->SourceFileExtensions.push_back("mm");