I have a project that builds with CMake system, and I like to import it in Eclipse. However, when I generate eclipse project files with 'cmake -G "Eclipse CDT4 - Unix Makefiles"' there are no default include paths in Eclipse project(such as /usr/include' or the gcc path for standard headers).
How to fix that in most right way?
System: linux gcc 4.3.3 cmake 2.6.4 eclipse 3.5.1
Simply right click on the file > go to Resource Configurations > Reset to Default... Your header files will be found now, provided that you've written the correct include paths in your project settings.
Starting with version 2.6. 0 CMake includes a generator for Eclipse CDT 4.0 or newer. It works together with the Makefile generators (i.e. "Unix Makefiles", "MinGW Makefiles", "MSYS Makefiles", and maybe "NMake Makefiles").
Built-in Settings. CDT will try to detect built-in compiler symbols and include paths running the compiler with special options and parse the output of this special run. Most compilers provide such an option to print built-in include paths and symbols.
In Eclipse, select File > New > C Project. Enter a project name and choose the root of your source tree as the project location. Click Finish, and you have a CMake project in your workspace.
You have to go to the project properties (right button over the project), "C/C++ include paths and symbols" and add them here as "external include paths".
In your CMakeLists.txt try adding the following two lines:
find_path(STDIO_INCLUDE_PATH stdio.h)
include_directories("${STDIO_INCLUDE_PATH}/dummy/../")
The first line looks up the path for stdio.h
, which is located in /usr/include
on my system. The second adds this folder to the CMake include path. The /dummy/../
part was added to trick CMake into adding the folder (it wouldn't otherwise), and will eventually get stripped off.
This works for me with CMake 2.8.8 and Eclipse 3.7.2.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With