<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title>CMake on UberMongoose</title>
		<link>http://localhost:1313/tags/cmake/</link>
		<description>Recent content in CMake on UberMongoose</description>
		<generator>Hugo</generator>
		<language>en-us</language>
		
		
		
		
			<lastBuildDate>Sun, 22 Dec 2013 10:13:40 +0530</lastBuildDate>
		
			<atom:link href="http://localhost:1313/tags/cmake/index.xml" rel="self" type="application/rss+xml" />
			<item>
				<title>CMake Platform Specific Actions</title>
				<link>http://localhost:1313/post/cmake-platform-specific-actions/</link>
				<pubDate>Sun, 22 Dec 2013 10:13:40 +0530</pubDate>
				<guid>http://localhost:1313/post/cmake-platform-specific-actions/</guid>
				<description>&lt;p&gt;Sometimes you need to link one library on Windows and another on Linux (or vice versa). CMake has a &lt;a href=&#34;http://www.cmake.org/Wiki/CMake_Useful_Variables&#34;&gt;number of variables&lt;/a&gt; that allow you to do this easily:&lt;/p&gt;&#xA;&lt;table&gt;&#xA;&#x9;&lt;thead&gt;&#xA;&#x9;&#x9;&#x9;&lt;tr&gt;&#xA;&#x9;&#x9;&#x9;&#x9;&#x9;&lt;th style=&#34;text-align: left&#34;&gt;&lt;/th&gt;&#xA;&#x9;&#x9;&#x9;&#x9;&#x9;&lt;th style=&#34;text-align: left&#34;&gt;&lt;/th&gt;&#xA;&#x9;&#x9;&#x9;&lt;/tr&gt;&#xA;&#x9;&lt;/thead&gt;&#xA;&#x9;&lt;tbody&gt;&#xA;&#x9;&#x9;&#x9;&lt;tr&gt;&#xA;&#x9;&#x9;&#x9;&#x9;&#x9;&lt;td style=&#34;text-align: left&#34;&gt;UNIX&lt;/td&gt;&#xA;&#x9;&#x9;&#x9;&#x9;&#x9;&lt;td style=&#34;text-align: left&#34;&gt;TRUE on all UNIX-like OS&amp;rsquo;s including Apple OS X and CygWin&lt;/td&gt;&#xA;&#x9;&#x9;&#x9;&lt;/tr&gt;&#xA;&#x9;&#x9;&#x9;&lt;tr&gt;&#xA;&#x9;&#x9;&#x9;&#x9;&#x9;&lt;td style=&#34;text-align: left&#34;&gt;WIN32&lt;/td&gt;&#xA;&#x9;&#x9;&#x9;&#x9;&#x9;&lt;td style=&#34;text-align: left&#34;&gt;TRUE on Windows including CygWin&lt;/td&gt;&#xA;&#x9;&#x9;&#x9;&lt;/tr&gt;&#xA;&#x9;&#x9;&#x9;&lt;tr&gt;&#xA;&#x9;&#x9;&#x9;&#x9;&#x9;&lt;td style=&#34;text-align: left&#34;&gt;APPLE&lt;/td&gt;&#xA;&#x9;&#x9;&#x9;&#x9;&#x9;&lt;td style=&#34;text-align: left&#34;&gt;TRUE on Apple systems. **&lt;/td&gt;&#xA;&#x9;&#x9;&#x9;&lt;/tr&gt;&#xA;&#x9;&#x9;&#x9;&lt;tr&gt;&#xA;&#x9;&#x9;&#x9;&#x9;&#x9;&lt;td style=&#34;text-align: left&#34;&gt;MINGW&lt;/td&gt;&#xA;&#x9;&#x9;&#x9;&#x9;&#x9;&lt;td style=&#34;text-align: left&#34;&gt;TRUE when using the MinGW compiler in Windows&lt;/td&gt;&#xA;&#x9;&#x9;&#x9;&lt;/tr&gt;&#xA;&#x9;&#x9;&#x9;&lt;tr&gt;&#xA;&#x9;&#x9;&#x9;&#x9;&#x9;&lt;td style=&#34;text-align: left&#34;&gt;MSYS&lt;/td&gt;&#xA;&#x9;&#x9;&#x9;&#x9;&#x9;&lt;td style=&#34;text-align: left&#34;&gt;TRUE when using the MSYS developer environment in Windows&lt;/td&gt;&#xA;&#x9;&#x9;&#x9;&lt;/tr&gt;&#xA;&#x9;&#x9;&#x9;&lt;tr&gt;&#xA;&#x9;&#x9;&#x9;&#x9;&#x9;&lt;td style=&#34;text-align: left&#34;&gt;CYGWIN&lt;/td&gt;&#xA;&#x9;&#x9;&#x9;&#x9;&#x9;&lt;td style=&#34;text-align: left&#34;&gt;TRUE on Windows when using the CygWin version of cmake&lt;/td&gt;&#xA;&#x9;&#x9;&#x9;&lt;/tr&gt;&#xA;&#x9;&#x9;&#x9;&lt;tr&gt;&#xA;&#x9;&#x9;&#x9;&#x9;&#x9;&lt;td style=&#34;text-align: left&#34;&gt;&lt;/td&gt;&#xA;&#x9;&#x9;&#x9;&#x9;&#x9;&lt;td style=&#34;text-align: left&#34;&gt;&lt;/td&gt;&#xA;&#x9;&#x9;&#x9;&lt;/tr&gt;&#xA;&#x9;&lt;/tbody&gt;&#xA;&lt;/table&gt;&#xA;&lt;p&gt;** &lt;em&gt;Note this does not imply the system is Mac OS X only that &lt;strong&gt;APPLE&lt;/strong&gt; is #defined in C/C++ header files. Obtain more specific system information via CMAKE_SYSTEM_VERSION. I.e. IF(${CMAKE_SYSTEM_NAME} MATCHES &amp;ldquo;Darwin&amp;rdquo;) then it&amp;rsquo;s Mac OS X&lt;/em&gt;&lt;/p&gt;</description>
			</item>
			<item>
				<title>CMake find_package</title>
				<link>http://localhost:1313/post/cmake-find-package/</link>
				<pubDate>Wed, 04 Dec 2013 10:05:36 +0530</pubDate>
				<guid>http://localhost:1313/post/cmake-find-package/</guid>
				<description>&lt;p&gt;In the &lt;a href=&#34;http://localhost:1313/post/cmake-add-library/&#34;&gt;last scroll&lt;/a&gt; on CMake we discussed adding libraries that you write to your own code. This time, we look at using third party libraries out of the box. This turns out to be fairly easy with CMake - though there are exceptions (alternatively spelled &amp;ldquo;bugs&amp;rdquo;). Adding a third party package such as the precious Boost libraries for C++ is fairly easy with CMake. In your CMakeLists.txt file add a call to FIND_PACKAGE like so:&lt;/p&gt;</description>
			</item>
			<item>
				<title>CMake add_library</title>
				<link>http://localhost:1313/post/cmake-add-library/</link>
				<pubDate>Mon, 29 Jul 2013 09:57:52 +0530</pubDate>
				<guid>http://localhost:1313/post/cmake-add-library/</guid>
				<description>&lt;p&gt;In the &lt;a href=&#34;http://localhost:1313/post/cmake-include-directories/&#34;&gt;last post&lt;/a&gt; we built an executable from a source file and a header only library. However, sometimes we need to build shared library binaries that can be linked into an executable. This is fairly simple with CMake. Instead of using &lt;code&gt;add_executable&lt;/code&gt; like the last time we now simply need to use &lt;code&gt;add_library&lt;/code&gt; like so:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-cmake&#34; data-lang=&#34;cmake&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;c&#34;&gt;# Sources &#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;nb&#34;&gt;file&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;s&#34;&gt;GLOB&lt;/span&gt; &lt;span class=&#34;s&#34;&gt;Library_SOURCES&lt;/span&gt; &lt;span class=&#34;s&#34;&gt;*.cpp&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt;&lt;span class=&#34;err&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;nb&#34;&gt;file&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;s&#34;&gt;GLOB&lt;/span&gt; &lt;span class=&#34;s&#34;&gt;Library_HEADER&lt;/span&gt; &lt;span class=&#34;s&#34;&gt;*.hpp&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt; &lt;span class=&#34;err&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;err&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;c&#34;&gt;# Executable&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;nb&#34;&gt;add_library&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;s&#34;&gt;LibProject&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;${&lt;/span&gt;&lt;span class=&#34;nv&#34;&gt;Library_SOURCES&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;}&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;${&lt;/span&gt;&lt;span class=&#34;nv&#34;&gt;Library_HEADERS&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;}&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&#xA;&lt;p&gt;CMake will now get the build system that you choose to create a shared library that can be linked into an executable one. You would end up with .lib files with Visual Studio and typically .a files with Unix make. Note that the name &lt;code&gt;Library_SOURCES&lt;/code&gt; is chosen for clarities sake. The variable can be named anything.&lt;/p&gt;</description>
			</item>
			<item>
				<title>CMake Include Directories</title>
				<link>http://localhost:1313/post/cmake-include-directories/</link>
				<pubDate>Sat, 20 Jul 2013 11:19:39 +0530</pubDate>
				<guid>http://localhost:1313/post/cmake-include-directories/</guid>
				<description>&lt;p&gt;To do almost anything today with C++ requires the use of a number of different third party libraries. Some of these come in the form of header only libraries containing only include files (.h and .hpp). The references to these libraries are easy to resolve with CMake, let&amp;rsquo;s contrive an example.&lt;/p&gt;&#xA;&lt;p&gt;Consider the following folder structure.&lt;/p&gt;&#xA;&lt;p&gt;[CMakeHome] [CMakeHome]\src&lt;br&gt;&#xA;Contains all the source code for the project&lt;/p&gt;&#xA;&lt;p&gt;[CMakeHome]\headerlib\&lt;br&gt;&#xA;Contains a small header only library with a number of different applications&lt;/p&gt;</description>
			</item>
			<item>
				<title>CMake The Beautiful Beast</title>
				<link>http://localhost:1313/post/cmake-the-beautiful-beast/</link>
				<pubDate>Wed, 17 Jul 2013 09:17:29 +0530</pubDate>
				<guid>http://localhost:1313/post/cmake-the-beautiful-beast/</guid>
				<description>&lt;p&gt;CMake is a mix of things. It&amp;rsquo;s a cross platform makefile generator that makes porting your C/C++ code from one OS to another or from one compiler to another inside the same OS really simple. However it complicates things a bit as well as now you need to write an extra &amp;ldquo;CMakeLists.txt&amp;rdquo; file for each of your code directories in order to allow CMake to generate those files for you. It doesn&amp;rsquo;t really help that the CMake documentation is &lt;em&gt;rather dense&lt;/em&gt; and that there are a number of caveats that you really don&amp;rsquo;t see until you get to actually implementing it. Learning CMake therefore can be a harrowing experience and sometimes you might be tempted to give up half way and stick to the warm consolation of the Visual Studio IDE. That&amp;rsquo;s where this guide will hopefully help you as a starting point in your CMake journey that is not too steep to learn.&lt;/p&gt;</description>
			</item>
			<item>
				<title>CMake Trickery - Platform Specific Linking</title>
				<link>http://localhost:1313/post/cmake-trickery-platform-specific-linking/</link>
				<pubDate>Wed, 26 Jun 2013 08:52:57 +0530</pubDate>
				<guid>http://localhost:1313/post/cmake-trickery-platform-specific-linking/</guid>
				<description>&lt;p&gt;Quite often when your working on cross platform code you need to build applications that use one set of libraries when compiled under Microsoft Windows and another set when compiled under Unix/Linux. Fortunately &lt;a href=&#34;http://www.cmake.org/&#34;&gt;CMake&lt;/a&gt; is a cunning tool to help you on your way. It has a bunch of predefined constants that you can use to switch libraries based on the platform like so:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-cmake&#34; data-lang=&#34;cmake&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;c&#34;&gt;# SomeCoolLibrary&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;nb&#34;&gt;IF&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;s&#34;&gt;WIN32&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt;&lt;span class=&#34;err&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;   &lt;span class=&#34;nb&#34;&gt;message&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;s&#34;&gt;STATUS&lt;/span&gt; &lt;span class=&#34;s2&#34;&gt;&amp;#34;Building on Microsoft Windows.&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt;&lt;span class=&#34;err&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;   &lt;span class=&#34;nb&#34;&gt;set&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;s&#34;&gt;SomeCoolLibrary&lt;/span&gt; &lt;span class=&#34;s&#34;&gt;someCoolWindows.lib&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt;&lt;span class=&#34;err&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;nb&#34;&gt;ELSEIF&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;s&#34;&gt;UNIX&lt;/span&gt; &lt;span class=&#34;s&#34;&gt;AND&lt;/span&gt; &lt;span class=&#34;s&#34;&gt;NOT&lt;/span&gt; &lt;span class=&#34;s&#34;&gt;MINGW&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt;&lt;span class=&#34;err&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;   &lt;span class=&#34;nb&#34;&gt;message&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;s&#34;&gt;STATUS&lt;/span&gt; &lt;span class=&#34;s2&#34;&gt;&amp;#34;Building on Linux/Unix.&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt;&lt;span class=&#34;err&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;   &lt;span class=&#34;nb&#34;&gt;set&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;s&#34;&gt;SomeCoolLibrary&lt;/span&gt; &lt;span class=&#34;s&#34;&gt;someCoolLinux.so&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt;&lt;span class=&#34;err&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;nb&#34;&gt;ENDIF&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;()&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&#xA;&lt;p&gt;Notice we check for the enviorenment being Unix but not MinGW. This is because CMake reports the enviorenment as Unix even if it&amp;rsquo;s MinGW running on Windows (which I suppose makes sense), but it pays to be specific. Finally you can target the generic link library that you&amp;rsquo;ve mentioned here:&lt;/p&gt;</description>
			</item>
	</channel>
</rss>
