I have a native CMake project, and I want to use the Eclipse IDE with it so that it makes my development easier by providing auto-complete and and other features. I can't seem to find how to import the a CMake project in Eclipse.
我有一个本地的CMake项目,我希望使用Eclipse IDE,这样可以通过提供自动完成和其他功能使我的开发变得更容易。我似乎找不到如何在Eclipse中导入CMake项目。
PS: I am open for suggestions for other IDE's that work well with CMake.
PS:我愿意为其他的IDE提供建议。
2 个解决方案
#1
25
KDevelop is an awesome IDE with great CMake support.
KDevelop是一个很棒的IDE,具有强大的CMake支持。
As for Eclipse - run this:
至于Eclipse,运行如下:
cd <project_dir>
cmake -G "Eclipse CDT4 - Unix Makefiles" ./
This will produce Eclipse project for you.
这将为您生成Eclipse项目。
#2
12
Elaborating on arrowd's answer for Eclipse:
详细阐述arrowd对Eclipse的解决方案:
First, choose a directory for the CMake files. I prefer to keep my Eclipse workspaces in ~/workspaces
and the source code in ~/src
. Data which I need to build or test the project goes in subdirs of the project's workspace dir, so I suggest doing the same for CMake.
首先,为CMake文件选择一个目录。我更喜欢在~/工作空间中保留我的Eclipse工作区和~/src中的源代码。我需要构建或测试项目的数据在项目的workspace dir的subdirs中进行,所以我建议对CMake做同样的事情。
Assuming both your workspace and source folders are named someproject
, do:
假设您的工作区和源文件夹都被命名为someproject,请执行:
cd ~/workspaces/someproject
mkdir cmake
cd cmake
cmake -G "Eclipse CDT4 - Unix Makefiles" ~/src/someproject
Then, in your Eclipse workspace, do:
然后,在您的Eclipse工作区中:
File > Import... > General > Existing Projects into Workspace
文件>导入…>通用>现有项目进入工作区。
Check Select root directory and choose ~/workspaces/someproject/cmake
. Make sure Copy projects into workspace is NOT checked.
检查选择根目录并选择~/工作区/someproject/cmake。确保没有检查到工作区中的复制项目。
Click Finish and you have a CMake project in your workspace.
单击Finish,您的工作区中有一个CMake项目。
Two things to note:
两个注意事项:
- I used
cmake
for the workspace subdir, but you can use a name of your choice. - 我使用cmake作为工作空间的子目录,但是您可以使用您选择的名称。
- If you make any changes to your build configuration (such as editing
Makefile.am
), you will need to re-run the last command in order for Eclipse to pick up the changes. - 如果您对构建配置进行了任何更改(例如编辑Makefile.am),您将需要重新运行最后一个命令,以便Eclipse能够接收更改。
#1
25
KDevelop is an awesome IDE with great CMake support.
KDevelop是一个很棒的IDE,具有强大的CMake支持。
As for Eclipse - run this:
至于Eclipse,运行如下:
cd <project_dir>
cmake -G "Eclipse CDT4 - Unix Makefiles" ./
This will produce Eclipse project for you.
这将为您生成Eclipse项目。
#2
12
Elaborating on arrowd's answer for Eclipse:
详细阐述arrowd对Eclipse的解决方案:
First, choose a directory for the CMake files. I prefer to keep my Eclipse workspaces in ~/workspaces
and the source code in ~/src
. Data which I need to build or test the project goes in subdirs of the project's workspace dir, so I suggest doing the same for CMake.
首先,为CMake文件选择一个目录。我更喜欢在~/工作空间中保留我的Eclipse工作区和~/src中的源代码。我需要构建或测试项目的数据在项目的workspace dir的subdirs中进行,所以我建议对CMake做同样的事情。
Assuming both your workspace and source folders are named someproject
, do:
假设您的工作区和源文件夹都被命名为someproject,请执行:
cd ~/workspaces/someproject
mkdir cmake
cd cmake
cmake -G "Eclipse CDT4 - Unix Makefiles" ~/src/someproject
Then, in your Eclipse workspace, do:
然后,在您的Eclipse工作区中:
File > Import... > General > Existing Projects into Workspace
文件>导入…>通用>现有项目进入工作区。
Check Select root directory and choose ~/workspaces/someproject/cmake
. Make sure Copy projects into workspace is NOT checked.
检查选择根目录并选择~/工作区/someproject/cmake。确保没有检查到工作区中的复制项目。
Click Finish and you have a CMake project in your workspace.
单击Finish,您的工作区中有一个CMake项目。
Two things to note:
两个注意事项:
- I used
cmake
for the workspace subdir, but you can use a name of your choice. - 我使用cmake作为工作空间的子目录,但是您可以使用您选择的名称。
- If you make any changes to your build configuration (such as editing
Makefile.am
), you will need to re-run the last command in order for Eclipse to pick up the changes. - 如果您对构建配置进行了任何更改(例如编辑Makefile.am),您将需要重新运行最后一个命令,以便Eclipse能够接收更改。