我已经看到CMake把中间文件,比如.obj放在这样的目录中:
project.dir/sort/of/copy/of/source/directory
Run Code Online (Sandbox Code Playgroud)
有办法有这样的东西:
project.dir/Debug/ myfiles.obj |--> for my debug
Run Code Online (Sandbox Code Playgroud)
和
project.dir/Release/ myfiles.obj |--> for my release
Run Code Online (Sandbox Code Playgroud)
暂时,我使用2个单独的目录来生成每次我的库或可执行文件的Debug和release.在我有了平台之后......
是否有类似于CMAKE_ARCHIVE_OUTPUT_DIRECTORY_RELEASE或CMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE ...
对于中间文件.obj?
我也尝试了/Fo但是当我使用这个FLAG时,Cmake覆盖了他的配置:
warning D9025 : overriding '/Fo;../x64/Debug/' with '/FoCMakeFiles\project.dir\src\project\main.cpp.obj'
请问有人有解决方案吗?
您不能 - 至少目前,请参阅0014999:更改 Visual Studio 2012功能请求的中间目录 - 更改 CMake 和 makefile 生成器中的中间目录 - 就像您的情况一样-每个二进制文件NMake只能有一种构建配置类型构建输出目录。
因此,正如 @usr1234567 所评论的那样,使用两个构建目录是正确的做法。
或者 - 如果可以选择 - 使用 Visual Studio 多重配置生成器。它确实使用您建议的中间目录:
project.dir/Debug/...
project.dir/Release/...
Run Code Online (Sandbox Code Playgroud)
命令行上的 NMake 与 Visual Studio 解决方案
这些差异也可以在我通常用来构建基于 CMake 的系统的包装脚本中看到。
所以NMake看起来像这样:
@ECHO off
"\Program Files (x86)\Microsoft Visual Studio 14.0\vc\vcvarsall.bat" x64
IF NOT EXIST "x64\Debug\Makefile" (
cmake -H"." -B"x64/Debug" -DCMAKE_BUILD_TYPE=Debug -G"NMake Makefiles"
)
cmake --build "x64/Debug" --target "project"
IF NOT EXIST "x64\Release\Makefile" (
cmake -H"." -B"x64/Release" -DCMAKE_BUILD_TYPE=Release -G"NMake Makefiles"
)
cmake --build "x64/Release" --target "project"
Run Code Online (Sandbox Code Playgroud)
我最喜欢的 Visual Studio 解决方案变体如下所示:
@ECHO off
IF NOT EXIST "x64\*.sln" (
cmake -H"." -B"x64" -G"Visual Studio 14 2015 Win64"
)
cmake --build "x64" --target "project" --config "Debug"
cmake --build "x64" --target "project" --config "Release"
Run Code Online (Sandbox Code Playgroud)
附加参考资料
| 归档时间: |
|
| 查看次数: |
4139 次 |
| 最近记录: |