<?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>Ivan Čukić &#187; CMake</title>
	<atom:link href="http://ivan.fomentgroup.org/blog/tag/cmake/feed/" rel="self" type="application/rss+xml" />
	<link>http://ivan.fomentgroup.org/blog</link>
	<description>Free Software Developer and Enthusiast</description>
	<lastBuildDate>Sun, 08 Jan 2012 22:36:29 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Improved KDE build scripts</title>
		<link>http://ivan.fomentgroup.org/blog/2010/01/02/improved-kde-build-scripts/</link>
		<comments>http://ivan.fomentgroup.org/blog/2010/01/02/improved-kde-build-scripts/#comments</comments>
		<pubDate>Sat, 02 Jan 2010 09:12:45 +0000</pubDate>
		<dc:creator><span property="dc:creator" resource="http://ivan.fomentgroup.org/blog/2010/01/02/improved-kde-build-scripts/">Ivan Čukić</span></dc:creator>
				<category><![CDATA[KDE]]></category>
		<category><![CDATA[CMake]]></category>
		<category><![CDATA[debug]]></category>
		<category><![CDATA[make]]></category>
		<category><![CDATA[planetKDE]]></category>

		<guid isPermaLink="false">http://ivan.fomentgroup.org/blog/?p=621</guid>
		<description><![CDATA[For quite some time now (seems like forever) I&#8217;ve used a bit modified scripts from Techbase: Increased Productivity in KDE4 with Scripts to build KDE. I don&#8217;t know why, but I&#8217;ve never even tried kdesvn-build script, so the things I&#8217;ll write here are maybe (probably) already present in it. So, if you don&#8217;t use kdesvn-build, [...]]]></description>
			<content:encoded><![CDATA[<p>For quite some time now (seems like forever) I&#8217;ve used a bit modified scripts from <a href="http://techbase.kde.org/Getting_Started/Increased_Productivity_in_KDE4_with_Scripts">Techbase: Increased Productivity in KDE4 with Scripts</a> to build <a href="http://www.kde.org/" class="kblinker" target="_blank">KDE</a>.</p>
<p>I don&#8217;t know why, but I&#8217;ve never even tried kdesvn-build script, so the things I&#8217;ll write here are maybe (probably) already present in it.</p>
<p>So, if you don&#8217;t use kdesvn-build, and have your system set up like it is explained in the above link, keep reading.</p>
<p><b>Important:</b> I&#8217;m using ZSH, so the scripts here maybe need changing in order to be usable in BASH.</p>
<p><strong>Environment</strong></p>
<p>First of all, we need to add some global, environment variables. You should put this in the script for setting KDE4 variables (for example in .my-setup)
<p>The first variable will be used by the build logging system. You should define it near the definitions of KDE_SRC and KDE_BUILD variables.</p>
<p><code><br />
    # build and src folders<br />
    # you might want to change these!<br />
    export KDE_BUILD=$KDE4ROOT/build<br />
    export KDE_SRC=$KDE4ROOT/src<br />
    export KDE_LOG=$KDE4ROOT/log<br />
</code></p>
<p>After this, we are making a variable that holds all the dirs to be included in the automatic build system.</p>
<p><code>
<pre>
# all build dirs
KDE_BUILD_DIRS=""

pushd $KDE_SRC > /dev/null
	for dir in                  \
		KDE/support         \
		KDE/libs            \
		KDE/pimlibs         \
		KDE/base            \
		KDE/plasmoids       \
		KDE/pim             \
		KDE/accessibility   \
		KDE/artwork         \
		KDE/bindings        \
		KDE/graphics        \
		KDE/multimedia      \
		KDE/network         \
		KDE/sdk             \
		KDE/utils           \
                                    \
		extragear/*         \
		other/*             \
		playground/*        \
	;
	do
		KDE_BUILD_DIRS="$KDE_BUILD_DIRS $dir";
	done

popd > /dev/null

export KDE_BUILD_DIRS
</pre>
<p></code></p>
<p><strong>SVN/GIT Updates</strong></p>
<p>Now, we can create two very easy functions for fetching the updates:</p>
<p><code>
<pre>
function updatesource {
    if [ -n "$1" ]; then
        cd $1;
    fi
    if [ -d .svn ]; then echo "Updating directory: $PWD (svn)"; svn up; fi
    if [ -d .git ]; then echo "Updating directory: $PWD (git)"; git pull; fi
}

function kdeup {
	# clearing update logs
	rm -fr $KDE_LOG/update.log
	rm -fr $KDE_LOG/*.update

	cd $KDE_SRC
	for dir in `echo $KDE_BUILD_DIRS`; do
		updatesource $KDE_SRC/$dir || echo "$dir (see $log_file) update failed" >> $KDE_LOG/update.log
	done
}
</pre>
<p></code></p>
<p>Notice that it reports errors in $KDE_LOG/update.log file.</p>
<p><strong>Building</strong></p>
<p>Now we define kdemake command which will build all the directories we specified in $KDE_BUILD_DIRS. Like kdeup, it logs the process. The main log is $KDE_LOG/build.log and each built directory has its own build log (the output of cmake + make).</p>
<p><code>
<pre>
function kdemake {
	# clearing all logs
	rm -fr $KDE_LOG/build.log
	rm -fr $KDE_LOG/*.build

	cd $KDE_SRC
	for dir in `echo $KDE_BUILD_DIRS`; do
		cd $KDE_SRC/$dir;
		echo "Building $dir";

		log_file=`echo $dir | sed 's/\//_/g'`;
		log_file="$KDE_LOG/$log_file.build";
		echo "Building $dir > $log_file" > $log_file;

		echo "Building $dir" >> $KDE_LOG/build.log
		( ( cmakekde || echo "FAILED: see $log_file" >> $KDE_LOG/build.log ) 2> /dev/stdout | tee -a $log_file )
	done
}
</pre>
<p></code></p>
<p><b>Debug builds</b>
<p>Sometimes you want to have a certain module build with debugging symbols &#8211; just replace the default cmakekde function with this one. It checks for the .debug file and if it exists, it builds that module with dbg symbols included.</p>
<p><code>
<pre>
function cmakekde {
	if test -n "$1"; then
		# srcFolder is defined via command line argument
		srcFolder="$1"
	else
		# get srcFolder for current dir
		srcFolder=`pwd | sed -e s,$KDE_BUILD,$KDE_SRC,`
	fi
	# we are in the src folder, change to build directory
	# Alternatively, we could just use makeobj in the commands below...
	current=`pwd`
	if [ "$srcFolder" = "$current" ]; then
		cb
	fi
	# to enable tests, add -DKDE4_BUILD_TESTS=TRUE to the next line.
	# you can also change "debugfull" to "debug" to save disk space.
        # added "nice make..." to allow the user to work on the box while
        # compiling
        # Note: To speed up compiling, change 'make -j2' to 'make -jx',
        #   where x is your number of processors +1

	if test -e ".debug"; then
		echo "debug yes" &#038;&#038; \
		cmake "$srcFolder" -GKDevelop3 -DCMAKE_INSTALL_PREFIX=$KDEDIR \
			-DCMAKE_BUILD_TYPE=debugfull \
			&#038;&#038; nice make -j3 &#038;&#038; make install
	elif test -e ".debug-release"; then
		echo "debug yes [release-debug]" &#038;&#038; \
		cmake "$srcFolder" -GKDevelop3 -DCMAKE_INSTALL_PREFIX=$KDEDIR \
			-DCMAKE_BUILD_TYPE=RelWithDebInfo \
			&#038;&#038; nice make -j3 &#038;&#038; make install
	else
		echo "debug no" &#038;&#038; \
		cmake "$srcFolder" -GKDevelop3 -DCMAKE_INSTALL_PREFIX=$KDEDIR \
			-DCMAKE_BUILD_TYPE=release \
			&#038;&#038; nice make -j3 &#038;&#038; make install
	fi
}
</pre>
<p></code></p>
<p><b>Checking logs</b></p>
<p>So, updating KDE is now a matter of calling kdeup and kdemake. The next thing to do is to create a watching mechanism (to put it in the command watch plasmoid for example).</p>
<p>The first script is outputting what is currently being built &#8211; something like this:</p>
<p><code>/opt/kde4trunk/log/KDE_support.build : [ 49%] Built target phonon</code></p>
<p>The code for this bash script is:</p>
<p><code>
<pre>
#!/bin/bash
WHATFILE=`ls -t1 /opt/kde4trunk/log/*.build | head -n 1`
WHAT=`grep '%' $WHATFILE | tail -n 1`
echo $WHATFILE ":" $WHAT
</pre>
<p></code></p>
<p><b>That&#8217;s all for today.</b><br />
]]></content:encoded>
			<wfw:commentRss>http://ivan.fomentgroup.org/blog/2010/01/02/improved-kde-build-scripts/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>CMake 2.6 required, and life</title>
		<link>http://ivan.fomentgroup.org/blog/2008/08/01/cmake-26-required-and-life/</link>
		<comments>http://ivan.fomentgroup.org/blog/2008/08/01/cmake-26-required-and-life/#comments</comments>
		<pubDate>Fri, 01 Aug 2008 09:55:57 +0000</pubDate>
		<dc:creator><span property="dc:creator" resource="http://ivan.fomentgroup.org/blog/2008/08/01/cmake-26-required-and-life/">Ivan Čukić</span></dc:creator>
				<category><![CDATA[KDE]]></category>
		<category><![CDATA[CMake]]></category>
		<category><![CDATA[Lancelot]]></category>
		<category><![CDATA[planetKDE]]></category>
		<category><![CDATA[Rant]]></category>

		<guid isPermaLink="false">http://ivan.fomentgroup.org/blog/?p=114</guid>
		<description><![CDATA[Since I&#8217;ve almost missed the BIG BIG BIG message saying &#8220;From August 4th CMake >= 2.6.0 will be required, please update your CMake&#8221; (I&#8217;ve set up scripted compiling in background, so it&#8217;s not that strange I did not see it) I thought that there could be someone else who could miss it. So, upgrade your [...]]]></description>
			<content:encoded><![CDATA[<p>Since I&#8217;ve almost missed the BIG BIG BIG message saying &#8220;From August 4th CMake >= 2.6.0 will be required, please update your CMake&#8221; (I&#8217;ve set up scripted compiling in background, so it&#8217;s not that strange I did not see it) I thought that there could be someone else who could miss it. <b>So, upgrade your CMake!</b> (for Debian users: CMake 2.6 is present in unstable)</p>
<p>BTW, I&#8217;ve switched to use the 4.1 branch for all modules. Obviously, I&#8217;ve set a trunk setup as well, but this time only <a href="http://plasma.kde.org/" class="kblinker" target="_blank">Plasma</a> is from the trunk. For the next few months, <a href="http://lancelot.fomentgroup.org/" class="kblinker" target="_blank">Lancelot</a> will be developed for both 4.1 and trunk (The separation was needed since there already is an API breakage).</p>
<p><b>Move along, nothing (more) to see here</b></p>
]]></content:encoded>
			<wfw:commentRss>http://ivan.fomentgroup.org/blog/2008/08/01/cmake-26-required-and-life/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

