mirror of
https://github.com/openharmony/third_party_cmake.git
synced 2026-07-18 18:14:28 -04:00
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
This commit is contained in:
@@ -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.
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user