Using CMake to generate Visual Studio C++ project files(使用 CMake 生成 Visual Studio C++ 项目文件)
问题描述
我正在开发一个开源 C++ 项目,用于在 Linux 和 Windows 上编译的代码.我使用 CMake 在 Linux 上构建代码.为了便于开发设置和政治原因,我必须坚持使用 Windows 上的 Visual Studio 项目文件/编辑器(我无法切换到 代码::块,例如).我看到使用 CMake 生成 Visual Studio 文件的说明,如此处.
I am working on an open source C++ project, for code that compiles on Linux and Windows. I use CMake to build the code on Linux. For ease of development setup and political reasons, I must stick to Visual Studio project files/editor on Windows (I can't switch to Code::Blocks, for example). I see instructions to generate Visual Studio files using CMake, as here.
您之前是否使用过 CMake 生成 Visual Studio 文件?您的体验如何?假设我想向我的项目添加一个新文件.这方面的工作流程是什么?
Have you used CMake to generate Visual Studio files before? How has been your experience? Suppose I want to add a new file to my project. What is the workflow for this?
推荐答案
CMake 实际上非常适合这个.关键是 Windows 端的每个人都必须记住在加载解决方案之前运行 CMake,而我们 Mac 端的每个人都必须记住在 make 之前运行它.
CMake is actually pretty good for this. The key part was everyone on the Windows side has to remember to run CMake before loading in the solution, and everyone on our Mac side would have to remember to run it before make.
最难的部分是作为 Windows 开发人员确保您的结构更改在 cmakelist.txt 文件中,而不是在解决方案或项目文件中,因为这些更改可能会丢失,即使没有丢失也不会转移到Mac 端也需要它们,Mac 人需要记住不要出于同样的原因修改 make 文件.
The hardest part was as a Windows developer making sure your structural changes were in the cmakelist.txt file and not in the solution or project files as those changes would probably get lost and even if not lost would not get transferred over to the Mac side who also needed them, and the Mac guys would need to remember not to modify the make file for the same reasons.
这只是需要一点思考和耐心,但一开始会有错误.但是,如果您在双方都使用持续集成,那么这些将很早就被淘汰,人们会最终养成习惯.
It just requires a little thought and patience, but there will be mistakes at first. But if you are using continuous integration on both sides then these will get shook out early, and people will eventually get in the habit.
这篇关于使用 CMake 生成 Visual Studio C++ 项目文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:使用 CMake 生成 Visual Studio C++ 项目文件
基础教程推荐
- 如何“在 Finder 中显示"或“在资源管理器中显 2021-01-01
- 使用从字符串中提取的参数调用函数 2022-01-01
- 如何在不破坏 vtbl 的情况下做相当于 memset(this, ...) 的操作? 2022-01-01
- 在 C++ 中循环遍历所有 Lua 全局变量 2021-01-01
- 从 std::cin 读取密码 2021-01-01
- Windows Media Foundation 录制音频 2021-01-01
- 为 C/C++ 中的项目的 makefile 生成依赖项 2022-01-01
- 为什么语句不能出现在命名空间范围内? 2021-01-01
- 如何使图像调整大小以在 Qt 中缩放? 2021-01-01
- 管理共享内存应该分配多少内存?(助推) 2022-12-07