/cmake_test

These are my first steps with CMake.

Primary LanguageCMake

Goal

This will be an example how to set up CMake for a more complex project. I did this to 1) learn how to CMake to 2) be able to cross-compile this project here more easily.

Setup

Make sure you have installed and available:

  • gcc --version (should be 4.7.2 or higher)
  • g++ --version (should be 4.7.2 or higher)
  • make --version (should be 3.81 or higher)
  • cmake --version (should be 2.8 or higher)

In your project folder, switch to folder _build (create it if it doesn't exist). Here will be all the temporary build stuff.

mkdir _build
cd _build

Then, depending on your OS, execute

  • Linux/OSX: cmake ..
  • Windows: cmake -G "MinGW Makefiles" .. if you have MinGW installed

This will create you a perfect Makefile. Now you can execute make to build your project, and make install to install it into your system. To build a debug version, run from your project folder

mkdir _debug
cd _debug
cmake -DCMAKE_BUILD_TYPE=Debug ..

and then build it as usual.

Sources

This example is combined of information mainly from this sources: