mirror of
https://github.com/Kitware/CMake.git
synced 2026-01-11 08:20:18 -06:00
FindBISON: Add new keyword OPTIONS
This adds a new keyword OPTIONS which is a semicolon-separated list of command-line options added to bison command line. This enables adding options more intuitively. It mainly adds options as quoted arguments which among other things enables adding paths containing spaces and similar. Fixes: - https://gitlab.kitware.com/cmake/cmake/-/issues/23301
This commit is contained in:
6
Help/release/dev/FindBISON.rst
Normal file
6
Help/release/dev/FindBISON.rst
Normal 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>`.
|
||||
@@ -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}")
|
||||
|
||||
Reference in New Issue
Block a user