<?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: tinhnguyentrung</title>
    <description>The latest articles on DEV Community by tinhnguyentrung (@tinhnguyentrung).</description>
    <link>https://dev.to/tinhnguyentrung</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%2F722172%2F7a00618d-7dee-4f30-a165-ca5f9be3f6cb.png</url>
      <title>DEV Community: tinhnguyentrung</title>
      <link>https://dev.to/tinhnguyentrung</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/tinhnguyentrung"/>
    <language>en</language>
    <item>
      <title>Zephyr OS - new application</title>
      <dc:creator>tinhnguyentrung</dc:creator>
      <pubDate>Sat, 01 Apr 2023 17:50:17 +0000</pubDate>
      <link>https://dev.to/tinhnguyentrung/zephyr-os-new-application-3n90</link>
      <guid>https://dev.to/tinhnguyentrung/zephyr-os-new-application-3n90</guid>
      <description></description>
    </item>
    <item>
      <title>CMake basic - find_packet</title>
      <dc:creator>tinhnguyentrung</dc:creator>
      <pubDate>Sat, 01 Apr 2023 08:47:40 +0000</pubDate>
      <link>https://dev.to/tinhnguyentrung/cmake-basic-findpacket-je2</link>
      <guid>https://dev.to/tinhnguyentrung/cmake-basic-findpacket-je2</guid>
      <description>&lt;h1&gt;
  
  
  Refer to &lt;a href="https://stackoverflow.com/questions/20746936/what-use-is-find-package-when-you-need-to-specify-cmake-module-path"&gt;Find_package&lt;/a&gt;
&lt;/h1&gt;

&lt;p&gt;The command &lt;code&gt;find_package&lt;/code&gt; has two modes:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Module mode&lt;/li&gt;
&lt;li&gt;Config mode&lt;/li&gt;
&lt;/ul&gt;

&lt;h1&gt;
  
  
  Module mode
&lt;/h1&gt;

&lt;p&gt;This command finds &lt;code&gt;Find&amp;lt;package&amp;gt;.cmake&lt;/code&gt; file located withing our project.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;CMakeLists.txt
cmake/FindFoo.cmake
cmake/FindBoo.cmake
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake")
find_package(Foo REQUIRED) # FOO_INCLUDE_DIR, FOO_LIBRARIES
find_package(Boo REQUIRED) # BOO_INCLUDE_DIR, BOO_LIBRARIES
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;....&lt;/p&gt;

</description>
    </item>
    <item>
      <title>CMake Basic 2</title>
      <dc:creator>tinhnguyentrung</dc:creator>
      <pubDate>Sat, 01 Apr 2023 05:13:00 +0000</pubDate>
      <link>https://dev.to/tinhnguyentrung/cmake-basic-2-4de5</link>
      <guid>https://dev.to/tinhnguyentrung/cmake-basic-2-4de5</guid>
      <description>&lt;h1&gt;
  
  
  The first line
&lt;/h1&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight cmake"&gt;&lt;code&gt;&lt;span class="nb"&gt;cmake_minimum_required&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;VERSION 3.25&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;# range supported&lt;/span&gt;

&lt;span class="nb"&gt;cmake_minimum_required&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;VERSION 3.7...3.26&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="nb"&gt;if&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="si"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;CMAKE_VERSION&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt; VERSION_LESS 3.12&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="nb"&gt;cmake_policy&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;VERSION &lt;span class="si"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;CMAKE_MAJOR_VERSION&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;.&lt;span class="si"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;CMAKE_MINOR_VERSION&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="nb"&gt;endif&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If the CMake versions is less than 3.12, the if block will be true, and the policy will be set to the current CMake version. if CMake is 3.12 or higher, the if block is false but the new syntax in &lt;code&gt;cmake_minimum_required&lt;/code&gt; will be respected.&lt;/p&gt;

&lt;h1&gt;
  
  
  Setting a project
&lt;/h1&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;project(MyProject VERSION 1.0
                  DESCRIPTION "Very nice project"
                  LANGUAGES CXX)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h1&gt;
  
  
  Making an executable
&lt;/h1&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;add_executable(one two.cpp three.h)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;one: is the name of executable file which is generated&lt;/li&gt;
&lt;li&gt;one: is the name of the CMake target created&lt;/li&gt;
&lt;li&gt;two.cpp three.h : is the source files
&lt;/li&gt;
&lt;/ul&gt;

&lt;h1&gt;
  
  
  Making a library
&lt;/h1&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;add_library(one STATIC two.cpp three.h)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Library type: STATIC, SHARED and MODULE.&lt;/p&gt;

&lt;h1&gt;
  
  
  Targets are your friend
&lt;/h1&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# include directory

target_include_directories(one PUBLIC include)
                           target name
                                 policy?
                                       directory
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;PUBLIC -&amp;gt; for a library, it lets CMake know that any targets that link to this target must also need that include directory.&lt;br&gt;&lt;br&gt;
PRIVATE -&amp;gt; only affect the current target&lt;br&gt;&lt;br&gt;
INTERFACE -&amp;gt; only needed for dependencies ?!  &lt;/p&gt;

&lt;h2&gt;
  
  
  We can then chain targets
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;add_library(another STATIC another.cpp another.h)
target_link_libraries(another PUBLIC one)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
    </item>
    <item>
      <title>Cmake basic</title>
      <dc:creator>tinhnguyentrung</dc:creator>
      <pubDate>Sat, 01 Apr 2023 04:58:02 +0000</pubDate>
      <link>https://dev.to/tinhnguyentrung/cmake-basic-3lp8</link>
      <guid>https://dev.to/tinhnguyentrung/cmake-basic-3lp8</guid>
      <description>&lt;h1&gt;
  
  
  Some basic syntax
&lt;/h1&gt;

&lt;h2&gt;
  
  
  Build a project
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ mkdir build
$ cmake -S . -B build
$ cmake --build build
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Install
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ cmake --build build --target install
$ cmake -v # verbose build
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Picking a compiler
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ CC=clang CXX=clang++ cmake ...
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Picking a generator
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ cmake -G"mytool"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
    </item>
  </channel>
</rss>
