Merge topic 'error-multiple-targets'
497cad7c
cmake: Teach --build to reject multiple --target options886acd80
Help: Fix reference to `cmake --build` in cmake(1) manual
This commit is contained in:
commit
08e5362004
|
@ -58,13 +58,14 @@ Options
|
||||||
|
|
||||||
<dir> = Project binary directory to be built.
|
<dir> = Project binary directory to be built.
|
||||||
--target <tgt> = Build <tgt> instead of default targets.
|
--target <tgt> = Build <tgt> instead of default targets.
|
||||||
|
May only be specified once.
|
||||||
--config <cfg> = For multi-configuration tools, choose <cfg>.
|
--config <cfg> = For multi-configuration tools, choose <cfg>.
|
||||||
--clean-first = Build target 'clean' first, then build.
|
--clean-first = Build target 'clean' first, then build.
|
||||||
(To clean only, use --target 'clean'.)
|
(To clean only, use --target 'clean'.)
|
||||||
--use-stderr = Ignored. Behavior is default in CMake >= 3.0.
|
--use-stderr = Ignored. Behavior is default in CMake >= 3.0.
|
||||||
-- = Pass remaining options to the native tool.
|
-- = Pass remaining options to the native tool.
|
||||||
|
|
||||||
Run cmake --build with no options for quick help.
|
Run ``cmake --build`` with no options for quick help.
|
||||||
|
|
||||||
``-N``
|
``-N``
|
||||||
View mode only.
|
View mode only.
|
||||||
|
|
|
@ -0,0 +1,6 @@
|
||||||
|
error-multiple-targets
|
||||||
|
----------------------
|
||||||
|
|
||||||
|
* The :manual:`cmake(1)` ``--build`` command-line tool now rejects multiple
|
||||||
|
``--target`` options with an error instead of silently ignoring all but the
|
||||||
|
last one.
|
|
@ -60,6 +60,7 @@ static const char * cmDocumentationUsageNote[][2] =
|
||||||
#define CMAKE_BUILD_OPTIONS \
|
#define CMAKE_BUILD_OPTIONS \
|
||||||
" <dir> = Project binary directory to be built.\n" \
|
" <dir> = Project binary directory to be built.\n" \
|
||||||
" --target <tgt> = Build <tgt> instead of default targets.\n" \
|
" --target <tgt> = Build <tgt> instead of default targets.\n" \
|
||||||
|
" May only be specified once.\n" \
|
||||||
" --config <cfg> = For multi-configuration tools, choose <cfg>.\n" \
|
" --config <cfg> = For multi-configuration tools, choose <cfg>.\n" \
|
||||||
" --clean-first = Build target 'clean' first, then build.\n" \
|
" --clean-first = Build target 'clean' first, then build.\n" \
|
||||||
" (To clean only, use --target 'clean'.)\n" \
|
" (To clean only, use --target 'clean'.)\n" \
|
||||||
|
@ -386,6 +387,7 @@ static int do_build(int ac, char const* const* av)
|
||||||
std::string dir;
|
std::string dir;
|
||||||
std::vector<std::string> nativeOptions;
|
std::vector<std::string> nativeOptions;
|
||||||
bool clean = false;
|
bool clean = false;
|
||||||
|
bool hasTarget = false;
|
||||||
|
|
||||||
enum Doing { DoingNone, DoingDir, DoingTarget, DoingConfig, DoingNative};
|
enum Doing { DoingNone, DoingDir, DoingTarget, DoingConfig, DoingNative};
|
||||||
Doing doing = DoingDir;
|
Doing doing = DoingDir;
|
||||||
|
@ -397,7 +399,17 @@ static int do_build(int ac, char const* const* av)
|
||||||
}
|
}
|
||||||
else if(strcmp(av[i], "--target") == 0)
|
else if(strcmp(av[i], "--target") == 0)
|
||||||
{
|
{
|
||||||
doing = DoingTarget;
|
if (!hasTarget)
|
||||||
|
{
|
||||||
|
doing = DoingTarget;
|
||||||
|
hasTarget = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
std::cerr << "'--target' may not be specified more than once.\n\n";
|
||||||
|
dir = "";
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if(strcmp(av[i], "--config") == 0)
|
else if(strcmp(av[i], "--config") == 0)
|
||||||
{
|
{
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
1
|
|
@ -0,0 +1,3 @@
|
||||||
|
^'--target' may not be specified more than once\.
|
||||||
|
+
|
||||||
|
Usage: cmake --build <dir> \[options\] \[-- \[native-options\]\]
|
|
@ -3,3 +3,5 @@ add_custom_command(
|
||||||
COMMAND ${CMAKE_COMMAND} -E echo CustomCommand > output.txt
|
COMMAND ${CMAKE_COMMAND} -E echo CustomCommand > output.txt
|
||||||
)
|
)
|
||||||
add_custom_target(CustomTarget ALL DEPENDS output.txt)
|
add_custom_target(CustomTarget ALL DEPENDS output.txt)
|
||||||
|
add_custom_target(CustomTarget2 ALL DEPENDS output.txt)
|
||||||
|
add_custom_target(CustomTarget3 ALL DEPENDS output.txt)
|
||||||
|
|
|
@ -51,6 +51,8 @@ function(run_BuildDir)
|
||||||
run_cmake(BuildDir)
|
run_cmake(BuildDir)
|
||||||
run_cmake_command(BuildDir--build ${CMAKE_COMMAND} -E chdir ..
|
run_cmake_command(BuildDir--build ${CMAKE_COMMAND} -E chdir ..
|
||||||
${CMAKE_COMMAND} --build BuildDir-build --target CustomTarget)
|
${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)
|
||||||
endfunction()
|
endfunction()
|
||||||
run_BuildDir()
|
run_BuildDir()
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue