How to configure Eclipse CDT for cmake?

kspacja picture kspacja · Feb 26, 2012 · Viewed 83.9k times · Source

How to configure Eclipse "Helios" with plugin CDT for cmake?

cmake all 
CMake Error: The source directory "D:/javaworkspace/workspace/Planner/Debug/all" does not    exist.

Eclipse always wants to use 'all' option and I don't know how to stop its to not use it.

I've seen that in "Build behavior" section, in "Preference" there have been 'all' option. I erased this, but it still works wrong (this same error).

Answer

gvd picture gvd · Mar 12, 2012

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)