diff options
author | Brad King <brad.king@kitware.com> | 2024-06-21 13:34:08 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2024-06-21 16:21:36 (GMT) |
commit | b1a804d6167c8e2dc82efad72e98be58ce5eb6a5 (patch) | |
tree | 64c48c1003795329aeae7c92c172881d860b1737 /Source | |
parent | 9f8afacb3e512debd1d53f14f685802eda4a54f8 (diff) | |
download | CMake-b1a804d6167c8e2dc82efad72e98be58ce5eb6a5.zip CMake-b1a804d6167c8e2dc82efad72e98be58ce5eb6a5.tar.gz CMake-b1a804d6167c8e2dc82efad72e98be58ce5eb6a5.tar.bz2 |
Ninja Multi-Config: Fix crash if config list is changed in subdirectory
Look up the value of `CMAKE_CONFIGURATION_TYPES` only in the top level
directory.
Fixes: #26064
Diffstat (limited to 'Source')
-rw-r--r-- | Source/cmLocalCommonGenerator.cxx | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/Source/cmLocalCommonGenerator.cxx b/Source/cmLocalCommonGenerator.cxx index aa953f4..14b3040 100644 --- a/Source/cmLocalCommonGenerator.cxx +++ b/Source/cmLocalCommonGenerator.cxx @@ -2,10 +2,12 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmLocalCommonGenerator.h" +#include <memory> #include <utility> #include <vector> #include "cmGeneratorTarget.h" +#include "cmGlobalGenerator.h" #include "cmMakefile.h" #include "cmOutputConverter.h" #include "cmStateDirectory.h" @@ -13,14 +15,18 @@ #include "cmStringAlgorithms.h" #include "cmValue.h" -class cmGlobalGenerator; - cmLocalCommonGenerator::cmLocalCommonGenerator(cmGlobalGenerator* gg, cmMakefile* mf) : cmLocalGenerator(gg, mf) { - this->ConfigNames = - this->Makefile->GetGeneratorConfigs(cmMakefile::IncludeEmptyConfig); + // Multi-config generators define one set of configurations at the top. + // Single-config generators nominally define one configuration at the top, + // but the implementation has never been strict about that, so look up the + // per-directory config to preserve behavior. + this->ConfigNames = (gg->IsMultiConfig() && !gg->GetMakefiles().empty() + ? gg->GetMakefiles().front().get() + : this->Makefile) + ->GetGeneratorConfigs(cmMakefile::IncludeEmptyConfig); } cmLocalCommonGenerator::~cmLocalCommonGenerator() = default; |