@@ -25,16 +25,15 @@ php_bison(
25
25
)
26
26
```
27
27
28
- This creates a CMake target `<name>` and adds a command that generates parser
29
- file `<output>` from the given `<input>` template file using the `bison` parser
28
+ This creates a target `<name>` and adds a command that generates parser file
29
+ `<output>` from the given `<input>` template file using the Bison parser
30
30
generator. Relative source file path `<input>` is interpreted as being relative
31
31
to the current source directory . Relative `<output>` file path is interpreted as
32
32
being relative to the current binary directory . If generated files are already
33
33
available (for example, shipped with the released archive ), and Bison is not
34
- found, it will create a custom target but skip the `bison` command -line
35
- execution.
34
+ found, it will create a target but skip the `bison` command -line execution.
36
35
37
- When used in CMake command -line script mode (see `CMAKE_SCRIPT_MODE_FILE` ) it
36
+ When used in command -line script mode (see `CMAKE_SCRIPT_MODE_FILE` ) it
38
37
generates the parser right away without creating a target .
39
38
40
39
#### Options
@@ -57,38 +56,36 @@ generates the parser right away without creating a target.
57
56
* `DEPENDS <depends>...` - Optional list of dependent files to regenerate the
58
57
output file .
59
58
60
- * `VERBOSE` - This adds the `--verbose` (`-v` ) command -line option to and will
61
- create extra output file `<parser-output-filename>.output` containing verbose
62
- descriptions of the grammar and parser. File will be by default created in the
63
- current binary directory .
59
+ * `VERBOSE` - Adds the `--verbose` (`-v` ) command -line option and creates extra
60
+ output file `<parser-output-filename>.output` in the current binary directory .
61
+ Report contains verbose grammar and parser descriptions.
64
62
65
- * `REPORT_FILE <file>` - This adds the `--report-file=<file>` command -line
66
- option and will create verbose information report in the specified `<file>`.
67
- This option must be used together with the `VERBOSE` option . Relative file
68
- path is interpreted as being relative to the current binary directory .
63
+ * `REPORT_FILE <file>` - Adds the `--report-file=<file>` command -line option and
64
+ creates verbose information report in the specified `<file>`. This option must
65
+ be used with the `VERBOSE` option . Relative file path is interpreted as being
66
+ relative to the current binary directory .
69
67
70
- * `CODEGEN` - This adds the `CODEGEN` option to the `add_custom_command ()` call.
71
- Works as of CMake 3.31 when policy `CMP0171` is set to `NEW`, which provides a
72
- global CMake `codegen` target for convenience to call only the
73
- code-generation-related targets and skip the majority of the build :
68
+ * `CODEGEN` - Adds the `CODEGEN` option to the `add_custom_command ()` call. This
69
+ option is available starting with CMake 3.31 when the policy `CMP0171` is set
70
+ to `NEW`. It provides a `codegen` target for convenience, allowing to run only
71
+ code-generation-related targets while skipping the majority of the build :
74
72
75
73
```sh
76
74
cmake --build <dir> --target codegen
77
75
```
78
76
79
- * `WORKING_DIRECTORY <working- directory>` - The path where the `bison ` is
80
- executed. Relative `<working- directory>` path is interpreted as being relative
81
- to the current binary directory . If not set , `bison` is by default executed in
82
- the `PHP_SOURCE_DIR` when building the php-src repository. Otherwise it is
77
+ * `WORKING_DIRECTORY <directory>` - The path where the `re2c ` is executed.
78
+ Relative `<directory>` path is interpreted as being relative to the current
79
+ binary directory . If not set , `bison` is by default executed in the
80
+ `PHP_SOURCE_DIR` when building the php-src repository. Otherwise it is
83
81
executed in the directory of the `<output>` file . If variable
84
82
`PHP_BISON_WORKING_DIRECTORY` is set before calling the `php_bison ()` without
85
83
this option , it will set the default working directory to that instead.
86
84
87
85
* `ABSOLUTE_PATHS` - Whether to use absolute file paths in the `bison`
88
- command -line invocations. By default all file paths are added to `bison` as
89
- relative to the working directory . Using relative paths is convenient when
90
- line directives (` #line ...`) are generated in the output files to not show
91
- the full path on the disk, if file is committed to Git repository.
86
+ command -line invocations. By default all file paths are added as relative to
87
+ the working directory . Using relative paths is convenient when line directives
88
+ (` #line ...`) are generated in the output files committed to Git repository.
92
89
93
90
When this option is enabled:
94
91
@@ -119,7 +116,7 @@ These variables can be set before using this module to configure behavior:
119
116
120
117
* `PHP_BISON_WORKING_DIRECTORY` - Set the default global working directory
121
118
for all `php_bison ()` invocations in the directory scope where the
122
- `WORKING_DIRECTORY <dir >` option is not set .
119
+ `WORKING_DIRECTORY <directory >` option is not set .
123
120
124
121
## Examples
125
122
@@ -159,9 +156,9 @@ php_bison(foo foo.y foo.c OPTIONS $<$<CONFIG:Debug>:--debug> --yacc)
159
156
# bison --yacc foo.y --output foo.c
160
157
```
161
158
162
- ### Custom target usage
159
+ ### Target usage
163
160
164
- To specify dependencies with the custom target created by `php_bison ()`:
161
+ Target created by `php_bison ()` can be used to specify additional dependencies :
165
162
166
163
```cmake
167
164
# CMakeLists.txt
@@ -172,29 +169,20 @@ php_bison(foo_parser parser.y parser.c)
172
169
add_dependencies (some_target foo_parser )
173
170
```
174
171
175
- Or to run only the specific `foo_parser` target , which generates the
176
- parser-related files :
172
+ Running only the `foo_parser` target to generate the parser-related files :
177
173
178
174
```sh
179
175
cmake --build <dir> --target foo_parser
180
176
```
181
177
182
178
### Module configuration
183
179
184
- To specify minimum required Bison version other than the module's default,
185
- `find_package (BISON )` can be called before the `php_bison ()`:
180
+ To specify different minimum required Bison version than the module's default,
181
+ the `find_package (BISON )` can be called before `php_bison ()`:
186
182
187
183
```cmake
188
- find_package (BISON 3.7 )
189
- include (PHP/Bison )
190
- php_bison (... )
191
- ```
192
-
193
- Set `PHP_BISON_*` variables to override module default configuration :
194
-
195
- ```cmake
196
- set (PHP_BISON_VERSION_DOWNLOAD 3.7 )
197
184
include (PHP/Bison )
185
+ find_package (BISON 3.7 )
198
186
php_bison (... )
199
187
```
200
188
#]=============================================================================]
@@ -204,12 +192,12 @@ php_bison(...)
204
192
################################################################################
205
193
206
194
macro (_php_bison_config )
207
- # Minimum required bison version.
195
+ # Minimum required Bison version.
208
196
if (NOT PHP_BISON_VERSION )
209
197
set (PHP_BISON_VERSION 3.0.0 )
210
198
endif ()
211
199
212
- # If bison is not found on the system, set which version to download.
200
+ # If Bison is not found on the system, set which version to download.
213
201
if (NOT PHP_BISON_VERSION_DOWNLOAD )
214
202
set (PHP_BISON_VERSION_DOWNLOAD 3.8.2 )
215
203
endif ()
@@ -354,7 +342,7 @@ function(php_bison name input output)
354
342
BASE_DIRECTORY ${CMAKE_BINARY_DIR}
355
343
OUTPUT_VARIABLE relativePath
356
344
)
357
- set (message "[bison ] Generating ${relativePath} with Bison ${BISON_VERSION} " )
345
+ set (message "[Bison ] Generating ${relativePath} with Bison ${BISON_VERSION} " )
358
346
359
347
if (CMAKE_SCRIPT_MODE_FILE )
360
348
message (STATUS "${message} " )
@@ -632,7 +620,6 @@ function(_php_bison_download)
632
620
LOG_INSTALL TRUE
633
621
)
634
622
635
- # Set bison executable.
636
623
ExternalProject_Get_Property (bison INSTALL_DIR )
637
624
set_property (CACHE BISON_EXECUTABLE PROPERTY VALUE ${INSTALL_DIR} /bin/bison )
638
625
0 commit comments