Skip to main content

The independent CMake tutorial (Tulip 3)

Hello everyone,

Since Tulip 3.4.0, support for autotools has been dropped to the benefit of CMake.
CMake is a cross-platform, open-source build system, it provides with a complete family of tools designed to build, test and package software. CMake is available on several plateforms and is used alongside Tulip on Mac, Linux and Windows.
 
This page is not meant to provide with in-depth instructions for CMake compilation, it will only help you getting a valid compiled Tulip on one of the plateform listed above.
 
1 - Getting the deps
 
To compile Tulip, you'll first need to download and install the following libraries on your system:
  • libxml2
  • python
  • zlib
  • freetype
  • glew
  • libjpeg
  • libpng
  • Qt, including at least the following modules: QtCore, QtGui, QtNetwork, QtOpenGL, QtXML
  • cmake
  • cmake-gui (On various plateform, this is directly provided by the cmake package)
  •  
  • On certain systems (like Ubuntu), you'll need to install the *-dev package for those libraries in order to retrieve the C++ headers (eg. To install glew, type apt-get install libglew1.5-dev)
  •  
  • To install a valid compilation environment on Windows plateforms, please refer to either the Visual Studio or MinGW compilation tutorial on our website (depending of the compilation suite you want to use)
     

2 - Getting the sources

Once external deps are installed, you'll have to checkout Tulip sources, either from one of our SourceForge source packages or directly from SVN.

Note: While source packages available on sourceforge correspond to specific releases of Tulip, sources from our SVN repo correspond to a developement stage and are not guaranteed to build on all plateforms.

The Tulip SVN structure:
In this tutorial, we assume that you know how SVN works, this is how the Tulip SVN is organized:

The /auber/tulip branch corresponds to the trunk. This is the main branch where devs for the next release are located.

The auber/branches directory contains several sub-folders. Each one corresponding to a specific release (indicated in the folder's name). Those are maintenance branches, meaning that they will only get bug fixes.

So once you selected the source package you want to use, just download it and save it somewhere on your disk. In this tutorial, we will assume that the source directory is located in /home/user/tulip-sources.

3 - Setting up the build environment

Unlike the auto-tools system, CMake provides with an out-of-source build tree. This means that object files and libraries generated when compiling sources are put in a separate folder, keeping the source directory clean.

The first thing you'll need to do is to create a folder where build files will be put. Let's call it /home/user/tulip-build (you can choose anything).

Next, run the cmake-gui utility, this will open a window:

On the topmost of this window, you have two input boxes:

  • In the first, input the absolute path of the tulip sources directory (eg. /home/user/tulip-sources)
  • In the second box, input the absolute path of the tulip build directory (eg. /home/user/tulip-build)

Then click on the Generate button.

A new popup will show up, asking what CMake generator you want to use.

The CMake generator defines the compilation suite used to build Tulip sources. Currently supported generators are:

  • Unix Makefiles (Linux and Mac): corresponds to the GCC compiler suite.
  • MSYS Makefiles (Windows only): The GCC compiler suite used with the make utility provided with MSYS
  • MinGW Makefiles (Windows only): The GCC compiler suite used with the mingw32-make utility provided with MinGW
  • NMake Makefiles (Windows Only): The MSVC compiler suite used along with the NMake program.
  • NMake Makefiles (JOM) (Windows only): The MSVC compiler suite used along with the JOM program provided by Qt.
  • Visual Studio (2008 and 2010): See our Visual studio compilation tutorial for details.
  • Clang Makefiles (Windows only): The Clang compiler suite.

 

Be sure to check the Use default native compilers box and click on the Finish button.

CMake will test the compilation environment and raise errors if some required libraries were not found on your system. If you get an error at this step, feel free to ask for help on our Forums or directly on our IRC channel.

Please don't post a bug report for a CMake check-related error.

CMake build configuration is made by setting global variables values. Those variable will control the way Tulip is build and are somehow equivalent to a ./configure script arguments.

If BUILD_TESTS is checked, Tulip's unit tests will be compiled and installed alongside with the Tulip software.

The CMAKE_BUILD_TYPE controls the type of binaries that will be generated. You may choose one of those two values:

  • Debug: Binaries will be compiled with debug symbols (-g), allowing the use of a debugger (eg. gdb). Tulip libraries will also provide a lot of extra check on data structure when procedures are called. This mode is mainly used at a development-stage to ensure that everything we do is valid and well-supported by the Tulip libraries.
  • Release: Binaries will be stripped of any extra checks (speeding up the application) and will be compiled without debugging symbols. Extra optimization flags will also be passed to the compiler (eg. -O2 for GCC)

 

The CMAKE_INSTALL_PREFIX variable describes the root directory where Tulip binaries will be installed when calling the make install target.

The ENABLE_RENDERING_TIME_DISPLAY will provide console benchmarking for the Tulip OpenGL engine.

Just setup those values the way you want. You may also check the Advanced box to tweak advanced CMake settings. (see CMake documentation for details)

In this tutorial, we will compile Tulip in Release mode and install binaries in the /home/user/tulip-install directory:

Once again, click on the Configure button. Once it's finished loading, click on Generate.

You can close the cmake-gui window.

4 - The real deal

Ok, it's now time to actually compile tulip. Go to your build directory (eg. /home/user/tulip-build) and type the build command related to the generator you previously selected. (eg. On Linux and Mac, this will be the classic make command):

Note that CMake generated a standard build tree for your plateform. You can use any option related to your compiler suite (eg. the -j option for Unix Makefiles)

Time for some coffee while Tulip sources are built, also enjoy the eye-candy, colored output of CMake with the beloved progress percentage.

Once everything is build, just call the install target and you are done ! Binaries will be put in the directory pointed by the CMAKE_INSTALL_PREFIX variable (eg. /home/user/tulip-install). You are now ready to run Tulip !