summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Modules/FindBISON.cmake41
1 files changed, 23 insertions, 18 deletions
diff --git a/Modules/FindBISON.cmake b/Modules/FindBISON.cmake
index e1cad81e25..30d7c4f194 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)