Difference between revisions of "CMake"

From ReactOS Wiki
Jump to: navigation, search
(History)
 
(56 intermediate revisions by 22 users not shown)
Line 1: Line 1:
[http://www.cmake.org/ CMake] is a cross-platform build system. It is a proposed alternative to [[RBuild]].
 
  
'''Latest version (cmake 2.8.4) has a bug ([http://www.cmake.org/Bug/view.php?id=12190 cmake bug report]). Please comment the line "set_property(GLOBAL PROPERTY RULE_MESSAGES OFF)" in root CMakeLists.txt. (place a # in front of it)'''
+
 
 +
'''CMake''' is a cross-platform build system. For ReactOS it is used as a high level generator for the low level build systems [[ninja]] or ''make''(deprecated).
 +
 
 +
The CMake executable comes with the [[ReactOS Build Environment]]; for both environments (Windows NT-compatible OS Version 2.1.5 and Unix-compatible Operating Systems Version 2.1.2) as version v3.2.1 (see README.pdf: [https://svn.reactos.org/svn/project-tools/trunk/RosBE/RosBE-Unix/Base-i386/README?view=markup#l138 Unix Environment]).
 +
 
 +
The initial call to CMake comes from the configure script ([https://git.reactos.org/?p=reactos.git;a=blob;f=configure.cmd;hb=refs/heads/master win], [https://git.reactos.org/?p=reactos.git;a=blob;f=configure.sh;hb=refs/heads/master#l74 Unix]). Afterwards the generated low level build script contains a call to CMake in the first place. Thus whenever ''ninja'' (or ''(n)make'') is called then CMake searches first for changes in the CMake configuration scripts and generates a new ''ninja'' (or ''(n)make'') script if necessary.
 +
 
 +
== Weblinks ==
 +
 
 +
* Project website: https://cmake.org/
 +
* Documentation: https://cmake.org/documentation/
 +
* Description of cmake-buildsystem version 3.2: https://cmake.org/cmake/help/v3.2/manual/cmake-buildsystem.7.html
 +
* Tutorial: https://cmake.org/cmake-tutorial/
 +
* Wikipedia article: https://en.wikipedia.org/wiki/CMake
 +
 
 +
 
 +
== History ==
 +
 
 +
{{rev|56105}} implements cmake RC (Win resource file) handling, but mentions a bug in cmake. That bug is located [http://www.cmake.org/Bug/view.php?id=12998 here] and [https://gitlab.kitware.com/cmake/cmake/issues/12998 here].
 +
 
 +
Since revision {{rev|51836}}, <tt>trunk</tt> can be built using cmake.
 +
 
 +
= Building with CMake =
 +
 
 +
{{Notice|This section is deprecated and is purely here for archival purposes. For instructions on building ReactOS, please see the [[Build Environment]] page of the development guide.}}
 +
 
 +
{{Warning|The commands <tt>make</tt> and <tt>makex</tt> are now deprecated.}}
  
 
== Preparing the Build Environment ==
 
== Preparing the Build Environment ==
First you need to download and install Cmake build system from [http://www.cmake.org/cmake/resources/software.html here]
+
First you need to download and install the [http://reactos.org/wiki/Build_Environment ReactOS Build Environment].
  
To build using CMake the <tt>cmake-bringup</tt> branch (now also <tt>trunk</tt> is supported) must first be [[Subversion/Using the command line client#Checking out the sources|checked out]]. After obtaining the source, the following two subfolders must be created:
+
== Precompiled Headers Support (PCH) ==
* <tt>build</tt>
+
For reduced build time, [[wikipedia:Precompiled header|Precompiled Headers Support]] was introduced. Next you should enable this feature in ReactOS CMake configure script (configure.cmd/configure.sh) by changing <tt>-DPCH=0</tt> to <tt>-DPCH=1</tt>.
* <tt>build-ros</tt>
 
  
Navigate to the tools subfolder in the RosBE folder and copy <tt>make.exe</tt> to <tt>mingw32-make.exe</tt>.
+
== Preparing the Output Location ==
 +
Before building either the tools or ReactOS itself the output location must be created and prepared. This is an easy step and involves only one command. This command is located in the root of recent revisions of the source code and can be run either from the root directory itself or any other directory you want the build your sources in.
  
== Preparing the Output Location ==
+
=== Linux/Unix ===
 +
Run:
 +
configure.sh
  
Before building either the tools or ReactOS itself the output location must be created and prepared. This is an easy step and involves only one command:
+
=== Windows ===
 +
Both MinGW and Microsoft Visual C++ compiler (versions 2010 and above) is supported. Command is very similar with slightly different output location.
  
 +
==== MinGW ====
 +
Run:
 
  configure.cmd
 
  configure.cmd
  
This command is located in the root of recent revisions of cmake branch and must be run in the directory the branch was checked out.
+
After executing, folder <tt>output-MinGW-i386</tt> will be created in root of ReactOS tree. You will be redirected to it.
 +
 
 +
=== Visual Studio and Microsoft Visual C++ (2010+) ===
 +
To prepare the location for use with Visual Studio or Microsoft Visual C++:
 +
 
 +
# Open a Windows DDK/WDK/Visual Studio command prompt.
 +
# There are two methods to compile using Microsoft Visual C++.
 +
:* If you prefer older method of building, just configure as usual:
 +
 
 +
:: <code>configure.cmd</code>
 +
 
 +
:* To generate Visual Studio solution files instead, using the following command:
 +
 
 +
:: <code>configure.cmd VSSolution</code>
 +
 
 +
After executing, folder <tt>output-VS-i386</tt> will be created in root of ReactOS tree. You will be redirected to it.
 +
 
 +
== Building Tools ==
 +
To build the branch, build tools must be compiled first. This only needs to be done for the first build and whenever there is a change to the build tools.
 +
 
 +
From your output directory, go to <tt>host-tools</tt>. Follow specific instruction for your compiler.
 +
<syntaxhighlight lang="dos">
 +
cd host-tools
 +
</syntaxhighlight>
 +
=== MinGW ===
 +
ninja
 +
 
 +
=== Visual Studio or Microsoft Visual C++ ===
 +
ninja
 +
 
 +
or:
 +
 
 +
nmake
 +
 
 +
If you are using Visual Studio or Microsoft Visual C++ (and you executed <tt>configure.cmd VSSolution</tt> earlier from DDK/WDK/VS command prompt), use <tt>msbuild</tt> instead of <tt>make</tt> (there are few solutions/projects in folder so you must specify solution/project name after msbuild):
 +
 
 +
msbuild reactos.sln
  
===Visual Studio and Microsoft Visual C++===
+
If you have problems with building things from command line go [http://connect.microsoft.com/VisualStudio/feedback/details/488433/vcbuild-cannot-locate-vcbuildui-dll-messages-will-not-be-localized here]. This must help.
To prepare the location for use with Visual Studio or Microsoft Visual C++ open a Windows DDK/WDK/Visual Studio command prompt and enter the command above.
 
  
====Generating Visual Studio solution files====
+
And of course you can use IDE with GUI instead of doing this in command line. If you still have questions go [http://msdn.microsoft.com/en-us/library/f35ctcxw.aspx here]
To generate Visual Studio solution files instead use the following (from Windows DDK/WDK/Visual Studio command prompt):
 
  
configure.cmd VSSolution
+
If you want to build ReactOS with both nmake and msbuild you need to create another folder for one of them (because by default configure.cmd creates output-VS9-i386 for both and files will be mixed). For example to use for nmake build folder output-VS9nmake-i386 you need to do next:
  
== Building Tools==
 
To build the branch the build tools must first be compiled using CMake. This needs to be done for the first build and whenever there is a change to the build tools.
 
  
 +
To generate Visual Studio solution files too, create another folder, because by default, configure.cmd uses the same folder name, which leads to mixed files. For example to use for nmake build folder <tt>output-VS10nmake-i386</tt> you should do the following:
 +
 +
<syntaxhighlight lang="dos">
 +
mkdir output-VS-nmake-i386
 +
cd output-VS-nmake-i386
 +
..\configure.cmd
 +
</syntaxhighlight>
 +
And then build host tools as usual:
 +
<syntaxhighlight lang="dos">
 
  cd host-tools
 
  cd host-tools
  make
+
  nmake
 
  cd ..
 
  cd ..
 +
</syntaxhighlight>
 +
  
 
With the build tools compiled, ReactOS can now be compiled. In the case of <tt>CMakeLists</tt> being updated it is best to remove the content of the <tt>build-ros</tt> folder and rebuild ReactOS.
 
With the build tools compiled, ReactOS can now be compiled. In the case of <tt>CMakeLists</tt> being updated it is best to remove the content of the <tt>build-ros</tt> folder and rebuild ReactOS.
 
+
<syntaxhighlight lang="dos">
 
  cd reactos
 
  cd reactos
  make
+
  ninja
 
+
</syntaxhighlight>
 
Combining the above steps together:
 
Combining the above steps together:
 
+
<syntaxhighlight lang="dos">
 
  configure.cmd
 
  configure.cmd
 
  cd host-tools
 
  cd host-tools
  make
+
  ninja
 
  cd ../reactos
 
  cd ../reactos
  make
+
  ninja
 +
</syntaxhighlight>
 +
 
 +
== Building ReactOS ==
 +
=== Building Modules ===
 +
To build a specific module (i.e: "win32k") you can follow the next steps: [[Building Modules]]
 +
 
 +
=== Building ReactOS with nmake/msbuild ===
 +
If you want to build ReactOS with nmake you can receive such error during building
  
== Building ReactOS==
+
'mc' is not recognized as an internal or external command,operable program or batch file.
===Building Modules===
 
To build a specific module (i.e: "win32k" ) you can follow the next steps:  [[Building Modules]]
 
  
====Building Modules much Faster (CMake feature)====
+
Seems you are using Microsoft Visual C++ Express Edition. Go [http://groups.google.com/group/sage-windows/browse_thread/thread/6f27a9f61266f9a4 here] for getting info and working around the issue.
 +
It might also be possible to use "windmc" from MinGW binutils as an alternative implementation of MC.exe.
  
NOTE: The following syntax can be used just with CMake.
+
==== Building Modules much Faster (CMake feature) ====
 +
{{Notice|The following syntax can be used just with CMake.}}
  
 
CMake implements a feature that can speed up the modules building process using the Fast syntax.
 
CMake implements a feature that can speed up the modules building process using the Fast syntax.
Line 60: Line 141:
 
This /fast syntax skips dependency checking before compiling starts, so it is terrible fast.
 
This /fast syntax skips dependency checking before compiling starts, so it is terrible fast.
  
NOTE2: '''You need at least to have compiled the desired module once with "make '''Desired_module''' " before using the Fast syntax.
+
{{Notice|You need at least to have compiled the desired module once with "make '''Desired_module''' " before using the Fast syntax.}}
'''
 
  
 
One simple example:
 
One simple example:
Line 73: Line 153:
  
 
If you want to compile Win32k, it would be:
 
If you want to compile Win32k, it would be:
+
 
 
  make win32k/fast
 
  make win32k/fast
  
===Building a Bootcd ===
+
=== Building a Bootcd ===
 
To build a bootcd  you can follow the next steps: [[Building ReactOS]]
 
To build a bootcd  you can follow the next steps: [[Building ReactOS]]
  
====Building a bootcd much Faster ====
+
==== Building a bootcd much Faster ====
 
  NOTE: This method is just available with CMake.
 
  NOTE: This method is just available with CMake.
  
Line 93: Line 173:
  
 
  make win32k/fast
 
  make win32k/fast
,as your changes are just related to win32k.
+
as your changes are just related to win32k.
  
 
And then:
 
And then:
Line 110: Line 190:
 
* [[Building ReactOS]]
 
* [[Building ReactOS]]
 
* [[Building Modules]]
 
* [[Building Modules]]
* [[CMake Todo]]
+
* (Deprecated and unsupported) [[RBuild]]
  
 
[[Category:Building]]
 
[[Category:Building]]
 +
[[Category:Tutorial]]

Latest revision as of 13:08, 29 December 2017


CMake is a cross-platform build system. For ReactOS it is used as a high level generator for the low level build systems ninja or make(deprecated).

The CMake executable comes with the ReactOS Build Environment; for both environments (Windows NT-compatible OS Version 2.1.5 and Unix-compatible Operating Systems Version 2.1.2) as version v3.2.1 (see README.pdf: Unix Environment).

The initial call to CMake comes from the configure script (win, Unix). Afterwards the generated low level build script contains a call to CMake in the first place. Thus whenever ninja (or (n)make) is called then CMake searches first for changes in the CMake configuration scripts and generates a new ninja (or (n)make) script if necessary.

Weblinks


History

r56105 implements cmake RC (Win resource file) handling, but mentions a bug in cmake. That bug is located here and here.

Since revision r51836, trunk can be built using cmake.

Building with CMake

Imbox notice.png

Notice: This section is deprecated and is purely here for archival purposes. For instructions on building ReactOS, please see the Build Environment page of the development guide.

Icon speedy deletion.png Warning: The commands make and makex are now deprecated.


Preparing the Build Environment

First you need to download and install the ReactOS Build Environment.

Precompiled Headers Support (PCH)

For reduced build time, Precompiled Headers Support was introduced. Next you should enable this feature in ReactOS CMake configure script (configure.cmd/configure.sh) by changing -DPCH=0 to -DPCH=1.

Preparing the Output Location

Before building either the tools or ReactOS itself the output location must be created and prepared. This is an easy step and involves only one command. This command is located in the root of recent revisions of the source code and can be run either from the root directory itself or any other directory you want the build your sources in.

Linux/Unix

Run:

configure.sh

Windows

Both MinGW and Microsoft Visual C++ compiler (versions 2010 and above) is supported. Command is very similar with slightly different output location.

MinGW

Run:

configure.cmd

After executing, folder output-MinGW-i386 will be created in root of ReactOS tree. You will be redirected to it.

Visual Studio and Microsoft Visual C++ (2010+)

To prepare the location for use with Visual Studio or Microsoft Visual C++:

  1. Open a Windows DDK/WDK/Visual Studio command prompt.
  2. There are two methods to compile using Microsoft Visual C++.
  • If you prefer older method of building, just configure as usual:
configure.cmd
  • To generate Visual Studio solution files instead, using the following command:
configure.cmd VSSolution

After executing, folder output-VS-i386 will be created in root of ReactOS tree. You will be redirected to it.

Building Tools

To build the branch, build tools must be compiled first. This only needs to be done for the first build and whenever there is a change to the build tools.

From your output directory, go to host-tools. Follow specific instruction for your compiler.

 cd host-tools

MinGW

ninja

Visual Studio or Microsoft Visual C++

ninja

or:

nmake

If you are using Visual Studio or Microsoft Visual C++ (and you executed configure.cmd VSSolution earlier from DDK/WDK/VS command prompt), use msbuild instead of make (there are few solutions/projects in folder so you must specify solution/project name after msbuild):

msbuild reactos.sln

If you have problems with building things from command line go here. This must help.

And of course you can use IDE with GUI instead of doing this in command line. If you still have questions go here

If you want to build ReactOS with both nmake and msbuild you need to create another folder for one of them (because by default configure.cmd creates output-VS9-i386 for both and files will be mixed). For example to use for nmake build folder output-VS9nmake-i386 you need to do next:


To generate Visual Studio solution files too, create another folder, because by default, configure.cmd uses the same folder name, which leads to mixed files. For example to use for nmake build folder output-VS10nmake-i386 you should do the following:

 mkdir output-VS-nmake-i386
 cd output-VS-nmake-i386
 ..\configure.cmd

And then build host tools as usual:

 cd host-tools
 nmake
 cd ..


With the build tools compiled, ReactOS can now be compiled. In the case of CMakeLists being updated it is best to remove the content of the build-ros folder and rebuild ReactOS.

 cd reactos
 ninja

Combining the above steps together:

 configure.cmd
 cd host-tools
 ninja
 cd ../reactos
 ninja

Building ReactOS

Building Modules

To build a specific module (i.e: "win32k") you can follow the next steps: Building Modules

Building ReactOS with nmake/msbuild

If you want to build ReactOS with nmake you can receive such error during building

'mc' is not recognized as an internal or external command,operable program or batch file.

Seems you are using Microsoft Visual C++ Express Edition. Go here for getting info and working around the issue. It might also be possible to use "windmc" from MinGW binutils as an alternative implementation of MC.exe.

Building Modules much Faster (CMake feature)

Imbox notice.png

Notice: The following syntax can be used just with CMake.

CMake implements a feature that can speed up the modules building process using the Fast syntax. You can use the Fast syntax if your changes just affects one module and does not change any code of others modules that the Desired module depends on. This /fast syntax skips dependency checking before compiling starts, so it is terrible fast.

Imbox notice.png

Notice: You need at least to have compiled the desired module once with "make Desired_module " before using the Fast syntax.

One simple example: You have changed just some "win32k" code (desired module) but you did not change any module that the desired module depends on (i.e,the PSDK headers), you have also the "Win32k-before-changes" module compiled, then you can use the Fast syntax to compile the new "win32k" module in few seconds.

Warning: The Fast syntax just will look for changes in the Desired module, not checking if any other modules have been modified.

The Fast syntax to build any module is:

make Desired_module/fast

If you want to compile Win32k, it would be:

make win32k/fast

Building a Bootcd

To build a bootcd you can follow the next steps: Building ReactOS

Building a bootcd much Faster

NOTE: This method is just available with CMake.

Thanks to Fast syntax,creating a bootcd is much faster. Before compiling bootcd with Fast syntax you have to be sure that any Dependent module has been compiled previously. "/Fast" skips dependency checking before compiling starts.

Remember: You need at least to have compiled the Desired module once with "make Desired_module " before using the bootcd Fast syntax.
Read  Building Modules much Faster for more info.

An example: "You have added some changes in win32k module and now you want a bootcd with your new modified win32k.You have,also, the "win32k-before-changes" compiled."

make win32k/fast

as your changes are just related to win32k.

And then:

make bootcd/fast

Read the following carefully:

It's mandatory to compile at least once with "make bootcd" before using the Fast syntax.
It's mandatory to compile the module changes before invoking bootcd/fast, otherwise your changes won't be added.
If your changes are modifying modules that win32k depends on, you should use "make win32k" and then invoke "make bootcd/fast" instead.
If your changes are modifying several INDEPENDENT modules, compile all of them with Fast syntax and afterwards a perform a bootcd/fast compilation.
This method becomes less practical when you alter many modules.

See also