API Documentation

DataConverter

Manage conversion of data into CMake
class cmake_converter.data_converter.DataConverter

Bases: object

Base class for converters

static collect_data(context)

Collect data for converter.

convert_project(context, xml_project_path, cmake_lists_destination_path)

Method template for data collecting and writing

merge_data_settings(context)

Merge common settings found among configuration settings (reduce copy-paste)

Parameters:context
Returns:
static write_data(context, cmake_file)

Write data defined in converter.

Parameters:
  • context (Context) – converter context
  • cmake_file (_io.TextIOWrapper) – CMakeLists IO wrapper

Context object descriptor

class cmake_converter.context.Context

Bases: object

Converter context

clone()

Deep clone of Context

Returns:
init(xml_project_path, cmake_lists_destination_path)

Initialize instance of Context with Initializer

Parameters:
  • xml_project_path
  • cmake_lists_destination_path
Returns:

Data Files

Manage the VS Project data and creation of CMakeLists.txt file
cmake_converter.data_files.get_cmake_lists(context, cmake_path=None, open_type='w')

Create CMakeLists.txt file in wanted “cmake_path”

Parameters:
  • context (Context) – the context of converter
  • cmake_path (str) – path where CMakeLists.txt should be open
  • open_type (str) – type that CMakeLists.txt should be opened
Returns:

cmake file wrapper opened

Return type:

_io.TextIOWrapper

cmake_converter.data_files.get_definitiongroup(target_platform)

Return ItemDefinitionGroup namespace depends on platform and target

Parameters:target_platform (tuple[str,str]) – wanted target: debug | release
Returns:wanted ItemDefinitionGroup namespace
Return type:str
cmake_converter.data_files.get_propertygroup(target_platform, attributes='')

Return “property_groups” value for wanted platform and target

Parameters:
  • target_platform (tuple[str,str]) – wanted target: debug | release
  • attributes (str) – attributes to add to namespace
Returns:

“property_groups” value

Return type:

str

cmake_converter.data_files.get_vcxproj_data(context, vs_project)

Return xml data from “vcxproj” file

Parameters:
  • context (Context) – the context of converter
  • vs_project (str) – the vcxproj file
Returns:

dict with VS Project data

Return type:

dict

cmake_converter.data_files.get_xml_data(context, xml_file)

Return xml data from “xml” file

Parameters:
  • context (Context) – the context of converter
  • xml_file (str) – the xml file
Returns:

dict with VS Project data

Return type:

dict

Dependencies

Manage directories and libraries of project dependencies
class cmake_converter.dependencies.Dependencies

Bases: object

Class who find and write dependencies of project, additionnal directories…

static get_dependency_target_name(context, vs_project)

Return dependency target name

Parameters:
  • context (Context) – the context of converter
  • vs_project (str) – path to “.vcxproj” file
Returns:

target name

Return type:

str

static set_additional_include_directories(aid_text, setting, context)

Return additional include directories of given context

Parameters:
  • aid_text (str) – path to sources
  • setting (str) – current setting (Debug|x64, Release|Win32,…)
  • context (Context) – current context
Returns:

include directories of context, separated by semicolons

Return type:

str

write_custom_build_events_of_files(context, cmake_file)
static write_file_build_event_of_setting(cmake_file, property_indent, config_condition_expr, property_value, width, **kwargs)
static write_include_directories(context, cmake_file)

Write include directories of given context to given CMakeLists.txt file

Parameters:
  • context (Context) – current context data
  • cmake_file (_io.TextIOWrapper) – CMakeLists.txt IO wrapper

Write link dependencies of project to given cmake file

Parameters:
  • context (Context) – current context
  • cmake_file (_io.TextIOWrapper) – CMakeLists.txt IO wrapper
static write_property_sheets(cmake_file, property_indent, config_condition_expr, property_value, width, **kwargs)
static write_target_build_event_of_setting(cmake_file, property_indent, config_condition_expr, property_value, width, **kwargs)
static write_target_dependency_packages(context, cmake_file)

Write target dependency packages of current context

