What does the `-H.` option means for CMake?

前端 未结 2 1647
一向
一向 2020-12-04 13:08

This answer to a former question on CMake shows this command line:

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

What task does the -H.

2条回答
  •  庸人自扰
    2020-12-04 13:36

    As mentioned in the linked answer, it is an undocumented option, but looking at the source code reveals 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, 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 where cmake is executed, and the source directory can be given as a positional argument (if not found, the source folder will also be the current working directory).

提交回复
热议问题