How to Import a CMake project into Eclipse CDT?

How to Import a CMake project into Eclipse CDT?

For example, the current CMake project source directory is ./src.

mkdir ./cdt && cd ./cdt && 
cmake -G "Eclipse CDT4 - Unix Makefiles" ../src

cmake will generate a Eclipse project in ./cdt and you can open it in Eclipse.

Eric Ma

Eric is a systems guy. Eric is interested in building high-performance and scalable distributed systems and related technologies. The views or opinions expressed here are solely Eric's own and do not necessarily represent those of any third parties.

One comment:

  1. The cmake generator for Eclipse is sadly not really maintained, and it in pretty poor shape. The projects generated are for some ancient version of Eclipse.
    However, it does remain the only sensible way to import cmake projects into Eclipse in my opinion.
    For a commercial development, I have the following requirements (as an ABSOLUTE MINIMUM):
    – Must be able to import and already configured build tree.
    – Must be able to have build tree outside source tree.
    – Must index only the source files (or at least projects) that are included in the generated build system. To index my whole source tree otherwise would take over a week and a half.
    – Must get indexer include paths and preprocessor defines correct
    The linked project approach of the cmake eclipse generator seems to work best.
    Only projects that are part of the build system get included under the subprojects & targets.
    I can then have a script that post-processes the generated Eclipse project to remove [Sources] from the indexer path.
    This has to be hacked in, by starting a process that watches for the termination of cmake itself, since cmake [deliberately] doesn’t support post generate tasks.
    The Eclipse indexer, while very good when it works, is EXTREMELY buggy, and prone to randomly locking up, requiring regular restarts of Eclipse. In fact, some releases (eg. Photon) have such frequent lockups, that they are totally unusable.

Leave a Reply

Your email address will not be published. Required fields are marked *