Skip to content

Commit d75ef41

Browse files
committed
Simplify usage and make configuration extendable
1 parent 1e76ee7 commit d75ef41

File tree

10 files changed

+342
-578
lines changed

10 files changed

+342
-578
lines changed

cmake/Zend/cmake/GenerateGrammar.cmake

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ php_bison(
1717
zend_ini_parser.y
1818
${CMAKE_CURRENT_SOURCE_DIR}/zend_ini_parser.c
1919
HEADER
20+
ADD_DEFAULT_OPTIONS
2021
${verbose}
2122
CODEGEN
2223
)
@@ -26,6 +27,7 @@ php_bison(
2627
zend_language_parser.y
2728
${CMAKE_CURRENT_SOURCE_DIR}/zend_language_parser.c
2829
HEADER
30+
ADD_DEFAULT_OPTIONS
2931
${verbose}
3032
CODEGEN
3133
)
@@ -103,7 +105,7 @@ php_re2c(
103105
zend_ini_scanner.l
104106
${CMAKE_CURRENT_SOURCE_DIR}/zend_ini_scanner.c
105107
HEADER ${CMAKE_CURRENT_SOURCE_DIR}/zend_ini_scanner_defs.h
106-
APPEND
108+
ADD_DEFAULT_OPTIONS
107109
OPTIONS
108110
--bit-vectors
109111
--case-inverted
@@ -118,7 +120,7 @@ php_re2c(
118120
zend_language_scanner.l
119121
${CMAKE_CURRENT_SOURCE_DIR}/zend_language_scanner.c
120122
HEADER ${CMAKE_CURRENT_SOURCE_DIR}/zend_language_scanner_defs.h
121-
APPEND
123+
ADD_DEFAULT_OPTIONS
122124
OPTIONS
123125
--bit-vectors
124126
--case-inverted

cmake/cmake/modules/FindBISON.cmake

Lines changed: 4 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,11 @@
33
44
Find `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.
77
See: https://cmake.org/cmake/help/latest/module/FindBISON.html
88
#]=============================================================================]
99

1010
include(FeatureSummary)
11-
include(FindPackageHandleStandardArgs)
12-
13-
################################################################################
14-
# Configuration.
15-
################################################################################
1611

1712
set_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

Comments
 (0)