{"id":8,"date":"2013-03-28T19:19:19","date_gmt":"2013-03-29T00:19:19","guid":{"rendered":"https:\/\/104.236.124.184\/cmake-tutorial.html"},"modified":"2013-03-28T19:19:19","modified_gmt":"2013-03-29T00:19:19","slug":"cmake-tutorial","status":"publish","type":"post","link":"https:\/\/www.johnlamp.net\/?p=8","title":{"rendered":"CMake Tutorial"},"content":{"rendered":"<nav class=\"global-contents\">\n<h1 id=\"section-Contents\">Contents<\/h1>\n<ol>\n<li>\n      Introduction\n    <\/li>\n<li>\n      <a href=\"https:\/\/www.johnlamp.net\/cmake-tutorial-1-getting-started.html\">Getting Started<\/a>    <\/li>\n<li>\n      <a href=\"https:\/\/www.johnlamp.net\/cmake-tutorial-2-ide-integration.html\">IDE Integration<\/a>    <\/li>\n<li>\n      <a href=\"https:\/\/www.johnlamp.net\/cmake-tutorial-3-gui-tool.html\">GUI Tool<\/a>    <\/li>\n<li>\n      <a href=\"https:\/\/www.johnlamp.net\/cmake-tutorial-4-libraries-and-subdirectories.html\">Libraries and Subdirectories<\/a>    <\/li>\n<li>\n      <a href=\"https:\/\/www.johnlamp.net\/cmake-tutorial-5-functionally-improved-testing.html\">Functionally Improved Testing<\/a>    <\/li>\n<li>\n      <a href=\"https:\/\/www.johnlamp.net\/cmake-tutorial-6-realistically-getting-a-boost.html\">Realistically Getting a Boost<\/a>    <\/li>\n<\/ol>\n<\/nav>\n<section>\n<h1 id=\"section-Introduction\">Introduction<\/h1>\n<h2 id=\"section-WhatIsCmake?\">What is CMake?<\/h2>\n<p>\n    According to CMake&#8217;s creators, Kitware, CMake is an open-source cross<br \/>\n    platform build system. This is not completely accurate as CMake is not<br \/>\n    actually a build system. What CMake provides is an easy way to build C\/C++<br \/>\n    projects across platforms. The reason I say that CMake isn&#8217;t a build system<br \/>\n    is because it doesn&#8217;t actually build software. &#8220;A build system<br \/>\n    that <em>doesn&#8217;t<\/em> build software?&#8221; you ask. Yes; what CMake does is<br \/>\n    generate a configuration for your existing build system, e.g. Make. This<br \/>\n    allows CMake to focus on things that most build systems don&#8217;t; such as cross<br \/>\n    platform configuration, dependency calculation, testing, packaging, and<br \/>\n    installation.\n  <\/p>\n<h2 id=\"section-WhyCmake?\">Why CMake?<\/h2>\n<p>\n    By not being a true build system, per se, CMake allows for a more flexible<br \/>\n    development environment as it can generate Makefiles or projects for a<br \/>\n    variety of IDEs. This allows developers to easily work on different<br \/>\n    platforms using different tools since one can build using Microsoft&#8217;s Visual<br \/>\n    Studio on Windows or with GNU Make on Linux just as easily.\n  <\/p>\n<p>\n    CMake also includes tools for finding libraries, e.g. boost, and the ability<br \/>\n    to easily include external projects in your build. These two features, in<br \/>\n    particular, make it much simpler to build projects that have external<br \/>\n    dependencies and by using the find tools rather than hard coding paths it is<br \/>\n    much easier for new developers to get started on an existing project.\n  <\/p>\n<p>\n    Included with CMake is CTest, a test driver program. Both work together to<br \/>\n    make it easy to run a project&#8217;s test programs and\/or scripts. When you<br \/>\n    configure your project you specify how to run your tests and CMake generates<br \/>\n    a configuration for CTest. CTest will run all of your tests and provide a<br \/>\n    summary of which ones passed and which ones failed. In addition it logs the<br \/>\n    output of all the tests it ran. Optionally CTest can be directed to run only<br \/>\n    specific tests or skip specific tests, perhaps the slow ones. While it may<br \/>\n    not be a continuous build system you have most of the components provided.\n  <\/p>\n<p>\n    In addition to setting up a build CMake can also create an install target<br \/>\n    that will install the outputs of your project in the appropriate<br \/>\n    locations. Once you have configured your project to be installed you can<br \/>\n    also package your project using the included CPack utility. A variety of<br \/>\n    packages can be created including tar files, zip files, or an installer.\n  <\/p>\n<\/section>\n<section>\n<h1 id=\"section-Acknowledgements\">Acknowledgements<\/h1>\n<p>\n    I would like to thank the following people for their help and contributions<br \/>\n    to this tutorial. Without them it would not exist.\n  <\/p>\n<dl>\n<dt>\n      <a href=\"http:\/\/devin.ronge.name\/\">Devin Ronge<\/a>    <\/dt>\n<dd>\n      This tutorial would not exist without Devin, he suggested I write it and<br \/>\n      motivated me to start. Despite being primarily a C# and JavaScript<br \/>\n      developer Devin has read every word of this tutorial at least once. Thanks<br \/>\n      to him you get a better written tutorial than you would had he not<br \/>\n      proof-read it first.\n    <\/dd>\n<dt>\n      Steve Rieman\n    <\/dt>\n<dd>\n      As a C++ developer who actively uses CMake Steve has provided a technical<br \/>\n      review of the sample code in addition to a review of the prose. He has<br \/>\n      also provided numerous ideas for the contents of this tutorial.\n    <\/dd>\n<\/dl>\n<\/section>\n<section>\n<h1 id=\"section-FullTutorial\">Full Tutorial<\/h1>\n<p>\n    The entire tutorial can be downloaded as a <a href=\"https:\/\/www.johnlamp.net\/files\/CMakeTutorial.pdf\">PDF file<\/a>.  <\/p>\n<\/section>\n","protected":false},"excerpt":{"rendered":"<p>What is CMake?<\/p>\n<p>    According to CMake&#8217;s creators, Kitware, CMake is an open-source cross<br \/>\n    platform build system. This is not completely accurate as CMake is not<br \/>\n    actually a build system. What CMake provides is an easy way to build C\/C++<br \/>\n    projects across platforms. The reason I say that CMake isn&#8217;t a build system<br \/>\n    is because it &hellip;<br \/><a href=\"https:\/\/www.johnlamp.net\/?p=8\" rel=\"bookmark\">Continue reading &quot;CMake Tutorial&quot;<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[2],"tags":[3,4,5],"_links":{"self":[{"href":"https:\/\/www.johnlamp.net\/index.php?rest_route=\/wp\/v2\/posts\/8"}],"collection":[{"href":"https:\/\/www.johnlamp.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.johnlamp.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.johnlamp.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.johnlamp.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=8"}],"version-history":[{"count":0,"href":"https:\/\/www.johnlamp.net\/index.php?rest_route=\/wp\/v2\/posts\/8\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.johnlamp.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=8"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.johnlamp.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=8"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.johnlamp.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=8"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}