<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>woah! &#187; cmake</title>
	<atom:link href="http://www.alexhudson.com/tag/cmake/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.alexhudson.com</link>
	<description>world of alex hudson</description>
	<lastBuildDate>Mon, 10 Oct 2011 08:54:45 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Compiling Bongo</title>
		<link>http://www.alexhudson.com/2009/07/20/compiling-bongo/</link>
		<comments>http://www.alexhudson.com/2009/07/20/compiling-bongo/#comments</comments>
		<pubDate>Mon, 20 Jul 2009 13:19:20 +0000</pubDate>
		<dc:creator>Alex</dc:creator>
				<category><![CDATA[bongo]]></category>
		<category><![CDATA[autotools]]></category>
		<category><![CDATA[cmake]]></category>

		<guid isPermaLink="false">http://www.alexhudson.com/blog/?p=202</guid>
		<description><![CDATA[Recently, we changed the build system of Bongo &#8211; we&#8217;ve moved away from autotools. This isn&#8217;t to say that autotools is necessarily that deficient, but the new CMake system we&#8217;re using is a lot more suitable for our kind of project. This has brought some immediate benefits &#8211; much simpler build system, much quicker compiles [...]]]></description>
			<content:encoded><![CDATA[<p>Recently, we changed the build system of Bongo &#8211; we&#8217;ve moved away from autotools. This isn&#8217;t to say that autotools is necessarily that deficient, but the new CMake system we&#8217;re using is a lot more suitable for our kind of project. This has brought some immediate benefits &#8211; much simpler build system, much quicker compiles and installations (&#8216;make install&#8217; in particular is now much faster), and a slightly simpler source tree. We can also now build binaries out-of-source, which is a huge boon.</p>
<p>However, we haven&#8217;t yet really documented properly all the different build options and how it works. So here it is &#8211; your primer to the new Bongo build system.</p>
<p>Once you&#8217;ve checked out Bongo, you&#8217;ll see a source tree which looks something like this:</p>
<pre style="padding-left: 30px;">$ ls
ABOUT-NLS  cmake           COPYING  import   INSTALL  po      TODO
AUTHORS    CMakeLists.txt  doxygen  include  man      README  zoneinfo
ChangeLog  config.h.cmake  HACKING  init     NEWS     src</pre>
<p>The first thing we should do is create a new directory to do our build in: this stops all our build files from littering the source tree.</p>
<pre style="padding-left: 30px;">$ mkdir build
$ cd build/</pre>
<p>Now we need to configure the build. There are two ways of doing this, and I use both! One way is good to start off, the other way is good for tweaking. You&#8217;ll see what I mean, but let&#8217;s start with the initial configuration. This is how I usually start:</p>
<pre style="padding-left: 30px;">$ cmake ../ -DCMAKE_INSTALL_PREFIX=/tmp/build -DBONGO_USER=alex -DCMAKE_BUILD_TYPE=Debug -DDEBUG=On</pre>
<p>The first argument points to the Bongo source directory. Because I made a &#8216;build&#8217; directory in the source tree and went into it, we&#8217;re just pointing at our parent directory. Then come some other options. Every option is prefixed with &#8220;-D&#8221;, and some of them are CMake options and others are Bongo options. In full:</p>
<ul>
<li>CMAKE_INSTALL_PREFIX: where we want to install to. I use /tmp/build for testing, and /usr/local/bongo when I want to run it in production.</li>
<li>BONGO_USER: which user you want Bongo to run as. I use my user account for testing, &#8220;bongo&#8221; for production. You can also run as &#8220;root&#8221; if brave (not recommended!)</li>
<li>CMAKE_BUILD_TYPE: set this to Debug to generate information for gdb, otherwise leave this option out.</li>
<li>DEBUG: enable code paths which generate debugging messages. Both this option and the previous are for either advanced users or developers, really.</li>
</ul>
<p>There are other options to the Bongo build, but these are the main ones. However, once you&#8217;ve configured Bongo, you may want to tweak something: perhaps turn on debugging, or change one of the file paths, or something different. The easiest way to do that is simply:</p>
<pre style="padding-left: 30px;">$ ccmake ./</pre>
<p>Note that it&#8217;s &#8220;ccmake&#8221;, not &#8220;cmake&#8221;. This starts an interactive application where you can change each configuration item. You point it at the <strong>build</strong> directory, not the source, and it gives you all the various tweakable options. You&#8217;ll see that they are the same options that we pass to cmake &#8211; and indeed, you can pass them to cmake! There&#8217;s even an advanced mode with even more knobs (press &#8216;t&#8217;). When you&#8217;re done, press &#8216;c&#8217; to configure the build and then &#8216;q&#8217; to quit.</p>
<p>Once you have configured the build, you have access to the usual make commands:</p>
<pre style="padding-left: 30px;">$ make
$ make install
$ make clean</pre>
<p>The first builds Bongo, the second installs it to your prefix, the last removes the built files.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.alexhudson.com/2009/07/20/compiling-bongo/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>A few words on CMake&#8230;</title>
		<link>http://www.alexhudson.com/2009/06/16/a-few-words-on-cmake/</link>
		<comments>http://www.alexhudson.com/2009/06/16/a-few-words-on-cmake/#comments</comments>
		<pubDate>Tue, 16 Jun 2009 22:47:26 +0000</pubDate>
		<dc:creator>Alex</dc:creator>
				<category><![CDATA[bongo]]></category>
		<category><![CDATA[freesoftware]]></category>
		<category><![CDATA[cmake]]></category>

		<guid isPermaLink="false">http://www.alexhudson.com/blog/?p=177</guid>
		<description><![CDATA[I did promise Lance that I would blog more on Bongo, and I&#8217;m going to try to stick to a post a week at least &#8211; however, this first one will only tangentially be about Bongo. Since the project was initially released, the autotools build system was what you needed to create Bongo. There are [...]]]></description>
			<content:encoded><![CDATA[<p>I did promise Lance that I would blog more on Bongo, and I&#8217;m going to try to stick to a post a week at least &#8211; however, this first one will only tangentially be about Bongo.</p>
<p>Since the project was initially released, the autotools build system was what you needed to create Bongo. There are a variety of benefits to using autotools, and it&#8217;s an extremely well-tested and mature system. However, it&#8217;s also relatively difficult to understand and not particularly quick. Over time we accreted more and more things into our build which no-one understood fully and that would occasionally blow up in our face.</p>
<p>Now, a little while ago I started a new branch of Bongo, called &#8220;memmgr-glib&#8221;. This was mainly to replace the memory allocator &#8211; maybe Pat can blog a bit more about this, but the short story is that this change has highlighted a variety of bugs in Bongo. The branch version of Bongo therefore seems extremely unstable &#8211; actually, it&#8217;s just a lot less bug-tolerant, which is overall a good thing &#8211; but we used that as a cue to make some other changes.</p>
<p>One of which was a switch from autotools to CMake as our build system. Just to give one really obvious stat:</p>
<table style="height: 92px;" border="0" width="519">
<tbody>
<tr>
<th></th>
<th>autotools</th>
<th>cmake</th>
</tr>
<tr>
<th>Configure</th>
<td>52 seconds</td>
<td>3 seconds</td>
</tr>
<tr>
<th>Initial compile</th>
<td>47 seconds</td>
<td>21 seconds</td>
</tr>
<tr>
<th>Install</th>
<td>1m 15 seconds(!)</td>
<td>2 seconds</td>
</tr>
</tbody>
</table>
<p>Clearly, there is a big difference in each category: it must be said that the build systems aren&#8217;t doing quite the same things at this point, and I haven&#8217;t done these tests properly as benchmarks, but fundamentally the times are extremely different. I expect eventually that the compile time will even out &#8211; the difference will become minimal, and is already of the same order. Configure and install are clearly quicker though, and there aren&#8217;t any amazing short-cuts being taken on the cmake side.</p>
<p>The huge difference this makes for developers is the compile-test cycle. A re-compile with either system is basically pretty quick &#8211; something like a few seconds each. However, &#8220;make install&#8221; with both systems is quite different. To do a proper update, it&#8217;s much quicker with cmake, which means the testing cycle is really quick.</p>
<p>One other thing that is also big, for me at least: with CMake, we can finally do out-of-source builds. It&#8217;s possible with autotools, but our system never quite got it right. With CMake, you can check out Bongo from svn and then do something like &#8216;mkdir build/; cd build/; cmake ../; make&#8217;. The source we checked out isn&#8217;t touched, and nothing gets built in the source tree &#8211; it all happens in another directory. Not only does it feel cleaner, but it means that you&#8217;re not likely to commit any files which shouldn&#8217;t be there and if something goes wrong you can just nuke the build directory and start again easily.</p>
<p>I&#8217;ve yet to teach the bongo-build bot on IRC about this new system, but I expect that it will make building there a lot quicker too &#8211; mainly because it goes through the cycle above more than once (it configures twice, for example). It will be interesting to see what a difference it makes!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.alexhudson.com/2009/06/16/a-few-words-on-cmake/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

