From 3357d377612fc238ff9da61666041764792034bb Mon Sep 17 00:00:00 2001 From: Brad King Date: Tue, 23 Feb 2021 08:50:40 -0500 Subject: cmake: Add support for '--build --prefix=' form of the argument The main `cmake --preset` argument for configure presets supports both forms, so support it for `cmake --build --preset` too. Issue: #21855 --- Help/manual/cmake.1.rst | 2 +- Source/cmakemain.cxx | 3 ++- Tests/RunCMake/CMakePresetsBuild/RunCMakeTest.cmake | 12 ++++++++++-- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/Help/manual/cmake.1.rst b/Help/manual/cmake.1.rst index 1759b9d..157ea5f 100644 --- a/Help/manual/cmake.1.rst +++ b/Help/manual/cmake.1.rst @@ -416,7 +416,7 @@ following options: Project binary directory to be built. This is required (unless a preset is specified) and must be first. -``--preset `` +``--preset ``, ``--preset=`` Use a build preset to specify build options. The project binary directory is inferred from the ``configurePreset`` key. The current working directory must contain CMake preset files. diff --git a/Source/cmakemain.cxx b/Source/cmakemain.cxx index 4260ca2..88ba011 100644 --- a/Source/cmakemain.cxx +++ b/Source/cmakemain.cxx @@ -511,6 +511,7 @@ int do_build(int ac, char const* const* av) bool hasPreset = false; for (int i = 2; i < ac; ++i) { if (strcmp(av[i], "--list-presets") == 0 || + cmHasLiteralPrefix(av[i], "--preset=") || strcmp(av[i], "--preset") == 0) { hasPreset = true; break; @@ -584,7 +585,7 @@ int do_build(int ac, char const* const* av) "Usage: cmake --build [ | --preset ] [options] [-- [native-options]]\n" "Options:\n" " = Project binary directory to be built.\n" - " --preset \n" + " --preset , --preset=\n" " = Specify a build preset.\n" " --list-presets\n" " = List available build presets.\n" diff --git a/Tests/RunCMake/CMakePresetsBuild/RunCMakeTest.cmake b/Tests/RunCMake/CMakePresetsBuild/RunCMakeTest.cmake index 9491524..fd95c2c 100644 --- a/Tests/RunCMake/CMakePresetsBuild/RunCMakeTest.cmake +++ b/Tests/RunCMake/CMakePresetsBuild/RunCMakeTest.cmake @@ -40,6 +40,7 @@ function(run_cmake_build_presets name CMakePresetsBuild_CONFIGURE_PRESETS CMakeP endforeach() endif() + set(eq 0) foreach(BUILD_PRESET ${CMakePresetsBuild_BUILD_PRESETS}) if (EXISTS "${RunCMake_SOURCE_DIR}/${name}-build-${BUILD_PRESET}-check.cmake") set(RunCMake-check-file "${name}-build-${BUILD_PRESET}-check.cmake") @@ -47,8 +48,15 @@ function(run_cmake_build_presets name CMakePresetsBuild_CONFIGURE_PRESETS CMakeP set(RunCMake-check-file "check.cmake") endif() - run_cmake_command(${name}-build-${BUILD_PRESET} - ${CMAKE_COMMAND} "--build" "--preset" "${BUILD_PRESET}" ${ARGN}) + if(eq) + run_cmake_command(${name}-build-${BUILD_PRESET} + ${CMAKE_COMMAND} "--build" "--preset=${BUILD_PRESET}" ${ARGN}) + set(eq 0) + else() + run_cmake_command(${name}-build-${BUILD_PRESET} + ${CMAKE_COMMAND} "--build" "--preset" "${BUILD_PRESET}" ${ARGN}) + set(eq 1) + endif() endforeach() endfunction() -- cgit v0.12