Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No support of VS Qt projects #121

Open
bLuka opened this issue Aug 24, 2020 · 4 comments
Open

No support of VS Qt projects #121

bLuka opened this issue Aug 24, 2020 · 4 comments

Comments

@bLuka
Copy link

bLuka commented Aug 24, 2020

Description

  1. On Qt projects, parsing some custom build conditions is failing
  2. cmakeconverter version 2.1.0
  3. You'll find relevant logs below:
0.000038 Converter runs in verbose mode
0.000059 processes count = 1
0.000065 warnings level = 2
0.000075 INFO : ------- Started parsing solution [solution folder]/Client.sln -------
0.000439 INFO : Version of solution is 12.00
0.000447 INFO : Start parsing projects info (Project .. EndProject)
0.000688 INFO :     Found project "Client/Client.vcxproj" with {DCF6E4F7-3F82-4FC8-AB84-DB8CA2B4AC21}
0.000908 INFO :     Found project "SomeLib/SomeLib.vcxproj" with {91569819-112E-4D7E-81B2-C6D85D54E526}
0.000920 INFO :     Found project "ClientTests/ClientTests.vcxproj" with {AA174CD4-0F4D-4867-809B-7978093C6F9D}
0.000928 INFO :     Found project "extern/gtest/build/googletest/gtest.vcxproj" with {F44378F4-B5DD-3793-BA76-4DC6B29EFC7A}
0.000933 INFO : Start parsing GlobalSection(SolutionConfigurationPlatforms) = preSolution
0.001239 INFO :     Found sln setting "Debug|x64"
0.001250 INFO :     Found sln setting "Debug|x86"
0.001254 WARN L1 : Solution architecture is x86 and may be mapped onto Win32 at projects.To avoid problems rename x86 -> Win32.
0.001261 INFO :     Found sln setting "Release|x64"
0.001267 INFO :     Found sln setting "Release|x86"
0.001271 WARN L1 : Solution architecture is x86 and may be mapped onto Win32 at projects.To avoid problems rename x86 -> Win32.
0.001281 INFO : Start parsing GlobalSection(ProjectConfigurationPlatforms) = postSolution (Mapping sln-setting -> project-settong)
0.001706 INFO :     "Debug|x64" -> "Debug|x64" for Client
0.001719 INFO :     "Debug|x86" -> "Debug|x64" for Client
0.001726 INFO :     "Release|x64" -> "Release|x64" for Client
0.001734 INFO :     "Release|x86" -> "Release|x64" for Client
0.001744 INFO :     "Debug|x64" -> "Debug|x64" for SomeLib
0.001754 INFO :     "Debug|x86" -> "Debug|x64" for SomeLib
0.001765 INFO :     "Release|x64" -> "Release|x64" for SomeLib
0.001776 INFO :     "Release|x86" -> "Release|x64" for SomeLib
0.001787 INFO :     "Debug|x64" -> "Debug|x64" for ClientTests
0.001795 INFO :     "Debug|x86" -> "Debug|x64" for ClientTests
0.001805 INFO :     "Release|x64" -> "Release|x64" for ClientTests
0.001817 INFO :     "Release|x86" -> "Release|x64" for ClientTests
0.001824 INFO :     "Debug|x64" -> "Debug|x64" for gtest
0.001835 INFO :     "Debug|x86" -> "Debug|x64" for gtest
0.001843 INFO :     "Release|x64" -> "Release|x64" for gtest
0.001852 INFO :     "Release|x86" -> "Release|x64" for gtest
0.002106 INFO : ------ Finished parsing solution [solution folder]/Client.sln -------
0.002512 1> INFO : ------ Starting 1 -------
0.002523 1> INFO : Initialization data for conversion of project [solution folder]/Client.sln
0.002859 1> INFO : == start making default flags ==
0.003024 1> INFO : == end making default flags ==
0.003044 1> Conversion started: Project Client
0.003062 1> INFO : Collecting data for project [solution folder]/Client/Client.vcxproj
0.018485 1> INFO : Parsing... line 3 node ItemGroup attrib {'Label': 'ProjectConfigurations'}
0.018579 1> INFO : Parsing... line 4 node ProjectConfiguration attrib {'Include': 'Debug|x64'}
0.018639 1> INFO : Parsing... line 8 node ProjectConfiguration attrib {'Include': 'Release|x64'}
0.018687 1> INFO : Parsing... line 13 node PropertyGroup attrib {'Label': 'Globals'}
0.018719 1> INFO : Parsing... line 14 node ProjectGuid attrib {}
0.018744 1> INFO : Parsing... line 15 node Keyword attrib {}
0.018769 1> INFO : Parsing... line 16 node WindowsTargetPlatformVersion attrib {}
0.018794 1> INFO : Parsing... line 17 node QtMsBuild attrib {'Condition': "'$(QtMsBuild)'=='' OR !Exists('$(QtMsBuild)\\qt.targets')"}
Traceback (most recent call last):
  File "/usr/local/bin/cmake-converter", line 8, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.8/site-packages/cmake_converter/main.py", line 144, in main
    converter.convert_solution(project_context, os.path.abspath(args.solution))
  File "/usr/local/lib/python3.8/site-packages/cmake_converter/visual_studio/solution.py", line 331, in convert_solution
    results = self.do_conversion(project_context, input_data_for_converter)
  File "/usr/local/lib/python3.8/site-packages/cmake_converter/data_converter.py", line 301, in do_conversion
    results.append(self.run_conversion(data_for_converter))
  File "/usr/local/lib/python3.8/site-packages/cmake_converter/data_converter.py", line 266, in run_conversion
    converted = self.convert_project(
  File "/usr/local/lib/python3.8/site-packages/cmake_converter/data_converter.py", line 235, in convert_project
    self.collect_data(context)
  File "/usr/local/lib/python3.8/site-packages/cmake_converter/data_converter.py", line 53, in collect_data
    context.parser.parse(context)
  File "/usr/local/lib/python3.8/site-packages/cmake_converter/visual_studio/vcxproj/parser.py", line 145, in parse
    self._parse_nodes(context, root)
  File "/usr/local/lib/python3.8/site-packages/cmake_converter/parser.py", line 101, in _parse_nodes
    node_handlers[child_node_tag](context, child_node)
  File "/usr/local/lib/python3.8/site-packages/cmake_converter/visual_studio/vcxproj/parser.py", line 190, in __parse_property_group
    self._parse_nodes(context, node)
  File "/usr/local/lib/python3.8/site-packages/cmake_converter/parser.py", line 92, in _parse_nodes
    self._parse_attributes(context, child_node)
  File "/usr/local/lib/python3.8/site-packages/cmake_converter/parser.py", line 119, in _parse_attributes
    attributes_handlers[attr](context, attr, node.get(attr), node)
  File "/usr/local/lib/python3.8/site-packages/cmake_converter/visual_studio/vcxproj/parser.py", line 291, in __parse_condition
    cmake_setting = make_cmake_configuration(context, found.group(1))
  File "/usr/local/lib/python3.8/site-packages/cmake_converter/utils.py", line 508, in make_cmake_configuration
    return "{}|{}".format(*sln_conf_arch)
IndexError: Replacement index 1 out of range for positional args tuple
  1. I cannot attach the full vcxproj, but here's the culprit: <ImportGroup Condition="Exists('$(QtMsBuild)\qt.targets')">

To Reproduce
Steps to reproduce the behavior:

  1. Create any Qt VC++ Project
  2. Try converting it with cmakeconverter

Expected behavior
Hopefully, a fully working converter handling Qt projects, but I know even though we manage to fix this issue, some other stuff like Qt MOC will be troublesome.

A workaround would be to have it ignore the Qt build part of the related projects, and put placeholders in the CMakeLists to make it easy filling what's missing by hand.
Does that sound easy to do?

Additional context
Working on a VC++ Qt solution I'm willing to be able to cross-build through a Linux system.
Cross-platform and Linux build would be for later.

@pavelliavonau
Copy link
Owner

It's hard to support VS Qt solutions because of many Qt specific things there.
You should investigate by yourself why does it fail and fix input files.
I can add check for Qt solution and skip conversion in that case but it's better to let user try and see this crash to my mind.

It has been asked for full verbose logs. Have you missed it?

@pavelliavonau pavelliavonau changed the title Issue with Qt projects No support of VS Qt projects Aug 24, 2020
@bLuka
Copy link
Author

bLuka commented Aug 24, 2020

Thanks for fast feedback!
Yup, my mistake for full logs. I just edited.

About Qt, there's only a few steps in the build process requiring Qt, so I hope we could have a “partial CMakeLists.txt” regarding Qt projects, only containing standard build processes, and stuff like comments regarding manual Qt implementation, but I have no idea how easy it is to do.

Otherwise, I'll just have to write the whole CMakeLists.txt by hand it sounds like.

@pavelliavonau
Copy link
Owner

I would not like to implement partial solution. It's not so easy to support Qt and all versions of it at VS solutions. Also I have no setup of Qt on my machine to develop that. If you propose PR with our idea I could consider to apply your work. Your solution is small and you can easily change some lines there to achieve your "partial CMakeLists.txt". Verbose mode will help you.

@mpaperno
Copy link

The error quoted here is simply a result of an overly-permissive regex here: https://github.com/pavelliavonau/cmakeconverter/blob/develop/cmake_converter/visual_studio/vcxproj/parser.py#L287

Changing it to r".*=='(.*\|.*)'" fixes the issue and allows the conversion to continue.

Now whether it produces a ready-to-go Qt build is another story. At least some Qt bits need to be added manually, it seems like. But it's a nice start, thanks for that!

As for adding further Qt support, IMHO don't bother at this point... Qt project has switched to CMake so sooner or later seems like their Qt VS Tools extension will need to support exporting to CMake instead of qmake. 🤷🏼‍♂️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants