summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
Diffstat (limited to 'Modules')
-rw-r--r--Modules/FindBISON.cmake86
1 files changed, 42 insertions, 44 deletions
diff --git a/Modules/FindBISON.cmake b/Modules/FindBISON.cmake
index bb1b577..6b1c7bd 100644
--- a/Modules/FindBISON.cmake
+++ b/Modules/FindBISON.cmake
@@ -126,14 +126,47 @@ if(BISON_EXECUTABLE)
endif()
# internal macro
- macro(BISON_TARGET_set_verbose_file BisonOutput)
- get_filename_component(BISON_TARGET_output_path "${BisonOutput}" PATH)
- get_filename_component(BISON_TARGET_output_name "${BisonOutput}" NAME_WE)
- set(BISON_TARGET_verbose_file
- "${BISON_TARGET_output_path}/${BISON_TARGET_output_name}.output")
+ # sets BISON_TARGET_cmdopt
+ macro(BISON_TARGET_option_extraopts Options)
+ set(BISON_TARGET_cmdopt "")
+ set(BISON_TARGET_extraopts "${Options}")
+ separate_arguments(BISON_TARGET_extraopts)
+ list(APPEND BISON_TARGET_cmdopt ${BISON_TARGET_extraopts})
endmacro()
# internal macro
+ # sets BISON_TARGET_output_header and BISON_TARGET_cmdopt
+ macro(BISON_TARGET_option_defines BisonOutput Header)
+ if("${Header}" STREQUAL "")
+ # default header path generated by bison (see option -d)
+ string(REGEX REPLACE "^(.*)(\\.[^.]*)$" "\\2" _fileext "${BisonOutput}")
+ string(REPLACE "c" "h" _fileext ${_fileext})
+ string(REGEX REPLACE "^(.*)(\\.[^.]*)$" "\\1${_fileext}"
+ BISON_TARGET_output_header "${BisonOutput}")
+ list(APPEND BISON_TARGET_cmdopt "-d")
+ else()
+ set(BISON_TARGET_output_header "${Header}")
+ list(APPEND BISON_TARGET_cmdopt "--defines=${BISON_TARGET_output_header}")
+ endif()
+ endmacro()
+
+ # internal macro
+ # sets BISON_TARGET_verbose_file and BISON_TARGET_cmdopt
+ macro(BISON_TARGET_option_report_file BisonOutput ReportFile)
+ if("${ReportFile}" STREQUAL "")
+ get_filename_component(BISON_TARGET_output_path "${BisonOutput}" PATH)
+ get_filename_component(BISON_TARGET_output_name "${BisonOutput}" NAME_WE)
+ set(BISON_TARGET_verbose_file
+ "${BISON_TARGET_output_path}/${BISON_TARGET_output_name}.output")
+ else()
+ set(BISON_TARGET_verbose_file "${ReportFile}")
+ list(APPEND BISON_TARGET_cmdopt "--report-file=${BISON_TARGET_verbose_file}")
+ endif()
+ endmacro()
+
+ # internal macro
+ # adds a custom command and sets
+ # BISON_TARGET_cmdopt, BISON_TARGET_verbose_file, BISON_TARGET_extraoutputs
macro(BISON_TARGET_option_verbose Name BisonOutput filename)
list(APPEND BISON_TARGET_cmdopt "--verbose")
list(APPEND BISON_TARGET_extraoutputs
@@ -154,35 +187,13 @@ if(BISON_EXECUTABLE)
endif()
endmacro()
- # internal macro
- macro(BISON_TARGET_option_extraopts Options)
- set(BISON_TARGET_extraopts "${Options}")
- separate_arguments(BISON_TARGET_extraopts)
- 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()
-
- # internal macro
- macro(BISON_TARGET_option_report_file ReportFile)
- set(BISON_TARGET_verbose_file "${ReportFile}")
- list(APPEND BISON_TARGET_cmdopt "--report-file=${BISON_TARGET_verbose_file}")
- endmacro()
-
#============================================================
# BISON_TARGET (public macro)
#============================================================
#
macro(BISON_TARGET Name BisonInput BisonOutput)
- set(BISON_TARGET_output_header "")
- set(BISON_TARGET_cmdopt "")
set(BISON_TARGET_outputs "${BisonOutput}")
set(BISON_TARGET_extraoutputs "")
- BISON_TARGET_set_verbose_file("${BisonOutput}")
# Parsing parameters
set(BISON_TARGET_PARAM_OPTIONS
@@ -209,15 +220,10 @@ if(BISON_EXECUTABLE)
# [VERBOSE [<file>] hack: <file> is non-multi value by usage
message(SEND_ERROR "Usage")
else()
- 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()
- if(NOT "${BISON_TARGET_ARG_REPORT_FILE}" STREQUAL "")
- BISON_TARGET_option_report_file("${BISON_TARGET_ARG_REPORT_FILE}")
- endif()
+
+ BISON_TARGET_option_extraopts("${BISON_TARGET_ARG_COMPILE_FLAGS}")
+ 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 "")
BISON_TARGET_option_verbose(${Name} ${BisonOutput} "${BISON_TARGET_ARG_VERBOSE}")
else()
@@ -230,14 +236,6 @@ if(BISON_EXECUTABLE)
endif()
endif()
- 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}