C++ Eclipse 中的 Cmake 支持

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/6915876/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-28 20:53:15  来源:igfitidea点击:

Cmake support in Eclipse

c++eclipsecmake

提问by McHalls

According to this, I have 3 options to use cmake in Eclipse CDT for C++. None of them works.

根据这个,我有3个选择使用的cmake在Eclipse CDT进行C ++。它们都不起作用。

The first is because I use out-of-source builds and the limitations of the generator is so lame. Also, it uses a hardcoded Eclipse project template, so it is fragile like hell. The second is the poor man's version of cmake support. It does not add any value to Eclipse, really. The third one simply does not work. I can't make an existing cmake project. I can create a new one, but not opening an existing one. Also, the cmake properties in the project properties windows throw an exception and that's it. Does not even show up.

第一个是因为我使用了源外构建并且生成器的局限性太小了。此外,它使用硬编码的 Eclipse 项目模板,因此它非常脆弱。二是穷人版的cmake支持。实际上,它不会为 Eclipse 增加任何价值。第三个根本行不通。我无法制作现有的 cmake 项目。我可以创建一个新的,但不能打开现有的。此外,项目属性窗口中的 cmake 属性会引发异常,仅此而已。甚至不出现。

Is there any GOOD support in Eclipse for cmake? Or any other powerful IDE? Like adding the CmakeList.txt and the corresponding project is created? I am mainly interested in having the proper include paths and the global make targets based on the cmake files. And of course it would be nice to have syntax colored editing of cmake files, etc.

Eclipse 中是否有对 cmake 的良好支持?或者任何其他强大的IDE?比如添加CmakeList.txt,对应的项目就创建好了?我主要对基于 cmake 文件的正确包含路径和全局 make 目标感兴趣。当然,对 cmake 文件等进行语法彩色编辑会很好。

回答by Sascha

We successfully use both Eclipse CDT and Qt Creator with a large CMake based project.

我们成功地将 Eclipse CDT 和 Qt Creator 用于基于 CMake 的大型项目。

For Eclipse, we usually use option two exactly as described. There is also a CMake Eclipse plug-in called CMake Editorfor syntax highlighting and command completion.

对于 Eclipse,我们通常完全按照描述使用选项 2。还有一个名为CMake Editor的 CMake Eclipse 插件,用于语法高亮和命令补全。

Personally, I am using QtCreator. It has quite good CMake support and is very fast. You should initially configure your project with the CMake GUI (using the Make or NMake Generator) and then open your top-level CMakeLists.txt file in QtCreator and point it to your already configured binary directory.

就个人而言,我正在使用 QtCreator。它有很好的 CMake 支持并且速度非常快。您应该首先使用 CMake GUI(使用 Make 或 NMake Generator)配置您的项目,然后在 QtCreator 中打开您的顶级 CMakeLists.txt 文件并将其指向您已配置的二进制目录。

回答by decimus phostle

Have you taken a look at Qt Creator? It might have the features you are looking for.

你看过Qt Creator吗?它可能具有您正在寻找的功能。

回答by Sergei

I use CMake GUI for generating CDT project or Unix makefiles and then import it via Eclipse.

我使用 CMake GUI 生成 CDT 项目或 Unix 生成文件,然后通过 Eclipse 导入它。

Also I use KDevelop 4 because it simply opens CMake projects and tightly integrates CMake support.

我还使用 KDevelop 4,因为它只是打开 CMake 项目并紧密集成了 CMake 支持。

回答by Sergei

Congratulations, CLion http://www.jetbrains.com/clion/new C++ IDE with CMake well integrated. See its features https://www.youtube.com/watch?feature=player_embedded&v=MY_Z90Tj6is

恭喜,CLion http://www.jetbrains.com/clion/与 CMake 很好地集成的新 C++ IDE。查看其功能https://www.youtube.com/watch?feature=player_embedded&v=MY_Z90Tj6is

回答by Christopher Bruns

I tried all three and have found option 2 to be the only useful one. Option 1, the cmake CDT generator, is useless. I cannot get option 3 to work either.

我尝试了所有三个,并发现选项 2 是唯一有用的一个。选项 1,cmake CDT 生成器,没用。我也无法让选项 3 起作用。

Yes, option 2 is the "poor man's version" insofar as you must follow a series of steps when setting up a new project, rather than pressing a single button. But I have had good success with it for many projects in the past year. Like you, I always do out of source builds.

是的,选项 2 是“穷人版”,因为您在设置新项目时必须遵循一系列步骤,而不是按一个按钮。但在过去的一年里,我在许多项目中都取得了很好的成功。像你一样,我总是做源代码构建。

Also, to get syntax coloring of CMake files, use the excellent CMakeEdplugin for eclipse. It's beautiful.

此外,要获得 CMake 文件的语法着色,请使用优秀的CMakeEd插件进行 Eclipse。真漂亮。

回答by Sergei

CDT has official CMake support plugin currently. You can find through Help->Install menu of Eclipse.

CDT 目前有官方的 CMake 支持插件。您可以通过 Eclipse 的 Help->Install 菜单找到。