使用 CMake 生成 Visual Studio C++ 项目文件 [英] Using CMake to generate Visual Studio C++ project files

查看:31
本文介绍了使用 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++ 项目文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