Importing a Cmake Project into Eclipse Cdt

Importing a CMake project into Eclipse CDT

KDevelop is an awesome IDE with great CMake support.

As for Eclipse - run this:

cd <project_dir>
cmake -G "Eclipse CDT4 - Unix Makefiles" ./

This will produce Eclipse project for you.

Import cmake project from github in Eclipse

From their git repository, the readme has the following instruction:

mkdir build
cd build
cmake ..
make -j4
sudo make install

You need to run cmake first. It it will do what it needs to do and gives you a make file to run. You don't need eclipse to build and compile!

How to configure Eclipse CDT for cmake?

In Eclipse-CDT you do not create cmake projects but you import cmake projects.
This is what you should do:

  1. Say the source of your CMake project named "Planner" is located in D:/javaworkspace/src/Planner

  2. Create a folder (the folders NEED to be parallel to each other): D:/javaworkspace/build/Planner

  3. Go to the folder D:/javaworkspace/build/Planner and run CMake using the Eclipse generator:

     cmake ../../src/Planner -G"Eclipse CDT4 - Unix Makefiles"

    This will generate the make files for your Planner project.

  4. To import this in Eclipse do the following:

    File -> Import -> C/C++ -> Existing code as Makefile project

    and select D:/javaworkspace/build/Planner (the build output folder with the make files) as the "Existing Code location"

However, looking at your paths it seems to me that you are working on Windows. In windows CMake can generate Visual Studio projects. If you want to use CMake I suggest first creating a "hello world" project using CMake (remember, Eclipse does not create CMake projects, you have to create a CMakeLists.txt file by hand)

How to set Eclipse for cmake project?

Using CMake you can generate a project for Eclipse and then open it in the IDE. CMake will be called automatically to regenerate project if you make some changes at that level.

How to add files to Eclipse CDT project with CMake?

The problem I had was I made an "in-source" build instead of an "out-of-source" build. Now it works fine, and it was actually lots of info on this on the Wiki but somehow I misunderstood it.

Creating Eclipse CDT using CMake on Windows

I ended up not using the GUI. Instead I used the VS x64 Native Tools Command Prompt then ran the cmake command:

cmake -G "Eclipse CDT4 - NMake Makefiles" -DCMAKE_BUILD_TYPE=Debug -DCMAKE_ECLIPSE_GENERATE_SOURCE_PROJECT=TRUE -DCMAKE_ECLIPSE_MAKE_ARGUMENTS=-j8 ../


Related Topics



Leave a reply



Submit