FindBISON: Use CMAKE_PARSE_ARGUMENTS to parse arguments

This commit is contained in:
Eon Jeong 2015-06-08 23:35:49 +09:00 committed by Brad King
parent 29985ad894
commit eb859263ae
1 changed files with 23 additions and 18 deletions

View File

@ -84,6 +84,8 @@
find_program(BISON_EXECUTABLE NAMES bison win_bison DOC "path to the bison executable")
mark_as_advanced(BISON_EXECUTABLE)
include(CMakeParseArguments)
if(BISON_EXECUTABLE)
# the bison commands should be executed with the C locale, otherwise
# the message (which are parsed) may be translated
@ -146,27 +148,30 @@ if(BISON_EXECUTABLE)
set(BISON_TARGET_output_header "")
set(BISON_TARGET_cmdopt "")
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")
else()
# Parsing parameters
if(${ARGC} GREATER 5 OR ${ARGC} EQUAL 5)
if("${ARGV3}" STREQUAL "VERBOSE")
BISON_TARGET_option_verbose(${Name} ${BisonOutput} "${ARGV4}")
endif()
if("${ARGV3}" STREQUAL "COMPILE_FLAGS")
BISON_TARGET_option_extraopts("${ARGV4}")
endif()
endif()
if(${ARGC} EQUAL 7)
if("${ARGV5}" STREQUAL "VERBOSE")
BISON_TARGET_option_verbose(${Name} ${BisonOutput} "${ARGV6}")
endif()
if("${ARGV5}" STREQUAL "COMPILE_FLAGS")
BISON_TARGET_option_extraopts("${ARGV6}")
if(NOT "${BISON_TARGET_ARG_VERBOSE}" STREQUAL "")
BISON_TARGET_option_verbose(${Name} ${BisonOutput} "${BISON_TARGET_ARG_VERBOSE}")
endif()
if(NOT "${BISON_TARGET_ARG_COMPILE_FLAGS}" STREQUAL "")
BISON_TARGET_option_extraopts("${BISON_TARGET_ARG_COMPILE_FLAGS}")
endif()
# Header's name generated by bison (see option -d)