FindBISON: Add DEFINES_FILE option to pass --defines=FILE
This commit is contained in:
parent
eb859263ae
commit
12e534c2b8
@ -22,6 +22,7 @@
|
|||||||
#
|
#
|
||||||
# BISON_TARGET(<Name> <YaccInput> <CodeOutput>
|
# BISON_TARGET(<Name> <YaccInput> <CodeOutput>
|
||||||
# [COMPILE_FLAGS <flags>]
|
# [COMPILE_FLAGS <flags>]
|
||||||
|
# [DEFINES_FILE <file>]
|
||||||
# [VERBOSE <file>]
|
# [VERBOSE <file>]
|
||||||
# )
|
# )
|
||||||
#
|
#
|
||||||
@ -35,6 +36,9 @@
|
|||||||
# ``COMPILE_FLAGS <flags>``
|
# ``COMPILE_FLAGS <flags>``
|
||||||
# Specify flags to be added to the ``bison`` command line.
|
# Specify flags to be added to the ``bison`` command line.
|
||||||
#
|
#
|
||||||
|
# ``DEFINES_FILE <file>``
|
||||||
|
# Specify a non-default header ``<file>`` to be generated by ``bison``.
|
||||||
|
#
|
||||||
# ``VERBOSE <file>``
|
# ``VERBOSE <file>``
|
||||||
# Tell ``bison`` to write verbose descriptions of the grammar and
|
# Tell ``bison`` to write verbose descriptions of the grammar and
|
||||||
# parser to the given ``<file>``.
|
# parser to the given ``<file>``.
|
||||||
@ -64,7 +68,8 @@
|
|||||||
# .. code-block:: cmake
|
# .. code-block:: cmake
|
||||||
#
|
#
|
||||||
# find_package(BISON)
|
# find_package(BISON)
|
||||||
# BISON_TARGET(MyParser parser.y ${CMAKE_CURRENT_BINARY_DIR}/parser.cpp)
|
# 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})
|
# add_executable(Foo main.cpp ${BISON_MyParser_OUTPUTS})
|
||||||
|
|
||||||
#=============================================================================
|
#=============================================================================
|
||||||
@ -140,6 +145,12 @@ if(BISON_EXECUTABLE)
|
|||||||
list(APPEND BISON_TARGET_cmdopt ${BISON_TARGET_extraopts})
|
list(APPEND BISON_TARGET_cmdopt ${BISON_TARGET_extraopts})
|
||||||
endmacro()
|
endmacro()
|
||||||
|
|
||||||
|
# internal macro
|
||||||
|
macro(BISON_TARGET_option_defines Header)
|
||||||
|
set(BISON_TARGET_output_header "${Header}")
|
||||||
|
list(APPEND BISON_TARGET_cmdopt --defines=${BISON_TARGET_output_header})
|
||||||
|
endmacro()
|
||||||
|
|
||||||
#============================================================
|
#============================================================
|
||||||
# BISON_TARGET (public macro)
|
# BISON_TARGET (public macro)
|
||||||
#============================================================
|
#============================================================
|
||||||
@ -154,6 +165,7 @@ if(BISON_EXECUTABLE)
|
|||||||
set(BISON_TARGET_PARAM_ONE_VALUE_KEYWORDS
|
set(BISON_TARGET_PARAM_ONE_VALUE_KEYWORDS
|
||||||
VERBOSE
|
VERBOSE
|
||||||
COMPILE_FLAGS
|
COMPILE_FLAGS
|
||||||
|
DEFINES_FILE
|
||||||
)
|
)
|
||||||
set(BISON_TARGET_PARAM_MULTI_VALUE_KEYWORDS)
|
set(BISON_TARGET_PARAM_MULTI_VALUE_KEYWORDS)
|
||||||
cmake_parse_arguments(
|
cmake_parse_arguments(
|
||||||
@ -173,14 +185,19 @@ if(BISON_EXECUTABLE)
|
|||||||
if(NOT "${BISON_TARGET_ARG_COMPILE_FLAGS}" STREQUAL "")
|
if(NOT "${BISON_TARGET_ARG_COMPILE_FLAGS}" STREQUAL "")
|
||||||
BISON_TARGET_option_extraopts("${BISON_TARGET_ARG_COMPILE_FLAGS}")
|
BISON_TARGET_option_extraopts("${BISON_TARGET_ARG_COMPILE_FLAGS}")
|
||||||
endif()
|
endif()
|
||||||
|
if(NOT "${BISON_TARGET_ARG_DEFINES_FILE}" STREQUAL "")
|
||||||
|
BISON_TARGET_option_defines("${BISON_TARGET_ARG_DEFINES_FILE}")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if("${BISON_TARGET_output_header}" STREQUAL "")
|
||||||
# Header's name generated by bison (see option -d)
|
# Header's name generated by bison (see option -d)
|
||||||
list(APPEND BISON_TARGET_cmdopt "-d")
|
list(APPEND BISON_TARGET_cmdopt "-d")
|
||||||
string(REGEX REPLACE "^(.*)(\\.[^.]*)$" "\\2" _fileext "${BisonOutput}")
|
string(REGEX REPLACE "^(.*)(\\.[^.]*)$" "\\2" _fileext "${BisonOutput}")
|
||||||
string(REPLACE "c" "h" _fileext ${_fileext})
|
string(REPLACE "c" "h" _fileext ${_fileext})
|
||||||
string(REGEX REPLACE "^(.*)(\\.[^.]*)$" "\\1${_fileext}"
|
string(REGEX REPLACE "^(.*)(\\.[^.]*)$" "\\1${_fileext}"
|
||||||
BISON_${Name}_OUTPUT_HEADER "${BisonOutput}")
|
BISON_TARGET_output_header "${BisonOutput}")
|
||||||
list(APPEND BISON_TARGET_outputs "${BISON_${Name}_OUTPUT_HEADER}")
|
endif()
|
||||||
|
list(APPEND BISON_TARGET_outputs "${BISON_TARGET_output_header}")
|
||||||
|
|
||||||
add_custom_command(OUTPUT ${BISON_TARGET_outputs}
|
add_custom_command(OUTPUT ${BISON_TARGET_outputs}
|
||||||
${BISON_TARGET_extraoutputs}
|
${BISON_TARGET_extraoutputs}
|
||||||
@ -196,6 +213,7 @@ if(BISON_EXECUTABLE)
|
|||||||
set(BISON_${Name}_OUTPUTS ${BISON_TARGET_outputs})
|
set(BISON_${Name}_OUTPUTS ${BISON_TARGET_outputs})
|
||||||
set(BISON_${Name}_COMPILE_FLAGS ${BISON_TARGET_cmdopt})
|
set(BISON_${Name}_COMPILE_FLAGS ${BISON_TARGET_cmdopt})
|
||||||
set(BISON_${Name}_OUTPUT_SOURCE "${BisonOutput}")
|
set(BISON_${Name}_OUTPUT_SOURCE "${BisonOutput}")
|
||||||
|
set(BISON_${Name}_OUTPUT_HEADER "${BISON_TARGET_output_header}")
|
||||||
|
|
||||||
endif()
|
endif()
|
||||||
endmacro()
|
endmacro()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user