<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: hongping</title>
    <description>The latest articles on DEV Community by hongping (@hongping).</description>
    <link>https://dev.to/hongping</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F154086%2F25a0e6c4-981a-48f5-9681-e7942f3128c1.png</url>
      <title>DEV Community: hongping</title>
      <link>https://dev.to/hongping</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/hongping"/>
    <language>en</language>
    <item>
      <title>Basic C++ Project Template with CMake</title>
      <dc:creator>hongping</dc:creator>
      <pubDate>Wed, 23 Oct 2019 05:37:02 +0000</pubDate>
      <link>https://dev.to/hongping/basic-c-project-template-with-cmake-49p8</link>
      <guid>https://dev.to/hongping/basic-c-project-template-with-cmake-49p8</guid>
      <description>&lt;p&gt;It has been awhile since I last coded in C++. The last compiler I used was Borland Turbo C++. Ever since then, I shifted away from C++ to other interpreted languages like Perl and Python, and also bits of Javascript for web based works.&lt;/p&gt;

&lt;p&gt;I am ramping up on C++ again as I am creating executable which performance is what I am craving for. I was looking at the tools for C++, and am pretty amazed with all the new (and open source!) technologies available today.&lt;/p&gt;

&lt;p&gt;After hunting for a week or two (yes, I am a indecisive programmer, with a bit of procrastination as well), I settled down with &lt;a href="https://clang.llvm.org"&gt;clang&lt;/a&gt; as my compiler, &lt;a href="https://cmake.org"&gt;CMake&lt;/a&gt; as the build files generator, and &lt;a href="https://ninja-build.org"&gt;ninja&lt;/a&gt; as the build system. Also, not to forget about unit testing, I used &lt;a href="https://github.com/google/googletest"&gt;Google Test&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;The criteria of tool selection is largely based on cross OS compatibility. For e.g., I choose clang over MSVC or gcc mostly due to clang can easily be used in either Windows or Linux. Same as CMake. Using CMake, I don't need to worried about which build tool to be selected later. I opt for ninja as in Windows, that's the most sensible option for me since I am not using Visual Studio.&lt;/p&gt;

&lt;p&gt;While setting up a C++ project of mine, I noticed that there will be a fixed structure of directory I could reuse, hence, I created this repository in Github, served as the basic template for my future project. It is known as &lt;a href="https://github.com/hongping/cpp_template"&gt;hongping/cpp_template&lt;/a&gt; in Github.&lt;/p&gt;

&lt;p&gt;The template comes with Google Test version 1.10.0 source code in the &lt;code&gt;external&lt;/code&gt; directory, and the CMake files will build a basic test in &lt;code&gt;tests&lt;/code&gt; directory which is to test the aliveness of the project. Once done build and execute &lt;code&gt;tests\runUnitTests&lt;/code&gt;, you should be able to see the following&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Running main() from ../external/googletest-release-1.10.0/googletest/src/gtest_main.cc
[==========] Running 1 test from 1 test suite.
[----------] Global test environment set-up.
[----------] 1 test from DOA
[ RUN      ] DOA.gtestAlive
[       OK ] DOA.gtestAlive (0 ms)
[----------] 1 test from DOA (0 ms total)

[----------] Global test environment tear-down
[==========] 1 test from 1 test suite ran. (4 ms total)
[  PASSED  ] 1 test.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Feel free to clone &lt;a href="https://github.com/hongping/cpp_template"&gt;hongping/cpp_template&lt;/a&gt; and use this for your future project!&lt;/p&gt;

</description>
      <category>cpp</category>
      <category>beginners</category>
    </item>
  </channel>
</rss>
