mirror of
https://github.com/Kitware/CMake.git
synced 2026-01-01 19:30:13 -06:00
Ninja Multi-Config: Always generate build.ninja
If CMAKE_DEFAULT_BUILD_TYPE is not specified, use the first item from CMAKE_CONFIGURATION_TYPES instead.
This commit is contained in:
@@ -12,9 +12,10 @@ multiple configurations at once with :variable:`CMAKE_CONFIGURATION_TYPES`
|
||||
instead of only one configuration with :variable:`CMAKE_BUILD_TYPE`. One
|
||||
``build-<Config>.ninja`` file will be generated for each of these
|
||||
configurations (with ``<Config>`` being the configuration name.) These files
|
||||
are intended to be run with ``ninja -f build-<Config>.ninja``. No
|
||||
``build.ninja`` file is generated by default (see below for how to generate
|
||||
it.)
|
||||
are intended to be run with ``ninja -f build-<Config>.ninja``. A
|
||||
``build.ninja`` file is also generated, using the configuration from either
|
||||
:variable:`CMAKE_DEFAULT_BUILD_TYPE` or the first item from
|
||||
:variable:`CMAKE_CONFIGURATION_TYPES`.
|
||||
|
||||
``cmake --build . --config <Config>`` will always use ``build-<Config>.ninja``
|
||||
to build. If no ``--config`` argument is specified, ``cmake --build .`` will
|
||||
@@ -51,10 +52,10 @@ The ``Ninja Multi-Config`` generator recognizes the following variables:
|
||||
|
||||
:variable:`CMAKE_DEFAULT_BUILD_TYPE`
|
||||
Specifies the configuration to use by default in a ``build.ninja`` file. If
|
||||
this variable is specified, a ``build.ninja`` file is generated which uses
|
||||
build rules from ``build-<Config>.ninja`` by default. All custom commands are
|
||||
executed with this configuration. If the variable is not specified, no
|
||||
``build.ninja`` file is generated.
|
||||
this variable is specified, ``build.ninja`` uses build rules from
|
||||
``build-<Config>.ninja`` by default. All custom commands are executed with
|
||||
this configuration. If the variable is not specified, the first item from
|
||||
:variable:`CMAKE_CONFIGURATION_TYPES` is used instead.
|
||||
|
||||
The value of this variable must be one of the items from
|
||||
:variable:`CMAKE_CONFIGURATION_TYPES`.
|
||||
|
||||
@@ -2488,8 +2488,7 @@ bool cmGlobalNinjaMultiGenerator::OpenBuildFileStreams()
|
||||
return false;
|
||||
}
|
||||
*this->DefaultFileStream
|
||||
<< "# This file is a convenience file generated by\n"
|
||||
<< "# CMAKE_DEFAULT_BUILD_TYPE.\n\n"
|
||||
<< "# Build using rules for '" << this->DefaultFileConfig << "'.\n\n"
|
||||
<< "include " << GetNinjaImplFilename(this->DefaultFileConfig) << "\n\n";
|
||||
}
|
||||
|
||||
@@ -2606,9 +2605,6 @@ bool cmGlobalNinjaMultiGenerator::InspectConfigTypeVariables()
|
||||
|
||||
std::string cmGlobalNinjaMultiGenerator::GetDefaultBuildConfig() const
|
||||
{
|
||||
if (this->DefaultFileConfig.empty()) {
|
||||
return "Debug";
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
@@ -2625,8 +2621,10 @@ bool cmGlobalNinjaMultiGenerator::ReadCacheEntriesForBuild(
|
||||
|
||||
this->DefaultFileConfig =
|
||||
state.GetSafeCacheEntryValue("CMAKE_DEFAULT_BUILD_TYPE");
|
||||
if (!this->DefaultFileConfig.empty() &&
|
||||
!configs.count(this->DefaultFileConfig)) {
|
||||
if (this->DefaultFileConfig.empty()) {
|
||||
this->DefaultFileConfig = configsVec.front();
|
||||
}
|
||||
if (!configs.count(this->DefaultFileConfig)) {
|
||||
std::ostringstream msg;
|
||||
msg << "The configuration specified by "
|
||||
<< "CMAKE_DEFAULT_BUILD_TYPE (" << this->DefaultFileConfig
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
1
|
||||
@@ -1,6 +0,0 @@
|
||||
^CMake Error:
|
||||
CMAKE_DEFAULT_CONFIGS cannot be used without CMAKE_DEFAULT_BUILD_TYPE or
|
||||
CMAKE_CROSS_CONFIGS
|
||||
|
||||
|
||||
CMake Generate step failed\. Build files cannot be regenerated correctly\.$
|
||||
@@ -81,7 +81,9 @@ endfunction()
|
||||
set(RunCMake_TEST_NO_CLEAN 1)
|
||||
|
||||
set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/Simple-build)
|
||||
set(RunCMake_TEST_OPTIONS "-DCMAKE_CONFIGURATION_TYPES=Debug\\;Release\\;MinSizeRel\\;RelWithDebInfo;-DCMAKE_DEFAULT_BUILD_TYPE=RelWithDebInfo;-DCMAKE_CROSS_CONFIGS=all")
|
||||
# IMPORTANT: Setting RelWithDebInfo as the first item in CMAKE_CONFIGURATION_TYPES
|
||||
# generates a build.ninja file with that configuration
|
||||
set(RunCMake_TEST_OPTIONS "-DCMAKE_CONFIGURATION_TYPES=RelWithDebInfo\\;Debug\\;Release\\;MinSizeRel;-DCMAKE_CROSS_CONFIGS=all")
|
||||
run_cmake_configure(Simple)
|
||||
unset(RunCMake_TEST_OPTIONS)
|
||||
include(${RunCMake_TEST_BINARY_DIR}/target_files.cmake)
|
||||
@@ -153,10 +155,6 @@ set(RunCMake_TEST_OPTIONS "-DCMAKE_CROSS_CONFIGS=Debug\\;Release;-DCMAKE_DEFAULT
|
||||
run_cmake(InvalidDefaultConfigsCross)
|
||||
unset(RunCMake_TEST_OPTIONS)
|
||||
|
||||
set(RunCMake_TEST_OPTIONS "-DCMAKE_CROSS_CONFIGS=Debug\\;Release;-DCMAKE_DEFAULT_CONFIGS=all")
|
||||
run_cmake(InvalidDefaultConfigsNoDefaultFile)
|
||||
unset(RunCMake_TEST_OPTIONS)
|
||||
|
||||
set(RunCMake_TEST_OPTIONS "-DCMAKE_DEFAULT_BUILD_TYPE=Release;-DCMAKE_DEFAULT_CONFIGS=all")
|
||||
run_cmake(InvalidDefaultConfigsNoCross)
|
||||
unset(RunCMake_TEST_OPTIONS)
|
||||
|
||||
Reference in New Issue
Block a user