1 # This file is included in CMakeSystemSpecificInformation.cmake if
2 # the Eclipse CDT4 extra generator has been selected.
4 FIND_PROGRAM(CMAKE_ECLIPSE_EXECUTABLE NAMES eclipse DOC "The Eclipse executable")
7 # The Eclipse generator needs to know the standard include path
8 # so that Eclipse ca find the headers at runtime and parsing etc. works better
9 # This is done here by actually running gcc with the options so it prints its
10 # system include directories, which are parsed then and stored in the cache.
11 MACRO(_DETERMINE_GCC_SYSTEM_INCLUDE_DIRS _lang _result)
14 FILE(WRITE "${CMAKE_BINARY_DIR}/CMakeFiles/dummy" "\n" )
15 EXECUTE_PROCESS(COMMAND ${CMAKE_C_COMPILER} -v -E -x ${_lang} dummy
16 WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/CMakeFiles
17 ERROR_VARIABLE _gccOutput
19 FILE(REMOVE "${CMAKE_BINARY_DIR}/CMakeFiles/dummy")
21 IF( "${_gccOutput}" MATCHES "> search starts here[^\n]+\n *(.+) *\n *End of (search) list" )
22 SET(${_result} ${CMAKE_MATCH_1})
23 STRING(REPLACE "\n" " " ${_result} "${${_result}}")
24 SEPARATE_ARGUMENTS(${_result})
25 ENDIF( "${_gccOutput}" MATCHES "> search starts here[^\n]+\n *(.+) *\n *End of (search) list" )
26 ENDMACRO(_DETERMINE_GCC_SYSTEM_INCLUDE_DIRS _lang)
28 # Save the current LC_ALL, LC_MESSAGES, and LANG environment variables and set them
29 # to "C" that way GCC's "search starts here" text is in English and we can grok it.
30 SET(_orig_lc_all $ENV{LC_ALL})
31 SET(_orig_lc_messages $ENV{LC_MESSAGES})
32 SET(_orig_lang $ENV{LANG})
37 SET(ENV{LC_MESSAGES} C)
38 ENDIF(_orig_lc_messages)
44 IF ("${CMAKE_C_COMPILER_ID}" MATCHES GNU AND NOT CMAKE_ECLIPSE_C_SYSTEM_INCLUDE_DIRS)
45 _DETERMINE_GCC_SYSTEM_INCLUDE_DIRS(c _dirs)
46 SET(CMAKE_ECLIPSE_C_SYSTEM_INCLUDE_DIRS "${_dirs}" CACHE INTERNAL "C compiler system include directories")
47 ENDIF ("${CMAKE_C_COMPILER_ID}" MATCHES GNU AND NOT CMAKE_ECLIPSE_C_SYSTEM_INCLUDE_DIRS)
49 # And now the same for C++
50 IF ("${CMAKE_CXX_COMPILER_ID}" MATCHES GNU AND NOT CMAKE_ECLIPSE_CXX_SYSTEM_INCLUDE_DIRS)
51 _DETERMINE_GCC_SYSTEM_INCLUDE_DIRS(c++ _dirs)
52 SET(CMAKE_ECLIPSE_CXX_SYSTEM_INCLUDE_DIRS "${_dirs}" CACHE INTERNAL "CXX compiler system include directories")
53 ENDIF ("${CMAKE_CXX_COMPILER_ID}" MATCHES GNU AND NOT CMAKE_ECLIPSE_CXX_SYSTEM_INCLUDE_DIRS)
55 # Restore original LC_ALL, LC_MESSAGES, and LANG
57 SET(ENV{LC_ALL} ${_orig_lc_all})
60 SET(ENV{LC_MESSAGES} ${_orig_lc_messages})
61 ENDIF(_orig_lc_messages)
63 SET(ENV{LANG} ${_orig_lang})