API Documentation

DataConverter

Manage conversion of vcxproj data
class cmake_converter.data_converter.DataConverter(data)

Bases: object

Class who convert data to CMakeLists.txt.

close_cmake_file()

Close the “CMakeLists.txt” file

create_data()

Create the data and convert each part of “vcxproj” project

init_files(vs_project, cmake_lists)

Initialize opening of CMakeLists.txt and VS Project files

Parameters:
  • vs_project (str) – Visual Studio project file path
  • cmake_lists (str) – CMakeLists.txt file path
write_cmake_headers(vs_project)

Write generation informations and set CMake version

Data Files

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

Create CMakeLists.txt file in wanted “cmake_path”

Parameters:cmake_path (str) – path where CMakeLists.txt should be write
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 (str) – wanted target (Debug|Win32, Release|x64, …)
Returns:wanted ItemDefinitionGroup namespace
Return type:str
cmake_converter.data_files.get_propertygroup(target_platform, attributes='')

Return “propertygroup” value for wanted platform and target

Parameters:
  • target_platform (str) – wanted target (Debug|Win32, Release|x64, …)
  • attributes (str) – attributes to add to namespace (@Label=”Configuration”, …)
Returns:

“propertygroup” value

Return type:

str

cmake_converter.data_files.get_vcxproj_data(vs_project)

Return xml data from “vcxproj” file

Parameters:vs_project (str) – the vcxproj file
Returns:dict with VS Project data
Return type:dict

Dependencies

Manage directories and libraries of project dependencies
class cmake_converter.dependencies.Dependencies(data)

Bases: object

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

add_dependencies()

Add dependencies to CMake project

get_dependency_target_name(vs_project)

Return dependency target name of VS Project

Parameters:vs_project (str) – the .vcxproj file
Returns:project name or empty string
Return type:str

Write link dependencies of project.

write_dependencies()

Write on “CMakeLists.txt” subdirectories or link directories for external libraries.

write_include_dir()

Write on “CMakeLists.txt” include directories required for compilation.

Flags

Manage compilation flags of project
class cmake_converter.flags.Flags(data)

Bases: object

Class who check and create compilation flags

available_std = ['c++11', 'c++14', 'c++17']
define_defines()

DEFINES

define_group_properties()

Define the PropertyGroups and DefinitionGroups of XML properties

define_linux_flags()

Define the Flags for Linux platforms

define_settings()

Define settings of project for each configuration

define_windows_flags()

Define the Flags for Win32 platforms

set_exception_handling()

Set ExceptionHandling flag: /EHsc

set_function_level_linking()

Set FunctionLevelLinking flag: /Gy

set_generate_debug_information()

Set GenerateDebugInformation flag: /Zi

set_intrinsic_functions()

Set Intrinsic Functions flag: /Oi

set_optimization()

Set Optimization flag: /Od

set_runtime_library()

Set RuntimeLibrary flag: /MDd

set_runtime_type_info()

Set RuntimeTypeInfo flag: /GR

set_use_debug_libraries()

Set Use Debug Libraries flag: /MD

set_warning_level()

Set Warning level for Windows: /W

set_whole_program_optimization()

Set Whole Program Optimization flag: /GL

write_defines_and_flags()

Get and write Preprocessor Macros definitions

write_flags()

Parse all flags properties and write them inside “CMakeLists.txt” file

ProjectFiles

Manages the recovery of project files
class cmake_converter.project_files.ProjectFiles(data)

Bases: object

Class who collect and store project files

add_additional_code(filename)

Add additional file with CMake code inside

Parameters:filename (str) – the file who contains CMake code
add_include_cmake(filename)

Add include directive for filename

Parameters:filename (str) – name of file to include
add_target_artefact()

Add Library or Executable target

collects_source_files()

Collects the project source files in CMakeLists.txt file

write_source_files()

Write source files variables to file() cmake function

ProjectVariables

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

Bases: object

Class who defines all the CMake variables to be used by the project

add_cmake_output_directories()

Add output directory for each artefacts CMake target

add_cmake_project(language)

Add CMake Project

Parameters:language (list) – type of project language: cpp | c
add_default_target()

Add default target release if not define.

add_dependencies_variables()

Add dependencies variables

add_output_variables()

Add output variables

add_project_variables()

Add main CMake project variables

static cleaning_output(output)

Clean Output string by remove VS Project Variables

Parameters:output (str) – Output to clean
Returns:clean output
Return type:str
write_project_messages()

Write some messages for project to inform user during cmake generation

Utils

Utils manage function needed by converter

cmake_converter.utils.get_title(title, text)

Return formatted title for writing

Parameters:
  • title (str) – main title text
  • text (str) – text related to title
Returns:

formatted title

Return type:

str

cmake_converter.utils.message(text, status)

Displays a message while the script is running

Parameters:
  • text (str) – content of the message
  • status (str) – level of the message (change color)