summaryrefslogtreecommitdiff
path: root/Source/CTest/cmCTestBuildCommand.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'Source/CTest/cmCTestBuildCommand.cxx')
-rw-r--r--Source/CTest/cmCTestBuildCommand.cxx55
1 files changed, 29 insertions, 26 deletions
diff --git a/Source/CTest/cmCTestBuildCommand.cxx b/Source/CTest/cmCTestBuildCommand.cxx
index 8aab167cf4..1cc267e95a 100644
--- a/Source/CTest/cmCTestBuildCommand.cxx
+++ b/Source/CTest/cmCTestBuildCommand.cxx
@@ -2,7 +2,6 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmCTestBuildCommand.h"
-#include <cstring>
#include <sstream>
#include <cmext/string_view>
@@ -39,12 +38,13 @@ cmCTestGenericHandler* cmCTestBuildCommand::InitializeHandler()
this->Handler = handler;
- cmProp ctestBuildCommand = this->Makefile->GetDef("CTEST_BUILD_COMMAND");
+ cmProp ctestBuildCommand =
+ this->Makefile->GetDefinition("CTEST_BUILD_COMMAND");
if (cmNonempty(ctestBuildCommand)) {
this->CTest->SetCTestConfiguration("MakeCommand", *ctestBuildCommand,
this->Quiet);
} else {
- const char* cmakeGeneratorName =
+ cmProp cmakeGeneratorName =
this->Makefile->GetDefinition("CTEST_CMAKE_GENERATOR");
// Build configuration is determined by: CONFIGURATION argument,
@@ -52,49 +52,51 @@ cmCTestGenericHandler* cmCTestBuildCommand::InitializeHandler()
// CTEST_CONFIGURATION_TYPE script variable, or ctest -C command
// line argument... in that order.
//
- const char* ctestBuildConfiguration =
+ cmProp ctestBuildConfiguration =
this->Makefile->GetDefinition("CTEST_BUILD_CONFIGURATION");
- const char* cmakeBuildConfiguration = !this->Configuration.empty()
- ? this->Configuration.c_str()
- : (cmNonempty(ctestBuildConfiguration)
- ? ctestBuildConfiguration
- : this->CTest->GetConfigType().c_str());
-
- const char* cmakeBuildAdditionalFlags = !this->Flags.empty()
- ? this->Flags.c_str()
+ const std::string* cmakeBuildConfiguration = !this->Configuration.empty()
+ ? &this->Configuration
+ : (cmNonempty(ctestBuildConfiguration) ? ctestBuildConfiguration
+ : &this->CTest->GetConfigType());
+
+ const std::string* cmakeBuildAdditionalFlags = !this->Flags.empty()
+ ? &this->Flags
: this->Makefile->GetDefinition("CTEST_BUILD_FLAGS");
- const char* cmakeBuildTarget = !this->Target.empty()
- ? this->Target.c_str()
+ const std::string* cmakeBuildTarget = !this->Target.empty()
+ ? &this->Target
: this->Makefile->GetDefinition("CTEST_BUILD_TARGET");
if (cmNonempty(cmakeGeneratorName)) {
if (!cmakeBuildConfiguration) {
- cmakeBuildConfiguration = "Release";
+ static const std::string sRelease = "Release";
+ cmakeBuildConfiguration = &sRelease;
}
if (this->GlobalGenerator) {
- if (this->GlobalGenerator->GetName() != cmakeGeneratorName) {
+ if (this->GlobalGenerator->GetName() != *cmakeGeneratorName) {
this->GlobalGenerator.reset();
}
}
if (!this->GlobalGenerator) {
this->GlobalGenerator =
this->Makefile->GetCMakeInstance()->CreateGlobalGenerator(
- cmakeGeneratorName);
+ *cmakeGeneratorName);
if (!this->GlobalGenerator) {
std::string e = cmStrCat("could not create generator named \"",
- cmakeGeneratorName, '"');
+ *cmakeGeneratorName, '"');
this->Makefile->IssueMessage(MessageType::FATAL_ERROR, e);
cmSystemTools::SetFatalErrorOccured();
return nullptr;
}
}
- if (strlen(cmakeBuildConfiguration) == 0) {
- const char* config = nullptr;
+ if (cmakeBuildConfiguration->empty()) {
+ const std::string* config = nullptr;
#ifdef CMAKE_INTDIR
- config = CMAKE_INTDIR;
+ static const std::string sIntDir = CMAKE_INTDIR;
+ config = &sIntDir;
#endif
if (!config) {
- config = "Debug";
+ static const std::string sDebug = "Debug";
+ config = &sDebug;
}
cmakeBuildConfiguration = config;
}
@@ -102,8 +104,8 @@ cmCTestGenericHandler* cmCTestBuildCommand::InitializeHandler()
std::string dir = this->CTest->GetCTestConfiguration("BuildDirectory");
std::string buildCommand =
this->GlobalGenerator->GenerateCMakeBuildCommand(
- cmakeBuildTarget ? cmakeBuildTarget : "", cmakeBuildConfiguration,
- cmakeBuildAdditionalFlags ? cmakeBuildAdditionalFlags : "",
+ cmakeBuildTarget ? *cmakeBuildTarget : "", *cmakeBuildConfiguration,
+ cmakeBuildAdditionalFlags ? *cmakeBuildAdditionalFlags : "",
this->Makefile->IgnoreErrorsCMP0061());
cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
"SetMakeCommand:" << buildCommand << "\n",
@@ -123,13 +125,14 @@ cmCTestGenericHandler* cmCTestBuildCommand::InitializeHandler()
}
}
- if (cmProp useLaunchers = this->Makefile->GetDef("CTEST_USE_LAUNCHERS")) {
+ if (cmProp useLaunchers =
+ this->Makefile->GetDefinition("CTEST_USE_LAUNCHERS")) {
this->CTest->SetCTestConfiguration("UseLaunchers", *useLaunchers,
this->Quiet);
}
if (cmProp labelsForSubprojects =
- this->Makefile->GetDef("CTEST_LABELS_FOR_SUBPROJECTS")) {
+ this->Makefile->GetDefinition("CTEST_LABELS_FOR_SUBPROJECTS")) {
this->CTest->SetCTestConfiguration("LabelsForSubprojects",
*labelsForSubprojects, this->Quiet);
}