diff options
author | Eon Jeong <eonikupy@gmail.com> | 2015-06-09 00:59:15 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2015-06-09 14:26:01 (GMT) |
commit | 12e534c2b8ad0009aba746ee6e4b47423c52f3e3 (patch) | |
tree | 08971520977c0d1546c006d9cf5e35bba68b1c2a /Modules | |
parent | eb859263aeffc79d73d046dbf9f5656e4c9739ef (diff) | |
download | CMake-12e534c2b8ad0009aba746ee6e4b47423c52f3e3.zip CMake-12e534c2b8ad0009aba746ee6e4b47423c52f3e3.tar.gz CMake-12e534c2b8ad0009aba746ee6e4b47423c52f3e3.tar.bz2 |
FindBISON: Add DEFINES_FILE option to pass --defines=FILE
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/FindBISON.cmake | 34 |
1 files changed, 26 insertions, 8 deletions
diff --git a/Modules/FindBISON.cmake b/Modules/FindBISON.cmake index 30d7c4f..7d81276 100644 --- a/Modules/FindBISON.cmake +++ b/Modules/FindBISON.cmake @@ -22,6 +22,7 @@ # # BISON_TARGET(<Name> <YaccInput> <CodeOutput> # [COMPILE_FLAGS <flags>] +# [DEFINES_FILE <file>] # [VERBOSE <file>] # ) # @@ -35,6 +36,9 @@ # ``COMPILE_FLAGS <flags>`` # 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>`` # Tell ``bison`` to write verbose descriptions of the grammar and # parser to the given ``<file>``. @@ -64,7 +68,8 @@ # .. code-block:: cmake # # 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}) #============================================================================= @@ -140,6 +145,12 @@ if(BISON_EXECUTABLE) list(APPEND BISON_TARGET_cmdopt ${BISON_TARGET_extraopts}) 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) #============================================================ @@ -154,6 +165,7 @@ if(BISON_EXECUTABLE) set(BISON_TARGET_PARAM_ONE_VALUE_KEYWORDS VERBOSE COMPILE_FLAGS + DEFINES_FILE ) set(BISON_TARGET_PARAM_MULTI_VALUE_KEYWORDS) cmake_parse_arguments( @@ -173,14 +185,19 @@ if(BISON_EXECUTABLE) if(NOT "${BISON_TARGET_ARG_COMPILE_FLAGS}" STREQUAL "") BISON_TARGET_option_extraopts("${BISON_TARGET_ARG_COMPILE_FLAGS}") endif() + if(NOT "${BISON_TARGET_ARG_DEFINES_FILE}" STREQUAL "") + BISON_TARGET_option_defines("${BISON_TARGET_ARG_DEFINES_FILE}") + endif() - # Header's name generated by bison (see option -d) - list(APPEND BISON_TARGET_cmdopt "-d") - string(REGEX REPLACE "^(.*)(\\.[^.]*)$" "\\2" _fileext "${BisonOutput}") - string(REPLACE "c" "h" _fileext ${_fileext}) - string(REGEX REPLACE "^(.*)(\\.[^.]*)$" "\\1${_fileext}" - BISON_${Name}_OUTPUT_HEADER "${BisonOutput}") - list(APPEND BISON_TARGET_outputs "${BISON_${Name}_OUTPUT_HEADER}") + if("${BISON_TARGET_output_header}" STREQUAL "") + # Header's name generated by bison (see option -d) + list(APPEND BISON_TARGET_cmdopt "-d") + string(REGEX REPLACE "^(.*)(\\.[^.]*)$" "\\2" _fileext "${BisonOutput}") + string(REPLACE "c" "h" _fileext ${_fileext}) + string(REGEX REPLACE "^(.*)(\\.[^.]*)$" "\\1${_fileext}" + BISON_TARGET_output_header "${BisonOutput}") + endif() + list(APPEND BISON_TARGET_outputs "${BISON_TARGET_output_header}") add_custom_command(OUTPUT ${BISON_TARGET_outputs} ${BISON_TARGET_extraoutputs} @@ -196,6 +213,7 @@ if(BISON_EXECUTABLE) set(BISON_${Name}_OUTPUTS ${BISON_TARGET_outputs}) set(BISON_${Name}_COMPILE_FLAGS ${BISON_TARGET_cmdopt}) set(BISON_${Name}_OUTPUT_SOURCE "${BisonOutput}") + set(BISON_${Name}_OUTPUT_HEADER "${BISON_TARGET_output_header}") endif() endmacro() |