[cmake-developers] PATCH Offending entry when using FindBISON.cmake with bison++

Ondrej Balaz ondra at blami.net
Fri Nov 11 14:13:55 EST 2011


Hi,
I've just found out that use of FindBISON.cmake shipped with CMake 2.8
on system where bison++ is default bison executable (e.g. Debian Linux)
will result in corrupted CMakeCache.txt file and parse error due to
"Offending entry"

As FindBISON.cmake logic used to obtain installed bison executable
version is tailored to match only the message used in GNU Bison it fails
on absolutely different Bison++ version message and whole version
message including \n characters is stored into BISON_VERSION which is
then dumped into CMakeCache.txt, so everything after first \n character
makes "Offending entry".

Attached patch fixes this by adding regexp for bison++.

Regards,
Ondrej

--- FindBISON.cmake.orig	2011-07-08 14:21:44.000000000 +0200
+++ FindBISON.cmake	2011-11-11 19:37:12.544611500 +0100
@@ -67,8 +67,17 @@
   IF(NOT ${BISON_version_result} EQUAL 0)
     MESSAGE(SEND_ERROR "Command \"${BISON_EXECUTABLE} --version\" failed with output:\n${BISON_version_error}")
   ELSE()
-    STRING(REGEX REPLACE "^bison \\(GNU Bison\\) ([^\n]+)\n.*" "\\1"
-      BISON_VERSION "${BISON_version_output}")
+    # Bison++
+    IF(${BISON_version_output} MATCHES "^bison\\+\\+")
+      STRING(REGEX REPLACE "^bison\\+\\+ Version ([^,]+).*" "\\1"
+        BISON_VERSION "${BISON_version_output}")
+    # GNU Bison
+    ELSEIF(${BISON_version_output} MATCHES "^bison[^+]")
+      STRING(REGEX REPLACE "^bison \\(GNU Bison\\) ([^\n]+)\n.*" "\\1"
+        BISON_VERSION "${BISON_version_output}")
+    ELSE()
+      SET(BISON_VERSION "unknown")
+    ENDIF()
   ENDIF()
 
   # internal macro

-- 
Ondrej Balaz





More information about the cmake-developers mailing list