Parameters:
  • context (Context) – current context
  • cmake_file (_io.TextIOWrapper) – CMakeLists.txt IO wrapper
write_target_post_build_events(context, cmake_file)
write_target_pre_build_events(context, cmake_file)
static write_target_property_sheets(context, cmake_file)

Write target property sheets of current context

Parameters:
  • context (Context) – current context
  • cmake_file (_io.TextIOWrapper) – CMakeLists.txt IO wrapper
static write_target_references(context, cmake_file)

Write target references on given CMakeLists.txt file

Parameters:
  • context (Context) – current context
  • cmake_file (_io.TextIOWrapper) – CMakeLists.txt IO wrapper

Flags

Manage compilation flags of project
class cmake_converter.flags.Flags

Bases: object

Class who manage flags of projects

Parameters:
  • context
  • cmake_file
  • kwargs
Returns:

write_defines(context, cmake_file)
write_flags(context, cmake_file)

Get and write Preprocessor Macros definitions

Parameters:
  • context (Context) – converter Context
  • cmake_file (_io.TextIOWrapper) – CMakeLists.txt IO wrapper
static write_target_artifact(context, cmake_file)

Add Library or Executable target

Parameters:
  • context (Context) – converter Context
  • cmake_file (_io.TextIOWrapper) – CMakeLIsts.txt IO wrapper
static write_target_headers_only_artifact(context, cmake_file)

Add a dummy target to given CMake file

Parameters:
  • context (Context) – the context of converter
  • cmake_file (_io.TextIOWrapper) – CMakeLists.txt IO wrapper
write_use_pch_function(context, cmake_file)

ProjectFiles

Manages the recovery of project files
class cmake_converter.project_files.ProjectFiles

Bases: object

Class who collect and store project files

static add_additional_code(context, file_to_add, cmake_file)

Add additional file with CMake code inside

Parameters:
  • context (Context) – the context of converter
  • cmake_file (_io.TextIOWrapper) – CMakeLists.txt IO wrapper
  • file_to_add (str) – the file who contains CMake code
add_file_from_node(context, **kwargs)
apply_files_to_context(context)
find_cmake_project_languages(context)

Add CMake Project

static get_source_group_var(context, source_group_name)
include_directive_case_check(context, file_path_name, file_lists_for_include_paths)
init_file_lists_for_include_paths(context)

For include directive case ad path checking. Works only with vfproj. :param context: :return:

static write_cmake_project(context, cmake_file)

Write cmake project for given CMake file

Parameters:
  • context (Context) – Converter context
  • cmake_file (_io.TextIOWrapper) – CMakeLists.txt IO wrapper
write_source_groups(context, cmake_file)

ProjectVariables

Manage creation of CMake variables that will be used during compilation
class cmake_converter.project_variables.ProjectVariables

Bases: object

Class who manage project variables

static set_output_dir_impl(context, output_node_text)
Parameters:
  • context
  • output_node_text
Returns:

static set_output_file_impl(context, output_file_node_text)
static set_path_and_name_from_node(context, node_name, value, path_property, name_property)
static set_target_name(context, target_name_value)
static write_target_outputs(context, cmake_file)

Add outputs for each artefacts CMake target

Parameters:
  • context (Context) – related full context
  • cmake_file (_io.TextIOWrapper) – CMakeLists.txt IO wrapper
static write_target_property(cmake_file, property_indent, config_condition_expr, property_value, width, **kwargs)

Utils

Utils manage function needed by converter
class cmake_converter.utils.Utils

Bases: object

init_context_current_setting(context)

Define settings of converter.

Parameters:context (Context) – converter context
static lists_of_settings_to_merge()
cmake_converter.utils.check_for_relative_in_path(context, path, remove_relative=True)

Return path by adding CMake variable or current path prefix, to remove relative

Parameters:
  • context (Context) – the context of converter
  • path (str) – original path
  • remove_relative (bool) – flag
Returns:

formatted path without relative

Return type:

str

cmake_converter.utils.cleaning_output(context, output)

Clean Output string by remove VS Project Variables

Parameters:
  • context (Context) – the context of converter
  • output (str) – Output to clean
