CMake 为 Win32 和 x64 生成 Visual Studio 2008 解决方案
我在 Windows XP 下使用 CMake 2.8,想要生成一个 Visual Studio 2008 解决方案文件,其中包含 Win32 和 x64 的发布和调试配置。
可以通过在 CMakeLists.txt
文件中设置 CMake 配置变量来完成此操作吗?
I am using CMake 2.8 under Windows XP and want to generate a Visual Studio 2008 solution file which contains Release and Debug configurations for both Win32 and x64.
Can this be done by setting a CMake configuration variable in the CMakeLists.txt
file?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
CMakeLists 不是您为项目指定生成器( makefile、XCode、Visual Studio )的位置。当用户在源上运行 CMake 时指定生成器。
The CMakeLists is not where you specify the generator ( makefile, XCode, Visual Studio ) for a project. The generator is specified when a user runs CMake on your source.
您应该使用 CMake.exe 在控制台下生成一个解决方案文件。
CMake -G "Visual Studio 9 2008" (包含 CMakeLists.txt 文件的目录)// 这适用于 X86。
CMake -G "Visual Studio 9 2008 Win64" (包含 CMakeLists.txt 文件的目录)// 这适用于 X64。
You should produce a solution file under a console with CMake.exe.
CMake -G "Visual Studio 9 2008" (The directory which contains your CMakeLists.txt file)// This is for X86.
CMake -G "Visual Studio 9 2008 Win64" (The directory which contains your CMakeLists.txt file)// This is for X64.
您绝对应该使用批处理脚本来自动化这些过程。我与您分享我自己的构建器脚本的简化版本。我自己的环境要复杂得多,因此我编写了这个脚本供您轻松使用。
它的用法非常基本。
表示源代码在当前目录,编译配置为64位Debug版本。
您只需要更改脚本中的全局配置变量即可
Visual Studio目录和cmake目录。
SET VISUAL_STUDIO_9_HOME=
SET CMAKE_HOME=
You should definitely use batch scripts to automate these kind of processes. I share simplified version of my own builder script with you. My own environment is much more complicated hence I wrote this script for you for using easily.
Its usage is pretty basic.
Means source code is in the current directory and compilation configuration is 64bit Debug version.
You only need to change global configuration variables in the script which point
visual studio directory and cmake directory.
SET VISUAL_STUDIO_9_HOME=
SET CMAKE_HOME=