samples: cpp: add a Hello, world! C++ app

Create a separate hello world C++ app for Zephyr.

Signed-off-by: Christopher Friedt <cfriedt@meta.com>
This commit is contained in:
Christopher Friedt 2023-11-25 16:44:40 -05:00 committed by Carles Cufí
parent db24a8b461
commit 574e641297
5 changed files with 80 additions and 0 deletions

View file

@ -0,0 +1,8 @@
# SPDX-License-Identifier: Apache-2.0
cmake_minimum_required(VERSION 3.20.0)
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
project(hello_cpp_world)
target_sources(app PRIVATE src/main.cpp)

View file

@ -0,0 +1,33 @@
.. _hello_cpp_world:
Hello C++ World
###############
Overview
********
A simple :ref:`C++ <language_cpp>` sample that can be used with many supported board and prints
"Hello, C++ world!" to the console.
Building and Running
********************
This configuration can be built and executed on QEMU as follows:
.. zephyr-app-commands::
:zephyr-app: samples/cpp/hello_world
:host-os: unix
:board: qemu_riscv32
:goals: run
:compact:
To build for another board, change "qemu_riscv32" above to that board's name.
Sample Output
=============
.. code-block:: console
Hello C++, world! qemu_riscv32
Exit QEMU by pressing :kbd:`CTRL+C`

View file

@ -0,0 +1,2 @@
CONFIG_CPP=y
CONFIG_REQUIRES_FULL_LIBCPP=y

View file

@ -0,0 +1,24 @@
sample:
description: Hello World C++ sample, the simplest C++ Zephyr application
name: hello cpp world
common:
tags: introduction
integration_platforms:
- qemu_riscv32
harness: console
harness_config:
type: one_line
regex:
- "Hello, C\\+\\+ world! (.*)"
tests:
sample.cpp.helloworld:
min_ram: 128
arch_exclude:
# See #66027
- xtensa
platform_exclude:
# See zephyrproject-rtos/sdk-ng#593
- qemu_x86
- intel_ish_5_4_1
- intel_ish_5_6_0
- intel_ish_5_8_0

View file

@ -0,0 +1,13 @@
/*
* Copyright (c) 2023, Meta
*
* SPDX-License-Identifier: Apache-2.0
*/
#include <iostream>
int main(void)
{
std::cout << "Hello, C++ world! " << CONFIG_BOARD << std::endl;
return 0;
}