BuildAnubisFromSources

Version 1 (Anonymous, 01/20/2009 01:58 PM)

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