Getting CMake to build out of source without wrapping scripts

后端 未结 3 1417
余生分开走
余生分开走 2020-11-30 04:05

I\'m trying to get CMake to build into a directory \'build\', as in project/build, where the CMakeLists.txt is in project/.

I know I can do

3条回答
  •  猫巷女王i
    2020-11-30 04:45

    CMake 3.13 or newer supports the command line options -S and -B to specify source and binary directory, respectively.

    cmake -S . -B build -G "MSYS Makefiles"
    

    This will look for the CMakeLists.txt in the current folder and create a build folder (if it does not yet exist) in it.

    For older versions of CMake, you can use the undocumented CMake options -H and -B to specify the source and binary directory upon invoking cmake:

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

    Note that there must not be a space character between the option and the directory path.

提交回复
热议问题