zephyr/samples/application_development/external_lib
Jonathon Penix 4ddd3ebd51 samples: external_lib: Include `--target` in exported build flags
Appropriately setting the `--target` flag is necessary when using clang
and building for a target other than the default. Zephyr generally
accomplishes this by setting the CMAKE_<LANG>_COMPILER_TARGET variables and
allowing cmake to automatically provide the `--target` flag when building.

For the external_lib sample, however, cmake can't add the flag and it was
not otherwise exported. As such, clang typically threw errors when building
this sample for any non-default targets due to mismatches between
target-specific flags and the default target.

To fix this, ensure we select the correct target by checking if
CMAKE_C_COMPILER_TARGET has been defined and adding
`--target=<triple>` to the list of flags that are exported if so.

Signed-off-by: Jonathon Penix <jpenix@quicinc.com>
2024-07-31 10:08:33 +02:00
..
mylib
src
CMakeLists.txt
README.rst
prj.conf
sample.yaml

README.rst

.. _external_library:

External Library
#################

Overview
********

A simple example that demonstrates how to include an external static library
into the Zephyr build system.
The demonstrates both how to build the external library using a different build
system and how to include the built static library.

Windows Note
************

To use this sample on a Windows host operating system, GNU Make needs to be in
your path. This can be setup using chocolatey or by manually installing it.

Chocolatey Method
=================

Install make using the following command:

.. code-block:: bash

   choco install make

Once installed, build the application as normal.

Manual Install Method
=====================

The pre-built make application can be downloaded from
https://gnuwin32.sourceforge.net/packages/make.htm by either getting both the
``Binaries`` and ``Dependencies`` and extracting them to the same folder, or
getting the ``Complete package`` setup. Once installed and in the path, build
the application as normal.