Menu

Building with CMake

leg0

Why CMake?

Using CMake it's a lot easier to manage the Visual Studio solutions and projects. This page describes shortly how to use CMake to generate Visual Studio project files.

First you need to get CMake. You can get it from http://www.cmake.org/ for example.

Generate project files and solution

For this you have two options - command line, or GUI. Both produce equivalent results, but the experience of generating the build files differs a bit, the GUI makes it a bit easier to configure the generated build files.

Command line

Assuming you have checked winlirc out to c:\my_projects\winlirc, and you want to build in c:\temp\build-winlirc:

mkdir c:\temp\build-winlirc
cd c:\temp\build-winlirc

Generate visual studio 2013 solution and projects for x86:

cmake -G "Visual Studio 12" c:\my_projects\winlirc

Generate visual studio 2013 solution and projects for x64:

cmake -G "Visual Studio 12 Win64" c:\my_projects\winlirc

You can also generate project files for older Visual Studio versions. Just run cmake without arguments and it will present you with a list of available generators.

When cmake has successfully completed, directory c:\temp\build-winlirc should now contain Visual Studio solution WinLIRC.sln and project files to build winlirc, tools and plugins.

To disable a plugin, add -DEnablePlugin_<plugin name>=0 to command line. To disable a tool, add -DEnableTool_<tool name>=0 to command line.

GUI

CMake comes with a tool called cmake-gui. Start it and do the following:

  • Enter the directory of winlirc source code (the directory that you checked out from SVN) into "Where is the source code" text box.
  • Enter the directory you want to generate the build files to into "Where to build the binaries".
  • Click "Configure" button. After this you can select/deselect plugins and tools you want build files generated for. For better overview, checkbox "Grouped" can be checked.
  • Change the values in the listbox - choose which plugins and tools to include/exclude from build. Specify paths of dependent libraries.
  • Click "Generate". After this step succeeds, the build files are generated in the directory you specified.

Update project files

When you want to make changes to the generated project files, do not do it via Visual Studio properties dialog - you will lose these changes when the project files are generated again. Instead change the CMakeLists.txt file that was used to generate the project file. The project file has a reference to appropriate CMakeLists.txt.