gustavonihei commented on a change in pull request #3138:
URL: https://github.com/apache/incubator-nuttx/pull/3138#discussion_r598720216



##########
File path: Documentation/guides/cpp_cmake.rst
##########
@@ -0,0 +1,283 @@
+.. include:: /substitutions.rst
+.. _cpp_cmake:
+
+C++ Example using CMake
+=======================
+
+In some situations, developers intend to implement software using the NuttX 
platform in
+a previously set hardware and configuration where it is not possible or 
allowed to make
+changes. In such situations, less contact with the operating source tree is 
better, where
+it is only used for the application.
+
+Some approaches are possible to do that today:
+
+* 
https://cwiki.apache.org/confluence/display/NUTTX/Building+NuttX+with+Applications+Outside+of+the+Source+Tree
+* https://www.programmersought.com/article/61604062421/
+
+We have been seen the increase of the use of C++ language in embedded systems 
application. And
+CMake (https://www.cmake.org) is the preferred build system used to build C++ 
projects. NuttX
+support C++ based projects.
+
+Using the 'build as a library' procedure of NuttX, it is possible to build 
NuttX
+applications using C++ language and also the cmake build tool.
+
+This document will show how to reimplement the hellocpp project using this 
cmake.
+
+Preparation
+-----------
+
+#. Base NuttX compilation changes
+
+    For this example, load the configuration 'stm32f4discovery:testlibcxx' for 
building
+
+    .. code-block:: console
+
+       $ cd nuttx
+       $ ./tools/configure.sh stm32f4discovery:testlibcxx
+
+    In menuconfig, the main points to be changed on a typical NuttX 
configuration are the following:
+
+    * Set RTOS Features -> Tasks and Scheduling -> Application entry point to 
'hellocpp_main'
+
+    * Build NuttX and generate the export 
+
+    .. code-block:: console
+
+       $ make export
+
+Creating the project
+--------------------
+
+#. Create your project file structure
+
+    The project structure is organized as follow:
+
+    .. code-block:: console
+
+       hellocpp/
+       hellocpp/CMakeLists.txt
+       hellocpp/cmake/stm32f4discovery.cmake
+       hellocpp/nuttx-export-10.0.1/
+       hellocpp/src/CMakeLists.txt
+       hellocpp/src/main.cpp
+       hellocpp/src/HelloWorld.h
+       hellocpp/src/HelloWorld.cpp
+
+    The directory 'nuttx-export-10.0.1' is the unzipped content from the file 
created during
+    make export procedure done before.
+
+#. File contents
+
+* hellocpp/CMakeLists.txt
+
+.. code-block:: cmake
+
+    cmake_minimum_required(VERSION 3.2...3.15)
+
+    project(phigw
+            VERSION 1.0
+            DESCRIPTION "Hello world Phi-GW C++ Nuttx"
+    )

Review comment:
       ```suggestion
       project(HelloCpp
               VERSION 1.0
               DESCRIPTION "Hello world C++ Nuttx"
       )
   ```




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to