Difference between revisions of "CMake"

From Inkscape Wiki
Jump to navigation Jump to search
(Major cleanup)
(mark as outdated / moved to GitLab)
 
Line 1: Line 1:
Inkscape uses CMake for building. CMake is a powerful cross-platform build system.
{{Outdated|message=Developer documentation has been moved to [https://gitlab.com/inkscape/inkscape/-/blob/master/doc/readme.md GitLab].}}
 
== Compiling Inkscape with CMake ==
See https://inkscape.org/develop/getting-started/
 
== Using CMake to run tests ==
 
First, install Google Test framework: Preferably by getting the packaged version for your distribution, if that fails you can try to download a local copy by running download-gtest.sh in the main directory of inkscape source:
 
<pre>
cd /path/to/inkscape
bash download-gtest.sh
</pre>
 
Then re-run cmake to detect the configuration change:
 
<pre>
cd /path/to/buildinkscape
cmake ../inkscape
</pre>
 
Finally, run "make check" from same directory to run the tests:
 
<pre>
make check
</pre>
 
== Configuring your build further ==
 
It is possible to change some more options of the build, e.g. whether to compile against GTK2 or GTK3 libraries. If you fiddle a lot with this, you may want to install the interactive cmake configuration tool "ccmake", like so:
[[File:CCMAKE.PNG|200px|thumb|right|ccmake screen capture]]
<pre>
sudo apt-get install cmake-curses-gui
ccmake ../inkscape  # In buildinkscape folder
</pre>
 
The ccmake utility will have features to re-run cmake for you before exiting.<br />
For example you can use CMAKE_INSTALL_PREFIX Path in which "make install" installs Inkscape and allow handle multiple Inkscape instalations. <br />
Press enter on the line to edit. <br />Press again to save, when all your changes are done press c to configure, exit help and press g to generate.<br /> After this you exit ccmake and can finish with make.
 
=== adding options to cmake ===
 
you can specify some variable on cmake invokation. i.e.
 
<pre>
cmake .. -G "MinGW Makefiles" -DCMAKE_BUILD_TYPE=Debug
</pre>
 
Useful CMake configuration variables include
 
* CMAKE_BUILD_TYPE: Either Release or Debug (a string).
* CMAKE_INSTALL_PREFIX: Path in which "make install" installs Inkscape.
 
== Variations ==
 
=== Using CMake with Ninja to build Inkscape ===
 
Another option for building with CMake is to use it in combination with [https://ninja-build.org/ Ninja] which is a small build system with a focus on speed and replaces GNU Make.
 
Usage of Ninja will significantly speed up incremental rebuilds (i.e. if only few code files need to be re-compiled) as the build systems overhead is greatly reduced and scanning dependencies is almost instantaneous.
 
After following the instructions on the website to get Ninja the procedure is almost identical (only changes necessary highlighted in red):
mkdir build
cd build
cmake <span style="color:red">-G Ninja</span> /path/to/inkscape
<span style="color:red">ninja</span>
<span style="color:red">ninja</span> install    <span style="color:gray"># only if you want to install the distribution</span>
Basically, you have to replace "make" with "ninja" in the compilation instructions.
 
== Background ==
All the CMake configuration can be found in CMakeLists.txt and the CMakeScripts/ folder. See the CMake documentation for more information. https://cmake.org/cmake/help/latest/guide/tutorial/index.html

Latest revision as of 11:57, 31 May 2025

This page is outdated. It is kept for historical reasons, e.g. to document specific decisions in Inkscape development.

Developer documentation has been moved to GitLab.