MantisBT - CMake
View Issue Details
0016093CMakeCMakepublic2016-05-04 10:212016-06-10 14:21
Andreas Schuh 
Brad King 
normalminorhave not tried
closedfixed 
Apple MacOS X10.11.4
CMake 3.5.2 
CMake 3.6CMake 3.6 
0016093: Clarify documentation of --build as a separate command mode
The following results in an error as if I'd specified a subdirectory underneath the current build directory. Changing the order of --build and --target options works as expected, though. Just "--build ." followed directly by "--target" gives this error.

cmake --config Release --build . --target apidoc
CMake Error: The source directory "/Users/as12312/Software/BASIS/Xcode/apidoc" does not exist.
Specify --help for usage, or press the help button on the CMake GUI.


cmake --config Release --target apidoc --build .
No tags attached.
Issue History
2016-05-04 10:21Andreas SchuhNew Issue
2016-05-04 10:24Andreas SchuhNote Added: 0041024
2016-05-05 08:33Brad KingNote Added: 0041026
2016-05-05 08:33Brad KingStatusnew => resolved
2016-05-05 08:33Brad KingResolutionopen => won't fix
2016-05-05 08:36Andreas SchuhNote Added: 0041027
2016-05-10 04:19AntonioNote Added: 0041038
2016-05-10 09:47Brad KingNote Added: 0041039
2016-05-10 09:47Brad KingAssigned To => Brad King
2016-05-10 09:47Brad KingResolutionwon't fix => fixed
2016-05-10 09:47Brad KingFixed in Version => CMake 3.6
2016-05-10 09:47Brad KingTarget Version => CMake 3.6
2016-05-10 09:47Brad KingSummaryOrder of --build and --target "cmake" command options matters => Clarify documentation of --build as a separate command mode
2016-05-11 03:47AntonioNote Added: 0041047
2016-06-10 14:21Kitware RobotNote Added: 0041177
2016-06-10 14:21Kitware RobotStatusresolved => closed

Notes
(0041024)
Andreas Schuh   
2016-05-04 10:24   
Actually, the error message seems to suggest that the argument "--target" is taken as the argument of the "--build" option, ignoring the dot ".". Then the name of the target following the "--target" option becomes the positional argument of "cmake" which is the source directory.
(0041026)
Brad King   
2016-05-05 08:33   
The command mode is "cmake --build <dir>" followed by other options. This is just like "git clone" has options that must come after "clone" and not before. This is shown in the documented command synopsis:

 https://cmake.org/cmake/help/v3.5/manual/cmake.1.html [^]
 cmake --build <dir> [<options>] [-- <build-tool-options>...]
(0041027)
Andreas Schuh   
2016-05-05 08:36   
Fair enough. Although there is an important difference between "git clone" and "cmake --build". The first makes it clear the "clone" is a subcommand (cf. Python argparse subcommand) while "--build" suggest it to be just an option... obviously not to be changed now, but I think you see where the assumption that the order of arguments should not matter comes from.
(0041038)
Antonio   
2016-05-10 04:19   
I understand the synopsis shows that --build, -E and --find-package have to be given as first, but I think then it should be made explicit in the option description and/or cmake should give a clear error if such an option doesn't appear as first. In fact, calling them "options" makes things ambiguous: staying with the comparison with "git clone", they should be called "commands".
(0041039)
Brad King   
2016-05-10 09:47   
Re 0016093:0041038: Yes, fixed:

Help: Document `cmake --find-package` as a separate command mode
https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=d4faed2f [^]

Help: Document `cmake --build` as a separate command mode (0016093)
https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=3e503fe1 [^]
(0041047)
Antonio   
2016-05-11 03:47   
Great, thank you!
(0041177)
Kitware Robot   
2016-06-10 14:21   
This issue tracker is no longer used. Further discussion of this issue may take place in the current CMake Issues page linked in the banner at the top of this page.