33
44Find `bison`, the general-purpose parser generator, command-line executable.
55
6- This module extends the upstream CMake `FindBISON` module.
6+ This module extends the CMake `FindBISON` module.
77See: https://cmake.org/cmake/help/latest/module/FindBISON.html
88#]=============================================================================]
99
1010include (FeatureSummary)
11- include (FindPackageHandleStandardArgs)
12-
13- ################################################################################
14- # Configuration.
15- ################################################################################
1611
1712set_package_properties(
1813 BISON
@@ -21,75 +16,6 @@ set_package_properties(
2116 DESCRIPTION "General-purpose parser generator"
2217)
2318
24- # Find package with upstream CMake module; override CMAKE_MODULE_PATH to prevent
25- # the maximum nesting/recursion depth error on some systems, like macOS.
26- #set(_php_cmake_module_path ${CMAKE_MODULE_PATH})
27- #unset(CMAKE_MODULE_PATH)
28- #include(FindBISON)
29- #set(CMAKE_MODULE_PATH ${_php_cmake_module_path})
30- #unset(_php_cmake_module_path)
31-
32- ################################################################################
33- # Find the executable.
34- ################################################################################
35-
36- set (_reason "" )
37-
38- find_program (
39- BISON_EXECUTABLE
40- NAMES bison win-bison win_bison
41- DOC "The path to the bison executable"
42- )
43- mark_as_advanced (BISON_EXECUTABLE)
44-
45- if (NOT BISON_EXECUTABLE)
46- string (APPEND _reason "The bison command-line executable not found. " )
47- endif ()
48-
49- ################################################################################
50- # Check version.
51- ################################################################################
52-
53- block(PROPAGATE BISON_VERSION _reason)
54- if (CMAKE_VERSION VERSION_GREATER_EQUAL 3.29)
55- set (test IS_EXECUTABLE)
56- else ()
57- set (test EXISTS )
58- endif ()
59-
60- if (${test} ${BISON_EXECUTABLE} )
61- execute_process (
62- COMMAND ${BISON_EXECUTABLE} --version
63- OUTPUT_VARIABLE version
64- RESULT_VARIABLE result
65- ERROR_QUIET
66- OUTPUT_STRIP_TRAILING_WHITESPACE
67- )
68-
69- if (NOT result EQUAL 0)
70- string (APPEND _reason "Command ${BISON_EXECUTABLE} --version failed. " )
71- elseif (version )
72- # Bison++
73- if (version MATCHES "^bison\\ +\\ + Version ([^,]+)" )
74- set (BISON_VERSION "${CMAKE_MATCH_1} " )
75- # GNU Bison
76- elseif (version MATCHES "^bison \\ (GNU Bison\\ ) ([^\n ]+)\n " )
77- set (BISON_VERSION "${CMAKE_MATCH_1} " )
78- elseif (version MATCHES "^GNU Bison (version )?([^\n ]+)" )
79- set (BISON_VERSION "${CMAKE_MATCH_2} " )
80- else ()
81- string (APPEND _reason "Invalid version format. " )
82- endif ()
83- endif ()
84- endif ()
85- endblock()
86-
87- find_package_handle_standard_args(
88- BISON
89- REQUIRED_VARS BISON_EXECUTABLE BISON_VERSION
90- VERSION_VAR BISON_VERSION
91- HANDLE_VERSION_RANGE
92- REASON_FAILURE_MESSAGE "${_reason} "
93- )
94-
95- unset (_reason)
19+ # Include CMake find module. Absolute path prevents the maximum
20+ # nesting/recursion depth error on some systems, like macOS.
21+ include (${CMAKE_ROOT} /Modules/FindBISON.cmake)
0 commit comments