diff --git a/Help/release/dev/FindBISON.rst b/Help/release/dev/FindBISON.rst new file mode 100644 index 0000000000..10058698b7 --- /dev/null +++ b/Help/release/dev/FindBISON.rst @@ -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 `. diff --git a/Modules/FindBISON.cmake b/Modules/FindBISON.cmake index fca054dd7d..313e54cb8c 100644 --- a/Modules/FindBISON.cmake +++ b/Modules/FindBISON.cmake @@ -28,6 +28,7 @@ If ``bison`` is found, the module defines the macro: .. code-block:: cmake bison_target( + [OPTIONS ...] [COMPILE_FLAGS ] [DEFINES_FILE ] [VERBOSE []] @@ -45,9 +46,18 @@ the token list. The options are: +``OPTIONS ...`` + .. versionadded:: 3.32 + + A :ref:`semicolon-separated list ` of options added to + the ``bison`` command line. + ``COMPILE_FLAGS `` + .. deprecated:: 3.32 + Space-separated bison options added to the ``bison`` command line. A :ref:`;-list ` will not work. + This option is deprecated in favor of ``OPTIONS ...``. ``DEFINES_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__COMPILE_FLAGS`` +``BISON__OPTIONS`` + .. versionadded:: 3.32 + Options used in the ``bison`` command line. +``BISON__COMPILE_FLAGS`` + .. deprecated:: 3.32 + + Options used in the ``bison`` command line. This variable is deprecated in + favor of ``BISON__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 :-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}")