Merge topic 'FindBISON-OPTIONS-keyword'

211cec0f20 FindBISON: Add new keyword OPTIONS

Acked-by: Kitware Robot <kwrobot@kitware.com>
Tested-by: buildbot <buildbot@kitware.com>
Merge-request: !10129
This commit is contained in:
Brad King
2025-01-08 14:29:30 +00:00
committed by Kitware Robot
2 changed files with 55 additions and 1 deletions

View File

@@ -0,0 +1,6 @@
FindBISON
---------
* The :module:`FindBISON` module :command:`bison_target` command has a new
``OPTIONS`` option to add Bison command-line options as a
:ref:`semicolon-separated list <CMake Language Lists>`.

View File

@@ -28,6 +28,7 @@ If ``bison`` is found, the module defines the macro:
.. code-block:: cmake
bison_target(<Name> <YaccInput> <CodeOutput>
[OPTIONS <options>...]
[COMPILE_FLAGS <string>]
[DEFINES_FILE <file>]
[VERBOSE [<file>]]
@@ -45,9 +46,18 @@ the token list.
The options are:
``OPTIONS <options>...``
.. versionadded:: 3.32
A :ref:`semicolon-separated list <CMake Language Lists>` of options added to
the ``bison`` command line.
``COMPILE_FLAGS <string>``
.. deprecated:: 3.32
Space-separated bison options added to the ``bison`` command line.
A :ref:`;-list <CMake Language Lists>` will not work.
This option is deprecated in favor of ``OPTIONS <options>...``.
``DEFINES_FILE <file>``
.. versionadded:: 3.4
@@ -85,9 +95,17 @@ The macro defines the following variables:
All files generated by ``bison`` including the source, the header and the
report.
``BISON_<Name>_COMPILE_FLAGS``
``BISON_<Name>_OPTIONS``
.. versionadded:: 3.32
Options used in the ``bison`` command line.
``BISON_<Name>_COMPILE_FLAGS``
.. deprecated:: 3.32
Options used in the ``bison`` command line. This variable is deprecated in
favor of ``BISON_<Name>_OPTIONS`` variable.
Examples
^^^^^^^^
@@ -97,6 +115,29 @@ Examples
bison_target(MyParser parser.y ${CMAKE_CURRENT_BINARY_DIR}/parser.cpp
DEFINES_FILE ${CMAKE_CURRENT_BINARY_DIR}/parser.h)
add_executable(Foo main.cpp ${BISON_MyParser_OUTPUTS})
Adding additional command-line options to the ``bison`` executable can be passed
as a list. For example, adding the ``-Wall`` option to report all warnings, and
``--no-lines`` (``-l``) to not generate ``#line`` directives.
.. code-block:: cmake
find_package(BISON)
if(BISON_FOUND)
bison_target(MyParser parser.y parser.cpp OPTIONS -Wall --no-lines)
endif()
Generator expressions can be used in ``OPTIONS <options...``. For example, to
add the ``--debug`` (``-t``) option only for the ``Debug`` build type:
.. code-block:: cmake
find_package(BISON)
if(BISON_FOUND)
bison_target(MyParser parser.y parser.cpp OPTIONS $<$<CONFIG:Debug>:-t>)
endif()
#]=======================================================================]
find_program(BISON_EXECUTABLE NAMES bison win-bison win_bison DOC "path to the bison executable")
@@ -236,6 +277,7 @@ if(BISON_EXECUTABLE)
REPORT_FILE
)
set(BISON_TARGET_PARAM_MULTI_VALUE_KEYWORDS
OPTIONS
VERBOSE
)
cmake_parse_arguments(
@@ -254,6 +296,11 @@ if(BISON_EXECUTABLE)
else()
BISON_TARGET_option_extraopts("${BISON_TARGET_ARG_COMPILE_FLAGS}")
if(BISON_TARGET_ARG_OPTIONS)
list(APPEND BISON_TARGET_cmdopt ${BISON_TARGET_ARG_OPTIONS})
endif()
BISON_TARGET_option_defines("${BisonOutput}" "${BISON_TARGET_ARG_DEFINES_FILE}")
BISON_TARGET_option_report_file("${BisonOutput}" "${BISON_TARGET_ARG_REPORT_FILE}")
if(NOT "${BISON_TARGET_ARG_VERBOSE}" STREQUAL "")
@@ -297,6 +344,7 @@ if(BISON_EXECUTABLE)
set(BISON_${Name}_DEFINED TRUE)
set(BISON_${Name}_INPUT ${_BisonInput})
set(BISON_${Name}_OUTPUTS ${BISON_TARGET_outputs} ${BISON_TARGET_extraoutputs})
set(BISON_${Name}_OPTIONS ${BISON_TARGET_cmdopt})
set(BISON_${Name}_COMPILE_FLAGS ${BISON_TARGET_cmdopt})
set(BISON_${Name}_OUTPUT_SOURCE "${BisonOutput}")
set(BISON_${Name}_OUTPUT_HEADER "${BISON_TARGET_output_header}")