Returns:

clean output

Return type:

str

cmake_converter.utils.get_actual_filename(context, name)

Return actual filename from given name if file iis found, else return None

Parameters:
  • context (Context) – the context of converter
  • name (str) – name of file
Returns:

None | str

Return type:

None | str

cmake_converter.utils.get_comment(text)
cmake_converter.utils.get_dir_name_with_vars(context, path)
cmake_converter.utils.get_global_project_name_from_vcxproj_file(vcxproj)

Return global project name from “.vcxproj” file

Parameters:vcxproj (dict) – vcxproj data
Returns:project name
Return type:str
cmake_converter.utils.get_mapped_architectures(sln_setting_2_project_setting, arch)
cmake_converter.utils.get_mount_point(path)
cmake_converter.utils.get_str_value_from_property_value(property_value, separator)
cmake_converter.utils.init_colorama()
cmake_converter.utils.insensitive_glob(path)
cmake_converter.utils.is_settings_has_data(sln_configurations_map, settings, settings_key, sln_arch=None, conf=None)
cmake_converter.utils.make_cmake_literal(context, input_str)
cmake_converter.utils.make_os_specific_shell_path(output)
cmake_converter.utils.message(context, text, status)

Displays a message while the script is running

Parameters:
  • context (Context) – the context of converter
  • text (str) – content of the message
  • status (str) – level of the message (change color)
cmake_converter.utils.normalize_path(context, working_path, path_to_normalize, remove_relative=True)

Normalize path from working path

Parameters:
  • context (Context) – the context of converter
  • working_path (str) – current working path
  • path_to_normalize (str) – path to be normalized
  • remove_relative (bool) – remove relative from path flag
Returns:

normalized path

Return type:

str

cmake_converter.utils.prepare_build_event_cmd_line_for_cmake(context, build_event)
cmake_converter.utils.replace_vs_var_with_cmake_var(context, var)
cmake_converter.utils.replace_vs_vars_with_cmake_vars(context, output)
cmake_converter.utils.resolve_path_variables_of_vs(context, path_with_vars)
cmake_converter.utils.set_native_slash(raw_path)

Set native slash

Parameters:raw_path (str) – any style path
Returns:unix style path
Return type:str
cmake_converter.utils.set_unix_slash(win_path)

Set windows path to unix style path

Parameters:win_path (str) – windows style path
Returns:unix style path
Return type:str
cmake_converter.utils.take_name_from_list_case_ignore(context, search_list, name_to_search)

Return real name of name to search

Parameters:
  • context (Context) – the context of converter
  • search_list (list) – list to makje research
  • name_to_search (str) – name tosearch in list
Returns:

real name

Return type:

str

cmake_converter.utils.write_arch_types(cmake)
cmake_converter.utils.write_comment(cmake_file, text)

Write formated comment in given file wrapper

Parameters:
  • text (str) – text in middle of title
  • cmake_file (_io.TextIOWrapper) – CMakeLists.txt IO wrapper
cmake_converter.utils.write_property_of_setting_f(cmake_file, property_indent, config_condition_expr, property_value, width, **kwargs)
cmake_converter.utils.write_property_of_settings(cmake_file, settings, sln_setting_2_project_setting, **kwargs)

Write property of given settings.

Parameters:
  • cmake_file (_io.TextIOWrapper) – CMakeLists.txt IO wrapper
  • settings (dict) – global settings
  • sln_setting_2_project_setting (dict) – solution settings attached to project
  • kwargs – begin of text

kwargs: indent: indent to use when writing indent: str default: default text to add default: None | str separator: separator for property list separator: ; | str in_quotes: Enclose configuration settings in quotes in_quotes: False | bool write_setting_property_func: function for writing property for setting write_setting_property_func: write_property_of_setting | lambda

cmake_converter.utils.write_selected_sln_setting(cmake_file, settings, sln_setting_2_project_setting, sln_setting, has_property_value, command_indent, sln_conf, config_expressions, max_config_condition_width, **kwargs)
cmake_converter.utils.write_use_package_stub(cmake)