Generating Microsoft Visual Studio Project using CMake

Compiling C/C++ libraries with CMake for generating Visual Studio projects is a pain. Alot of times compiling with CMake goes wrong or doesn't work at all. The documentation for compilation is not adequate & doesn't cover most of the scenario's for different compiler options, which CMake uses to generate the project from the source code.


My experience with CMake wasn't good either. I tried to compile a library & got all sorts of weird errors in configuring & generating the project. However the following steps worked for me like a charm.

I am using Microsoft Visual Studio 2010 express, CMake 2.8 & Windows 7 however these settings should work on other versions of Windows & Visual Studios.

CMake won't work with Microsoft Visual Studio 2010 Ultimate Edition for some unknown reason.

  1. Open CMake-GUI application.
  2. Locate the folder which contains CMakeLists.txt & set it as source directory.
  3. Create an output directory anywhere on your HDD, however the directory containing CMake binaries is preferred.
  4. Go to Visual Studio's project settings & set Incremental Linker: NO.
  5. Locate cvtres.exe file in visual studio directory & replace it with Visual Studio 2012 Ultimate edition's cvtres.exe.
  6. Click configure button in CMake-GUI application and leave the default radio button settings.
  7. Select Visual Studio 2010 from compilers list in configure window.
  8. Click generate.
  9. You are done !

Comments

Popular posts from this blog

Noir A8: Battery Friendly Jelly Bean Rom

ICS Themed Rom For Noir A2

Exploring Redux in React Native: Building a Test App with Example Code