Eclipse CDT4 Generator: Difference between revisions

From KitwarePublic
Jump to navigationJump to search
No edit summary
Line 16: Line 16:


<ol>
<ol>
<li> Create a build directory and goes there
<li> Create a build directory, go there and run CMake:
    <pre>mkdir /home/eric/certi_build  
<pre>mkdir /home/eric/certi_build  
cd /home/eric/certi_build</pre>
cd /home/eric/certi_build
</li>
cmake -G"Eclipse CDT4 - Unix </pre>
<li> Launch CMake
    <pre>cmake -G"Eclipse CDT4 - Unix Makefiles" ../certi_src</pre>
After that you will find two Eclipse file in your build tree:
After that you will find two Eclipse file in your build tree:
     <ol>
     <ol>
Line 27: Line 25:
     <li> <tt>certi_build/.cproject</tt></li>
     <li> <tt>certi_build/.cproject</tt></li>
     </ol>
     </ol>
</li>
</li>
</li>
<li> Import the created project file into Eclipse:
<li> Import the created project file into Eclipse:
Line 34: Line 33:
           [[Image:Capture-EclipseMenuFileImport.jpg|thumb|center|200px|Eclipse Menu->File->Import]]</li>
           [[Image:Capture-EclipseMenuFileImport.jpg|thumb|center|200px|Eclipse Menu->File->Import]]</li>


     <li> Select ''Existing projects into workspace'':
     <li> Select ''General->Existing projects into workspace'':
           [[Image:Capture-EclipseProjectsIntoWorkspace.jpg|thumb|center|200px|Existing Projects into Workspace]]</li>
           [[Image:Capture-EclipseProjectsIntoWorkspace.jpg|thumb|center|200px|Existing Projects into Workspace]]</li>


     <li> Browse where your build tree is and select the root build tree directory
     <li> Browse where your build tree is and select the root build tree directory. Keep "Copy projects into workspace" unchecked.
           [[Image:Capture-Import.jpg|thumb|center|200px|Eclipse Import after build tree selection]]</li>
           [[Image:Capture-Import.jpg|thumb|center|200px|Eclipse Import after build tree selection]]</li>



Revision as of 10:12, 25 November 2007


Eclipse opens CMake project file

Starting with version 2.6.0 CMake includes an Eclipse CDT 4.0 generator (not released yet, but already in cvs). It works together with the Makefile generators available now (i.e. "Unix Makefiles", "MinGW Makefiles", "MSYS Makefiles", and maybe "NMake Makefiles"). With this generator it is possible to create a set of .project/.cproject files that can be imported in Eclipse as an "Existing Eclipse project".

Note that CMake 2.4.x users may follow instructions provided here CMake:Eclipse in order to setup an Eclipse+CMake usage manually.


Using Eclipse CDT4 Generator

Using the Eclipse CDT4 generator is not different as using another CMake generator, it works for in-source and out-of-source builds. In this example I assume the source tree of my project is /home/eric/certi_src

  1. Create a build directory, go there and run CMake:
    mkdir /home/eric/certi_build 
    cd /home/eric/certi_build
    cmake -G"Eclipse CDT4 - Unix 

    After that you will find two Eclipse file in your build tree:

    1. certi_build/.project
    2. certi_build/.cproject
  2. Import the created project file into Eclipse:
    1. Launch eclipse
    2. Import project using Menu File->Import
      Eclipse Menu->File->Import
    3. Select General->Existing projects into workspace:
      Existing Projects into Workspace
    4. Browse where your build tree is and select the root build tree directory. Keep "Copy projects into workspace" unchecked.
      Eclipse Import after build tree selection
    5. You get a fully functional eclipse project
      Eclipse Imported CERTI project

Integration with version control systems

If you are using in-source builds, there are no problems with the Eclipse support for version control systems like cvs or Subversion.

If you are using out-of-source builds, there is a limitation of the CMake CDT4 Eclipse generator when your source tree is handled by a versioning system (like CVS, Subversion or other). You may read the referred discussions in the links below.

One solution is to have multiple projects:

  1. One project for version management. This one may be obtained by a normal checkout using new project from CVS/Subversion/etc. .
  2. One or more projects for building, resulting from the imported CMake generated project(s) obtained by the previously described procedure.


You will find a screen cast describing how to it here: File:CMakeEclipseCDT4andCVS-2.ogg

Discussion about Eclipse CDT4 Generator limitations

If you would like to monitor the changes to the EclipseCDT4 support, you can view the following links which contain the cvs history log for changes to the two main files:


Eclipse assumes project files (i.e. .project and .cproject) must be at the root of the project tree and a project may be handled by a versioning system (CVS, SVN, ...) iff the root project tree is.

This assumption clashes with the fact that CMake generated files should stay in the build tree whereas source files (which are usually those handled by a versioning system) reside in the source tree.

There has been a fair amount of discussion regarding this problem of the Eclipse CDT4 Generator:

  1. Trouble with CMake + Eclipse + SVN/CVS
  2. *Updated* Eclipse CDT4 CMake Generator - Pre-Alpha version
  3. Partially Shared project using Eclipse CDT (cdt-dev ML)



CMake: [Welcome | Site Map]