Difference between revisions of "CMake"

From Inkscape Wiki
Jump to navigation Jump to search
(Added Cmake samples)
m
 
(22 intermediate revisions by 10 users not shown)
Line 1: Line 1:
==
'''CMake will replace Autotools as our build system for Inkscape 0.92 onwards!'''
'''Work is a on going to get this build system functional.''' ==


 
Cmake is a cross-platform build system known to work on all major platforms we support (*nix, Windows, OSX).
Cmake is a cross-platform build system know to work on all major platforms we support(*nix, Windows, OSX).


CMake is an extensible, open-source system that has many powerful features.
CMake is an extensible, open-source system that has many powerful features.
Those features include:
Those features include:


    * Supports complex, large build environments. CMake has been proven in several large projects (KDE, ParaView, SecondLife)
* Supports complex, large build environments. CMake has been proven in several large projects (KDE, ParaView, SecondLife, Scribus)
    * Generates native build files (e.g., makefiles on Unix; workspaces/projects on MS Visual C++). Therefore, standard tools can be used on any platform/compiler configuration.
* Generates native build files (e.g., makefiles on Unix; workspaces/projects on MS Visual C++). Therefore, standard tools can be used on any platform/compiler configuration.
    * Powerful system introspection abilities including the ability to find installed include files, libraries and executables. Also the ability to test the compiler for supported features.
* Powerful system introspection abilities including the ability to find installed include files, libraries and executables. Also the ability to test the compiler for supported features.
    * Integrated testing system called CTest.
* Integrated testing system called CTest.
    * Integrated packaging system called CPack.
* Integrated packaging system called CPack.
    * Easy integration with CDash and Dart dashboard servers.
* Easy integration with CDash and Dart dashboard servers.
    * Powerful scripting language with simple syntax.
* Powerful scripting language with simple syntax.
    * Supports in-place and out-of-place builds. Multiple compilation trees are possible from a single source tree.
* Supports in-place and out-of-place builds. Multiple compilation trees are possible from a single source tree.
    * Can be easily extended to add new features.
* Can be easily extended to add new features.
    * CMake is open source, under a liberal BSD license.
* CMake is open source, under a liberal BSD license.
    * CMake operates with a cache designed to be interfaced with a graphical editor. The cache provides optional interaction to conditionally control the build process.
* CMake operates with a cache designed to be interfaced with a graphical editor. The cache provides optional interaction to conditionally control the build process.
    * Ability to create Mac OSX Frameworks and Application Bundles.
* Ability to create Mac OSX Frameworks and Application Bundles.
    * Supports adding complex custom rules to the build.
* Supports adding complex custom rules to the build.


== How you can help ==


== How you can help. ==
We have completed the building of the CMakeLists.txt for almost everything needed.
We are now working on get the build to compile properly. See below Testing/Using to help.


Right now we are going through all of the directories and sub-directories in the src folder and add a CMakeLists.txt file
There is a separate [[CMake Tasks]] page with things that are left to do w.r.t. cmake building of Inkscape.


== SIMPLE CmakeLists.txt ==
== SIMPLE CmakeLists.txt ==
<nowiki>
    SET(libavoid_SRC
SET(libavoid_SRC
    connector.cpp
connector.cpp
    geometry.cpp
geometry.cpp
    graph.cpp
graph.cpp
    makepath.cpp
makepath.cpp
    polyutil.cpp
polyutil.cpp
    region.cpp
region.cpp
    router.cpp
router.cpp
    shape.cpp
shape.cpp
    static.cpp
static.cpp
    timer.cpp
timer.cpp
    vertices.cpp
vertices.cpp
    visibility.cpp
visibility.cpp
    )
)
 
</nowiki>
== SIMPLE with single sub-directory Cmakelists.txt ==
 
    SET(libavoid_SRC
    connector.cpp
    geometry.cpp
    graph.cpp
    makepath.cpp
    polyutil.cpp
    region.cpp
    router.cpp
    shape.cpp
    static.cpp
    timer.cpp
    vertices.cpp
    visibility.cpp
    #Add our subdirectory sourcelist Var
    ${libavoid_parameter_SRC}
    )
    # this adds a single sub-directory
    ADD_SUBDIRECTORY(parameter)
 
== Using CMake to build Inkscape ==
 
Experience with Scribus '''strongly''' suggests using an "out of source" build arrangement. E.g.
mkdir build
cd build
cmake /path/to/inkscape
make
make install      <span style="color:gray"># only if you want to install the distribution</span>
<code>/path/to/inkscape</code> is the root directory of your Inkscape checkout (or the folder to where you extracted the source when working with an official source tarball).
 
