diff --git a/update.py b/update.py index 84b4982..0bad7af 100644 --- a/update.py +++ b/update.py @@ -224,6 +224,21 @@ def gen_cmakelists(project_name, minimum_cmake_version, relative_path, modules): # ------------------------------------------------------------------------------ +def prepend_or_set(config, section, option, value): + """ + If option is already set, then value is prepended. + If option is not set, then it is created and set to value. + This is used to prepend options with values which come from the module documentation. + """ + if value: + if config.has_option(section, option): + value += '\n%s' % config.get(section, option) + config.set(section, option, value) + return config + +# ------------------------------------------------------------------------------ + + def fetch_modules(config, relative_path): """ Assemble modules which will @@ -272,14 +287,10 @@ def fetch_modules(config, relative_path): if parse_doc: with open(file_name, 'r') as f: config_docopt, config_define, config_export, config_fetch = parse_cmake_module(f.read()) - if config_docopt: - config.set(section, 'docopt', config_docopt) - if config_define: - config.set(section, 'define', config_define) - if config_export: - config.set(section, 'export', config_export) - if config_fetch: - config.set(section, 'fetch', config_fetch) + config = prepend_or_set(config, section, 'docopt', config_docopt) + config = prepend_or_set(config, section, 'define', config_define) + config = prepend_or_set(config, section, 'export', config_export) + config = prepend_or_set(config, section, 'fetch', config_fetch) modules.append(Module(path=path, name=name)) i += 1 print_progress_bar(