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.
- Go to: File > New > Makefile Project with Existing Code
In the Import Existing Code dialog, provide a Project Name and in the Existing Code Location give the directory containing your CMake project.
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.
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
makein the project directory, thus using the generated Makefile.
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.
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:
.cprojecthidden files in the source code directory
- All other project details are stored in
Tried with: Eclipse 4.4.2, NVIDIA Nsight 5.5.0 and Ubuntu 14.04