CMake Howto

From ReactOS Wiki
Revision as of 05:10, 16 January 2017 by Curiousone (talk | contribs) (Show specific example of using older windows build environment with earlier revision)
Jump to: navigation, search

Cmake Crash Course

Understanding cmake

Cmake builds makefiles in the current directory. It leaves a cache file called CMakeCache.txt, even when cmake fails. Always delete this, as command line options don't override what's in there. It's common to bang your head on cmake only to remember that the cache file contains your first mistake.

There are two intermixed cmake instances in reactos, one for host tools and one for reactos itself. ReactOS is built by specifying an alternate toolchain definition for reasons nobody has explained to me. The one for unixen is toolchain-mingw32.cmake and you tell cmake to use it with -DCMAKE_TOOLCHAIN_FILE= .. It'd be nice to name that variable something more understandable.

Makefile emitted by cmake can have VERBOSE=1 specified.

Building tools

make a tools dir somewhere (like ./build/tools)

cmake -G "Unix Makefiles" [reactos-dir]
TOOLS=`pwd`

or for a windows environment (using RosBE 2.1.1 (r64030) or RosBE 2.0 (r55995))

 mkdir ./build/host-tools
 cd ./build/host-tools
 cmake -G "MinGW Makefiles" <pathtoyourreactossourcedir>
 set TOOLS=<pathtoyourreactossourcedir>
 mingw32-make

A specific example for windows Mingw RosBE 2.1.1:

 mkdir c:\dev\ReactOS_work\bld_r64030\host-tools
 cd c:\dev\ReactOS_work\bld_r64030\host-tools
 cmake -G "MinGW Makefiles" c:\dev\ReactOS_work\svn_r64030
 set TOOLS=c:\dev\ReactOS_work\bld_r64030\host-tools
 mingw32-make

Building ReactOS

make a different directory (like ./build/ros).

NOTE: This directory will contain a different logical cmake instance.

cmake -G "Unix Makefiles" -DREACTOS_BUILD_TOOLS_DIR:DIR=$TOOLS -DCMAKE_TOOLCHAIN_FILE=toolchain-mingw32.cmake [reactos-dir]

NOTE: The path to the tools dir *must* be specified as a full path

When cmake fails, errors look like this:

CMake Error at CMakeLists.txt:90 (include):
 include could not find load file:

   ../build/ImportExecutables.cmake

The most common reason for this step to fail is not specifying the path to the tools.