summaryrefslogtreecommitdiff
path: root/Source/cmCreateTestSourceList.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'Source/cmCreateTestSourceList.cxx')
-rw-r--r--Source/cmCreateTestSourceList.cxx53
1 files changed, 22 insertions, 31 deletions
diff --git a/Source/cmCreateTestSourceList.cxx b/Source/cmCreateTestSourceList.cxx
index b78493f99..9d492ba84 100644
--- a/Source/cmCreateTestSourceList.cxx
+++ b/Source/cmCreateTestSourceList.cxx
@@ -4,22 +4,21 @@
#include <algorithm>
+#include "cmExecutionStatus.h"
#include "cmMakefile.h"
#include "cmSourceFile.h"
+#include "cmStringAlgorithms.h"
#include "cmSystemTools.h"
-class cmExecutionStatus;
-
-// cmCreateTestSourceList
-bool cmCreateTestSourceList::InitialPass(std::vector<std::string> const& args,
- cmExecutionStatus&)
+bool cmCreateTestSourceList(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
{
if (args.size() < 3) {
- this->SetError("called with wrong number of arguments.");
+ status.SetError("called with wrong number of arguments.");
return false;
}
- std::vector<std::string>::const_iterator i = args.begin();
+ auto i = args.begin();
std::string extraInclude;
std::string function;
std::vector<std::string> tests;
@@ -28,20 +27,17 @@ bool cmCreateTestSourceList::InitialPass(std::vector<std::string> const& args,
if (*i == "EXTRA_INCLUDE") {
++i;
if (i == args.end()) {
- this->SetError("incorrect arguments to EXTRA_INCLUDE");
+ status.SetError("incorrect arguments to EXTRA_INCLUDE");
return false;
}
- extraInclude = "#include \"";
- extraInclude += *i;
- extraInclude += "\"\n";
+ extraInclude = cmStrCat("#include \"", *i, "\"\n");
} else if (*i == "FUNCTION") {
++i;
if (i == args.end()) {
- this->SetError("incorrect arguments to FUNCTION");
+ status.SetError("incorrect arguments to FUNCTION");
return false;
}
- function = *i;
- function += "(&ac, &av);\n";
+ function = cmStrCat(*i, "(&ac, &av);\n");
} else {
tests.push_back(*i);
}
@@ -56,13 +52,12 @@ bool cmCreateTestSourceList::InitialPass(std::vector<std::string> const& args,
// Name of the test driver
// make sure they specified an extension
if (cmSystemTools::GetFilenameExtension(*i).size() < 2) {
- this->SetError(
+ status.SetError(
"You must specify a file extension for the test driver file.");
return false;
}
- std::string driver = this->Makefile->GetCurrentBinaryDirectory();
- driver += "/";
- driver += *i;
+ cmMakefile& mf = status.GetMakefile();
+ std::string driver = cmStrCat(mf.GetCurrentBinaryDirectory(), '/', *i);
++i;
std::string configFile = cmSystemTools::GetCMakeRoot();
@@ -70,7 +65,7 @@ bool cmCreateTestSourceList::InitialPass(std::vector<std::string> const& args,
configFile += "/Templates/TestDriver.cxx.in";
// Create the test driver file
- std::vector<std::string>::const_iterator testsBegin = i;
+ auto testsBegin = i;
std::vector<std::string> tests_func_name;
// The rest of the arguments consist of a list of test source files.
@@ -124,36 +119,32 @@ bool cmCreateTestSourceList::InitialPass(std::vector<std::string> const& args,
numTests++;
}
if (!extraInclude.empty()) {
- this->Makefile->AddDefinition("CMAKE_TESTDRIVER_EXTRA_INCLUDES",
- extraInclude.c_str());
+ mf.AddDefinition("CMAKE_TESTDRIVER_EXTRA_INCLUDES", extraInclude);
}
if (!function.empty()) {
- this->Makefile->AddDefinition("CMAKE_TESTDRIVER_ARGVC_FUNCTION",
- function.c_str());
+ mf.AddDefinition("CMAKE_TESTDRIVER_ARGVC_FUNCTION", function);
}
- this->Makefile->AddDefinition("CMAKE_FORWARD_DECLARE_TESTS",
- forwardDeclareCode.c_str());
- this->Makefile->AddDefinition("CMAKE_FUNCTION_TABLE_ENTIRES",
- functionMapCode.c_str());
+ mf.AddDefinition("CMAKE_FORWARD_DECLARE_TESTS", forwardDeclareCode);
+ mf.AddDefinition("CMAKE_FUNCTION_TABLE_ENTIRES", functionMapCode);
bool res = true;
- if (!this->Makefile->ConfigureFile(configFile, driver, false, true, false)) {
+ if (!mf.ConfigureFile(configFile, driver, false, true, false)) {
res = false;
}
// Construct the source list.
std::string sourceListValue;
{
- cmSourceFile* sf = this->Makefile->GetOrCreateSource(driver);
+ cmSourceFile* sf = mf.GetOrCreateSource(driver);
sf->SetProperty("ABSTRACT", "0");
sourceListValue = args[1];
}
for (i = testsBegin; i != tests.end(); ++i) {
- cmSourceFile* sf = this->Makefile->GetOrCreateSource(*i);
+ cmSourceFile* sf = mf.GetOrCreateSource(*i);
sf->SetProperty("ABSTRACT", "0");
sourceListValue += ";";
sourceListValue += *i;
}
- this->Makefile->AddDefinition(sourceList, sourceListValue.c_str());
+ mf.AddDefinition(sourceList, sourceListValue);
return res;
}