def _extract_cmake_and_make_arguments(args, extract_catkin_make):

    cmake_args = []
    make_args = []
    catkin_make_args = []

    arg_types = {}

    if '--no-cmake-args' not in args:
        arg_types['--cmake-args'] = cmake_args
    if '--no-make-args' not in args:
        arg_types['--make-args'] = make_args
    if '--no-catkin_make_args' not in args and extract_catkin_make:
        arg_types['--catkin-make-args'] = catkin_make_args

    # Get the splitter indexes for each type (multiples allowed) starting at the end
    ordered_splitters = reversed([
        (i, t)
        for i, t in enumerate(args)
        if t in arg_types
    ])
    # Extract explicit specific args
    head_args = args
    tail_args = []
    for index, name in ordered_splitters:
        # Update whole args list, get specific args
        head_args, specific, tail = split_arguments(head_args, splitter_index=index)
        tail_args.extend(tail)
        arg_types[name][0:0] = specific

    args = head_args + tail_args

    # classify -D* and -G* arguments as cmake specific arguments
    if '--cmake-args' in arg_types:
        implicit_cmake_args = [a for a in args if a.startswith('-D') or a.startswith('-G')]
        args = [a for a in args if a not in implicit_cmake_args]
        cmake_args = implicit_cmake_args + cmake_args

    if '--no-cmake-args' not in args and len(cmake_args) == 0:
        cmake_args = None
    if '--no-make-args' not in args and len(make_args) == 0:
        make_args = None
    if '--no-catkin-make-args' not in args and len(catkin_make_args) == 0 and extract_catkin_make:
        catkin_make_args = None

    return args, cmake_args, make_args, catkin_make_args
Extract arguments which are meant to be passed to CMake and GNU Make
dataset/ETHPy150Open catkin/catkin_tools/catkin_tools/argument_parsing.py/_extract_cmake_and_make_arguments