我的问题是与此类似: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
但它不是解决办法。
http://stackoverflow.com/questions/1564668/cmake-and-eclipse-default-include-paths这只是一种变通方法。不是解决方案 –
要设置系统自动包括你可以看看这里:http://stackoverflow.com/questions/26444845/cmake-generated-c-project-with-system-and-standard-includes – Tik0