CMake Howto

From ReactOS Wiki
Revision as of 13:25, 8 April 2011 by Arty (talk | contribs)
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.

Building tools

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

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

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 -DREACTOS_TOOLCHAIN_FILE=toolchain-mingw32.cmake

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.