Giter Club home page Giter Club logo

cmakeconverter's Introduction

CMake Converter

image

Code Health

image

Documentation Status

Most recent PyPi version

Supported Python versions

License AGPL v3

image

Introduction

This project aims to facilitate the conversion of Visual Studio solution to CMake projects. The goal is to give to a Python script, a *.sln file, and output a set of CMakeLists.txt that may be used for generating visual studio solution backward as perfect as possible. Project is useful for porting VS projects into CMake build system.

Note : Actually, it's only works with C/C++ (*.vcxproj) and Fortran (*.vfproj) projects.

Install & Run

Install package from PyPI

Install last stable release of cmake-converter:

pip install cmake-converter

Note : If you found an issue in the package installed from pip, please, do not create github issue at once and check for pre-release version (pip -pre) or last source from develop first. It might be has fixed already and ready to release.

Install package from source code

Simply clone or download the repository and type the following command to install it:

# Inside repository folder.
pip install .

Run

After install library, just run the script as below. Your *.sln file is of course required:

cmake-converter -s <path/to/file.sln>

Note : If you satisfied with conversion, give a star to the project and consider to donate, please.

Documentation

Documentation for CMake Converter is available on Read The Docs.

Bugs, issues and contributing

Contributions to this project are welcome and encouraged ... Issues in the project repository are the common way to raise an information.

Note: if you have an issue, please provide me if possible the visual studio project involved.

Donations

If you appreciate my efforts related to this project, give me a gift. I'll be glad to get some money working for free ;) To make a donation - please press the button below.

image

cmakeconverter's People

Contributors

aferritto avatar algorys avatar jhobern avatar nicklauslittle avatar pavelliavonau avatar yrhetatejlb avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

cmakeconverter's Issues

Respect `ExcludedFromBuild`?

The element <ExcludedFromBuild> hasn't been respected, which leads to all files are included for diffenent configuration.

Handle property "Ignore Specific Default Libraries"

For the following *.vcxproj:

<Link>
    <IgnoreSpecificDefaultLibraries>libcmt.lib</IgnoreSpecificDefaultLibraries>
</Link>

CMake equivalent is:
set_target_properties(${PROJECT_NAME} PROPERTIES LINK_FLAGS_RELEASE "/NODEFAULTLIB:libcmt.lib")

program trow UnicodeDecodeError

Sorry, i bad at English.

i clone this repository and i run python ./cmake_converter/main.py -s test.sln,
but program threw UnicodeDecodeError.

Traceback (most recent call last):
  File "C:\Python36\Scripts\cmake-converter-script.py", line 11, in <module>
    load_entry_point('cmake-converter==1.2.0', 'console_scripts', 'cmake-converter')()
  File "c:\python36\lib\site-packages\cmake_converter\main.py", line 159, in main
    projects = p.findall(sln.read())
UnicodeDecodeError: 'cp932' codec can't decode byte 0xef in position 0: illegal multibyte sequence

Environment

  • Windows 10 64bit (Japanese)
  • Python 3.6.5

Solution

i found solution.
modify main.py (line 156)

# sln = open(data['solution'])
sln = open(data['solution'], encoding='utf8')

AttributeError: 'NoneType' object has no attribute 'split'

convertion fails with AttributeError

