From 2cf5df3e58842a3e0fdeb919414f32e53dbe0aec Mon Sep 17 00:00:00 2001 From: Rolf Eike Beer Date: Fri, 20 Jan 2012 17:44:00 +0100 Subject: [PATCH 1/2] FindFLEX: fix version parsing for old flex versions --- Modules/FindFLEX.cmake | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Modules/FindFLEX.cmake b/Modules/FindFLEX.cmake index 6a70b4030..6309bc923 100644 --- a/Modules/FindFLEX.cmake +++ b/Modules/FindFLEX.cmake @@ -91,8 +91,12 @@ IF(FLEX_EXECUTABLE) MESSAGE("Command \"${FLEX_EXECUTABLE} --version\" failed with output:\n${FLEX_version_output}\n${FLEX_version_error}\nFLEX_VERSION will not be available") ENDIF() ELSE() - STRING(REGEX REPLACE "^flex (.*)$" "\\1" + # older versions of flex printed "/full/path/to/executable version X.Y" + # newer versions use "basename(executable) X.Y" + GET_FILENAME_COMPONENT(FLEX_EXE_NAME "${FLEX_EXECUTABLE}" NAME) + STRING(REGEX REPLACE "^.*${FLEX_EXE_NAME} (version )?([0-9]+[^ ]*)$" "\\2" FLEX_VERSION "${FLEX_version_output}") + UNSET(FLEX_EXE_NAME) ENDIF() #============================================================ From 0b2e81c63ce6ca9dcf9d775d3f5cd22749e8c134 Mon Sep 17 00:00:00 2001 From: Rolf Eike Beer Date: Mon, 23 Jan 2012 23:40:17 +0100 Subject: [PATCH 2/2] FindFLEX: fix version parsing when the executable is quoted --- Modules/FindFLEX.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Modules/FindFLEX.cmake b/Modules/FindFLEX.cmake index 6309bc923..586f77a6e 100644 --- a/Modules/FindFLEX.cmake +++ b/Modules/FindFLEX.cmake @@ -94,7 +94,7 @@ IF(FLEX_EXECUTABLE) # older versions of flex printed "/full/path/to/executable version X.Y" # newer versions use "basename(executable) X.Y" GET_FILENAME_COMPONENT(FLEX_EXE_NAME "${FLEX_EXECUTABLE}" NAME) - STRING(REGEX REPLACE "^.*${FLEX_EXE_NAME} (version )?([0-9]+[^ ]*)$" "\\2" + STRING(REGEX REPLACE "^.*${FLEX_EXE_NAME}\"? (version )?([0-9]+[^ ]*)$" "\\2" FLEX_VERSION "${FLEX_version_output}") UNSET(FLEX_EXE_NAME) ENDIF()