diff options
author | Eon Jeong <eonikupy@gmail.com> | 2015-06-08 14:35:49 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2015-06-09 14:21:52 (GMT) |
commit | eb859263aeffc79d73d046dbf9f5656e4c9739ef (patch) | |
tree | 2b458eff120638d40f81f1f6a3312c0dbef8e07c /Modules | |
parent | 29985ad8948af74d8b6ad4e58428f65434e68f0c (diff) | |
download | CMake-eb859263aeffc79d73d046dbf9f5656e4c9739ef.zip CMake-eb859263aeffc79d73d046dbf9f5656e4c9739ef.tar.gz CMake-eb859263aeffc79d73d046dbf9f5656e4c9739ef.tar.bz2 |
FindBISON: Use CMAKE_PARSE_ARGUMENTS to parse arguments
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/FindBISON.cmake | 41 |
1 files changed, 23 insertions, 18 deletions
diff --git a/Modules/FindBISON.cmake b/Modules/FindBISON.cmake index e1cad81..30d7c4f 100644 --- a/Modules/FindBISON.cmake +++ b/Modules/FindBISON.cmake @@ -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() + if(NOT "${BISON_TARGET_ARG_VERBOSE}" STREQUAL "") + BISON_TARGET_option_verbose(${Name} ${BisonOutput} "${BISON_TARGET_ARG_VERBOSE}") 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}") - 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) |