Importing CMake Projects into Eclipse CDT
Eclipse CDT has evolved to handle CMake projects effectively. The key is understanding which approach fits your workflow — native CMake integration (recommended for 2023+ versions) or generating build files.
Native CMake Integration (Recommended)
Eclipse CDT 2023 and later include robust native CMake support. This is the simplest approach for new projects or when you control the IDE setup.
Setting up a new CMake project in CDT:
- File → New → C/C++ Project
- Select “C++ Managed Build”
- In the wizard, choose CMake as your build system
- Point the source directory to your CMake project root
- CDT will automatically configure indexing and build paths
CDT handles the build directory creation and CMake invocation internally. No manual cmake generation step needed.
Importing Existing CMake Projects
For projects already using CMake, the process varies by project structure:
Standard out-of-source build setup:
mkdir build
cd build
cmake ..
Then in Eclipse:
- File → Open Projects from File System
- Select your project root directory
- Eclipse will detect the CMakeLists.txt and offer to configure it
- Accept the configuration — CDT will set up build directory handling
If you have a pre-generated build directory:
You can skip the cmake invocation and import directly:
- File → New → Makefile Project with Existing Code
- Point to your source root (where CMakeLists.txt lives)
- Set the build directory in Project → Properties → C/C++ Build → Build directory
- Configure the build command (see below)
Configuring the Build Command
Navigate to Project → Properties → C/C++ Build and verify these settings:
- Builder: Set to “External builder” or “CDT Internal Builder”
- Build directory:
${ProjDirPath}/build(your actual build folder path) - Build command: Use one of:
make(if you generated with Makefiles)cmake --build .(generator-agnostic, works with any generator)ninja(if you prefer Ninja generator)
For consistency across IDEs and machines, prefer cmake --build . over specific build tools.
Generator Selection
The legacy “Eclipse CDT4 – Unix Makefiles” generator still works but is outdated. For modern projects:
Using Ninja (faster, more reliable):
mkdir build
cd build
cmake -G Ninja ..
ninja
Then configure Eclipse’s build command to ninja instead of make.
Using the default generator:
mkdir build
cd build
cmake ..
Works on Linux/macOS (Unix Makefiles) and Windows (Visual Studio generators). CDT adapts to whatever build files CMake creates.
CMake Presets (3.21+)
For complex projects with multiple build configurations, use CMakePresets.json:
{
"version": 3,
"configurePresets": [
{
"name": "default",
"generator": "Ninja",
"binaryDir": "${sourceDir}/build",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug"
}
}
],
"buildPresets": [
{
"name": "default",
"configurePreset": "default"
}
]
}
Configure Eclipse to use:
- Build command:
cmake --build --preset default - Configure command:
cmake --preset default
This ensures consistent builds whether you’re using Eclipse, command line, or CI/CD.
Resolving Indexer and Include Path Issues
Indexer not finding includes:
The CDT indexer needs the build directory to exist before it can parse generated headers.
- Run a build from Eclipse (Project → Build Project or Ctrl+B)
- Refresh the project (F5 or right-click → Refresh)
- If still unresolved, go to Project → Properties → C/C++ General → Paths and Symbols
- Ensure “CDT GCC Built-in Compiler Settings” or equivalent is enabled
For generated code not being indexed:
Explicitly add generated header directories:
- Project → Properties → C/C++ General → Paths and Symbols → Includes
- Add the path to your generated headers (typically
${ProjDirPath}/build/generated)
Best Practices
- Always use out-of-source builds: Keep source and build directories separate. Never run cmake in the source root.
- Use relative paths: In Project Properties, prefer
${ProjDirPath}/buildover absolute paths for portability. - Commit CMakePresets.json: Version control your presets so team members get consistent configurations.
- Test builds from command line first: Before importing into Eclipse, verify
cmakeand your build command work from the terminal. This isolates configuration issues from IDE problems.

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.