15

I'm learning CMake, reading the "Mastering CMake" book and other online available stuff. I wonder is there a detailed documentation for some command line options, for example -H, and -B which are used by generated files. Or the "-E echo" has additional options for coloring etc. I was not able to find some documentation for this yet.

Right now I saw this for CMake version 3.14.4:

$ cmake --help
  ...
  cmake [options] -S <path-to-source> -B <path-to-build>
  ...
  -S <path-to-source>          = Explicitly specify a source directory.
  -B <path-to-build>           = Explicitly specify a build directory.
  ...

Is this the official version of -H and -B?

Daniel Widdis
  • 8,424
  • 13
  • 41
  • 63
Andi
  • 888
  • 2
  • 10
  • 24
  • 2
    https://cmake.org/cmake/help/v3.2/manual/cmake.1.html#options for the documented ones, internet for the undocumented (like http://stackoverflow.com/questions/31090821/what-does-the-h-option-means-for-cmake and http://stackoverflow.com/a/13713684/110118 for `-H` and `-B`) :) – mlvljr Apr 05 '16 at 17:39

3 Answers3

13

Definitely not. You do have to look at the source code of CMake.

The online docs are good, but there are some private-ish implementation details that we intentionally leave out of the official docs. Command-line stuff we use from generated projects and makefiles are some of those details.

Online docs here:

Documented command line options here:

Overview page, pointing to other sources of information:

Oren S
  • 1,820
  • 1
  • 19
  • 33
DLRdave
  • 13,876
  • 4
  • 53
  • 70
  • Thanks Dave for this information. To be honest I'm very interested in some of the hidden command line options because it is helpful for my own set of combinded projects. Especially the posibility to color echo output helps to read the makefile messages. And the possibility to call cmake for out-of-source build without creating the build-dir first with -B and -H sound very interesting. Maybe you will publish it in future versions. Kind regards, Andi – Andi Feb 26 '11 at 13:15
  • 5
    Why would you do this? Why would you intentionally make things hard? – mmr Apr 04 '13 at 17:44
  • I don't think the CMake developers have intentionally made things difficult. And I'm quite certain that is not one of their goals... – DLRdave Apr 04 '13 at 18:14
  • @DLRdave Perhaps, for those interested, you could reference where these options can be found in the source? – jwalk Jul 02 '13 at 18:41
3

Cmake documentation has sensibly improved in the meantime, but -H<directory> and -B keep being hidden, probably for good reasons (they shouldn't be used outside of CMake development context).

-H<directory> and -B are both explained here.

For cmake -E, options are documented in this section.

Antonio
  • 19,451
  • 13
  • 99
  • 197
  • I cannot confirm the your doubts regarding -H and -B. I use CMake version 3.5.1 with this options, it still works. If you try only "cmake -H" it prints help, but using "cmake -H." for example shows an error message like "CMake Error: The source directory ... does not appear to contain CMakeLists.txt.". -B is fine too. – Andi May 11 '16 at 05:58
  • Well, if it is undocumented, you cannot rely on it. They might change or break it anytime. – usr1234567 Jun 02 '17 at 12:16
  • @usr1234567 Exactly! – Antonio Jun 02 '17 at 12:16
1

Probably not. You might have to look at the source code of CMake.

Přemysl J.
  • 307
  • 4
  • 11