FindBISON: Use CMAKE_PARSE_ARGUMENTS to parse arguments
This commit is contained in:
parent
29985ad894
commit
eb859263ae
|
@ -84,6 +84,8 @@
|
||||||
find_program(BISON_EXECUTABLE NAMES bison win_bison DOC "path to the bison executable")
|
find_program(BISON_EXECUTABLE NAMES bison win_bison DOC "path to the bison executable")
|
||||||
mark_as_advanced(BISON_EXECUTABLE)
|
mark_as_advanced(BISON_EXECUTABLE)
|
||||||
|
|
||||||
|
include(CMakeParseArguments)
|
||||||
|
|
||||||
if(BISON_EXECUTABLE)
|
if(BISON_EXECUTABLE)
|
||||||
# the bison commands should be executed with the C locale, otherwise
|
# the bison commands should be executed with the C locale, otherwise
|
||||||
# the message (which are parsed) may be translated
|
# the message (which are parsed) may be translated
|
||||||
|
@ -146,27 +148,30 @@ if(BISON_EXECUTABLE)
|
||||||
set(BISON_TARGET_output_header "")
|
set(BISON_TARGET_output_header "")
|
||||||
set(BISON_TARGET_cmdopt "")
|
set(BISON_TARGET_cmdopt "")
|
||||||
set(BISON_TARGET_outputs "${BisonOutput}")
|
set(BISON_TARGET_outputs "${BisonOutput}")
|
||||||
if(NOT ${ARGC} EQUAL 3 AND NOT ${ARGC} EQUAL 5 AND NOT ${ARGC} EQUAL 7)
|
|
||||||
|
# Parsing parameters
|
||||||
|
set(BISON_TARGET_PARAM_OPTIONS)
|
||||||
|
set(BISON_TARGET_PARAM_ONE_VALUE_KEYWORDS
|
||||||
|
VERBOSE
|
||||||
|
COMPILE_FLAGS
|
||||||
|
)
|
||||||
|
set(BISON_TARGET_PARAM_MULTI_VALUE_KEYWORDS)
|
||||||
|
cmake_parse_arguments(
|
||||||
|
BISON_TARGET_ARG
|
||||||
|
"${BISON_TARGET_PARAM_OPTIONS}"
|
||||||
|
"${BISON_TARGET_PARAM_ONE_VALUE_KEYWORDS}"
|
||||||
|
"${BISON_TARGET_PARAM_MULTI_VALUE_KEYWORDS}"
|
||||||
|
${ARGN}
|
||||||
|
)
|
||||||
|
|
||||||
|
if(NOT "${BISON_TARGET_ARG_UNPARSED_ARGUMENTS}" STREQUAL "")
|
||||||
message(SEND_ERROR "Usage")
|
message(SEND_ERROR "Usage")
|
||||||
else()
|
else()
|
||||||
# Parsing parameters
|
if(NOT "${BISON_TARGET_ARG_VERBOSE}" STREQUAL "")
|
||||||
if(${ARGC} GREATER 5 OR ${ARGC} EQUAL 5)
|
BISON_TARGET_option_verbose(${Name} ${BisonOutput} "${BISON_TARGET_ARG_VERBOSE}")
|
||||||
if("${ARGV3}" STREQUAL "VERBOSE")
|
|
||||||
BISON_TARGET_option_verbose(${Name} ${BisonOutput} "${ARGV4}")
|
|
||||||
endif()
|
|
||||||
if("${ARGV3}" STREQUAL "COMPILE_FLAGS")
|
|
||||||
BISON_TARGET_option_extraopts("${ARGV4}")
|
|
||||||
endif()
|
|
||||||
endif()
|
endif()
|
||||||
|
if(NOT "${BISON_TARGET_ARG_COMPILE_FLAGS}" STREQUAL "")
|
||||||
if(${ARGC} EQUAL 7)
|
BISON_TARGET_option_extraopts("${BISON_TARGET_ARG_COMPILE_FLAGS}")
|
||||||
if("${ARGV5}" STREQUAL "VERBOSE")
|
|
||||||
BISON_TARGET_option_verbose(${Name} ${BisonOutput} "${ARGV6}")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if("${ARGV5}" STREQUAL "COMPILE_FLAGS")
|
|
||||||
BISON_TARGET_option_extraopts("${ARGV6}")
|
|
||||||
endif()
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Header's name generated by bison (see option -d)
|
# Header's name generated by bison (see option -d)
|
||||||
|
|
Loading…
Reference in New Issue