Skip to content

Commit e592cd7

Browse files
committed
cmake: Fix flex version check for overriding the register keyword
In doxygen#11113 a check was added to override the "register" keyword for older versions of flex. The check was added before the find_package() call which resulted in the workaround being active for any version of flex. This breaks the build with recent mingw-w64 which uses "register" in its headers. Fix by moving the version check after the find_package() call.
1 parent ee1bb44 commit e592cd7

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

CMakeLists.txt

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -107,13 +107,6 @@ endif()
107107
# produce compile_commands.json
108108
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
109109

110-
if (FLEX_VERSION VERSION_LESS 2.6.0)
111-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Dregister=")
112-
if (MSVC)
113-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_ALLOW_KEYWORD_MACROS=")
114-
endif()
115-
endif()
116-
117110
if (CMAKE_SYSTEM MATCHES "Darwin")
118111
set(CMAKE_OSX_DEPLOYMENT_TARGET "${MACOS_VERSION_MIN}" CACHE STRING "Minimum OS X deployment version" FORCE)
119112
set(CMAKE_CXX_FLAGS "-Wno-deprecated-register -mmacosx-version-min=${MACOS_VERSION_MIN} ${CMAKE_CXX_FLAGS}")
@@ -208,6 +201,12 @@ find_package(FLEX REQUIRED)
208201
if (FLEX_VERSION VERSION_LESS 2.5.37)
209202
message(SEND_ERROR "Doxygen requires at least flex version 2.5.37 (installed: ${FLEX_VERSION})")
210203
endif()
204+
if (FLEX_VERSION VERSION_LESS 2.6.0)
205+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Dregister=")
206+
if (MSVC)
207+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_ALLOW_KEYWORD_MACROS=")
208+
endif()
209+
endif()
211210
find_package(BISON REQUIRED)
212211
if (BISON_VERSION VERSION_LESS 2.7)
213212
message(SEND_ERROR "Doxygen requires at least bison version 2.7 (installed: ${BISON_VERSION})")

0 commit comments

Comments
 (0)