0.284577 101> INFO : Debug|Win32 : GenerateDebugInformation is {'ln_flags': '/DEBUG'}
multiprocessing.pool.RemoteTraceback:
"""
Traceback (most recent call last):
File "/usr/lib/python3.5/multiprocessing/pool.py", line 119, in worker
result = (True, func(*args, **kwds))
File "/usr/lib/python3.5/multiprocessing/pool.py", line 44, in mapstar
return list(map(*args))
File "/home/user/.local/lib/python3.5/site-packages/cmake_converter/visual_studio/solution.py", line 43, in run_conversion
project_data['subdirectory'],
File "/home/user/.local/lib/python3.5/site-packages/cmake_converter/visual_studio/solution.py", line 207, in convert_project
data_converter.convert(context)
File "/home/user/.local/lib/python3.5/site-packages/cmake_converter/data_converter.py", line 123, in convert
self.collect_data(context)
File "/home/user/.local/lib/python3.5/site-packages/cmake_converter/data_converter.py", line 49, in collect_data
context.parser.parse(context)
File "/home/user/.local/lib/python3.5/site-packages/cmake_converter/visual_studio/vcxproj/parser.py", line 113, in parse
self._parse_nodes(context, root)
File "/home/user/.local/lib/python3.5/site-packages/cmake_converter/parser.py", line 75, in _parse_nodes
node_handlers[child_node_tag](context, child_node)
File "/home/user/.local/lib/python3.5/site-packages/cmake_converter/visual_studio/vcxproj/parser.py", line 155, in __parse_item_definition_group
self._parse_nodes(context, node)
File "/home/user/.local/lib/python3.5/site-packages/cmake_converter/parser.py", line 75, in _parse_nodes
node_handlers[child_node_tag](context, child_node)
File "/home/user/.local/lib/python3.5/site-packages/cmake_converter/visual_studio/vcxproj/dependencies.py", line 289, in set_target_post_build_events
'Post build'
File "/home/user/.local/lib/python3.5/site-packages/cmake_converter/visual_studio/vcxproj/dependencies.py", line 256, in __set_target_build_events
for build_event in command.text.split('\n'):
AttributeError: 'NoneType' object has no attribute 'split'

Add a configuration file for projects (needed for conversion of solutions)

When converting solutions, each project may have specific needs, which the converter can not handle. For now, only adding code via the -a parameter can work around this problem.

A feature that could be interesting would be to have a configuration file (.cfg) next to the vcxproj concerned or in current directory. Each section will have the name of concerned project.

Example:

[foo]                                   ; name of project
cmake = ../platform/cmake/foo           ; CMakeLists destination
cmakeoutput = ${CMAKE_BINARY_DIR}/build ; Output of artefacts
dependencies =                          ; dependencies of project
include = yes                           ; Add include directories to project foo

[bar]                                   ; name of project
cmake = ../platform/cmake/bar           ; CMakeLists destination
cmakeoutput = ${CMAKE_BINARY_DIR}/build ; Output of artefacts
dependencies =                          ; dependencies of project
include = no                            ; Add include directories to project foo

Add possibility to choose C++ version

Currently, cmakeconverter only add c++11 and does not allow user to choose c++14 or c++17.

It might be useful to be able to set it when generating the CMakeLists.txt, especially for Linux.

Quick command expecting variables.

I am attempting to convert the ZFSin project into a cmake project and ran into this issue:

timothy@timothy-RVMatch-VirtualBox:~/Desktop/ZFSin-master/ZFSin$ cmake-converter -p ./ZFSin.vcxproj
INFO : Project to convert = ./ZFSin.vcxproj
WARN : CMakeLists.txt path is not set. He will be generated in current directory.
INFO : CMakeLists will be build in current directory.
Traceback (most recent call last):
  File "/usr/local/bin/cmake-converter", line 9, in <module>
    load_entry_point('cmake-converter==0.0.1', 'console_scripts', 'cmake-converter')()
  File "/usr/local/lib/python3.5/dist-packages/cmake_converter/main.py", line 104, in main
    all_data.create_data()
  File "/usr/local/lib/python3.5/dist-packages/cmake_converter/data_converter.py", line 88, in create_data
    variables.add_project_variables()
  File "/usr/local/lib/python3.5/dist-packages/cmake_converter/project_variables.py", line 98, in add_project_variables
    )[0]
IndexError: list index out of range

Interpreting path names ending with "\" (in <AdditionalIncludeDirectories> in vcxproject) results in an Error.

When converting a solution file (or a vcxproject file for that matter) paths ending with a "\" in <AdditionalIncludeDirectories> will lead to an error.

Example vcxproj producing an error:

...
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
  <ClCompile>
    ...
    <AdditionalIncludeDirectories>
      ..\foo\bar\;              <------------------------------- Line of Interest
    </AdditionalIncludeDirectories>
....

Error:

Traceback (most recent call last):
File "/usr/local/bin/cmake-converter", line 11, in
sys.exit(main())
File "/usr/local/lib/python3.7/site-packages/cmake_converter/main.py", line 152, in main
convert_solution(initial_context, os.path.abspath(args.solution))
File "/usr/local/lib/python3.7/site-packages/cmake_converter/visual_studio/solution.py", line 278, in convert_solution
results = __do_conversion(initial_context, input_data_for_converter)
File "/usr/local/lib/python3.7/site-packages/cmake_converter/visual_studio/solution.py", line 374, in __do_conversion
results.append(run_conversion(data_for_converter))
File "/usr/local/lib/python3.7/site-packages/cmake_converter/visual_studio/solution.py", line 43, in run_conversion
project_data['subdirectory'],
File "/usr/local/lib/python3.7/site-packages/cmake_converter/visual_studio/solution.py", line 207, in convert_project
data_converter.convert(context)
File "/usr/local/lib/python3.7/site-packages/cmake_converter/data_converter.py", line 123, in convert
self.collect_data(context)
File "/usr/local/lib/python3.7/site-packages/cmake_converter/data_converter.py", line 49, in collect_data
context.parser.parse(context)
File "/usr/local/lib/python3.7/site-packages/cmake_converter/visual_studio/vcxproj/parser.py", line 113, in parse
self._parse_nodes(context, root)
File "/usr/local/lib/python3.7/site-packages/cmake_converter/parser.py", line 75, in _parse_nodes
node_handlers[child_node_tag](context, child_node)
File "/usr/local/lib/python3.7/site-packages/cmake_converter/visual_studio/vcxproj/parser.py", line 155, in __parse_item_definition_group
self._parse_nodes(context, node)
File "/usr/local/lib/python3.7/site-packages/cmake_converter/parser.py", line 75, in _parse_nodes
node_handlers[child_node_tag](context, child_node)
File "/usr/local/lib/python3.7/site-packages/cmake_converter/parser.py", line 75, in _parse_nodes
node_handlers[child_node_tag](context, child_node)
File "/usr/local/lib/python3.7/site-packages/cmake_converter/visual_studio/vcxproj/dependencies.py", line 41, in set_include_dirs
incl_dir.text, context.current_setting, context
File "/usr/local/lib/python3.7/site-packages/cmake_converter/dependencies.py", line 94, in set_additional_include_directories
i = normalize_path(context, working_path, i)
File "/usr/local/lib/python3.7/site-packages/cmake_converter/utils.py", line 412, in normalize_path
actual_path_name = get_actual_filename(context, joined_path)
File "/usr/local/lib/python3.7/site-packages/cmake_converter/utils.py", line 385, in get_actual_filename
test_name += ["%s[%s]" % (d[:-1], d[-1])] <------------------------------- Line of Interest
IndexError: string index out of range

Fix (?):

in /usr/local/lib/python3.7/site-packages/cmake_converter/utils.py

before line 385 i added

if dirs[-1] == '':
    del dirs[-1]

to remove the last directory if it is '' (entry is created because of

..\directory\; instead of ..\directory; in vcxproj)

Colours broken on Windows

I just discovered this cool project; contrary to what the README says, the generated CMakeLists.txt actually worked for me in a plain C-project (except for a CMAKE_VS_PLATFORM_NAME "x64" that I replaced with "Win32").

Anyway, the colours in a Windows console gives me only ANSI sequences. Like this after changing usage = into:

from cmake_converter.utils import WARN, ENDC
usage = WARN + "cmake-converter -p <vcxproj> [-c | -a | -D | -O | -i | -std | -dry | -silent | -j]" + ENDC

a cmake-converter.exe -h gives:

usage: โ†[33mโ†[1mcmake-converter -p <vcxproj> [-c | -a | -D | -O | -i | -std | -dry | -silent | -j]โ†[39mโ†[0m

I have no TERM in my environment. And colorama (v.0.4.1) works fine in other Python2/3 programs.

Escaping parentheses in compile_definition

when passing some preprocessor definition like IMGUI_API=__declspec(dllexport), cmake complains:

WARNING: Function-style preprocessor definitions may not be passed on the compiler command line because many compilers do not support it.
CMake is dropping a preprocessor definition: (
Consider defining the macro in a (configured) header file.

We need to escape the parentheses : IMGUI_API=__declspec\(dllexport\).

Add support for C# Projects

Since version 3.8, CMake supports C# projects. It would be nice to be able to organize complex hierarchies of solutions and projects via CMake instead of separate Visual Studio solutions.

Sometimes cmake_path is instance of _io.TextIOWrapper in get_cmake_lists function

Sometimes, python raise a TypeError in get_cmake_lists. We have to try to catch this error or adapt conversion of data if needed:

Traceback (most recent call last):
  File "/home/mea/workspace/repos/cmake-converter/cmake_converter/main.py", line 328, in <module>
    main()
  File "/home/mea/workspace/repos/cmake-converter/cmake_converter/main.py", line 241, in main
    convert_project(context, project_abs, subdirectory)
  File "/home/mea/workspace/repos/cmake-converter/cmake_converter/main.py", line 59, in convert_project
    data_converter.convert()
  File "/home/mea/workspace/repos/cmake-converter/cmake_converter/data_converter.py", line 127, in convert
    cmake_file = get_cmake_lists(self.context['cmake'])
  File "/home/mea/workspace/repos/cmake-converter/cmake_converter/data_files.py", line 182, in get_cmake_lists
    if cmake_path[-1:] == '/' or cmake_path[-1:] == '\\':
TypeError: '_io.TextIOWrapper' object is not subscriptable

Function in data_files.py

Wrong and empty variables at TargetName section in generated CMakeLists.txt

The project I work on has a vcxproj file where
<RootNamespace>ProjName</RootNamespace>
and
<TargetName>FOO</TargetName>
and
<OutputFile>$(OutDir)$(TargetName)$(TargetExt)</OutputFile>

The conversion then yields:

string(CONCAT TARGET_NAME
          $<$<CONFIG:Debug>:${OUT_DIR}${TARGET_NAME}$ENV{TargetExt}>
        $<$<CONFIG:Release>:${OUT_DIR}${TARGET_NAME}$ENV{TargetExt}>
        $<$<NOT:$<OR:$<CONFIG:Debug>,$<CONFIG:Release>>>:${PROJECT_NAME}>
...
set_target_properties(${PROJECT_NAME} PROPERTIES OUTPUT_NAME ${TARGET_NAME})

Which creates the following error in CMake:

CMake Error at total/ProjName/CMakeLists.txt:31 (add_executable):
Target 'ProjName' OUTPUT_NAME depends on itself.

is this behavior expected?

(BTW. I hope I am not going on anyone's nerves, I am still new to github as well as testing/contributing to open-source projects)

Env variable can not be resolved

In projects, we define and use a system wise environment variable. But it can not be resolved by cmakeconverter properly.

For example, we define an environment variable CSE_ROOT. In vcxproj file it refers as $(CSE_ROOT) in AdditionalIncludeDirectories. But cmakeconverter can not recognize it during converting.

"-p option" :: if configuration_data not in context.sln_configurations_map: TypeError: argument of type 'NoneType' is not iterable

I am trying to convert visual studio project to cmake.
This is the output I am getting

C:\Users\uia78398\Documents\CMake_Project\aupprocessor\aupprocessor_cmake>cmake-
converter -p ../aupprocessor.vcxproj
0.000000 โ†[32mโ†[1mprocesses count = 8โ†[39mโ†[0m
0.015601 INFO : Initialization data for conversion of project ../aupprocessor.vcxproj
Traceback (most recent call last):
File "c:\users\uia78398\appdata\local\programs\python\python35\lib\runpy.py",
line 170, in _run_module_as_main
"main", mod_spec)
File "c:\users\uia78398\appdata\local\programs\python\python35\lib\runpy.py",
line 85, in run_code
exec(code, run_globals)
File "C:\Users\uia78398\AppData\Local\Programs\Python\Python35\Scripts\cmake-c
onverter.exe_main
.py", line 9, in
File "c:\users\uia78398\appdata\local\programs\python\python35\lib\site-packag
es\cmake_converter\main.py", line 137, in main
convert_project(initial_context, args.project, cmake_lists_path)
File "c:\users\uia78398\appdata\local\programs\python\python35\lib\site-packag
es\cmake_converter\visual_studio\solution.py", line 152, in convert_project
VCXContextInitializer(context, xml_project_path, cmake_lists_destination_pat
h)
File "c:\users\uia78398\appdata\local\programs\python\python35\lib\site-packag
es\cmake_converter\visual_studio\vcxproj\context.py", line 36, in init
ContextInitializer.init(self, context, xml_project_path, cmake_lists_des
tination_path)
File "c:\users\uia78398\appdata\local\programs\python\python35\lib\site-packag
es\cmake_converter\context.py", line 85, in init
self.define_settings(context)
File "c:\users\uia78398\appdata\local\programs\python\python35\lib\site-packag
es\cmake_converter\visual_studio\vcxproj\context.py", line 84, in define_setting
s
if configuration_data not in context.sln_configurations_map:
TypeError: argument of type 'NoneType' is not iterable

what should I do to solve this issue
i am using
Python 3.5
VS 15

UnicodeDecodeError: 'ascii' codec can't decode byte 0x80

When using cmake-converter on Linux (Redhat 7) under Anaconda 3, the following error has been generated:

_Traceback (most recent call last):
File "/anaconda3/bin/cmake-converter", line 11, in
sys.exit(main())
File "
/anaconda3/lib/python3.6/site-packages/cmake_converter/main.py", line 152, in main
convert_solution(initial_context, os.path.abspath(args.solution))
File "/anaconda3/lib/python3.6/site-packages/cmake_converter/visual_studio/solution.py", line 296, in convert_solution
results.append(run_conversion(threads_data))
File "
/anaconda3/lib/python3.6/site-packages/cmake_converter/visual_studio/solution.py", line 46, in run_conversion
project_data['subdirectory'],
File "/anaconda3/lib/python3.6/site-packages/cmake_converter/visual_studio/solution.py", line 199, in convert_project
data_converter.convert(context)
File "
/anaconda3/lib/python3.6/site-packages/cmake_converter/data_converter.py", line 124, in convert
self.collect_data(context)
File "/anaconda3/lib/python3.6/site-packages/cmake_converter/data_converter.py", line 48, in collect_data
context.parser.parse(context)
File "
/anaconda3/lib/python3.6/site-packages/cmake_converter/visual_studio/vfproj/parser.py", line 153, in parse
self._parse_nodes(context, root)
File "/anaconda3/lib/python3.6/site-packages/cmake_converter/parser.py", line 75, in _parse_nodes
node_handlers[child_node_tag](context, child_node)
File "
/anaconda3/lib/python3.6/site-packages/cmake_converter/visual_studio/vfproj/parser.py", line 245, in __parse_files
self._parse_nodes(context, filter_node)
File "/anaconda3/lib/python3.6/site-packages/cmake_converter/parser.py", line 75, in _parse_nodes
node_handlers[child_node_tag](context, child_node)
File "
/anaconda3/lib/python3.6/site-packages/cmake_converter/visual_studio/vfproj/parser.py", line 263, in __parse_filter
self.parse_nodes(context, filter_node)
File "/anaconda3/lib/python3.6/site-packages/cmake_converter/parser.py", line 69, in _parse_nodes
self._parse_attributes(context, child_node)
File "
/anaconda3/lib/python3.6/site-packages/cmake_converter/parser.py", line 89, in_arse_attributes
attributes_handlers[node_key](context, attr, node.get(attr), node)
File "/anaconda3/lib/python3.6/site-packages/cmake_converter/visual_studio/vfproj/parser.py", line 257, in __parse_file_relative_path
source_group
File "
/anaconda3/lib/python3.6/site-packages/cmake_converter/project_files.py", line 102, in add_file_from_node
self.file_lists_for_include_paths)
File "/anaconda3/lib/python3.6/site-packages/cmake_converter/visual_studio/vfproj/project_files.py", line 39, in include_directive_case_check
file_text = file.read()
File "
/anaconda3/lib/python3.6/encodings/ascii.py", line 26, in decode
return codecs.ascii_decode(input, self.errors)[0]
UnicodeDecodeError: 'ascii' codec can't decode byte 0x80 in position 10472: ordinal not in range(128)

after changing the Line 38 in cmake_converter/visual_studio/vfproject/project_files.py from "file = open(file_abs_path, 'r')" to "file = open(file_abs_path, 'r', errors="ignore")", the error is gone. I'm not sure if this causes other problems.

On Windows, it doesn't have this error.

AttributeError when convert project .vcxproj

Helllo everyone.

I have a problem when trying convert my project .vcxproj to CMake.

The project structure is:

- project/
      - project.sln
      - project.win/
         -  bin/
          - libs/
          - main.cpp
          - project.linux.vcxproj
          - project.linux.vcxproj.user
          - project.win.vcxproj
          - project.win.vcxproj.user
          - obj/
          - src/

I need convert the project.linux.vcxproj to CMake and when try:

 /c/repos/nptunnel.bridge.v2 (master)
$ cmake-converter -p project.win/project.linux.vcxproj

I have follow:

INFO : Project to convert = project.win/project.linux.vcxproj
WARN : CMakeLists.txt path is not set. He will be generated in current directory.
INFO : CMakeLists will be build in current directory.
WARN : No Output Debug define. Use [Debug/bin] by default !
WARN : No Output Release define. Use [Release/bin] by default !
INFO : C++ Extensions found: ['cpp']
INFO : Include Directories is not set.
INFO : No link needed.
OK   : Warning : TurnOffAllWarnings
INFO : No WholeProgramOptimization for Debug
INFO : No WholeProgramOptimization for Release
INFO : No UseDebugLibrairies for Debug
INFO : No UseDebugLibrairies for Release
INFO : No RuntimeLibrary for Debug
INFO : No RuntimeLibrary for Release
INFO : No Optimization for Debug
INFO : No Optimization for Release
INFO : No IntrinsicFunctions for Debug
INFO : No IntrinsicFunctions for Release
INFO : No RuntimeTypeInfo for Debug
INFO : No RuntimeTypeInfo for Release
INFO : No FunctionLevelLinking for release.
INFO : No GenerateDebugInformation for debug.
INFO : No GenerateDebugInformation for release.
OK   : ExceptionHandling for debug.
OK   : ExceptionHandling for release.
OK   : Debug   FLAGS found =  /Ws /EHsc
OK   : Release FLAGS found =  /Ws /EHsc
INFO : No C++ std version specified. CMake will use "c++11" by default.
Traceback (most recent call last):
  File "C:\Users\rafae\AppData\Local\Programs\Python\Python37-32\Scripts\cmake-converter-script.py", line 11, in <module>
    load_entry_point('cmake-converter==1.1.0', 'console_scripts', 'cmake-converter')()
  File "c:\users\rafae\appdata\local\programs\python\python37-32\lib\site-packages\cmake_converter\main.py", line 113, in main
    data_converter.create_data()
  File "c:\users\rafae\appdata\local\programs\python\python37-32\lib\site-packages\cmake_converter\data_converter.py", line 122, in create_data
    files.add_target_artefact()
  File "c:\users\rafae\appdata\local\programs\python\python37-32\lib\site-packages\cmake_converter\project_files.py", line 142, in add_target_artefact
    if configurationtype.text == 'DynamicLibrary':
AttributeError: 'NoneType' object has no attribute 'text'

convert backslash to forwardslash in path for target_link_libraries on windows

if backslashes are used in "Linker"->"Input"->"Additional Dependencies", e.g.
"$(ProjectDir)..\release\foo.lib"
they will not be converted to forward slashes after conversion, i.e.

"target_link_libraries(${PROJECT_NAME} $(ProjectDir)..\release\foo.lib)"

This will cause cmake to have error
"Invalid escape sequence ."

expected behavior: The converter should convert those back slashes to forward slashes.

Set proper PDB_NAME. Can't be implemented until GenEx support

Use
https://cmake.org/cmake/help/v3.8/prop_tgt/COMPILE_PDB_OUTPUT_DIRECTORY_CONFIG.html
https://cmake.org/cmake/help/v3.8/prop_tgt/COMPILE_PDB_NAME_CONFIG.html
for /Fd. But no support of generator expressions yet. Can't be used.

Use
https://cmake.org/cmake/help/v3.12/prop_tgt/PDB_OUTPUT_DIRECTORY.html
https://cmake.org/cmake/help/v3.8/prop_tgt/PDB_NAME.html
for /PDB. OK with generator expressions since CMake 3.12.
For example:
set_target_properties(${PROJECT_NAME} PROPERTIES PDB_OUTPUT_DIRECTORY "${OUT_DIR}/pdb")

Calling cmake-converter in project folder containing Main.vcxproj expects CMakeLists.txt/CMakeLists.txt to exist

When running
cd project
cmake-converter -p Main.vcxproj -j 1
(which was installed from source with "pip3 install .")
in bash of python docker image (python:latest) any .vcxproj produces:

FileNotFoundError: [Errno 2] No such file or directory: 'CMakeLists.txt/CMakeLists.txt'

It expects existance of following folder structure:
project/
โ””โ”€โ”€ CMakeLists.txt
โ”‚ โ””โ”€โ”€ CMakeLists.txt
โ””โ”€โ”€ Main.vcxproj

So
mkdir CMakeLists.txt && touch CMakeLists.txt
has to be done before invocation for conversion to work.

Keep props files order

The article Working with Project Properties says:

All the property sheets are imported automatically into the project's "master" property sheet (ms.cpp.props) and are evaluated in the order they appear in Property Manager. You can move them to change the evaluation order. Property sheets that are evaluated later will override the values in previously-evaluated sheets.

In a *.vcxproj file they are placed in the order of evaluation. But seems like cmakeconverter places them in alphabetical order.

Found 3 issues when there are non-existent Items in the VCXProj.

  1. PreprocessorDefinitions,(under Globals) if this is missing index [0] does not exist. Check for that.
INFO : CMakeLists will be build in current directory.
INFO : No Output Debug define.
INFO : No Output Release define.
Traceback (most recent call last):
  File "C:\Software\cmakeconverter-master\cmakeconverter.py", line 84, in <module>
    parse_argument()
  File "C:\Software\cmakeconverter-master\cmakeconverter.py", line 81, in parse_argument
    all_data.create_data()
  File "C:\Software\cmakeconverter-master\convertdata.py", line 27, in create_data
    macros.write_macro(self.data)
  File "C:\Software\cmakeconverter-master\macro.py", line 13, in write_macro
    preprocessor = tree.xpath('//ns:PreprocessorDefinitions', namespaces=ns)[0]
IndexError: list index out of range
  1. If PreprocessorDefinitions Exists, but the xml tag is blank, you get this because it can't split whats blank. Check for that.
C:\Software\cmakeconverter-master>python "C:\Software\cmakeconverter-master\cmakeconverter.py" -p "C:\UDefrag\ultradefrag-src\src\minimal_vc15\minimal_vc15.vcxproj"
INFO : Project to convert = C:\UDefrag\ultradefrag-src\src\minimal_vc15\minimal_vc15.vcxproj
INFO : CMakeLists will be build in current directory.
INFO : No Output Debug define.
INFO : No Output Release define.
Traceback (most recent call last):
  File "C:\Software\cmakeconverter-master\cmakeconverter.py", line 84, in <module>
    parse_argument()
  File "C:\Software\cmakeconverter-master\cmakeconverter.py", line 81, in parse_argument
    all_data.create_data()
  File "C:\Software\cmakeconverter-master\convertdata.py", line 27, in create_data
    macros.write_macro(self.data)
  File "C:\Software\cmakeconverter-master\macro.py", line 16, in write_macro
    for preproc in preprocessor.text.split(";"):
AttributeError: 'NoneType' object has no attribute 'split'
  1. RootNamespace under Globals. Check gracefully and emit a warning/error message.
C:\Software\cmakeconverter-master>python "C:\Software\cmakeconverter-master\cmakeconverter.py" -p "C:\UDefrag\ultradefrag-src\src\wxgui\wxgui.vcxproj"
INFO : Project to convert = C:\UDefrag\ultradefrag-src\src\wxgui\wxgui.vcxproj
INFO : CMakeLists will be build in current directory.
Traceback (most recent call last):
  File "C:\Software\cmakeconverter-master\cmakeconverter.py", line 84, in <module>
    parse_argument()
  File "C:\Software\cmakeconverter-master\cmakeconverter.py", line 81, in parse_argument
    all_data.create_data()
  File "C:\Software\cmakeconverter-master\convertdata.py", line 19, in create_data
    variables.define_variable()
  File "C:\Software\cmakeconverter-master\projectvariables.py", line 59, in define_variable
    projectname = self.tree.xpath('//ns:RootNamespace', namespaces=self.ns)[0]
IndexError: list index out of range

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.