Merge topic 'FixEclipseIncludePathParsingWithSpaces'
9fd4e18
Fix parsing of builtin macros so Eclipse handles them properly (#10868)
This commit is contained in:
commit
612c0b68a0
|
@ -47,16 +47,21 @@ MACRO(_DETERMINE_GCC_SYSTEM_INCLUDE_DIRS _lang _resultIncludeDirs _resultDefines
|
||||||
|
|
||||||
# now find the builtin macros:
|
# now find the builtin macros:
|
||||||
STRING(REGEX MATCHALL "#define[^\n]+\n" _defineLines "${_gccStdout}")
|
STRING(REGEX MATCHALL "#define[^\n]+\n" _defineLines "${_gccStdout}")
|
||||||
|
# A few example lines which the regexp below has to match properly:
|
||||||
|
# #define MAX(a,b) ((a) > (b) ? (a) : (b))
|
||||||
|
# #define __fastcall __attribute__((__fastcall__))
|
||||||
|
# #define FOO (23)
|
||||||
|
# #define __UINTMAX_TYPE__ long long unsigned int
|
||||||
|
# #define __UINTMAX_TYPE__ long long unsigned int
|
||||||
|
# #define __i386__ 1
|
||||||
|
|
||||||
FOREACH(nextLine ${_defineLines})
|
FOREACH(nextLine ${_defineLines})
|
||||||
STRING(REGEX REPLACE "#define " "" _defineRemoved "${nextLine}")
|
STRING(REGEX MATCH "^#define +([A-Za-z_][A-Za-z0-9_]*)(\\([^\\)]+\\))? +(.+) *$" _dummy "${nextLine}")
|
||||||
# not sure why this longer regexp was in the patch, the shorter one in the line below seems to work just fine:
|
SET(_name "${CMAKE_MATCH_1}${CMAKE_MATCH_2}")
|
||||||
# STRING(REGEX MATCH "[A-Za-z_][A-Za-z0-9_]*|[A-Za-z_][A-Za-z0-9_]*\\([A-Za-z0-9_, ]*\\)" _name "${_defineRemoved}")
|
STRING(STRIP "${CMAKE_MATCH_3}" _value)
|
||||||
STRING(REGEX MATCH "[A-Za-z_][A-Za-z0-9_]*" _name "${_defineRemoved}")
|
#MESSAGE(STATUS "m1: -${CMAKE_MATCH_1}- m2: -${CMAKE_MATCH_2}- m3: -${CMAKE_MATCH_3}-")
|
||||||
LIST(APPEND ${_resultDefines} "${_name}")
|
|
||||||
|
|
||||||
STRING(REPLACE ${_name} "" _nameRemoved "${_defineRemoved}")
|
LIST(APPEND ${_resultDefines} "${_name}")
|
||||||
STRING(STRIP "${_nameRemoved}" _value)
|
|
||||||
IF(_value)
|
IF(_value)
|
||||||
LIST(APPEND ${_resultDefines} "${_value}")
|
LIST(APPEND ${_resultDefines} "${_value}")
|
||||||
ELSE()
|
ELSE()
|
||||||
|
|
Loading…
Reference in New Issue