cmLocalCommonGenerator: Save CMAKE_BUILD_TYPE on construction

Copy the value to our `ConfigName` member on construction to ensure it
is available even to code paths that run before `Generate`.  We once
needed to delay this lookup until `Generate` because the local
generators were at one time created before `Configure`.  Now they are
created at generate time which is late enough to expect
`CMAKE_BUILD_TYPE` to be available.

Without this, `cmGlobalUnixMakefileGenerator3::WriteConvenienceRules`
causes use of `ConfigName` before it is populated which breaks use of
source files that depend on the `$<CONFIG>` generator expression.

Fixes: #16889
This commit is contained in:
Brad King 2017-05-15 11:51:57 -04:00
parent 4717797647
commit eeb47fbeb2
4 changed files with 4 additions and 13 deletions

View File

@ -15,14 +15,6 @@ cmLocalCommonGenerator::cmLocalCommonGenerator(cmGlobalGenerator* gg,
std::string const& wd)
: cmLocalGenerator(gg, mf)
, WorkingDirectory(wd)
{
}
cmLocalCommonGenerator::~cmLocalCommonGenerator()
{
}
void cmLocalCommonGenerator::SetConfigName()
{
// Store the configuration name that will be generated.
if (const char* config = this->Makefile->GetDefinition("CMAKE_BUILD_TYPE")) {
@ -34,6 +26,10 @@ void cmLocalCommonGenerator::SetConfigName()
}
}
cmLocalCommonGenerator::~cmLocalCommonGenerator()
{
}
std::string cmLocalCommonGenerator::GetTargetFortranFlags(
cmGeneratorTarget const* target, std::string const& config)
{

View File

@ -33,7 +33,6 @@ public:
protected:
std::string WorkingDirectory;
void SetConfigName();
std::string ConfigName;
friend class cmCommonTargetGenerator;

View File

@ -58,8 +58,6 @@ void cmLocalNinjaGenerator::Generate()
this->HomeRelativeOutputPath = "";
}
this->SetConfigName();
this->WriteProcessedMakefile(this->GetBuildFileStream());
#ifdef NINJA_GEN_VERBOSE_FILES
this->WriteProcessedMakefile(this->GetRulesFileStream());

View File

@ -105,8 +105,6 @@ cmLocalUnixMakefileGenerator3::~cmLocalUnixMakefileGenerator3()
void cmLocalUnixMakefileGenerator3::Generate()
{
this->SetConfigName();
// Record whether some options are enabled to avoid checking many
// times later.
if (!this->GetGlobalGenerator()->GetCMakeInstance()->GetIsInTryCompile()) {