现在的位置: 首页 > 综合 > 正文

CMake,如何将临时文件产生到一个特定的目录里面

2012年09月16日 ⁄ 综合 ⁄ 共 760字 ⁄ 字号 评论关闭
How can I build multiple modes without switching ?

To build multiple modes (e.g. Debug and Release) in one shot without constantly running cmake -DCMAKE_BUILD_TYPE=Debug and cmake -DCMAKE_BUILD_TYPE=Release in source tree create a directory for builds eg.:

Project-directory/
  /Build

Inside you can place as many target directories for out-of-source build modes as you want, e.g.:

Project-directory/
  /Build
    /Debug
    /Release

In each of these directories issue a command (assuming that you have CMakeLists.txt directly in Project-directory)

cmake -DCMAKE_BUILD_TYPE=type_of_build ../../

to create a cmake cache configured for requested build type.

Now you can make each build just by entering appropriate directory and executing a make command.

到这里为止,应该可以将所有的零时文件产生到各自目录里面了。但是实际运行情况却还是老样子,还是产生到了根目录。通过上网查找,发现了一个可能因素:CMakeCache.txt文件。

于是将根目录下面的这个文件删除掉,OK,一切正常了,产生到了预期位置。

抱歉!评论已关闭.