From 077ab5774c637eb2262587425199579c90967577 Mon Sep 17 00:00:00 2001 From: Bartosz Kosiorek Date: Fri, 8 Mar 2019 10:38:27 +0100 Subject: cmake: add short version of '--target ...' option --- Help/manual/cmake.1.rst | 2 +- Help/release/dev/cmake-short-target-option.rst | 6 ++++++ Source/cmakemain.cxx | 8 +++++--- Tests/RunCMake/CommandLine/RunCMakeTest.cmake | 2 +- 4 files changed, 13 insertions(+), 5 deletions(-) create mode 100644 Help/release/dev/cmake-short-target-option.rst diff --git a/Help/manual/cmake.1.rst b/Help/manual/cmake.1.rst index 17593f0..d70ef6e 100644 --- a/Help/manual/cmake.1.rst +++ b/Help/manual/cmake.1.rst @@ -276,7 +276,7 @@ following options: The :envvar:`CMAKE_BUILD_PARALLEL_LEVEL` environment variable, if set, specifies a default parallel level when this option is not given. -``--target ...`` +``--target ..., -t ...`` Build ```` instead of default targets. May be specified multiple times. ``--config `` diff --git a/Help/release/dev/cmake-short-target-option.rst b/Help/release/dev/cmake-short-target-option.rst new file mode 100644 index 0000000..5eac042 --- /dev/null +++ b/Help/release/dev/cmake-short-target-option.rst @@ -0,0 +1,6 @@ +cmake-short-target-option +---------------------------- + +* The :manual:`cmake(1)` ``--target`` parameter gained shorter + version ``-t``, e.g. ``cmake --build . -t Library1 Library2`` is + equivalant to ``cmake --build . --target Library1 Library2``. diff --git a/Source/cmakemain.cxx b/Source/cmakemain.cxx index a8431c4..b83c744 100644 --- a/Source/cmakemain.cxx +++ b/Source/cmakemain.cxx @@ -58,12 +58,13 @@ static const char* cmDocumentationUsageNote[][2] = { " = Build in parallel using the given number of jobs. \n" \ " If is omitted the native build tool's \n" \ " default number is used.\n" \ + " The CMAKE_BUILD_PARALLEL_LEVEL environment " \ "variable\n" \ " specifies a default parallel level when this " \ "option\n" \ " is not given.\n" \ - " --target = Build instead of default targets.\n" \ - " May be specified multiple times.\n" \ + " --target ..., -t ... \n" \ + " = Build instead of default targets.\n" \ " --config = For multi-configuration tools, choose .\n" \ " --clean-first = Build target 'clean' first, then build.\n" \ " (To clean only, use --target 'clean'.)\n" \ @@ -429,7 +430,8 @@ static int do_build(int ac, char const* const* av) dir.clear(); } doing = DoingNone; - } else if (strcmp(av[i], "--target") == 0) { + } else if ((strcmp(av[i], "--target") == 0) || + (strcmp(av[i], "-t") == 0)) { doing = DoingTarget; } else if (strcmp(av[i], "--config") == 0) { doing = DoingConfig; diff --git a/Tests/RunCMake/CommandLine/RunCMakeTest.cmake b/Tests/RunCMake/CommandLine/RunCMakeTest.cmake index ff2a8a5..5b5c5a5 100644 --- a/Tests/RunCMake/CommandLine/RunCMakeTest.cmake +++ b/Tests/RunCMake/CommandLine/RunCMakeTest.cmake @@ -106,7 +106,7 @@ function(run_BuildDir) run_cmake_command(BuildDir--build ${CMAKE_COMMAND} -E chdir .. ${CMAKE_COMMAND} --build BuildDir-build --target CustomTarget) run_cmake_command(BuildDir--build-multiple-targets ${CMAKE_COMMAND} -E chdir .. - ${CMAKE_COMMAND} --build BuildDir-build --target CustomTarget2 --target CustomTarget3) + ${CMAKE_COMMAND} --build BuildDir-build -t CustomTarget2 --target CustomTarget3) run_cmake_command(BuildDir--build-multiple-targets-jobs ${CMAKE_COMMAND} -E chdir .. ${CMAKE_COMMAND} --build BuildDir-build --target CustomTarget CustomTarget2 -j2 --target CustomTarget3) run_cmake_command(BuildDir--build-multiple-targets-with-clean-first ${CMAKE_COMMAND} -E chdir .. -- cgit v0.12