ソースを参照

cmake: Add support for '--build --prefix=<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
Brad King 4 年 前
コミット
3357d37761

+ 1 - 1
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 <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.

+ 2 - 1
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 [<dir> | --preset <preset>] [options] [-- [native-options]]\n"
       "Options:\n"
       "  <dir>          = Project binary directory to be built.\n"
-      "  --preset <preset>\n"
+      "  --preset <preset>, --preset=<preset>\n"
       "                 = Specify a build preset.\n"
       "  --list-presets\n"
       "                 = List available build presets.\n"

+ 10 - 2
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()