pavelliavonau/cmakeconverter

KeyError with solution generated by premake. (Premake bug?)

SupremeDeity opened this issue · 5 comments

I am working on a Windows 10, VS2019, C++ Project.

The Solution Has 2 Projects PersonalCUtils and TestUtil. PersonalCUtil is a StaticLibrary (.lib) and TestUtil is ConsoleApp(.exe). i create my solution and project files with the premake5.lua attached.

premake5.txt

When i run cmake-converter -s PersonalCUtils.sln. I get this:

0.000000 processes count = 4
0.000999 warnings level = 2
0.003996 WARN : not found F:\dev\PersonalCUtils\PersonalCUtils/CMakeLists.txt
0.004995 WARN : not found F:\dev\PersonalCUtils/CMakeLists.txt


0.357666 1> Conversion started: Project PersonalCUtils
0.369657 2> Conversion started: Project TestUtil
0.371655 2> WARN : file or path "F:\dev\PersonalCUtils\TestUtil/TestUtil.vcxproj.filters" not found.
0.391635 2> Conversion done   : Project TestUtil (3 warnings)
multiprocessing.pool.RemoteTraceback:
"""
Traceback (most recent call last):
  File "f:\python\anaconda\lib\multiprocessing\pool.py", line 121, in worker
    result = (True, func(*args, **kwds))
  File "f:\python\anaconda\lib\multiprocessing\pool.py", line 44, in mapstar
    return list(map(*args))
  File "f:\python\anaconda\lib\site-packages\cmake_converter\data_converter.py", line 278, in run_conversion
    project_data['subdirectory'],
  File "f:\python\anaconda\lib\site-packages\cmake_converter\data_converter.py", line 245, in convert_project
    self.collect_data(context)
  File "f:\python\anaconda\lib\site-packages\cmake_converter\data_converter.py", line 54, in collect_data
    context.parser.parse(context)
  File "f:\python\anaconda\lib\site-packages\cmake_converter\visual_studio\vcxproj\parser.py", line 140, in parse
    self._parse_nodes(context, root)
  File "f:\python\anaconda\lib\site-packages\cmake_converter\parser.py", line 86, in _parse_nodes
    node_handlers[child_node_tag](context, child_node)
  File "f:\python\anaconda\lib\site-packages\cmake_converter\visual_studio\vcxproj\parser.py", line 148, in __parse_item_group
    self._parse_nodes(context, node)
  File "f:\python\anaconda\lib\site-packages\cmake_converter\parser.py", line 80, in _parse_nodes
    self._parse_attributes(context, child_node)
  File "f:\python\anaconda\lib\site-packages\cmake_converter\parser.py", line 100, in _parse_attributes
    attributes_handlers[node_key](context, node_key, node.get(attr), node)
  File "f:\python\anaconda\lib\site-packages\cmake_converter\visual_studio\vcxproj\parser.py", line 206, in __parse_cl_compile_include_attr
    self.__parse_file_nodes(context, context.sources, cl_node, 'Sources')
  File "f:\python\anaconda\lib\site-packages\cmake_converter\visual_studio\vcxproj\parser.py", line 233, in __parse_file_nodes
    self._parse_nodes(file_context, file_node)
  File "f:\python\anaconda\lib\site-packages\cmake_converter\parser.py", line 86, in _parse_nodes
    node_handlers[child_node_tag](context, child_node)
  File "f:\python\anaconda\lib\site-packages\cmake_converter\visual_studio\vcxproj\flags.py", line 289, in set_flag
    self.flags[context.current_setting][flag_name] = {}  # reset default values
KeyError: ('Release', 'Win32')
"""

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "f:\python\anaconda\lib\runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "f:\python\anaconda\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "F:\Python\Anaconda\Scripts\cmake-converter.exe\__main__.py", line 9, in <module>
  File "f:\python\anaconda\lib\site-packages\cmake_converter\main.py", line 126, in main
    converter.convert_solution(root_context, os.path.abspath(args.solution))
  File "f:\python\anaconda\lib\site-packages\cmake_converter\visual_studio\solution.py", line 281, in convert_solution
    results = self.do_conversion(root_context, input_data_for_converter)
  File "f:\python\anaconda\lib\site-packages\cmake_converter\data_converter.py", line 307, in do_conversion
    results = pool.map(self.run_conversion, input_converter_data_list)
  File "f:\python\anaconda\lib\multiprocessing\pool.py", line 268, in map
    return self._map_async(func, iterable, mapstar, chunksize).get()
  File "f:\python\anaconda\lib\multiprocessing\pool.py", line 657, in get
    raise self._value
KeyError: ('Release', 'Win32')

There is this weird KeyError Message at the end aswell. if i remove the Release Configuration, it starts to give me error on the debug on. vice versa with the platform. Also it only creates a CMakeLists.txt for the TestUtil(exe) and not one for the PersonalCUtil(lib) or the root directory.

The cause might be related to:

  1. Vs2019 format. I tested widely only with 2017.
  2. Mapping of configurations is wrong. Check configs of sln and vcxproj files.

Try to look at warnings, and increase warning level.

If no solution - provide an example to me for reproducing on my side.

unfortunately i dont have vs2017 anymore.

This seems to be a problem of me using premake to create solution files ( because that is what i used first.)

This is the repo:
Repo
this contains premake5.lua to create the project, but i guess i either only use premake or cmake next time.

Your link is broken.

I'm not going to support custom generators of solution. Likely it's missing some info. You can investigate with native vs2019 by yourself, otherwise I'll close this issue as invalid.

I forgot the repository was private. I have checked and this indeed seems like a issue related with premake's solution file generation so i will close this issue.

@SupremeDeity, check fix from last develop, please