@@ -25,16 +25,15 @@ php_bison(
2525)
2626```
2727
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
3030generator. Relative source file path `<input>` is interpreted as being relative
3131to the current source directory. Relative `<output>` file path is interpreted as
3232being relative to the current binary directory. If generated files are already
3333available (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.
3635
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
3837generates the parser right away without creating a target.
3938
4039#### Options
@@ -57,38 +56,36 @@ generates the parser right away without creating a target.
5756* `DEPENDS <depends>...` - Optional list of dependent files to regenerate the
5857 output file.
5958
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.
6462
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.
6967
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:
7472
7573 ```sh
7674 cmake --build <dir> --target codegen
7775 ```
7876
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
8381 executed in the directory of the `<output>` file. If variable
8482 `PHP_BISON_WORKING_DIRECTORY` is set before calling the `php_bison()` without
8583 this option, it will set the default working directory to that instead.
8684
8785* `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.
9289
9390 When this option is enabled:
9491
@@ -119,7 +116,7 @@ These variables can be set before using this module to configure behavior:
119116
120117* `PHP_BISON_WORKING_DIRECTORY` - Set the default global working directory
121118 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.
123120
124121## Examples
125122
@@ -159,9 +156,9 @@ php_bison(foo foo.y foo.c OPTIONS $<$<CONFIG:Debug>:--debug> --yacc)
159156# bison --yacc foo.y --output foo.c
160157```
161158
162- ### Custom target usage
159+ ### Target usage
163160
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 :
165162
166163```cmake
167164# CMakeLists.txt
@@ -172,29 +169,20 @@ php_bison(foo_parser parser.y parser.c)
172169add_dependencies(some_target foo_parser)
173170```
174171
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:
177173
178174```sh
179175cmake --build <dir> --target foo_parser
180176```
181177
182178### Module configuration
183179
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()`:
186182
187183```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)
197184include(PHP/Bison)
185+ find_package(BISON 3.7)
198186php_bison(...)
199187```
200188#]=============================================================================]
@@ -204,12 +192,12 @@ php_bison(...)
204192################################################################################
205193
206194macro (_php_bison_config)
207- # Minimum required bison version.
195+ # Minimum required Bison version.
208196 if (NOT PHP_BISON_VERSION)
209197 set (PHP_BISON_VERSION 3.0.0)
210198 endif ()
211199
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.
213201 if (NOT PHP_BISON_VERSION_DOWNLOAD)
214202 set (PHP_BISON_VERSION_DOWNLOAD 3.8.2)
215203 endif ()
@@ -354,7 +342,7 @@ function(php_bison name input output)
354342 BASE_DIRECTORY ${CMAKE_BINARY_DIR}
355343 OUTPUT_VARIABLE relativePath
356344 )
357- set (message "[bison ] Generating ${relativePath} with Bison ${BISON_VERSION} " )
345+ set (message "[Bison ] Generating ${relativePath} with Bison ${BISON_VERSION} " )
358346
359347 if (CMAKE_SCRIPT_MODE_FILE )
360348 message (STATUS "${message} " )
@@ -632,7 +620,6 @@ function(_php_bison_download)
632620 LOG_INSTALL TRUE
633621 )
634622
635- # Set bison executable.
636623 ExternalProject_Get_Property(bison INSTALL_DIR)
637624 set_property (CACHE BISON_EXECUTABLE PROPERTY VALUE ${INSTALL_DIR} /bin/bison)
638625
0 commit comments