Project

General

Profile

BuildAnubisFromSources » History » Version 1

Anonymous, 01/20/2009 01:58 PM
Doc on using CMake

1 1 Anonymous
h1. BuildAnubisFromSources
2
3
{{>toc}}
4
5
h1. Introduction
6
7
Motivation of using CMake instead of popular Automake+Autoconf build system lies on being able to achieve many build tasks better. Here are the main benefits:
8
9
    * cross-platform: works well on Linux (and other UNIXes), Mac OS X and Windows
10
    * simpler syntax, easier to learn
11
    * faster build times
12
    * nice build output with progress and colors ;-) 
13
14
Autotools have the advantage that they're far more widespread and users know very well the usual ./configure && make && make install installation. This page tries to introduce CMake system to Anubis users that want build Anubis from source. It doesn't go much to details so if you're interested in further knowledge, seek for more information on home page: http://www.cmake.org/
15
16
h1. CMake installation
17
18
To install CMake, download it from http://www.cmake.org/HTML/Download.html for your platform or use your distribution's packages. Building CMake from source shouldn't be a problem, the only dependency is a C++ compiler.
19
20
Note: Use CMake version 2.6.2 or later!
21
22
h1. Simple build
23
24
To start configuration and generation of makefiles, go to source directory and run:
25
26
<pre>
27
cmake .
28
make
29
make install
30
</pre>
31
32
The dot means that it should use current directory as a root of the build. If configuration will end without errors CMake will also generate makefiles, otherwise it will show some errors. The problems usually lie in not being able to set some variables automatically - in that case you can specify them manually.
33
34
h1. Out-of-source build
35
36
This build option is good especially for developers as it allows building several different configurations with the same sources. E.g. you can build either debug / release version, use dynamic / static linking and more options. To use out-of-source build just create a directory where it will get built - nothing complicated:
37
38
<pre>
39
 mkdir build
40
 cd build
41
 cmake ..
42
 make
43
 make install
44
</pre>
45
46
Another benefit is that it's easy to delete the whole build just by deleting its directory.
47
48
h1. Configuration
49
50
All configuration settings are variables. You can set them manually in two different ways:
51
52
* specifying on command line:
53
    <pre>cmake -D VAR1=VALUE1 -D VAR2=VALUE2 ...</pre>
54
* using an interactive tool
55
** Windows: cmakesetup - tool providing a dialog for configuration
56
** UNIX/Mac OS: ccmake - ncurses based configuration tool You need to specify path for these tools what build do you want to configure 
57
58
h1. Important variables
59
60
There are several variables that you might want to set:
61
62
|*Variable*|*Default value*|*Meaning*|
63
|CMAKE_INSTALL_PREFIX|/usr/local|prefix where to install application and its data|
64
|CMAKE_BUILD_TYPE| |whether to compile with debugging support or not (values Release or Debug)|
65
|CMAKE_SKIP_RPATH *|OFF|turning this ON will save you some compile time as relinking during 'make install' won't happen|
66
67
Anubis specific variables:
68
69
|*Variable*|*Default value*|*Meaning*|
70
|BISON| |Full path for 'bison' command line|
71
|FLEX| |Full path for 'flex' command line|
72
|M4_PATH| |Full path for 'm4' command line|
73
74
75
Variables marked with * are advanced - this means that they're not shown by default in CMake GUI (ccmake or cmakesetup), however it's possible to show them.
76
77
Also if you have your libraries in non-standard locations you'll probably will need to specify their include directory and library file.
78
79
h1. Platform specific notes
80
81
h2. Unix notes
82
83
If you have all dependencies in standard paths (/usr or /usr/local), configuration should be done without any problems.
84
85
It should be possible to generate KDevelop3 project files with "KDevelop3" generator.
86
87
h2. Windows notes
88
89
Currently officially supported C/C++ compiler is Visual C++ version 6. Library dependencies (OpenSSL and libjpeg) are already compiled for this compiler into 'third_dev' folder.
90
91
h2. Mac OS X notes
92
93
Mac OS X is not yet supported.
94
95
h1. Troubleshooting
96
97
In case that something goes wrong and build fails, it's useful to see the actual commands being run by 'make' to find out what's wrong. This is how to do it:
98
99
make VERBOSE=1
100
101
h1. Links
102
103
This sections lists some additional materials about CMake:
104
105
* Cross-Platform Software Development Using CMake - introduction how to create a build system for an application with CMake