References:
[http://docs.scribus.net/index.php?lang=en&page=install4 Installing Scribus with Cmake] <br />
[http://docs.scribus.net/index.php?lang=en&page=install5 Installing with CMake on OSX]
 
=== 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>
 
== 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:


== SIMPLE with single sub-directory Cmakelists.txt ==
<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


SET(libavoid_SRC
* CMAKE_BUILD_TYPE: Either Release or Debug (a string).
connector.cpp
* WITH_GTK3_EXPERIMENTAL: ON/OFF. Toggle between GTK2 or GTK3 ui toolkit.
geometry.cpp
* CMAKE_INSTALL_PREFIX: Path in which "make install" installs Inkscape.
graph.cpp
makepath.cpp
polyutil.cpp
region.cpp
router.cpp
shape.cpp
static.cpp
timer.cpp
vertices.cpp
visibility.cpp
#Add our subdirectory sourcelist Var
${libavoid_parameter_SRC}
)
# this adds a single sub-directory
ADD_SUBDIRECTORY(parameter)

Latest revision as of 23:22, 15 February 2020

CMake will replace Autotools as our build system for Inkscape 0.92 onwards!

Cmake is a cross-platform build system known to work on all major platforms we support (*nix, Windows, OSX).

CMake is an extensible, open-source system that has many powerful features. Those features include:

  • Supports complex, large build environments. CMake has been proven in several large projects (KDE, ParaView, SecondLife, Scribus)
  • Generates native build files (e.g., makefiles on Unix; workspaces/projects on MS Visual C++). Therefore, standard tools can be used on any platform/compiler configuration.
  • Powerful system introspection abilities including the ability to find installed include files, libraries and executables. Also the ability to test the compiler for supported features.
  • Integrated testing system called CTest.
  • Integrated packaging system called CPack.
  • Easy integration with CDash and Dart dashboard servers.
  • Powerful scripting language with simple syntax.
  • Supports in-place and out-of-place builds. Multiple compilation trees are possible from a single source tree.
  • Can be easily extended to add new features.
  • CMake is open source, under a liberal BSD license.
  • CMake operates with a cache designed to be interfaced with a graphical editor. The cache provides optional interaction to conditionally control the build process.
  • Ability to create Mac OSX Frameworks and Application Bundles.
  • Supports adding complex custom rules to the build.

How you can help

We have completed the building of the CMakeLists.txt for almost everything needed. We are now working on get the build to compile properly. See below Testing/Using to help.

There is a separate CMake Tasks page with things that are left to do w.r.t. cmake building of Inkscape.

SIMPLE CmakeLists.txt

   SET(libavoid_SRC
   connector.cpp
   geometry.cpp
   graph.cpp
   makepath.cpp
   polyutil.cpp
   region.cpp
   router.cpp
   shape.cpp
   static.cpp
   timer.cpp
   vertices.cpp
   visibility.cpp
   )

SIMPLE with single sub-directory Cmakelists.txt

   SET(libavoid_SRC
   connector.cpp
   geometry.cpp
   graph.cpp
   makepath.cpp
   polyutil.cpp
   region.cpp
   router.cpp
   shape.cpp
   static.cpp
   timer.cpp
   vertices.cpp
   visibility.cpp
   #Add our subdirectory sourcelist Var
   ${libavoid_parameter_SRC}
   )
   # this adds a single sub-directory
   ADD_SUBDIRECTORY(parameter)

Using CMake to build Inkscape

Experience with Scribus strongly suggests using an "out of source" build arrangement. E.g.

mkdir build
cd build
cmake /path/to/inkscape
make
make install      # only if you want to install the distribution 

/path/to/inkscape is the root directory of your Inkscape checkout (or the folder to where you extracted the source when working with an official source tarball).

References: Installing Scribus with Cmake
Installing with CMake on OSX

Using CMake with Ninja to build Inkscape

Another option for building with CMake is to use it in combination with 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 -G Ninja /path/to/inkscape
ninja
ninja install     # only if you want to install the distribution

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:

cd /path/to/inkscape
bash download-gtest.sh

Then re-run cmake to detect the configuration change:

cd /path/to/buildinkscape
cmake ../inkscape

Finally, run "make check" from same directory to run the tests:

make check

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:

ccmake screen capture
sudo apt-get install cmake-curses-gui
ccmake ../inkscape  # In buildinkscape folder

The ccmake utility will have features to re-run cmake for you before exiting.
For example you can use CMAKE_INSTALL_PREFIX Path in which "make install" installs Inkscape and allow handle multiple Inkscape instalations.
Press enter on the line to edit.
Press again to save, when all your changes are done press c to configure, exit help and press g to generate.
After this you exit ccmake and can finish with make.


adding options to cmake

you can specify some variable on cmake invokation. i.e.

cmake .. -G "MinGW Makefiles" -DCMAKE_BUILD_TYPE=Debug

Useful CMake configuration variables include

  • CMAKE_BUILD_TYPE: Either Release or Debug (a string).
  • WITH_GTK3_EXPERIMENTAL: ON/OFF. Toggle between GTK2 or GTK3 ui toolkit.
  • CMAKE_INSTALL_PREFIX: Path in which "make install" installs Inkscape.