What does the -H option mean for CMake?

This answer to a previous question about CMake shows this command line:

cmake -H. -Bbuild -G "MSYS Makefiles" 

What task does the -H. function perform here -H. ? cmake --help says -H prints help ...

I am using CMake 3.2.3.

+29
cmake
Jun 27 '15 at 16:18
source share
2 answers

As mentioned in the linked answer, this is an undocumented option, but looking at the source code shows its effect:

In cmake::SetArgs() :

 if(arg.find("-H",0) == 0) { directoriesSet = true; std::string path = arg.substr(2); path = cmSystemTools::CollapseFullPath(path); cmSystemTools::ConvertToUnixSlashes(path); this->SetHomeDirectory(path); 

The last call to SetHomeDirectory actually sets the source directory for the project. The -B option (also undocumented), in turn, sets the binary directory.

If these options are not set, the binary directory will be the current folder in which cmake is running, and the source directory can be specified as a positional argument (if not found, the source folder will also be the current working folder).

+37
Jun 27 '15 at 18:26
source share

The CMake Auto-Stop Guide explains both the legacy and new features of CMake 3.13:

  • -H

    This internal version is not documented, but is widely used by the community.

    as well as

    It was replaced in 3.13 by the flag of the official source directory -S.

  • -B

    Starting with CMake 3.13, -B is an officially supported flag, can handle spaces correctly and can be used regardless of the -S or -H options.

0
Jan 20 '19 at 18:56
source share



All Articles