Personal tools

CMake build instructions

From MCRL2

Jump to: navigation, search

Contents

Introduction

CMake is a cross-platform open-source build system. It consists of a collection of tools that are designed to build, test and package software. CMake is used to control the software compilation process using simple platform and compiler independent configuration files. It generates native makefiles and workspaces that can be used in the compiler environment of your choice.

Currently, the system is developed and tested under Linux with GCC only. The current todo list can be found here.

Prerequisites

mCRL2

A copy of the source tree can be obtained in two ways:

The Subversion revision control system is used for storing the source code of the mCRL2 toolset in a repository. Using a Subversion client it is possible to obtain a local copy of the source tree. The following command achieves this:

svn checkout https://svn.win.tue.nl/repos/MCRL2/trunk MCRL2

This creates a local directory MCRL2 with the contents of the trunk directory in the MCRL2 repository. For more information on using SVN see the Subversion website.

Linux

The following packages must be installed:

Name Version Package
g++ >= 4.0.0 gcc-c++
make >= 3.80 make
Optional packages
Name Version Package
default icon locations "gnome-themes", "gnome-themes-extras" or "hicolor-icon-theme"
flex >= 2.5.4a-12 flex
bison >= 2.0 bison
doxygen >= 1.5.3 doxygen
python >= 2.5.1 python

Any of these default icon location packages ensure that the tools requiring "wxWidgets" do not generate warnings on missing icons. The packages for "flex", "bison", and "python" are used to generate source code. The package for "doxygen" is used to generate HTML documentation for the website. "flex", "bison", "python" and "doxygen" are only needed for developers.

Windows

A copy of Microsoft Visual Studio C++ should be installed. Express editions (may) require additional Windows SDK 6.0a or higher to be installed.

Name Version Package
Microsoft Visual Studio C++ >= 2008 Express / Professional/ Ultimate

Note: It is possible to install the toolset in a Cygwin/MinGW environment. However, we provide no guarantee that it will work out of the box, nor providing (active) support. To build for these environments follow the build instructions for Unix-Like platforms.

Mac OS X

Mac OS requires a copy of XCode which comes with the installation DVD's but which is generally not preinstalled on the Mac:

The mCRL2 toolset relies on Boost and wxWidgets. These libraries can be installed via MacPorts for local builds. For builds, that are used for distributions, we discourage the use of MacPorts, since it may install libraries that are not available on other systems. Instead, we advise to build Boost and wxWidgets from scratch. For portability these libraries, and the mCRL2 toolset as well, should be compiled static.

CMake

The CMake build system requires a installed copy of CMake (v2.8 or higher) to be installed on your system. If your copy does not match the requirements or is simply not available it can be downloaded here.

Boost

The mCRL2 toolset requires an external version of Boost and external version of wxWidgets for development. If Boost (v1.36 or higher) is correctly installed, CMake will find the installation and use it. Installing Boost can be done as described below.

Installing Boost for Windows

BoostPro Computing offers pre-compiled Boost library binaries for Windows. Currently BoostPro only offers 32-bit binaries. If these libraries are used during compilation of 64-bit libraries they can give strange linker errors. We recommend users that want to compile 64-bit binaries to build Boost from source.

WIN32 build
- Filesystem
- Serialization
- Signals
- Regex
- System

Note: Select only version for your compiler (unfold selection). Installing can take some time and disk- space.

WIN64 build

For this tutorial we require that a copy of Microsoft Visual Studio is already installed.

Configure Toolset

The following instructions can be used

 Add Entry -> Name = BOOST_ROOT, Type = PATH, Value = "C:\Program Files\boost\boost_1_44" -> OK 
 % Boost version: 1.44.0
 % Found the following Boost libraries:
 %   signals
 %   filesystem
 %   regex

Installing Boost for Linux

Select the following boost packages from the package manager:

- Filesystem
- Serialization
- Signals
- Regex
Installing Boost on Linux from scratch

Installing Boost on MacOS-X

Boost can be installed using MacPorts. This appears to be only a 32 bits version of Boost. For MacOS10.6 a 64 bits version can be obtained by downloading the sources from the boost webpages and translate it using ./bjam architecture=x86 address-model=32_64 (see hint from Technoboria. The macports version can be installed by:

Installing Boost on MacOS-X from scratch

wxWidgets

The mCRL2 toolset requires an external version of wxWidgets to develop graphical tools. Make sure that a copy is installed. Tools build in debug mode, require a debug version of wxWidgets. Tools that are not build in debug mode, require a release version of wxWidgets. If release tools are linked to debug libraries or vice-versa, it is possible that graphical tools will not work or compilation fails.

Installing wxWidgets on Linux

Install the following packages with your favorite package manager. When installed, they will be found by cmake.

Name Version Package Components
wxWidgets >= 2.8.11 "libwxgtk2.8-dev" or "libwxgtk2.8-dbg" base core adv xml html aui stc
OpenGL 7.0.1, >= 2.8.11 Mesa (GL and GLU), wxWidgets-gl

These packages are required for the following graphical tools:

Note: wxWidgets must be compiled with OpenGL for the following tools:

To build wxWidgets from scratch you could use the following configure for version 2.8:

./configure  --disable-shared --disable-compat24 --disable-mediactrl --disable-sound --with-opengl 

Installing wxWidgets on Windows

To install wxWidgets for use with the Microsoft Visual C++ compiler, the following steps have been reported to work:

cmake -DwxWidgets_LIB_DIR="<wxdir>/lib/vc_lib" -DwxWidgets_ROOT_DIR="<wxdir>"

Optional, you can compile mCRL2 with wxWidgets Styled Text Control (wxSTC). This provides features within mcrl2xi as syntax highlighting and bracket matching. To enable these features, perform the following steps:

Now mCRL2 can be compiled with wxSTC. To enable this option, the Cmake MCRL2_WITH_WXSTC should be set to TRUE.

Installing wxWidgets on MacOS-X

wxWidgets can be installed using MacPorts.

Installing wxWidgets on MacOS Snow Leopard 10.6.7 (x86-64)

Download and unpack the latest development version from the wxWidgets website. The tutorial, which is described here, uses version 2.9.1. To build the toolset for the "x86-64" architecture, we require the "cacoa" framework.

Change directory to the directory of the unpacked source. Perform the following commands to configure wxWidgets.

 set arch_flags="-arch x86_64" 
 ./configure -with-osx_cocoa --disable-shared --disable-compat24 --disable-unicode CFLAGS="$arch_flags" CXXFLAGS="$arch_flags" CPPFLAGS="$arch_flags" LDFLAGS="$arch_flags" OBJCFLAGS="$arch_flags" OBJCXXFLAGS="$arch_flags" --prefix=`pwd`/Release/ --with-libiconv-prefix=/opt/local/ --disable-mediactrl --disable-sound 

The first command sets the architecture. The second command configures the wxWidgets libraries. If MacPort has install "libiconv", we need to set "--with-libiconv-prefix" to the MacPort installation path, as it precedes the default version. The flag can be omitted if otherwise. Note that we disable media controls as well as the sound library, as they are not required.

To build wxWidgets for the i386 architecture, configure the toolset with the following commands:

arch_flags="-arch i386"
./configure --disable-shared --disable-compat24 CFLAGS="$arch_flags" CXXFLAGS="$arch_flags" CPPFLAGS="$arch_flags" LDFLAGS="$arch_flags" OBJCFLAGS="$arch_flags" OBJCXXFLAGS="$arch_flags"  --disable-mediactrl --disable-sound --with-opengl --with-macosx-version-min=10.5 --with-macosx-sdk=/Developer/SDKs/MacOSX10.5.sdk

Now build wxWidgets:

make

and install accordingly

make install

When configuring the mCRL2 toolset set the location of "wx-config" and "wxrc" to the locations of the tools where the custom installation of wxWidgets is installed. Make sure that to build the toolset static, e.g. the value "BUILD_SHARED_LIBS" of needs to be set to "FALSE".

As graphical tools are linked, they might give a warning:

 Linking CXX executable mcrl2-gui.app/Contents/MacOS/mcrl2-gui
ld: warning: in /System/Library/Frameworks//QuickTime.framework/QuickTime, missing required architecture x86_64 in file

Since we do not use the media controls or the sound library, we can remove all occurrences of "-framework QuickTime" from the "configure" and "configure.in", to remove this warning. This requires a make clean, configure, make and install of the wxWidgets.

Clang Compiler [Optional]

The toolset can also be compiled using the Clang compiler. The Clang compiler can be downloaded from [4]. A release of the compiler can be found here [5].

Download a binary copy (For Mac OS-X: "Clang Binaries for MacOS X/x86-64") and unpack the zip file. Optionally, move extracted directory structure to your favorite folder, say: "/Clang" To compile the mCRL2-toolset with the clang compiler, specify at the first configuration run of CMake, the location of the Clang C and C++ compiler:

 cmake -DCMAKE_CXX_COMPILER=/Clang/bin/clang++ -DCMAKE_C_COMPILER=/Clang/bin/clang 

Ensure that the location of the executables is specified in a full path notation. After the configuration, proceed with CMake_build_instructions#Compilation.


Configuration

After the CMake build files are inside the mCRL2 trunk, platform specific makefiles need to be generated for compilation and installation. These Makefiles can be generated inside the source tree or outside the source tree (resp. in-source and out-of-source builds). The advantage of an out-of-source build, is that it allows different build configurations to be maintained concurrently. The preference is given to an out-of-source build. We recommend not to mix in- and out-of-source builds, because they lead to errors when generating makefiles.

Out-of-source builds

For an out-of-source build, create a directory in the location of your choice (indicated by BUILD_DIR):

mkdir BUILD_DIR

Navigate to the directory:

cd BUILD_DIR

Makefiles are generated in BUILD_DIR by executing the following:

cmake /full/path/to/MCRL2

Note: Prior to running this command, the absence of file /path/to/MCRL2/CMakeCache.txt (the location of the SVN checkout) is required, because otherwise no makefiles are generated.

In-source builds

For an in-source build, first navigate to the mCRL2 source directory:

cd /path/to/MCRL2

Makefiles are generated by executing the following command:

cmake .

Note: CMake creates a "Makefile" that overrides the current one in the source directory for UNIX systems. Because boost-build requires this Makefile, users MAY NOT UPLOAD this file. To avoid clashes the "MCRL2_BUILD_IN_SOURCE" variable should explicitly be set to "ON".

Alternative Makefile Generation

It is possible to generate make files differently. Some methods are described below:

Command line (WIN, UNIX, MAC)

ccmake /full/path/to/MCRL2

The "ccmake" executable is the CMake curses interface. Project configuration settings may be specified interactively through this GUI in a terminal. Brief instructions are provided at the bottom of the terminal when the program is running.

Graphical (WIN, UNIX, MAC)

cmake-gui

The "cmake-gui" executable is the CMake curses interface. Project configuration settings may be specified interactively through this GUI. To use this command on Unix/MAC systems, additional packages may be required.

Parameters

The behaviour of generated Makefiles can be altered by using the -D<FLAG=option>. To set a variable, e.g. CMAKE_BUILD_TYPE to Debug, execute the following command (for both in-source and out-of-source builds):

cmake . -DCMAKE_BUILD_TYPE=debug

If the variable CMAKE_BUILD_TYPE is set to Maintainer code coverage will be performed when running tests. wxWidgets is found automatically, if installed. Sometimes it may be convenient to use a version of wxWidgets. If an user want to build with custom version of wxWidgets on Mac and UNIX systems, the user should specify the location (including the file) where wx-config is located. If wxWidgets is compiled and installed in e.g. /USER/Henk/wxWidgetsXYZ/wx-config one should execute the command:

cmake . -DwxWidgets_CONFIG_EXECUTABLE=/USER/Henk/wxWidgetsXYZ/wx-config

Note: Values of the flags are cached and are case insensitive. This implies that when changing a single value, all other flags remain the same. It is also possible to run ccmake instead of cmake with -D.

Here <FLAG=option> needs to be substituted by the variable and value by of your choice. The most important FLAG variables are (default values are indicated by a *):

A variable which controls the type of build when using a single-configuration generator like the Makefile generator. This variable has no effect for Visual Studio projects as they contain multiple-configurations.
The installation prefix for mCRL2, defaulting to /usr/local. All mCRL2 files will be installed there.
A variable which controls if the build is static or shared. By default libraries are shared.
A variable that is used if the internal Boost version should be use. By default the internal boost version is used.
A variable that is used to enable connectivity with SQuaDT. By default SQuaDT connectivity is enabled.
A variable that controls the build for experimental tools. By default no experimental tools are build.
A variable that controls the build for deprecated tools. By default no deprecated tools are build.
A variable that enables profiling when executing tools. By default this option is disabled.
A variable that enables the build of test targets. This option needs to be enabled in combination with BUILD_TESTING if one wants to execute library tests. By default this option is disabled.
A variable that controls the generation of man-pages. By default this option is enabled.
A variable that specifies if the separate libraries are build as one single library. This excludes third party libraries. By default this option is disabled.
A variable that controls the build of graphical tools. These tools are Diagraphica, Ltsgraph, Ltsview, Squadt (requires SQUADT_CONNECTIVITY) and Xsim. If this value is equal to OFF, no graphical tools are build. By default this option is enabled.
A variable that enables the execution of tests. If MCRL2_ENABLE_TEST_TARGETS is OFF, only tool tests are executed. If the value for MCRL2_ENABLE_TEST_TARGETS is ON, library tests are also executed. By default this option is enabled.
This variable specifies the location where Ctags can be found. Ctags is a program that generates an index (or tag) file of names found in source and header files of various programming languages.
This variable controls the timeout for running tests.
This variable controls the installation of BOOST headers. By default the value is OFF.
This variable specifies the location where svnversion can be found. svnversion is a program for summarizing the revision mixture of a working copy. The program is used to insert the revision number of into the tools.
This variable specifies the full pathname to the wx-config utility in your wxWidgets installation (typically this is located in the bin/ subdirectory of your wxWidgets root install. wx-config is a small command-line utility which can help you while building on unix-like systems (including linux and Mac OS X). wx-config will tell what compile flags to use (wx-config --cppflags), tell what link flags to use (wx-config --libs) and manage multiple wxWidgets installs with different configurations (wx-config --list et al).
This variable specifies if the wxWidgets libraries need to be linked static or shared. By default the libraries are used shared. If the toolset is statically build, this value should be changed to OFF.
This variable specifies if the wxWidgets libraries are use in Unicode. By default the value is equal to ON.
This variable specifies the full pathname to the wx-rc utility in your wxWidgets installation (typically this is located in the bin/ subdirectory of your wxWidgets root install. The wxrc utility compiles binary xml resource files.

Compilation

Unix Makefiles

After configuration the toolset can be compiled by executing

make

The Makefile provides targets for all tools and libraries. A complete list can be obtained using

make help

Compiling individual targets is useful to speed up incremental builds. For instance, in order to compile the target mcrl22lps, you can execute

make mcrl22lps

Or, if you have only made changes to the tool itself and not to the libraries, you can disable dependency checking by executing

make mcrl22lps/fast

It is possible to build the toolset with multiple threads, by using the j flag. To build the toolset with 8 threads use:

make -j8

Visual Studio

Please use Visual Studio 2010. Graphical tools, that are complied with earlier versions, are known to exit with a segmentation fault as the "vtable" gets corrupt.


NMake

Download Boost to <BOOSTROOT> Download wxWidgets to <WXROOT> Checkout mCRL2 into <MCRL2ROOT> Install the following components of Windows SDK 7.0 SP1:

Open the appropriate Visual Studio command prompt. This prompt can be found in <C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\bin\> for Windows SDK 7.0 SP1.

In the command prompt, build Boost as follows:

 cd <BOOSTROOT> 
 bootstrap.bat 
 bjam -j8 address-model=64 architecture=x86 --with-filesystem --with-serialization --with-signals stage 

Boost should now be compiled and the library files should be in the <BOOSTROOT>/stage directory.

Now edit <WXROOT/include/wx/msw/setup.h> such that wxUSE_GLCANVAS is defined to be 1. We are now ready to compile wxWidgets.

 cd <WXROOT>/build/msw 
 nmake BUILD="release" USE_OPENGL=1 UNICODE=0 makefile.vc 
 nmake BUILD="debug" USE_OPENGL=1 UNICODE=0 makefile.vc 

If everything went okay, wxWidgets is now compiled. To build the release version of mCRL2, first create an empty build directory (this will contain the intermediate compilation files). It does not matter where this directory is created, but let's call it <BUILDDIR>. Now go to the command prompt once more, and execute the following.

 cd <BUILDDIR> 
 cmake <MCRL2ROOT> -G "NMake Makefiles" -DBOOST_ROOT:PATH=<BOOSTROOT> -DwxWidgets_ROOT_DIR:PATH=<WXROOT> -DMCRL2_ENABLE_DEPRECATED=ON -DMCRL2_ENABLE_EXPERIMENTAL=ON -DCMAKE_BUILD_TYPE:STRING="Release" 
 nmake Makefile all 

The tools are now still in their subdirectories. If you wish to install them (which you probably do), then execute the command prompt again with administrator privileges and execute the following.

 nmake Makefile install 

This installs the mCRL2 into the program files directory.

Installation

The toolset can be installed by executing the following command in the source tree:

make install

This installs the toolset in the CMAKE_INSTALL_PREFIX directory.

Testing

Before executing tests, make sure that the makefile has been generated with the value of MCRL2_ENABLE_TEST_TARGETS set to YES and the toolset has been compiled once.

To conduct test specified in the source tree execute:

make tests

or

ctest .

To upload the tests to the public dashboard execute one of the following commands. For a nightly build (a build of a svn checkout at 00:00:00 CEST)

ctest -D Nightly 

For an experimental build (used to test new build features) of the current build:

ctest -D Experimental 

For an continuous build of the current build:

ctest -D Continuous 

More available options can be found using using:

ctest -D List 

Note: If multiple Nightly builds are executed, the labels of the buildnames should be disjoint from the other buildname label, in order to avoid the override of earlier builds. To avoid this side-effect, execute cmake and set the BUILDNAME variable with an unique label:

cmake . -DBUILDNAME=label 

Packaging

To build platform specific packages execute the following command:

make package

or

cpack .

To create packages for a specific distribution set the CPACK_SYSTEM_NAME variable to specific distribution by specifying the name, version and architecture.

When package are created for OS-X and Unix, we strongly advise to use the default value for CMAKE_INSTALL_PREFIX, or use a directory value that is available in the target platform.

We advise to use the latest stable version of Cmake and Cpack to generate packages for the various platforms.

Configure packaging for openSUSE

Configure Cmake by:

cmake . -DCPACK_SYSTEM_NAME="`cat /etc/SuSE-release | head -n1 | sed "s/ /\_/g"`"

Configure packaging for Fedora

Create script.sh:

#!/bin/bash
arch="_(`uname -i`)"
fed=`cat /etc/fedora-release | sed 's/ /\_/g'`
echo "$fed$arch"

Then configure Cmake by:

cmake . -DCPACK_SYSTEM_NAME="`script.sh`"

Setup CDash

CDash is an open source, web-based software testing server. CDash aggregates, analyzes and displays the results of software testing processes submitted from clients located around the world.

A generic manual on how to install CDash can be found here.

Tips and Tricks

Development

It is recommended to develop in debug mode. Improper use of the underlying ATerm Library may cause problems, that are caught by assertions in debug mode.

Build selective tools

By selecting single tools on the command-line with make, you can save time on building. For example to build mcrl22lps you can use the following command:

make mcrl22lps

Installing syntax highlighting in Vim

To install vim syntax highlighting of μCRL, mCRL2 and EBNF specifications, do the following.

syntax enable
filetype plugin on
if exists("did_load_filetypes")
  finish
endif

augroup filetypedetect
  au! BufRead,BufNewFile *.bnf          setfiletype ebnf
  au! BufRead,BufNewFile *.ebnf         setfiletype ebnf
  au! BufRead,BufNewFile *.mcrl         setfiletype mcrl
  au! BufRead,BufNewFile *.mcrl2        setfiletype mcrl2
augroup END
This page was last modified on 10 December 2011, at 09:48. This page has been accessed 35,089 times.
Copyright © 2005-2012 Technische Universiteit Eindhoven.
Powered by MediaWiki