Difference between revisions of "CMake Howto"

From ReactOS Wiki
Jump to: navigation, search
 
(6 intermediate revisions by 4 users not shown)
Line 15: Line 15:
 
  cmake -G "Unix Makefiles" [reactos-dir]
 
  cmake -G "Unix Makefiles" [reactos-dir]
 
  TOOLS=`pwd`
 
  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 ===
 
=== Building ReactOS ===
Line 22: Line 38:
 
NOTE: This directory will contain a different logical cmake instance.
 
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
+
  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
 
NOTE: The path to the tools dir *must* be specified as a full path
Line 34: Line 50:
  
 
The most common reason for this step to fail is not specifying the path to the tools.
 
The most common reason for this step to fail is not specifying the path to the tools.
 +
 +
And a specific example for windows (RosBE 2.0 (r55995))
 +
(but first note that this video may be helpful https://www.youtube.com/watch?v=q-DirQY_TL0)
 +
 +
  mkdir c:\dev\ReactOS_work\bld_r55995\reactos
 +
  cd c:\dev\ReactOS_work\bld_r55995\reactos
 +
  cmake -G "MinGW Makefiles" -DREACTOS_BUILD_TOOLS_DIR:DIR=%TOOLS% -DCMAKE_TOOLCHAIN_FILE=toolchain-gcc.cmake c:\dev\ReactOS_work\svn_r55995
 +
  mingw32-make livecd
 +
 +
 +
[[Category:Tutorial]]
 +
[[Category:Candidates for speedy deletion]]

Latest revision as of 19:56, 18 September 2021

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.

And a specific example for windows (RosBE 2.0 (r55995)) (but first note that this video may be helpful https://www.youtube.com/watch?v=q-DirQY_TL0)

 mkdir c:\dev\ReactOS_work\bld_r55995\reactos
 cd c:\dev\ReactOS_work\bld_r55995\reactos
 cmake -G "MinGW Makefiles" -DREACTOS_BUILD_TOOLS_DIR:DIR=%TOOLS% -DCMAKE_TOOLCHAIN_FILE=toolchain-gcc.cmake c:\dev\ReactOS_work\svn_r55995
 mingw32-make livecd