From 4371147ef4549feeb88c080cf5ba99281cbb7df3 Mon Sep 17 00:00:00 2001 From: Alex Neundorf Date: Sun, 3 Apr 2011 18:00:35 +0200 Subject: [PATCH 1/2] Fix parsing include dirs and builtin macros for CXX-only projects Alex --- Modules/CMakeFindEclipseCDT4.cmake | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Modules/CMakeFindEclipseCDT4.cmake b/Modules/CMakeFindEclipseCDT4.cmake index fbcdc98416..4c58f56f32 100644 --- a/Modules/CMakeFindEclipseCDT4.cmake +++ b/Modules/CMakeFindEclipseCDT4.cmake @@ -32,7 +32,13 @@ MACRO(_DETERMINE_GCC_SYSTEM_INCLUDE_DIRS _lang _resultIncludeDirs _resultDefines SET(${_resultIncludeDirs}) SET(_gccOutput) FILE(WRITE "${CMAKE_BINARY_DIR}/CMakeFiles/dummy" "\n" ) - EXECUTE_PROCESS(COMMAND ${CMAKE_C_COMPILER} -v -E -x ${_lang} -dD dummy + + IF (${_lang} STREQUAL "c++") + SET(_compilerExecutable "${CMAKE_CXX_COMPILER}") + ELSE (${_lang} STREQUAL "c++") + SET(_compilerExecutable "${CMAKE_C_COMPILER}") + ENDIF (${_lang} STREQUAL "c++") + EXECUTE_PROCESS(COMMAND ${_compilerExecutable} -v -E -x ${_lang} -dD dummy WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/CMakeFiles ERROR_VARIABLE _gccOutput OUTPUT_VARIABLE _gccStdout ) From 6a38cab2de2a529779c18e0c3872112e3851665b Mon Sep 17 00:00:00 2001 From: Alex Neundorf Date: Sun, 3 Apr 2011 18:07:27 +0200 Subject: [PATCH 2/2] Don't skip the last builtin include dir for the Eclipse project file The regex was slightly wrong, it excluded the last line, so e.g. /usr/include/ didn't end up in the .cproject file. Thanks to Shash Chatterjee for the patch. Alex --- Modules/CMakeFindEclipseCDT4.cmake | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Modules/CMakeFindEclipseCDT4.cmake b/Modules/CMakeFindEclipseCDT4.cmake index 4c58f56f32..a756e6454f 100644 --- a/Modules/CMakeFindEclipseCDT4.cmake +++ b/Modules/CMakeFindEclipseCDT4.cmake @@ -45,7 +45,7 @@ MACRO(_DETERMINE_GCC_SYSTEM_INCLUDE_DIRS _lang _resultIncludeDirs _resultDefines FILE(REMOVE "${CMAKE_BINARY_DIR}/CMakeFiles/dummy") # First find the system include dirs: - IF( "${_gccOutput}" MATCHES "> search starts here[^\n]+\n *(.+) *\n *End of (search) list" ) + IF( "${_gccOutput}" MATCHES "> search starts here[^\n]+\n *(.+ *\n) *End of (search) list" ) # split the output into lines and then remove leading and trailing spaces from each of them: STRING(REGEX MATCHALL "[^\n]+\n" _includeLines "${CMAKE_MATCH_1}") @@ -54,7 +54,7 @@ MACRO(_DETERMINE_GCC_SYSTEM_INCLUDE_DIRS _lang _resultIncludeDirs _resultDefines LIST(APPEND ${_resultIncludeDirs} "${_includePath}") ENDFOREACH(nextLine) - ENDIF( "${_gccOutput}" MATCHES "> search starts here[^\n]+\n *(.+) *\n *End of (search) list" ) + ENDIF( "${_gccOutput}" MATCHES "> search starts here[^\n]+\n *(.+ *\n) *End of (search) list" ) # now find the builtin macros: