Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

cmake and eclipse: default include paths?

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

like image 567
Anton Kazennikov Avatar asked Oct 14 '09 06:10

Anton Kazennikov


People also ask

Could not find include file in include paths eclipse?

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.

Does eclipse work with CMake?

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").

What is built in include path?

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.

How do I run CMake project in eclipse?

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.


2 Answers

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".

like image 64
fnieto - Fernando Nieto Avatar answered Oct 01 '22 09:10

fnieto - Fernando Nieto


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.

like image 29
Jo Inge Buskenes Avatar answered Oct 01 '22 10:10

Jo Inge Buskenes