2011-06-23 49 views
5

我的问题是与此类似:http://www.eclipse.org/forums/index.php/m/649323/CMake的生成Eclipse CDT的项目没有系统包括

我创建了一个cmake的项目,并用

​​

创建的Eclipse项目CDT4。

但是在CDT IDE中,标准include路径没有列出,而且所有STL或系统内置头文件包含的指令都被标记为“无法解析”,所以“Open Declaration”或其他很多操作无法完成。

但是,我可以编译它没有任何问题。

我的同事也有一个cmake项目,但它非常复杂。由他的cmake项目DOES生成的CDT项目包含该系统。但他的cmake太复杂了,他告诉我他没有做任何特别的事情来包含系统路径。

谁能帮助我吗?谢谢。

我主要的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) 

彼得

一种解决方法是手动添加这些到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 

但它不是解决办法。

+0

http://stackoverflow.com/questions/1564668/cmake-and-eclipse-default-include-paths这只是一种变通方法。不是解决方案 –

+0

要设置系统自动包括你可以看看这里:http://stackoverflow.com/questions/26444845/cmake-generated-c-project-with-system-and-standard-includes – Tik0

回答

1

我终于想通了,这条线是造成问题:

Project(MyProjectName CXX) 

如果我们卸下可选放慢参数CXX,生活是美好的。

有谁能告诉我为什么?

彼得

+0

我有完全相同的问题,但对我来说,它并没有帮助删除CXX。 Eclipse仍然无法找到std :: string或解析#include 。奇! – joscarsson