mirror of
https://github.com/Kitware/CMake.git
synced 2025-12-30 10:20:56 -06:00
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
This commit is contained in:
@@ -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;
|
||||
|
||||
1
Tests/RunCMake/add_subdirectory/ChangeConfigMulti.cmake
Normal file
1
Tests/RunCMake/add_subdirectory/ChangeConfigMulti.cmake
Normal file
@@ -0,0 +1 @@
|
||||
add_subdirectory(ChangeConfigMulti)
|
||||
@@ -0,0 +1 @@
|
||||
set(CMAKE_CONFIGURATION_TYPES NotDebug NotRelease)
|
||||
@@ -7,6 +7,10 @@ set(RunCMake_TEST_OPTIONS -DCMAKE_Fortran_COMPILER=${CMAKE_Fortran_COMPILER})
|
||||
run_cmake(System)
|
||||
unset(RunCMake_TEST_OPTIONS)
|
||||
|
||||
if(RunCMake_GENERATOR_IS_MULTI_CONFIG)
|
||||
run_cmake_with_options(ChangeConfigMulti "-DCMAKE_CONFIGURATION_TYPES=Debug\\;Release")
|
||||
endif()
|
||||
|
||||
macro(run_cmake_install case)
|
||||
set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/${case}-build)
|
||||
set(RunCMake_TEST_NO_CLEAN 1)
|
||||
|
||||
Reference in New Issue
Block a user