Merge topic 'cmprop-improve'

4d9b1b42bc cmCTestBuildCommand: code improvement

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !5548
This commit is contained in:
Brad King
2020-12-01 14:34:58 +00:00
committed by Kitware Robot

View File

@@ -54,22 +54,21 @@ cmCTestGenericHandler* cmCTestBuildCommand::InitializeHandler()
//
cmProp ctestBuildConfiguration =
this->Makefile->GetDefinition("CTEST_BUILD_CONFIGURATION");
const std::string* cmakeBuildConfiguration = !this->Configuration.empty()
? &this->Configuration
: (cmNonempty(ctestBuildConfiguration) ? ctestBuildConfiguration
: &this->CTest->GetConfigType());
std::string cmakeBuildConfiguration = cmNonempty(this->Configuration)
? this->Configuration
: cmNonempty(ctestBuildConfiguration) ? *ctestBuildConfiguration
: this->CTest->GetConfigType();
const std::string* cmakeBuildAdditionalFlags = !this->Flags.empty()
? &this->Flags
: this->Makefile->GetDefinition("CTEST_BUILD_FLAGS");
const std::string* cmakeBuildTarget = !this->Target.empty()
? &this->Target
: this->Makefile->GetDefinition("CTEST_BUILD_TARGET");
const std::string& cmakeBuildAdditionalFlags = cmNonempty(this->Flags)
? this->Flags
: this->Makefile->GetSafeDefinition("CTEST_BUILD_FLAGS");
const std::string& cmakeBuildTarget = cmNonempty(this->Target)
? this->Target
: this->Makefile->GetSafeDefinition("CTEST_BUILD_TARGET");
if (cmNonempty(cmakeGeneratorName)) {
if (!cmakeBuildConfiguration) {
static const std::string sRelease = "Release";
cmakeBuildConfiguration = &sRelease;
if (cmakeBuildConfiguration.empty()) {
cmakeBuildConfiguration = "Release";
}
if (this->GlobalGenerator) {
if (this->GlobalGenerator->GetName() != *cmakeGeneratorName) {
@@ -88,24 +87,18 @@ cmCTestGenericHandler* cmCTestBuildCommand::InitializeHandler()
return nullptr;
}
}
if (cmakeBuildConfiguration->empty()) {
const std::string* config = nullptr;
if (cmakeBuildConfiguration.empty()) {
#ifdef CMAKE_INTDIR
static const std::string sIntDir = CMAKE_INTDIR;
config = &sIntDir;
cmakeBuildConfiguration = CMAKE_INTDIR;
#else
cmakeBuildConfiguration = "Debug";
#endif
if (!config) {
static const std::string sDebug = "Debug";
config = &sDebug;
}
cmakeBuildConfiguration = config;
}
std::string dir = this->CTest->GetCTestConfiguration("BuildDirectory");
std::string buildCommand =
this->GlobalGenerator->GenerateCMakeBuildCommand(
cmakeBuildTarget ? *cmakeBuildTarget : "", *cmakeBuildConfiguration,
cmakeBuildAdditionalFlags ? *cmakeBuildAdditionalFlags : "",
cmakeBuildTarget, cmakeBuildConfiguration, cmakeBuildAdditionalFlags,
this->Makefile->IgnoreErrorsCMP0061());
cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
"SetMakeCommand:" << buildCommand << "\n",