From 7a63dafafbc666a184a007adca5b138796384f77 Mon Sep 17 00:00:00 2001 From: Kyle Edwards Date: Wed, 26 Feb 2020 13:22:32 -0500 Subject: Ninja Multi-Config: Remove "NMC" from variable names Also rename `..._DEFAULT_BUILD_FILE_CONFIG` to `..._DEFAULT_BUILD_TYPE`. These name changes make the variables meaningful for future use by other generators. --- Help/generator/Ninja Multi-Config.rst | 26 +++++++-------- Help/manual/cmake-variables.7.rst | 6 ++-- Help/variable/CMAKE_CROSS_CONFIGS.rst | 7 ++++ Help/variable/CMAKE_DEFAULT_BUILD_TYPE.rst | 6 ++++ Help/variable/CMAKE_DEFAULT_CONFIGS.rst | 7 ++++ Help/variable/CMAKE_NMC_CROSS_CONFIGS.rst | 7 ---- .../CMAKE_NMC_DEFAULT_BUILD_FILE_CONFIG.rst | 6 ---- Help/variable/CMAKE_NMC_DEFAULT_CONFIGS.rst | 7 ---- Source/cmGlobalNinjaGenerator.cxx | 20 +++++------- .../InvalidCrossConfigs-stderr.txt | 2 +- .../InvalidDefaultBuildFileConfig-stderr.txt | 4 +-- .../InvalidDefaultConfigsCross-stderr.txt | 2 +- .../InvalidDefaultConfigsNoCross-stderr.txt | 4 +-- .../InvalidDefaultConfigsNoDefaultFile-stderr.txt | 4 +-- Tests/RunCMake/NinjaMultiConfig/RunCMakeTest.cmake | 38 +++++++++++----------- 15 files changed, 72 insertions(+), 74 deletions(-) create mode 100644 Help/variable/CMAKE_CROSS_CONFIGS.rst create mode 100644 Help/variable/CMAKE_DEFAULT_BUILD_TYPE.rst create mode 100644 Help/variable/CMAKE_DEFAULT_CONFIGS.rst delete mode 100644 Help/variable/CMAKE_NMC_CROSS_CONFIGS.rst delete mode 100644 Help/variable/CMAKE_NMC_DEFAULT_BUILD_FILE_CONFIG.rst delete mode 100644 Help/variable/CMAKE_NMC_DEFAULT_CONFIGS.rst diff --git a/Help/generator/Ninja Multi-Config.rst b/Help/generator/Ninja Multi-Config.rst index 11c59f2..c2331f0 100644 --- a/Help/generator/Ninja Multi-Config.rst +++ b/Help/generator/Ninja Multi-Config.rst @@ -35,7 +35,7 @@ The ``Ninja Multi-Config`` generator recognizes the following variables: Specifies the total set of configurations to build. See the variable's documentation for more information. -:variable:`CMAKE_NMC_CROSS_CONFIGS` +:variable:`CMAKE_CROSS_CONFIGS` Specifies a :ref:`semicolon-separated list ` of configurations available from all ``build-.ninja`` files. This variable activates cross-config mode. @@ -49,7 +49,7 @@ The ``Ninja Multi-Config`` generator recognizes the following variables: The value of this variable must be a subset of :variable:`CMAKE_CONFIGURATION_TYPES`. -:variable:`CMAKE_NMC_DEFAULT_BUILD_FILE_CONFIG` +: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-.ninja`` by default. All custom commands are @@ -59,26 +59,26 @@ The ``Ninja Multi-Config`` generator recognizes the following variables: The value of this variable must be one of the items from :variable:`CMAKE_CONFIGURATION_TYPES`. -:variable:`CMAKE_NMC_DEFAULT_CONFIGS` +:variable:`CMAKE_DEFAULT_CONFIGS` Specifies a :ref:`semicolon-separated list ` of configurations to build for a target in ``build.ninja`` if no ``:`` suffix is specified. If it is set to ``all``, all - configurations from :variable:`CMAKE_NMC_CROSS_CONFIGS` are used. If + configurations from :variable:`CMAKE_CROSS_CONFIGS` are used. If it is not specified, it defaults to - :variable:`CMAKE_NMC_DEFAULT_BUILD_FILE_CONFIG`. + :variable:`CMAKE_DEFAULT_BUILD_TYPE`. For example, if you set - :variable:`CMAKE_NMC_DEFAULT_BUILD_FILE_CONFIG` to ``Release``, but - set :variable:`CMAKE_NMC_DEFAULT_CONFIGS` to ``Debug`` or ``all``, + :variable:`CMAKE_DEFAULT_BUILD_TYPE` to ``Release``, but + set :variable:`CMAKE_DEFAULT_CONFIGS` to ``Debug`` or ``all``, all ```` aliases in ``build.ninja`` will resolve to ``:Debug`` or ``:all``, but custom commands will still use the ``Release`` configuration. The value of this variable must be a subset of - :variable:`CMAKE_NMC_CROSS_CONFIGS` or be the same as - :variable:`CMAKE_NMC_DEFAULT_BUILD_FILE_CONFIG`. It must not be - specified if :variable:`CMAKE_NMC_DEFAULT_BUILD_FILE_CONFIG` or - :variable:`CMAKE_NMC_CROSS_CONFIGS` is not used. + :variable:`CMAKE_CROSS_CONFIGS` or be the same as + :variable:`CMAKE_DEFAULT_BUILD_TYPE`. It must not be + specified if :variable:`CMAKE_DEFAULT_BUILD_TYPE` or + :variable:`CMAKE_CROSS_CONFIGS` is not used. Consider the following example: @@ -104,8 +104,8 @@ This would build the ``Debug`` configuration of ``generator``, which would be used to generate ``generated.c``, which would be used to build the ``Debug`` configuration of ``generated``. -But if :variable:`CMAKE_NMC_CROSS_CONFIGS` is set to ``all``, and you -run the following instead: +But if :variable:`CMAKE_CROSS_CONFIGS` is set to ``all``, and you run the +following instead: .. code-block:: shell diff --git a/Help/manual/cmake-variables.7.rst b/Help/manual/cmake-variables.7.rst index 1023a66..a639b5d 100644 --- a/Help/manual/cmake-variables.7.rst +++ b/Help/manual/cmake-variables.7.rst @@ -372,11 +372,14 @@ Variables that Control the Build /variable/CMAKE_COMPILE_PDB_OUTPUT_DIRECTORY /variable/CMAKE_COMPILE_PDB_OUTPUT_DIRECTORY_CONFIG /variable/CMAKE_CONFIG_POSTFIX + /variable/CMAKE_CROSS_CONFIGS /variable/CMAKE_CTEST_ARGUMENTS /variable/CMAKE_CUDA_SEPARABLE_COMPILATION /variable/CMAKE_CUDA_RESOLVE_DEVICE_SYMBOLS /variable/CMAKE_CUDA_RUNTIME_LIBRARY /variable/CMAKE_DEBUG_POSTFIX + /variable/CMAKE_DEFAULT_BUILD_TYPE + /variable/CMAKE_DEFAULT_CONFIGS /variable/CMAKE_DISABLE_PRECOMPILE_HEADERS /variable/CMAKE_ENABLE_EXPORTS /variable/CMAKE_EXE_LINKER_FLAGS @@ -428,9 +431,6 @@ Variables that Control the Build /variable/CMAKE_MODULE_LINKER_FLAGS_INIT /variable/CMAKE_MSVCIDE_RUN_PATH /variable/CMAKE_MSVC_RUNTIME_LIBRARY - /variable/CMAKE_NMC_CROSS_CONFIGS - /variable/CMAKE_NMC_DEFAULT_BUILD_FILE_CONFIG - /variable/CMAKE_NMC_DEFAULT_CONFIGS /variable/CMAKE_NINJA_OUTPUT_PATH_PREFIX /variable/CMAKE_NO_BUILTIN_CHRPATH /variable/CMAKE_NO_SYSTEM_FROM_IMPORTED diff --git a/Help/variable/CMAKE_CROSS_CONFIGS.rst b/Help/variable/CMAKE_CROSS_CONFIGS.rst new file mode 100644 index 0000000..c850af2 --- /dev/null +++ b/Help/variable/CMAKE_CROSS_CONFIGS.rst @@ -0,0 +1,7 @@ +CMAKE_CROSS_CONFIGS +------------------- + +Specifies a :ref:`semicolon-separated list ` of +configurations available from all ``build-.ninja`` files in the +:generator:`Ninja Multi-Config` generator. See the generator's +documentation for more details. diff --git a/Help/variable/CMAKE_DEFAULT_BUILD_TYPE.rst b/Help/variable/CMAKE_DEFAULT_BUILD_TYPE.rst new file mode 100644 index 0000000..62ee0d2 --- /dev/null +++ b/Help/variable/CMAKE_DEFAULT_BUILD_TYPE.rst @@ -0,0 +1,6 @@ +CMAKE_DEFAULT_BUILD_TYPE +------------------------ + +Specifies the configuration to use by default in a ``build.ninja`` file in the +:generator:`Ninja Multi-Config` generator. See the generator's documentation +for more details. diff --git a/Help/variable/CMAKE_DEFAULT_CONFIGS.rst b/Help/variable/CMAKE_DEFAULT_CONFIGS.rst new file mode 100644 index 0000000..86d8a5a --- /dev/null +++ b/Help/variable/CMAKE_DEFAULT_CONFIGS.rst @@ -0,0 +1,7 @@ +CMAKE_DEFAULT_CONFIGS +--------------------- + +Specifies a :ref:`semicolon-separated list ` of configurations +to build for a target in ``build.ninja`` if no ``:`` suffix is specified in +the :generator:`Ninja Multi-Config` generator. +See the generator's documentation for more details. diff --git a/Help/variable/CMAKE_NMC_CROSS_CONFIGS.rst b/Help/variable/CMAKE_NMC_CROSS_CONFIGS.rst deleted file mode 100644 index 6eb6494..0000000 --- a/Help/variable/CMAKE_NMC_CROSS_CONFIGS.rst +++ /dev/null @@ -1,7 +0,0 @@ -CMAKE_NMC_CROSS_CONFIGS -------------------------------- - -Specifies a :ref:`semicolon-separated list ` of -configurations available from all ``build-.ninja`` files in the -:generator:`Ninja Multi-Config` generator. See the generator's -documentation for more details. diff --git a/Help/variable/CMAKE_NMC_DEFAULT_BUILD_FILE_CONFIG.rst b/Help/variable/CMAKE_NMC_DEFAULT_BUILD_FILE_CONFIG.rst deleted file mode 100644 index c0eab56..0000000 --- a/Help/variable/CMAKE_NMC_DEFAULT_BUILD_FILE_CONFIG.rst +++ /dev/null @@ -1,6 +0,0 @@ -CMAKE_NMC_DEFAULT_BUILD_FILE_CONFIG -------------------------------------------- - -Specifies the configuration to use by default in a ``build.ninja`` file in the -:generator:`Ninja Multi-Config` generator. See the generator's documentation -for more details. diff --git a/Help/variable/CMAKE_NMC_DEFAULT_CONFIGS.rst b/Help/variable/CMAKE_NMC_DEFAULT_CONFIGS.rst deleted file mode 100644 index e2bb017..0000000 --- a/Help/variable/CMAKE_NMC_DEFAULT_CONFIGS.rst +++ /dev/null @@ -1,7 +0,0 @@ -CMAKE_NMC_DEFAULT_CONFIGS ---------------------------------- - -Specifies a :ref:`semicolon-separated list ` of configurations -to build for a target in ``build.ninja`` if no ``:`` suffix is specified in -the :generator:`Ninja Multi-Config` generator. -See the generator's documentation for more details. diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx index b1e26b2..27c28fe 100644 --- a/Source/cmGlobalNinjaGenerator.cxx +++ b/Source/cmGlobalNinjaGenerator.cxx @@ -2489,7 +2489,7 @@ bool cmGlobalNinjaMultiGenerator::OpenBuildFileStreams() } *this->DefaultFileStream << "# This file is a convenience file generated by\n" - << "# CMAKE_NMC_DEFAULT_BUILD_FILE_CONFIG.\n\n" + << "# CMAKE_DEFAULT_BUILD_TYPE.\n\n" << "include " << GetNinjaImplFilename(this->DefaultFileConfig) << "\n\n"; } @@ -2624,12 +2624,12 @@ bool cmGlobalNinjaMultiGenerator::ReadCacheEntriesForBuild( std::set configs(configsVec.cbegin(), configsVec.cend()); this->DefaultFileConfig = - state.GetSafeCacheEntryValue("CMAKE_NMC_DEFAULT_BUILD_FILE_CONFIG"); + state.GetSafeCacheEntryValue("CMAKE_DEFAULT_BUILD_TYPE"); if (!this->DefaultFileConfig.empty() && !configs.count(this->DefaultFileConfig)) { std::ostringstream msg; msg << "The configuration specified by " - << "CMAKE_NMC_DEFAULT_BUILD_FILE_CONFIG (" << this->DefaultFileConfig + << "CMAKE_DEFAULT_BUILD_TYPE (" << this->DefaultFileConfig << ") is not present in CMAKE_CONFIGURATION_TYPES"; this->GetCMakeInstance()->IssueMessage(MessageType::FATAL_ERROR, msg.str()); @@ -2637,12 +2637,12 @@ bool cmGlobalNinjaMultiGenerator::ReadCacheEntriesForBuild( } std::vector crossConfigsVec; - cmExpandList(state.GetSafeCacheEntryValue("CMAKE_NMC_CROSS_CONFIGS"), + cmExpandList(state.GetSafeCacheEntryValue("CMAKE_CROSS_CONFIGS"), crossConfigsVec); auto crossConfigs = ListSubsetWithAll(configs, configs, crossConfigsVec); if (!crossConfigs) { std::ostringstream msg; - msg << "CMAKE_NMC_CROSS_CONFIGS is not a subset of " + msg << "CMAKE_CROSS_CONFIGS is not a subset of " << "CMAKE_CONFIGURATION_TYPES"; this->GetCMakeInstance()->IssueMessage(MessageType::FATAL_ERROR, msg.str()); @@ -2651,7 +2651,7 @@ bool cmGlobalNinjaMultiGenerator::ReadCacheEntriesForBuild( this->CrossConfigs = *crossConfigs; auto defaultConfigsString = - state.GetSafeCacheEntryValue("CMAKE_NMC_DEFAULT_CONFIGS"); + state.GetSafeCacheEntryValue("CMAKE_DEFAULT_CONFIGS"); if (defaultConfigsString.empty()) { defaultConfigsString = this->DefaultFileConfig; } @@ -2659,9 +2659,8 @@ bool cmGlobalNinjaMultiGenerator::ReadCacheEntriesForBuild( defaultConfigsString != this->DefaultFileConfig && (this->DefaultFileConfig.empty() || this->CrossConfigs.empty())) { std::ostringstream msg; - msg << "CMAKE_NMC_DEFAULT_CONFIGS cannot be used without " - << "CMAKE_NMC_DEFAULT_BUILD_FILE_CONFIG or " - << "CMAKE_NMC_CROSS_CONFIGS"; + msg << "CMAKE_DEFAULT_CONFIGS cannot be used without " + << "CMAKE_DEFAULT_BUILD_TYPE or CMAKE_CROSS_CONFIGS"; this->GetCMakeInstance()->IssueMessage(MessageType::FATAL_ERROR, msg.str()); return false; @@ -2675,8 +2674,7 @@ bool cmGlobalNinjaMultiGenerator::ReadCacheEntriesForBuild( this->CrossConfigs, defaultConfigsVec); if (!defaultConfigs) { std::ostringstream msg; - msg << "CMAKE_NMC_DEFAULT_CONFIGS is not a subset of " - << "CMAKE_NMC_CROSS_CONFIGS"; + msg << "CMAKE_DEFAULT_CONFIGS is not a subset of CMAKE_CROSS_CONFIGS"; this->GetCMakeInstance()->IssueMessage(MessageType::FATAL_ERROR, msg.str()); return false; diff --git a/Tests/RunCMake/NinjaMultiConfig/InvalidCrossConfigs-stderr.txt b/Tests/RunCMake/NinjaMultiConfig/InvalidCrossConfigs-stderr.txt index 6e165e8..76c5ecf 100644 --- a/Tests/RunCMake/NinjaMultiConfig/InvalidCrossConfigs-stderr.txt +++ b/Tests/RunCMake/NinjaMultiConfig/InvalidCrossConfigs-stderr.txt @@ -1,5 +1,5 @@ ^CMake Error: - CMAKE_NMC_CROSS_CONFIGS is not a subset of CMAKE_CONFIGURATION_TYPES + CMAKE_CROSS_CONFIGS is not a subset of CMAKE_CONFIGURATION_TYPES CMake Generate step failed\. Build files cannot be regenerated correctly\.$ diff --git a/Tests/RunCMake/NinjaMultiConfig/InvalidDefaultBuildFileConfig-stderr.txt b/Tests/RunCMake/NinjaMultiConfig/InvalidDefaultBuildFileConfig-stderr.txt index 114a8a3..5aa9038 100644 --- a/Tests/RunCMake/NinjaMultiConfig/InvalidDefaultBuildFileConfig-stderr.txt +++ b/Tests/RunCMake/NinjaMultiConfig/InvalidDefaultBuildFileConfig-stderr.txt @@ -1,6 +1,6 @@ ^CMake Error: - The configuration specified by CMAKE_NMC_DEFAULT_BUILD_FILE_CONFIG - \(RelWithDebInfo\) is not present in CMAKE_CONFIGURATION_TYPES + The configuration specified by CMAKE_DEFAULT_BUILD_TYPE \(RelWithDebInfo\) is + not present in CMAKE_CONFIGURATION_TYPES CMake Generate step failed\. Build files cannot be regenerated correctly\.$ diff --git a/Tests/RunCMake/NinjaMultiConfig/InvalidDefaultConfigsCross-stderr.txt b/Tests/RunCMake/NinjaMultiConfig/InvalidDefaultConfigsCross-stderr.txt index 8d52189..6c2df86 100644 --- a/Tests/RunCMake/NinjaMultiConfig/InvalidDefaultConfigsCross-stderr.txt +++ b/Tests/RunCMake/NinjaMultiConfig/InvalidDefaultConfigsCross-stderr.txt @@ -1,5 +1,5 @@ ^CMake Error: - CMAKE_NMC_DEFAULT_CONFIGS is not a subset of CMAKE_NMC_CROSS_CONFIGS + CMAKE_DEFAULT_CONFIGS is not a subset of CMAKE_CROSS_CONFIGS CMake Generate step failed\. Build files cannot be regenerated correctly\.$ diff --git a/Tests/RunCMake/NinjaMultiConfig/InvalidDefaultConfigsNoCross-stderr.txt b/Tests/RunCMake/NinjaMultiConfig/InvalidDefaultConfigsNoCross-stderr.txt index f9cb56d..5d090a0 100644 --- a/Tests/RunCMake/NinjaMultiConfig/InvalidDefaultConfigsNoCross-stderr.txt +++ b/Tests/RunCMake/NinjaMultiConfig/InvalidDefaultConfigsNoCross-stderr.txt @@ -1,6 +1,6 @@ ^CMake Error: - CMAKE_NMC_DEFAULT_CONFIGS cannot be used without - CMAKE_NMC_DEFAULT_BUILD_FILE_CONFIG or CMAKE_NMC_CROSS_CONFIGS + 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\.$ diff --git a/Tests/RunCMake/NinjaMultiConfig/InvalidDefaultConfigsNoDefaultFile-stderr.txt b/Tests/RunCMake/NinjaMultiConfig/InvalidDefaultConfigsNoDefaultFile-stderr.txt index f9cb56d..5d090a0 100644 --- a/Tests/RunCMake/NinjaMultiConfig/InvalidDefaultConfigsNoDefaultFile-stderr.txt +++ b/Tests/RunCMake/NinjaMultiConfig/InvalidDefaultConfigsNoDefaultFile-stderr.txt @@ -1,6 +1,6 @@ ^CMake Error: - CMAKE_NMC_DEFAULT_CONFIGS cannot be used without - CMAKE_NMC_DEFAULT_BUILD_FILE_CONFIG or CMAKE_NMC_CROSS_CONFIGS + 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\.$ diff --git a/Tests/RunCMake/NinjaMultiConfig/RunCMakeTest.cmake b/Tests/RunCMake/NinjaMultiConfig/RunCMakeTest.cmake index a608e9e..bed7531 100644 --- a/Tests/RunCMake/NinjaMultiConfig/RunCMakeTest.cmake +++ b/Tests/RunCMake/NinjaMultiConfig/RunCMakeTest.cmake @@ -81,7 +81,7 @@ 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_NMC_DEFAULT_BUILD_FILE_CONFIG=RelWithDebInfo;-DCMAKE_NMC_CROSS_CONFIGS=all") +set(RunCMake_TEST_OPTIONS "-DCMAKE_CONFIGURATION_TYPES=Debug\\;Release\\;MinSizeRel\\;RelWithDebInfo;-DCMAKE_DEFAULT_BUILD_TYPE=RelWithDebInfo;-DCMAKE_CROSS_CONFIGS=all") run_cmake_configure(Simple) unset(RunCMake_TEST_OPTIONS) include(${RunCMake_TEST_BINARY_DIR}/target_files.cmake) @@ -113,7 +113,7 @@ run_ninja(Simple default-build-file-clean-minsizerel build.ninja clean:MinSizeRe run_ninja(Simple default-build-file-all build.ninja all) set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/SimpleDefaultBuildAlias-build) -set(RunCMake_TEST_OPTIONS "-DCMAKE_CONFIGURATION_TYPES=Debug\\;Release\\;MinSizeRel\\;RelWithDebInfo;-DCMAKE_NMC_DEFAULT_BUILD_FILE_CONFIG=Release;-DCMAKE_NMC_DEFAULT_CONFIGS=all;-DCMAKE_NMC_CROSS_CONFIGS=all") +set(RunCMake_TEST_OPTIONS "-DCMAKE_CONFIGURATION_TYPES=Debug\\;Release\\;MinSizeRel\\;RelWithDebInfo;-DCMAKE_DEFAULT_BUILD_TYPE=Release;-DCMAKE_DEFAULT_CONFIGS=all;-DCMAKE_CROSS_CONFIGS=all") run_cmake_configure(SimpleDefaultBuildAlias) unset(RunCMake_TEST_OPTIONS) include(${RunCMake_TEST_BINARY_DIR}/target_files.cmake) @@ -122,7 +122,7 @@ run_ninja(SimpleDefaultBuildAlias all build.ninja all) run_ninja(SimpleDefaultBuildAlias clean build.ninja clean) set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/SimpleDefaultBuildAliasList-build) -set(RunCMake_TEST_OPTIONS "-DCMAKE_NMC_DEFAULT_BUILD_FILE_CONFIG=Release;-DCMAKE_NMC_DEFAULT_CONFIGS=Debug\\;Release;-DCMAKE_NMC_CROSS_CONFIGS=all") +set(RunCMake_TEST_OPTIONS "-DCMAKE_DEFAULT_BUILD_TYPE=Release;-DCMAKE_DEFAULT_CONFIGS=Debug\\;Release;-DCMAKE_CROSS_CONFIGS=all") run_cmake_configure(SimpleDefaultBuildAliasList) unset(RunCMake_TEST_OPTIONS) include(${RunCMake_TEST_BINARY_DIR}/target_files.cmake) @@ -133,7 +133,7 @@ run_ninja(SimpleDefaultBuildAliasList all-relwithdebinfo build.ninja all:RelWith run_ninja(SimpleDefaultBuildAliasList clean-configs build.ninja clean) set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/SimpleDefaultBuildAliasListCross-build) -set(RunCMake_TEST_OPTIONS "-DCMAKE_NMC_DEFAULT_BUILD_FILE_CONFIG=RelWithDebInfo;-DCMAKE_NMC_DEFAULT_CONFIGS=all;-DCMAKE_NMC_CROSS_CONFIGS=Debug\\;Release") +set(RunCMake_TEST_OPTIONS "-DCMAKE_DEFAULT_BUILD_TYPE=RelWithDebInfo;-DCMAKE_DEFAULT_CONFIGS=all;-DCMAKE_CROSS_CONFIGS=Debug\\;Release") run_cmake_configure(SimpleDefaultBuildAliasListCross) unset(RunCMake_TEST_OPTIONS) include(${RunCMake_TEST_BINARY_DIR}/target_files.cmake) @@ -141,27 +141,27 @@ run_ninja(SimpleDefaultBuildAliasListCross target-configs build.ninja simpleexe) unset(RunCMake_TEST_BINARY_DIR) -set(RunCMake_TEST_OPTIONS "-DCMAKE_CONFIGURATION_TYPES=Debug\\;Release;-DCMAKE_NMC_CROSS_CONFIGS=Debug\\;Release\\;RelWithDebInfo") +set(RunCMake_TEST_OPTIONS "-DCMAKE_CONFIGURATION_TYPES=Debug\\;Release;-DCMAKE_CROSS_CONFIGS=Debug\\;Release\\;RelWithDebInfo") run_cmake(InvalidCrossConfigs) unset(RunCMake_TEST_OPTIONS) -set(RunCMake_TEST_OPTIONS "-DCMAKE_CONFIGURATION_TYPES=Debug\\;Release;-DCMAKE_NMC_DEFAULT_BUILD_FILE_CONFIG=RelWithDebInfo") +set(RunCMake_TEST_OPTIONS "-DCMAKE_CONFIGURATION_TYPES=Debug\\;Release;-DCMAKE_DEFAULT_BUILD_TYPE=RelWithDebInfo") run_cmake(InvalidDefaultBuildFileConfig) unset(RunCMake_TEST_OPTIONS) -set(RunCMake_TEST_OPTIONS "-DCMAKE_NMC_CROSS_CONFIGS=Debug\\;Release;-DCMAKE_NMC_DEFAULT_BUILD_FILE_CONFIG=Release;-DCMAKE_NMC_DEFAULT_CONFIGS=Debug\\;Release\\;RelWithDebInfo") +set(RunCMake_TEST_OPTIONS "-DCMAKE_CROSS_CONFIGS=Debug\\;Release;-DCMAKE_DEFAULT_BUILD_TYPE=Release;-DCMAKE_DEFAULT_CONFIGS=Debug\\;Release\\;RelWithDebInfo") run_cmake(InvalidDefaultConfigsCross) unset(RunCMake_TEST_OPTIONS) -set(RunCMake_TEST_OPTIONS "-DCMAKE_NMC_CROSS_CONFIGS=Debug\\;Release;-DCMAKE_NMC_DEFAULT_CONFIGS=all") +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_NMC_DEFAULT_BUILD_FILE_CONFIG=Release;-DCMAKE_NMC_DEFAULT_CONFIGS=all") +set(RunCMake_TEST_OPTIONS "-DCMAKE_DEFAULT_BUILD_TYPE=Release;-DCMAKE_DEFAULT_CONFIGS=all") run_cmake(InvalidDefaultConfigsNoCross) unset(RunCMake_TEST_OPTIONS) -set(RunCMake_TEST_OPTIONS "-DCMAKE_NMC_DEFAULT_BUILD_FILE_CONFIG=Release") +set(RunCMake_TEST_OPTIONS "-DCMAKE_DEFAULT_BUILD_TYPE=Release") run_cmake(DefaultBuildFileConfig) unset(RunCMake_TEST_OPTIONS) @@ -178,7 +178,7 @@ run_ninja(SimpleNoCross all-all build-Debug.ninja all:all) run_cmake_build(SimpleNoCross all-clean Debug clean:all) set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/SimpleCrossConfigs-build) -set(RunCMake_TEST_OPTIONS "-DCMAKE_NMC_CROSS_CONFIGS=Debug\\;Release") +set(RunCMake_TEST_OPTIONS "-DCMAKE_CROSS_CONFIGS=Debug\\;Release") run_cmake_configure(SimpleCrossConfigs) include(${RunCMake_TEST_BINARY_DIR}/target_files.cmake) run_ninja(SimpleCrossConfigs release-in-release-graph build-Release.ninja simpleexe) @@ -192,21 +192,21 @@ run_cmake_build(SimpleCrossConfigs all-all-in-release-graph Release all:all) run_cmake_build(SimpleCrossConfigs all-relwithdebinfo-in-release-graph Release all:RelWithDebInfo) set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/Framework-build) -set(RunCMake_TEST_OPTIONS "-DCMAKE_NMC_CROSS_CONFIGS=all") +set(RunCMake_TEST_OPTIONS "-DCMAKE_CROSS_CONFIGS=all") run_cmake_configure(Framework) unset(RunCMake_TEST_OPTIONS) include(${RunCMake_TEST_BINARY_DIR}/target_files.cmake) run_cmake_build(Framework framework Debug all) set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/FrameworkDependencyAutogen-build) -set(RunCMake_TEST_OPTIONS "-DCMAKE_NMC_CROSS_CONFIGS=all") +set(RunCMake_TEST_OPTIONS "-DCMAKE_CROSS_CONFIGS=all") run_cmake_configure(FrameworkDependencyAutogen) unset(RunCMake_TEST_OPTIONS) include(${RunCMake_TEST_BINARY_DIR}/target_files.cmake) run_cmake_build(FrameworkDependencyAutogen framework Release test2:Debug) set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/CustomCommandGenerator-build) -set(RunCMake_TEST_OPTIONS "-DCMAKE_CONFIGURATION_TYPES=Debug\\;Release\\;MinSizeRel\\;RelWithDebInfo;-DCMAKE_NMC_CROSS_CONFIGS=all") +set(RunCMake_TEST_OPTIONS "-DCMAKE_CONFIGURATION_TYPES=Debug\\;Release\\;MinSizeRel\\;RelWithDebInfo;-DCMAKE_CROSS_CONFIGS=all") run_cmake_configure(CustomCommandGenerator) unset(RunCMake_TEST_OPTIONS) include(${RunCMake_TEST_BINARY_DIR}/target_files.cmake) @@ -223,7 +223,7 @@ run_ninja(CustomCommandGenerator release-in-debug-graph build-Debug.ninja genera run_cmake_command(CustomCommandGenerator-release-in-debug-graph-generated "${TARGET_FILE_generated_Release}") set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/CustomCommandsAndTargets-build) -set(RunCMake_TEST_OPTIONS "-DCMAKE_NMC_CROSS_CONFIGS=all") +set(RunCMake_TEST_OPTIONS "-DCMAKE_CROSS_CONFIGS=all") run_cmake_configure(CustomCommandsAndTargets) unset(RunCMake_TEST_OPTIONS) include(${RunCMake_TEST_BINARY_DIR}/target_files.cmake) @@ -243,7 +243,7 @@ unset(RunCMake_TEST_BINARY_DIR) run_cmake(CustomCommandDepfile) set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/PostfixAndLocation-build) -set(RunCMake_TEST_OPTIONS "-DCMAKE_CONFIGURATION_TYPES=Debug\\;Release;-DCMAKE_NMC_CROSS_CONFIGS=all") +set(RunCMake_TEST_OPTIONS "-DCMAKE_CONFIGURATION_TYPES=Debug\\;Release;-DCMAKE_CROSS_CONFIGS=all") run_cmake_configure(PostfixAndLocation) unset(RunCMake_TEST_OPTIONS) include(${RunCMake_TEST_BINARY_DIR}/target_files.cmake) @@ -258,14 +258,14 @@ run_ninja(Clean release-notall build-Release.ninja exenotall) run_cmake_build(Clean release-clean Release clean) set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/AdditionalCleanFiles-build) -set(RunCMake_TEST_OPTIONS "-DCMAKE_CONFIGURATION_TYPES=Debug\\;Release\\;MinSizeRel\\;RelWithDebInfo;-DCMAKE_NMC_CROSS_CONFIGS=all") +set(RunCMake_TEST_OPTIONS "-DCMAKE_CONFIGURATION_TYPES=Debug\\;Release\\;MinSizeRel\\;RelWithDebInfo;-DCMAKE_CROSS_CONFIGS=all") run_cmake_configure(AdditionalCleanFiles) unset(RunCMake_TEST_OPTIONS) run_cmake_build(AdditionalCleanFiles release-clean Release clean) run_ninja(AdditionalCleanFiles all-clean build-Debug.ninja clean:all) set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/Install-build) -set(RunCMake_TEST_OPTIONS "-DCMAKE_INSTALL_PREFIX=${RunCMake_TEST_BINARY_DIR}/install;-DCMAKE_NMC_CROSS_CONFIGS=all") +set(RunCMake_TEST_OPTIONS "-DCMAKE_INSTALL_PREFIX=${RunCMake_TEST_BINARY_DIR}/install;-DCMAKE_CROSS_CONFIGS=all") run_cmake_configure(Install) unset(RunCMake_TEST_OPTIONS) include(${RunCMake_TEST_BINARY_DIR}/target_files.cmake) @@ -287,7 +287,7 @@ endif() if(CMake_TEST_Qt5) set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/Qt5-build) - set(RunCMake_TEST_OPTIONS "-DCMAKE_NMC_CROSS_CONFIGS=all") + set(RunCMake_TEST_OPTIONS "-DCMAKE_CROSS_CONFIGS=all") run_cmake_configure(Qt5) unset(RunCMake_TEST_OPTIONS) include(${RunCMake_TEST_BINARY_DIR}/target_files.cmake) -- cgit v0.12 From 9590c3a400cc16882fee860818cfdcca82e17a37 Mon Sep 17 00:00:00 2001 From: Kyle Edwards Date: Wed, 26 Feb 2020 16:37:30 -0500 Subject: Generator: Don't allow Ninja Multi-Config variables on other generators We may want to enable these variables later on with specific semantics. To avoid breaking backwards compatibility, make it an error to use them for now. --- Source/cmGlobalGenerator.cxx | 35 ++++++++++++++++++++++ Source/cmGlobalGenerator.h | 7 +++++ Source/cmGlobalNinjaGenerator.h | 4 +++ .../Configure/NoCMAKE_CROSS_CONFIGS-result.txt | 1 + .../Configure/NoCMAKE_CROSS_CONFIGS-stderr.txt | 11 +++++++ .../RunCMake/Configure/NoCMAKE_CROSS_CONFIGS.cmake | 1 + .../NoCMAKE_DEFAULT_BUILD_TYPE-result.txt | 1 + .../NoCMAKE_DEFAULT_BUILD_TYPE-stderr.txt | 11 +++++++ .../Configure/NoCMAKE_DEFAULT_BUILD_TYPE.cmake | 1 + .../Configure/NoCMAKE_DEFAULT_CONFIGS-result.txt | 1 + .../Configure/NoCMAKE_DEFAULT_CONFIGS-stderr.txt | 11 +++++++ .../Configure/NoCMAKE_DEFAULT_CONFIGS.cmake | 1 + Tests/RunCMake/Configure/RunCMakeTest.cmake | 6 ++++ 13 files changed, 91 insertions(+) create mode 100644 Tests/RunCMake/Configure/NoCMAKE_CROSS_CONFIGS-result.txt create mode 100644 Tests/RunCMake/Configure/NoCMAKE_CROSS_CONFIGS-stderr.txt create mode 100644 Tests/RunCMake/Configure/NoCMAKE_CROSS_CONFIGS.cmake create mode 100644 Tests/RunCMake/Configure/NoCMAKE_DEFAULT_BUILD_TYPE-result.txt create mode 100644 Tests/RunCMake/Configure/NoCMAKE_DEFAULT_BUILD_TYPE-stderr.txt create mode 100644 Tests/RunCMake/Configure/NoCMAKE_DEFAULT_BUILD_TYPE.cmake create mode 100644 Tests/RunCMake/Configure/NoCMAKE_DEFAULT_CONFIGS-result.txt create mode 100644 Tests/RunCMake/Configure/NoCMAKE_DEFAULT_CONFIGS-stderr.txt create mode 100644 Tests/RunCMake/Configure/NoCMAKE_DEFAULT_CONFIGS.cmake diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index ff6ad9d..0404715 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -1361,8 +1361,43 @@ void cmGlobalGenerator::ComputeBuildFileGenerators() } } +bool cmGlobalGenerator::UnsupportedVariableIsDefined(const std::string& name, + bool supported) const +{ + if (!supported && this->Makefiles.front()->GetDefinition(name)) { + std::ostringstream e; + /* clang-format off */ + e << + "Generator\n" + " " << this->GetName() << "\n" + "does not support variable\n" + " " << name << "\n" + "but it has been specified." + ; + /* clang-format on */ + this->GetCMakeInstance()->IssueMessage(MessageType::FATAL_ERROR, e.str()); + return true; + } + + return false; +} + bool cmGlobalGenerator::Compute() { + // Make sure unsupported variables are not used. + if (this->UnsupportedVariableIsDefined("CMAKE_DEFAULT_BUILD_TYPE", + this->SupportsDefaultBuildType())) { + return false; + } + if (this->UnsupportedVariableIsDefined("CMAKE_CROSS_CONFIGS", + this->SupportsCrossConfigs())) { + return false; + } + if (this->UnsupportedVariableIsDefined("CMAKE_DEFAULT_CONFIGS", + this->SupportsDefaultConfigs())) { + return false; + } + // Some generators track files replaced during the Generate. // Start with an empty vector: this->FilesReplacedDuringGenerate.clear(); diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h index 0e7e03d..ba997b2 100644 --- a/Source/cmGlobalGenerator.h +++ b/Source/cmGlobalGenerator.h @@ -455,6 +455,10 @@ public: /** Generate an .rule file path for a given command output. */ virtual std::string GenerateRuleFile(std::string const& output) const; + virtual bool SupportsDefaultBuildType() const { return false; } + virtual bool SupportsCrossConfigs() const { return false; } + virtual bool SupportsDefaultConfigs() const { return false; } + static std::string EscapeJSON(const std::string& s); void ProcessEvaluationFiles(); @@ -674,6 +678,9 @@ private: virtual const char* GetBuildIgnoreErrorsFlag() const { return nullptr; } + bool UnsupportedVariableIsDefined(const std::string& name, + bool supported) const; + // Cache directory content and target files to be built. struct DirectoryContent { diff --git a/Source/cmGlobalNinjaGenerator.h b/Source/cmGlobalNinjaGenerator.h index 3db8356..5668dd1 100644 --- a/Source/cmGlobalNinjaGenerator.h +++ b/Source/cmGlobalNinjaGenerator.h @@ -640,6 +640,10 @@ public: bool ReadCacheEntriesForBuild(const cmState& state) override; + bool SupportsDefaultBuildType() const override { return true; } + bool SupportsCrossConfigs() const override { return true; } + bool SupportsDefaultConfigs() const override { return true; } + protected: bool OpenBuildFileStreams() override; void CloseBuildFileStreams() override; diff --git a/Tests/RunCMake/Configure/NoCMAKE_CROSS_CONFIGS-result.txt b/Tests/RunCMake/Configure/NoCMAKE_CROSS_CONFIGS-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/Configure/NoCMAKE_CROSS_CONFIGS-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/Configure/NoCMAKE_CROSS_CONFIGS-stderr.txt b/Tests/RunCMake/Configure/NoCMAKE_CROSS_CONFIGS-stderr.txt new file mode 100644 index 0000000..a5d149d --- /dev/null +++ b/Tests/RunCMake/Configure/NoCMAKE_CROSS_CONFIGS-stderr.txt @@ -0,0 +1,11 @@ +^CMake Error: + Generator + + [^ +]* + + does not support variable + + CMAKE_CROSS_CONFIGS + + but it has been specified. diff --git a/Tests/RunCMake/Configure/NoCMAKE_CROSS_CONFIGS.cmake b/Tests/RunCMake/Configure/NoCMAKE_CROSS_CONFIGS.cmake new file mode 100644 index 0000000..75d0c47 --- /dev/null +++ b/Tests/RunCMake/Configure/NoCMAKE_CROSS_CONFIGS.cmake @@ -0,0 +1 @@ +set(CMAKE_CROSS_CONFIGS "") diff --git a/Tests/RunCMake/Configure/NoCMAKE_DEFAULT_BUILD_TYPE-result.txt b/Tests/RunCMake/Configure/NoCMAKE_DEFAULT_BUILD_TYPE-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/Configure/NoCMAKE_DEFAULT_BUILD_TYPE-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/Configure/NoCMAKE_DEFAULT_BUILD_TYPE-stderr.txt b/Tests/RunCMake/Configure/NoCMAKE_DEFAULT_BUILD_TYPE-stderr.txt new file mode 100644 index 0000000..8aa3ed3 --- /dev/null +++ b/Tests/RunCMake/Configure/NoCMAKE_DEFAULT_BUILD_TYPE-stderr.txt @@ -0,0 +1,11 @@ +^CMake Error: + Generator + + [^ +]* + + does not support variable + + CMAKE_DEFAULT_BUILD_TYPE + + but it has been specified. diff --git a/Tests/RunCMake/Configure/NoCMAKE_DEFAULT_BUILD_TYPE.cmake b/Tests/RunCMake/Configure/NoCMAKE_DEFAULT_BUILD_TYPE.cmake new file mode 100644 index 0000000..64c7feb --- /dev/null +++ b/Tests/RunCMake/Configure/NoCMAKE_DEFAULT_BUILD_TYPE.cmake @@ -0,0 +1 @@ +set(CMAKE_DEFAULT_BUILD_TYPE "") diff --git a/Tests/RunCMake/Configure/NoCMAKE_DEFAULT_CONFIGS-result.txt b/Tests/RunCMake/Configure/NoCMAKE_DEFAULT_CONFIGS-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/Configure/NoCMAKE_DEFAULT_CONFIGS-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/Configure/NoCMAKE_DEFAULT_CONFIGS-stderr.txt b/Tests/RunCMake/Configure/NoCMAKE_DEFAULT_CONFIGS-stderr.txt new file mode 100644 index 0000000..040bf4d --- /dev/null +++ b/Tests/RunCMake/Configure/NoCMAKE_DEFAULT_CONFIGS-stderr.txt @@ -0,0 +1,11 @@ +^CMake Error: + Generator + + [^ +]* + + does not support variable + + CMAKE_DEFAULT_CONFIGS + + but it has been specified. diff --git a/Tests/RunCMake/Configure/NoCMAKE_DEFAULT_CONFIGS.cmake b/Tests/RunCMake/Configure/NoCMAKE_DEFAULT_CONFIGS.cmake new file mode 100644 index 0000000..5b65172 --- /dev/null +++ b/Tests/RunCMake/Configure/NoCMAKE_DEFAULT_CONFIGS.cmake @@ -0,0 +1 @@ +set(CMAKE_DEFAULT_CONFIGS "") diff --git a/Tests/RunCMake/Configure/RunCMakeTest.cmake b/Tests/RunCMake/Configure/RunCMakeTest.cmake index 76d843c..9fd4499 100644 --- a/Tests/RunCMake/Configure/RunCMakeTest.cmake +++ b/Tests/RunCMake/Configure/RunCMakeTest.cmake @@ -50,3 +50,9 @@ file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}") run_cmake(RemoveCache) file(REMOVE "${RunCMake_TEST_BINARY_DIR}/CMakeCache.txt") run_cmake(RemoveCache) + +if(NOT RunCMake_GENERATOR MATCHES "^Ninja Multi-Config$") + run_cmake(NoCMAKE_CROSS_CONFIGS) + run_cmake(NoCMAKE_DEFAULT_BUILD_TYPE) + run_cmake(NoCMAKE_DEFAULT_CONFIGS) +endif() -- cgit v0.12 From c794b70f194bcff6f06971767f18473da13950e3 Mon Sep 17 00:00:00 2001 From: Kyle Edwards Date: Wed, 26 Feb 2020 17:19:47 -0500 Subject: Ninja Multi-Config: Always generate build.ninja If CMAKE_DEFAULT_BUILD_TYPE is not specified, use the first item from CMAKE_CONFIGURATION_TYPES instead. --- Help/generator/Ninja Multi-Config.rst | 15 ++++++++------- Source/cmGlobalNinjaGenerator.cxx | 12 +++++------- .../InvalidDefaultConfigsNoDefaultFile-result.txt | 1 - .../InvalidDefaultConfigsNoDefaultFile-stderr.txt | 6 ------ .../InvalidDefaultConfigsNoDefaultFile.cmake | 0 Tests/RunCMake/NinjaMultiConfig/RunCMakeTest.cmake | 8 +++----- 6 files changed, 16 insertions(+), 26 deletions(-) delete mode 100644 Tests/RunCMake/NinjaMultiConfig/InvalidDefaultConfigsNoDefaultFile-result.txt delete mode 100644 Tests/RunCMake/NinjaMultiConfig/InvalidDefaultConfigsNoDefaultFile-stderr.txt delete mode 100644 Tests/RunCMake/NinjaMultiConfig/InvalidDefaultConfigsNoDefaultFile.cmake diff --git a/Help/generator/Ninja Multi-Config.rst b/Help/generator/Ninja Multi-Config.rst index c2331f0..1f68535 100644 --- a/Help/generator/Ninja Multi-Config.rst +++ b/Help/generator/Ninja Multi-Config.rst @@ -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-.ninja`` file will be generated for each of these configurations (with ```` being the configuration name.) These files -are intended to be run with ``ninja -f build-.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-.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 `` will always use ``build-.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-.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-.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`. diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx index 27c28fe..5243c36 100644 --- a/Source/cmGlobalNinjaGenerator.cxx +++ b/Source/cmGlobalNinjaGenerator.cxx @@ -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 diff --git a/Tests/RunCMake/NinjaMultiConfig/InvalidDefaultConfigsNoDefaultFile-result.txt b/Tests/RunCMake/NinjaMultiConfig/InvalidDefaultConfigsNoDefaultFile-result.txt deleted file mode 100644 index d00491f..0000000 --- a/Tests/RunCMake/NinjaMultiConfig/InvalidDefaultConfigsNoDefaultFile-result.txt +++ /dev/null @@ -1 +0,0 @@ -1 diff --git a/Tests/RunCMake/NinjaMultiConfig/InvalidDefaultConfigsNoDefaultFile-stderr.txt b/Tests/RunCMake/NinjaMultiConfig/InvalidDefaultConfigsNoDefaultFile-stderr.txt deleted file mode 100644 index 5d090a0..0000000 --- a/Tests/RunCMake/NinjaMultiConfig/InvalidDefaultConfigsNoDefaultFile-stderr.txt +++ /dev/null @@ -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\.$ diff --git a/Tests/RunCMake/NinjaMultiConfig/InvalidDefaultConfigsNoDefaultFile.cmake b/Tests/RunCMake/NinjaMultiConfig/InvalidDefaultConfigsNoDefaultFile.cmake deleted file mode 100644 index e69de29..0000000 diff --git a/Tests/RunCMake/NinjaMultiConfig/RunCMakeTest.cmake b/Tests/RunCMake/NinjaMultiConfig/RunCMakeTest.cmake index bed7531..b07b4f7 100644 --- a/Tests/RunCMake/NinjaMultiConfig/RunCMakeTest.cmake +++ b/Tests/RunCMake/NinjaMultiConfig/RunCMakeTest.cmake @@ -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) -- cgit v0.12