Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CMake Generated Eclipse CDT Project Does Not Have System Includes

My problem is similar with this: http://www.eclipse.org/forums/index.php/m/649323/

I created a cmake project, and used

cmake .. -G "Eclipse CDT4 - Unix Makefiles"

to create a Eclipse CDT4 project.

But in the CDT IDE, the standard include paths are not listed, and all STL or system build-in header files include directives are marked as "cannot be resolved", so the "Open Declaration" or other a lot of operation cannot be done.

However, I could compile it without any problems.

My co-worker also has a cmake project, but it's very complicated. The CDT project generated from his cmake project DOES have the system includes. But his cmake is way too complicated, and he told me that he didn't do anything special to include the system paths.

Can anyone help me out? Thanks.

My Main CMakeLists.txt:

CMake_Minimum_Required(VERSION 2.8)

# Some settings
Set(CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS ON)
CMake_Policy(SET CMP0015 NEW)

#Include(CMakeProcedures.cmake)
#CheckEnvironment()

# Set the compiler and its version if needed

# Create the project
Project(MyProjectName CXX)

# Set the compiler
Set(CMAKE_CXX_COMPILER /usr/bin/g++)

# Detect whether we are in-source
If (CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR)
    Message(FATAL_ERROR "In-source building is not allowed! Please create a 'build' folder and then do 'cd build; cmake ..'")
EndIf()

# Set the output dirs
Set(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin)
Set(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/lib)

# Add source subdirs to the build
Add_Subdirectory(src)
# Add_Subdirectory(test EXCLUDE_FROM_ALL)

Peter

One workaround is to manually add these to the CDT IDE:

/usr/include/c++/4.5
/usr/include/c++/4.5/backward
/usr/include/c++/4.5/i686-linux-gnu
/usr/include/i386-linux-gnu
/usr/lib/i386-linux-gnu/gcc/i686-linux-gnu/4.5.2/include
/usr/lib/i386-linux-gnu/gcc/i686-linux-gnu/4.5.2/include-fixed
/usr/local/include

But it's not the solution.

like image 907
Peter Lee Avatar asked Jun 23 '11 00:06

Peter Lee


1 Answers

I finally figured out that this line is causing the problem:

Project(MyProjectName CXX)

If we remove the optional paramter CXX, life is good.

Can anyone tell me why?

Peter

like image 174
Peter Lee Avatar answered Nov 15 '22 11:11

Peter Lee