diff options
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/FindFLEX.cmake | 28 |
1 files changed, 22 insertions, 6 deletions
diff --git a/Modules/FindFLEX.cmake b/Modules/FindFLEX.cmake index 55a9537..ca66493 100644 --- a/Modules/FindFLEX.cmake +++ b/Modules/FindFLEX.cmake @@ -27,13 +27,17 @@ # # :: # -# FLEX_TARGET(Name FlexInput FlexOutput [COMPILE_FLAGS <string>]) +# FLEX_TARGET(Name FlexInput FlexOutput +# [COMPILE_FLAGS <string>] +# [DEFINES_FILE <string>] +# ) # # which creates a custom command to generate the <FlexOutput> file from # the <FlexInput> file. If COMPILE_FLAGS option is specified, the next -# parameter is added to the flex command line. Name is an alias used to -# get details of this custom command. Indeed the macro defines the -# following variables: +# parameter is added to the flex command line. If flex is configured to +# output a header file, the DEFINES_FILE option may be used to specify its +# name. Name is an alias used to get details of this custom command. +# Indeed the macro defines the following variables: # # :: # @@ -41,6 +45,7 @@ # FLEX_${Name}_OUTPUTS - the source file generated by the custom rule, an # alias for FlexOutput # FLEX_${Name}_INPUT - the flex source file, an alias for ${FlexInput} +# FLEX_${Name}_OUTPUT_HEADER - the header flex output, if any. # # # @@ -147,11 +152,13 @@ if(FLEX_EXECUTABLE) #============================================================ # macro(FLEX_TARGET Name Input Output) + set(FLEX_TARGET_outputs "${Output}") set(FLEX_EXECUTABLE_opts "") set(FLEX_TARGET_PARAM_OPTIONS) set(FLEX_TARGET_PARAM_ONE_VALUE_KEYWORDS COMPILE_FLAGS + DEFINES_FILE ) set(FLEX_TARGET_PARAM_MULTI_VALUE_KEYWORDS) @@ -163,7 +170,7 @@ if(FLEX_EXECUTABLE) ${ARGN} ) - set(FLEX_TARGET_usage "FLEX_TARGET(<Name> <Input> <Output> [COMPILE_FLAGS <string>]") + set(FLEX_TARGET_usage "FLEX_TARGET(<Name> <Input> <Output> [COMPILE_FLAGS <string>] [DEFINES_FILE <string>]") if(NOT "${FLEX_TARGET_ARG_UNPARSED_ARGUMENTS}" STREQUAL "") message(SEND_ERROR ${FLEX_TARGET_usage}) @@ -172,8 +179,12 @@ if(FLEX_EXECUTABLE) set(FLEX_EXECUTABLE_opts "${FLEX_TARGET_ARG_COMPILE_FLAGS}") separate_arguments(FLEX_EXECUTABLE_opts) endif() + if(NOT "${FLEX_TARGET_ARG_DEFINES_FILE}" STREQUAL "") + list(APPEND FLEX_TARGET_outputs "${FLEX_TARGET_ARG_DEFINES_FILE}") + list(APPEND FLEX_EXECUTABLE_opts --header-file=${FLEX_TARGET_ARG_DEFINES_FILE}) + endif() - add_custom_command(OUTPUT ${Output} + add_custom_command(OUTPUT ${FLEX_TARGET_outputs} COMMAND ${FLEX_EXECUTABLE} ARGS ${FLEX_EXECUTABLE_opts} -o${Output} ${Input} DEPENDS ${Input} @@ -184,6 +195,11 @@ if(FLEX_EXECUTABLE) set(FLEX_${Name}_OUTPUTS ${Output}) set(FLEX_${Name}_INPUT ${Input}) set(FLEX_${Name}_COMPILE_FLAGS ${FLEX_EXECUTABLE_opts}) + if("${FLEX_TARGET_ARG_DEFINES_FILE}" STREQUAL "") + set(FLEX_${Name}_OUTPUT_HEADER "") + else() + set(FLEX_${Name}_OUTPUT_HEADER ${FLEX_TARGET_ARG_DEFINES_FILE}) + endif() endif() endmacro() #============================================================ |