<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Julian Becker on Medium]]></title>
        <description><![CDATA[Stories by Julian Becker on Medium]]></description>
        <link>https://medium.com/@awtem?source=rss-fc0f4e4e4641------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*nIjkjTpuGb00TIoO.jpg</url>
            <title>Stories by Julian Becker on Medium</title>
            <link>https://medium.com/@awtem?source=rss-fc0f4e4e4641------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 30 Nov 2026 06:11:50 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@awtem/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Automate your CMake project setup]]></title>
            <link>https://medium.com/@awtem/automate-your-cmake-project-setup-cb9ad173ebf?source=rss-fc0f4e4e4641------2</link>
            <guid isPermaLink="false">https://medium.com/p/cb9ad173ebf</guid>
            <category><![CDATA[c-programming]]></category>
            <category><![CDATA[creating-templates]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[cmake]]></category>
            <category><![CDATA[scaffolding]]></category>
            <dc:creator><![CDATA[Julian Becker]]></dc:creator>
            <pubDate>Thu, 15 Feb 2018 20:23:15 GMT</pubDate>
            <atom:updated>2018-02-15T20:23:15.272Z</atom:updated>
            <content:encoded><![CDATA[<p>In C++, more than in any other programming language, there seems to be a large effort involved in modularizing your code. But not only modularization, also the entire task of setting up your project (in a cross-platform way) is painful… Have you ever wondered, why your libraries just keep growing bigger and bigger? Frequently, I have observed that even the effort of putting a new class in a new file is seemingly too much work… and you end up with .cpp-files having 10k+ LOC(!)… Seriously?!</p><p>So, if you encounter big files or modules like that in one of your projects, it may be the case that for some reason or another, there is too much effort involved in keeping your code modularized, or in introducing new modules.</p><p>As far as I&#39;m concerned, files with 10k+ LOC or modules with 1k+ files are something I have encountered way too often, so a pragmatic solution was needed. That&#39;s when I had a look around the friendly Web-development neighborhood and their tooling. It appears there is -- unlike in C++ -- a whole plethora of tooling that helps with JavaScript project scaffolding.</p><p>What I set out to accomplish was basically a solution for two things:</p><ol><li>A tool that will allow me to quickly setup a CMake project workspace, i.e. the necessary infrastructure to have multiple libraries, executables, documentation, and tests etc. contained in one directory tree, allowing me to configure and build everything as a whole, instead of having to configure, build and install every library separately, before it can be used by other parts of the system.</li><li>The other thing that I set out to get was a tool that would allow me to quickly add a new library to my CMake workspace. Being able to do this quickly and effortlessly will most certainly positively impact the modularity of any system being built.</li></ol><p>So, I just went for the next best thing, and gave it a try. The next best thing in my case happened to be the npm package &#39;slush&#39;. Slush is a tool that allows you to scaffold a new project or library from a template, and you can quicky install new templates (as npm-packages), and you can quickly generate new templates (using a template generator, called &quot;slush-generator&quot;).</p><p>I ran a few google searches for tutorials, came across one that explained how to create a new template from <a href="https://www.npmjs.com/package/slush-generator">slush-generator</a>. It turned out to be very easy to do, and I quickly hacked together a very basic CMake project scaffolding tool, <a href="https://www.npmjs.com/package/slush-cmake">slush-cmake</a>:</p><p>To give it a try, make sure you have npm installed and then do</p><blockquote>&gt; npm install -g slush-cmake</blockquote><p>Then, to scaffold a new CMake super-project, just do the following:</p><p>&gt; mkdir MyNewProject &amp;&amp; cd MyNewProject</p><p>&gt; slush cmake</p><p>When executing the slush cmake command, you will be queried for a few project-related things like the project-name, your preferred license, your preferred testing framework, a brief description etc. You will also be queried for the name of two library components that will be setup for you, according to the names specified, alongside corresponding test applications, one for each library.</p><p>Have a look at the top-level CMakeLists.txt as well as the CMakeLists.txt files of the generated libraries.</p><p>Two libraries will be setup for you, the second one depending on the first one, and an executable depending on both. These dependencies are simply expressed using find_package(LibraryName REQUIRED)</p><p>Note that the project template also provides you with appropriate install() targets for the library and the documentation. In order to prevent the testing-frameworks from participating in the install-part of the CMake project, I had to resort to a nasty brute-force macro in the cmake-include(InstallBlock). Effectively, it works by replacing the CMake command install(...) with a custom version, that may or may not invoke the original behavior, depending on a variable ENABLE_INSTALL.</p><p>Last but not least, in case you want to extend your project with a new library, just go ahead and npm install -g slush-cmake-library. Using this, you can do a</p><p>cd MyNewProject &amp;&amp; slush cmake-library</p><p>and it will guide you through the setup of your new library component, will setup a test executable for the new library. The only thing it doesn&#39;t (yet) do is modify the superproject&#39;s CMakeLists.txt to include the new library. Maybe I&#39;ll get around to automating this as well. Until then, you still have to write two lines of Cake-code manually:</p><p>add_module(NAME newLibraryName)<br>add_module(NAME newLibraryName_test)</p><p>If you think a tool like this would be useful for you, go ahead and give it a try -- or adjust it to your liking. The code can be found on my <a href="https://github.com/julian-becker/slush-cmake">github</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cb9ad173ebf" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>