How to create Eclipse project from CMake project

CMake is a popular way to create and maintain C++ projects that are easy to build on different platforms. While CMake can be used to easily generate Visual Studio solutions, it does not work well at creating Eclipse CDT projects. One method to get around this is to create a Makefile project in Eclipse for an existing CMake project.

  1. Go to: File > New > Makefile Project with Existing Code

  2. In the Import Existing Code dialog, provide a Project Name and in the Existing Code Location give the directory containing your CMake project.

  3. The project is created and all the files and directories in your CMake project appear in the Project Explorer. Fear not, Eclipse has not made copies of these files (as it does for most types of imports). Instead, it is working directly from the location of your CMake project.

  4. To be able to build your project, run CMake from the terminal to generate its Makefile. Next, when you choose Project > Build Project, Eclipse runs make in the project directory, thus using the generated Makefile.

  5. The common CMake convention is to generate Makefile and other files in a separate subdirectory. If you would like Eclipse to work with this setup, configure your project to use that make location.

  6. This project can compile one or more target executables, but you cannot Run or Debug them. To be able to do that, create one or more Launch Configurations for the project. You can do this in Project > Properties > Run-Debug Settings. In a launch configuration, at a bare minimum you should at least provide the path to the target executable in the C/C++ Application field.

Now you can compile, run or debug your application from Eclipse itself! 🙂

You will find that Eclipse has not created any directory or files in your Workspace directory nor in the existing source code base directory. So, where is it storing the config files for your project?

These are just some of the files and directories, Eclipse uses for such a project:

  • .project and .cproject hidden files in the source code directory
  • All other project details are stored in your_workspace/.metadata/.plugins/org.eclipse.core.resources/.projects

Tried with: Eclipse 4.4.2, NVIDIA Nsight 5.5.0 and Ubuntu 14.04


8 thoughts on “How to create Eclipse project from CMake project

    1. Zeromemories: Go to Project > Properties > Run-Debug Settings. Click on New and in the C/C++ Application field, point it to the executable that your CMake project builds.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.