52

I'm developing cross-platform c++ project. The original idea is to work with msvc2010 and later compile for other systems with the help of CMake and Hudson. It doesn't seem to be convenient manually change CMake files after changes in studio settings.

So, what’s the easiest way: to write parser for vcxproj and vcxproj.filters, or there is another good solution?

tikkerey
  • 633
  • 1
  • 6
  • 7

3 Answers3

55

It might be useful, from time to time, to do this type of conversion, say for porting. On my travels I've found the following, in no particular order:

Specifically for VS to CMake/GYP:

  • vcproj2cmake
  • vcxproj2cmake (not a typo!)
  • gypify.py is a .sln/solution-reading Gyp file generator. Gyp is a Cmake alternative, currently being used by the Chromium project (base for Google's Chrome browser). Gyp will output Makefile, Visual Studio or XCode build files (see Gyp's '-f [make|scons|msvc|xcode]' switch). This Python script is quite promising, I'm hoping to modify it soon to correctly specify header-containing folders for gcc's '-I' include parameter.

Other Cmake/Make-related conversion tools:

  • Make It So Converts Visual Studio solutions to Linux gcc makefiles
  • sln2mak C# project
  • sln2mak Perl script
  • GUCEF Project includes the ProjectGenerator tool, for Cmake
  • gencmake (ruby) – KDE Project
  • 'pbtomake' says it can convert XCode xcodeproj/pbproj files to Makefiles (maybe outdated)

Cheers

Rich

Big Rich
  • 5,364
  • 37
  • 59
  • gypify didnt work for me ... it created a .gyp files that doesnt list any source files – Aviad Rozenhek May 22 '12 at 14:14
  • @ Aviad Rozenhek, briefly, I used 'gypify.py --sln=' then created my build file out of Gyp via 'gyp ./converted-vs20xx-sln.gyp --toplevel-dir=/path/to/project/root/ --depth=. -f [make|or|other|build] --generator-output=./'. Hope that helps. – Big Rich Jun 14 '12 at 10:25
  • Does gyp really support Scons? Thats wild. – JonnyRo Jun 26 '13 at 21:58
  • I currently develop a script for cpp project : [cmakeconverter](https://github.com/algorys/cmakeconverter) if you are interested. It converts `.vcxproj` to `CMakeLists.txt`. – Algorys Jun 01 '16 at 07:47
14

You're coming at it backwards -- set up all your CMakeLists.txt and then generate the MSVC project from it.

It shouldn't be hard or time-consuming. Basically you just need to say which directories to look into, declare your include paths, collect your *.cpps for each library with a glob expression, and declare your dependencies.

If you have to set up anything else, then your project probably isn't very portable :-/

spraff
  • 29,265
  • 19
  • 105
  • 197
  • 1
    I know about that option, but idea was to replace manual edion of CMake files with well known optinons in studio. – tikkerey Jul 11 '11 at 11:54
  • can you be more specific about which settings/options you are changing? – spraff Jul 11 '11 at 11:56
  • 15
    The point is that the cmake generated MSBuild projects and VS Solutions are unusable, if your main and primary tool is Visual Studio, i.e. if you create and configure projects, solutions and dependencies using VS first. If you want to support multiple platforms/build environments the only choice appears to be to give up the comfort of VS and dive into manually maintaining plenty of text files all the time. A tool which does this "inverse generation" would be indeed invaluable... – Paul Michalik Nov 17 '12 at 09:23
  • 4
    Agreed, the whole point of CMake is to specify the project as a build system agnostic list of libraries, programs, custom build steps... Then have cmake output a build system dependant project for you on demand. I think the conversion tools mentioned above are nice, but only if you are doing an initial (and one time) conversion of a legacy visual studio project to CMake, and even then I would still hand edit it. – JonnyRo Jun 26 '13 at 21:56
  • 4
    For anything but a small project, recreating all that build logic by hand from the VS project is going to be tedious and repetitive. Tedious and repetitive things should be done by a computer. When a human does them, it becomes error prone. – legalize Apr 27 '15 at 22:54
  • If you're aiming to be cross-platform, you need to do it from the start, or you get these sorts of headaches. – spraff May 02 '15 at 20:04
  • Sometimes, with 3rd party libs, one doesn't have much choice if you want to hit the ground running .... – UKMonkey Dec 07 '16 at 15:58
3

The best tool for this purprose is cmake-converter