BuildAnubisFromSources

Version 1 (Cédric RICARD, 01/20/2009 01:58 pm)

1 1
h1. BuildAnubisFromSources
2 1
3 1
{{>toc}}
4 1
5 1
h1. Introduction
6 1
7 1
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 1
9 1
    * cross-platform: works well on Linux (and other UNIXes), Mac OS X and Windows
10 1
    * simpler syntax, easier to learn
11 1
    * faster build times
12 1
    * nice build output with progress and colors ;-) 
13 1
14 1
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 1
16 1
h1. CMake installation
17 1
18 1
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 1
20 1
Note: Use CMake version 2.6.2 or later!
21 1
22 1
h1. Simple build
23 1
24 1
To start configuration and generation of makefiles, go to source directory and run:
25 1
26 1
<pre>
27 1
cmake .
28 1
make
29 1
make install
30 1
</pre>
31 1
32 1
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 1
34 1
h1. Out-of-source build
35 1
36 1
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 1
38 1
<pre>
39 1
 mkdir build
40 1
 cd build
41 1
 cmake ..
42 1
 make
43 1
 make install
44 1
</pre>
45 1
46 1
Another benefit is that it's easy to delete the whole build just by deleting its directory.
47 1
48 1
h1. Configuration
49 1
50 1
All configuration settings are variables. You can set them manually in two different ways:
51 1
52 1
* specifying on command line:
53 1
    <pre>cmake -D VAR1=VALUE1 -D VAR2=VALUE2 ...</pre>
54 1
* using an interactive tool
55 1
** Windows: cmakesetup - tool providing a dialog for configuration
56 1
** UNIX/Mac OS: ccmake - ncurses based configuration tool You need to specify path for these tools what build do you want to configure 
57 1
58 1
h1. Important variables
59 1
60 1
There are several variables that you might want to set:
61 1
62 1
|*Variable*|*Default value*|*Meaning*|
63 1
|CMAKE_INSTALL_PREFIX|/usr/local|prefix where to install application and its data|
64 1
|CMAKE_BUILD_TYPE| |whether to compile with debugging support or not (values Release or Debug)|
65 1
|CMAKE_SKIP_RPATH *|OFF|turning this ON will save you some compile time as relinking during 'make install' won't happen|
66 1
67 1
Anubis specific variables:
68 1
69 1
|*Variable*|*Default value*|*Meaning*|
70 1
|BISON| |Full path for 'bison' command line|
71 1
|FLEX| |Full path for 'flex' command line|
72 1
|M4_PATH| |Full path for 'm4' command line|
73 1
74 1
75 1
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 1
77 1
Also if you have your libraries in non-standard locations you'll probably will need to specify their include directory and library file.
78 1
79 1
h1. Platform specific notes
80 1
81 1
h2. Unix notes
82 1
83 1
If you have all dependencies in standard paths (/usr or /usr/local), configuration should be done without any problems.
84 1
85 1
It should be possible to generate KDevelop3 project files with "KDevelop3" generator.
86 1
87 1
h2. Windows notes
88 1
89 1
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 1
91 1
h2. Mac OS X notes
92 1
93 1
Mac OS X is not yet supported.
94 1
95 1
h1. Troubleshooting
96 1
97 1
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 1
99 1
make VERBOSE=1
100 1
101 1
h1. Links
102 1
103 1
This sections lists some additional materials about CMake:
104 1
105 1
* Cross-Platform Software Development Using CMake - introduction how to create a build system for an application with CMake