66 Commits

Author SHA1 Message Date
Abtin Keshavarzian fb216d335c [cmake] update CMake configurations for Apple platforms (#12729)
This commit updates various CMake configuration files to simplify
the check for Apple platforms. It replaces the `CMAKE_CXX_COMPILER_ID`
check for `AppleClang` with the built-in `APPLE` variable across
multiple targets (such as `ftd`, `mtd`, `cli`, and others). This
ensures that Apple-specific linker and compiler flags (like `-Wl,-map`
and `-Wimplicit-int-conversion`) are correctly applied when building
on macOS, regardless of the specific compiler used.

Additionally, this commit updates `CMakeLists.txt` to explicitly set
the `CMAKE_AR` and `CMAKE_RANLIB` paths to the default system
locations (`/usr/bin/ar` and `/usr/bin/ranlib`) when the `APPLE`
variable is set.
2026-03-20 13:19:29 -05:00
Yakun Xu 31631142c2 [build] add format-nonliteral to missed code (#12251)
This commit enables the format-nonliteral check for code missed in
`#12236`. This commit also enables the format-nonliteral warnings in
CMake to catch such warnings in future in CMake build.
2026-01-06 14:53:38 -08:00
Abtin Keshavarzian 2918437bb8 [build] enable -Wundef for MTD, FTD, and Radio builds (#11418)
This commit adds the `-Wundef` compiler flag to the OpenThread core,
CLI, and NCP builds when configured for MTD, FTD, or Radio types.

This flag helps ensure that no undefined macros are used within the
source code, protecting against potential typos in conditional
compilation checks (`#if` checks).
2025-04-17 11:36:18 -06:00
Yakun Xu f0d6007cc3 [style] converge some common utils (#10982)
This commit converges common utils in core and lib to avoid duplicate
code and conflicts caused by two common utils are included by some
units.
2024-12-04 08:39:44 -08:00
Abtin Keshavarzian 287dbfa251 [test] introduce Nexus test framework and platform (#10533)
This commit introduces a new test framework named Nexus. The
framework includes the Nexus platform implementation that emulates
platform behavior, allowing multiple nodes running the OpenThread
core stack to be simulated and interact with each other within the
same process.

Unlike the simulation platform, where nodes run in separate processes
and interact via POSIX sockets, Nexus nodes are simulated within a
single process. Nexus tests can interact directly with the C++ or C
OT core APIs, providing more control than the simulation platform's
CLI-based interactions. The flow of time in Nexus tests is directly
controlled by the test itself, allowing for quick time interval
advancement.

This model allows for faster and more scalable simulations, enabling
quick simulation of larger networks for longer durations.

This commit introduces the basic platform implementation, including:
- `nexus_alarm`, `nexus_radio`, and `nexus_settings` modules.
- Logging support, allowing logs to be distinguished per emulated
  node.
2024-10-09 14:27:54 -07:00
Yakun Xu aebecca964 [cmake] disable c extensions (#10460)
CMake by default enables c extensions. As a result, gnu99 is used
instead of c99. This commit explicitly disables c extensions.
2024-07-02 08:53:02 -07:00
Abtin Keshavarzian 793bf78df1 [config] define separate project and platform core config header (#9291)
This commit updates and enhances the specification of OT core config
header files. It adds `OPENTHREAD_PLATFORM_CORE_CONFIG_FILE`, which
can be used by platforms to provide a core config header file name.

The project and platform specific config header files are included in
the following order:

1. Project specific header (`OPENTHREAD_PROJECT_CORE_CONFIG_FILE`)
2. Platform specific header (`OPENTHREAD_PLATFORM_CORE_CONFIG_FILE`)
3. Default config values as specified by `config/{module}.h`

CMake config options `OT_PROJECT_CONFIG` and `OT_PLATFORM_CONFIG` are
also defined, which can be used to specify project and platform
config headers. Platforms can define a default config header for
`OT_PLATFORM_CONFIG`. The existing `OT_CONFIG` CMake option is marked
as deprecated (with a warning message which recommends use of the new
configs).

This commit also updates the default simulation and POSIX core config
headers to remove extra Doxygen-style documentation and ensure that
all definitions have an `#ifndef` guard check.
2023-07-21 10:33:12 -07:00
Abtin Keshavarzian 0e0a49716e [cmake] add macros to simplify CMake config definition (#9288)
This commit simplifies the definition of CMake configurations by
adding new macros:
- `ot_string_option` for string-valued options (`OT_VENDOR_NAME`)
- `ot_int_option` for int-valued options (`OT_MLE_MAX_CHILDREN`)
- `ot_multi_option` for multi-valued options (`OT_LOG_LEVEL`)

The option definitions have also been moved to the `options.cmake`
file from `./CMakeLists.txt`.
2023-07-17 17:45:08 -07:00
Abtin Keshavarzian e7b591e0e7 [cmake] fix OT_THREAD_VERSION comparison in CMake (#9158)
This commit fixes the check for CMake `OT_THREAD_VERSION` against
different version strings ("1.1", 1.2", "1.3", and "1.3.1"). The
previous check used `EQUAL`, which would do a numerical match and
would treat `1.3` and `1.3.1` as equal. This commit changes the check
to use `STREQUAL`, which does a string match and will correctly
distinguish between `1.3` and `1.3.1`.

This commit also adds new `message(STATUS)` commands to output the
selected Thread version. This makes it easier to see which version of
Thread is being built.
2023-06-08 20:44:02 -07:00
Mason Tran f86d560e0a [build] add CMake Android NDK support (#9010) 2023-05-09 11:01:51 -07:00
Abtin Keshavarzian 742f53f64a [version] introduce OT_THREAD_VERSION_1_3_1 (#8849)
This commit adds `OT_THREAD_VERSION_1_3_1` constant (equal to `5`) for
Thread Version 1.3.1. It also updates the build switch options for
CMake `OT_THREAD_VERSION` and autoconfig `THREAD_VERSION` and `BUILD.gn`
to support the new version value of "1.3.1".

Note that this commit does not change the default config value of
`OPENTHREAD_CONFIG_THREAD_VERSION` which is the default version to
use if it is not explicitly specified by build switches or in a
project config file.
2023-03-09 09:34:19 -08:00
Yakun Xu 0e667b8e03 [test] use cmake to run unit tests (#8724)
This commit migrates unit tests to cmake.
* build unit tests with cmake
* add missing tests in cmake
* use ctest
* add platform udp stubs for test platform
* skip some static_assert with gcc-4
2023-02-09 10:19:01 -08:00
Zhanglong Xia 8b59f4d31e [posix] add power calibration support (#8293)
The actual output power of the Thread device may be determined by both
the Thread radio chip and the FEM. Consider the output power error of
the Thread radio chip and the gain error of the FEM, the actual output
power is inconsistent with the expected output power.  To guarantee
that the actual output power is accurate and meet the regulatory
requirements, the output power should be calibrated in the factory if
the output power is not accurate.

This commit contains the following changes:

- Adds a power calibration implementation
- Adds a config file to configure the target power for different
  countries
- Adds a tool for the factory to persist the power calibration data
2022-12-21 10:15:48 -08:00
Mason Tran cc8e4cce15 [cmake] add interface libraries ot-config-(ftd|mtd|radio) (#8190)
This allows for more granular control of any configuration which
might need to be incorporated in the core library build.
2022-09-22 23:20:35 -07:00
Abtin Keshavarzian 658491a1aa [config] introduce OT_THREAD_VERSION_1_3 (#7692)
This commit adds `OT_THREAD_VERSION_1_3` constant (equal to `4`)
and change=s the `OPENTHREAD_CONFIG_THREAD_VERSION` default value
to be the 1.3 version number.

It also updates the build switch option (Cmake and autoconf)
to support 1.3 and use 1.3 as default version value (when not
explicitly specified).
2022-05-13 12:56:16 -07:00
Yakun Xu bdec466cee [build] remove unnecessary config files (#7414)
This commit removes unnecessary OPENTHREAD_CONFIG_FILE by only
including it when it's defined.
2022-02-22 12:44:06 -08:00
Yakun Xu 12a9ca19a7 [cmake] avoid unnecessary rebuild when git commit id changes (#6881)
This commit removes the PACKAGE_VERSION definition from the global
config target so that when the git commit id is changed, only a few
sources will be re-compiled.
2021-08-19 12:20:30 -07:00
Jonathan Hui 649e8e1756 [cmake] always use git hash for default package version (#6717) 2021-06-17 10:01:02 -07:00
Yakun Xu 6891fe6e0c [cmake] no cxx extensions (#6664)
This commit sets cxx stand as -std=c++11 instead of -std=gnu++11.
2021-05-21 09:46:22 -07:00
Jonathan Hui 550c2056de [nrf528xx] move to openthread/ot-nrf528xx (#6585) 2021-05-11 16:53:13 -07:00
Jonathan Hui 5078323d35 [efr32] move to openthread/ot-efr32 (#6403) 2021-05-06 14:28:28 -07:00
Yakun Xu 9ae780091f [cmake] set cxx and c standard once (#6551) 2021-05-03 22:50:41 -07:00
Yakun Xu bf422ee8b3 [cmake] add OT_DOC option (#6527) 2021-04-29 07:49:10 -07:00
Yakun Xu 2796615cf7 [cmake] print source directory (#6489)
Print source directory during cmake, which is useful to find the source
code location when OpenThread is built by other projects.
2021-04-19 22:23:06 -07:00
suveshpratapa 21417407dd [cmake] allow custom values for package name and package version (#6373) 2021-04-12 20:47:22 -07:00
Mason Tran 7b3c2ae66b [efr32] add CMake support (#6302)
This commit adds CMake support for the efr32 platforms and Silicon
Labs gecko_sdk_suite. It also adds the option to build the efr32
sleepy-demo apps.

Other changes:
- jlinkrtt: remove NordicSemi specific options/definitions/includes
  from default build
- Remove old include dirs that don't exist anymore from efr32 automake
  files
2021-03-19 16:06:54 -07:00
Rafał Kuźnia 8531eed158 [cmake] do not set CMAKE_BUILD_TYPE if OT is not a top-level project (#6289) 2021-03-17 18:00:06 -07:00
Jonathan Hui 16ebac8a17 [build] set Thread 1.2 as default version (#6281) 2021-03-16 11:38:57 -07:00
Torsten Tejlmand Rasmussen 32257403b0 [cmake] using cmake -E echo instead of shell echo command (#6175)
The echo command of the host system may have slight variations between
shell built-in echo and the echo command provided by the OS.

Especially the Windows OS echo command is different from practical any
other echo command.

This means that the currently used `COMMAND echo -e "<text>"` does not
work universally.

This commit introduces `etc/cmake/print.cmake` which allow to print a
CMake list where each item is printed on a new line, to get the desired
behavior on the `print-ot-config` target.

Using `cmake -E echo <text>` ensures identical behaviour across
different systems.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2021-02-16 11:30:01 -08:00
Jonathan Hui abb415c419 [fuzz] add CMake support (#6147) 2021-02-08 11:28:05 -08:00
Łukasz Maciejończyk 8bbbe194f1 [cmake] add support for nrf528xx (#6109) 2021-01-27 13:29:49 -08:00
Yakun Xu de34f75b58 [cmake] set default build type to Debug (#5709) 2020-10-26 08:17:31 -07:00
Yakun Xu f83d1ff999 [cmake] add external platform support (#5693)
This commit adds external platform support into cmake build system.
2020-10-23 07:23:00 -07:00
Yakun Xu d6fb9de9f3 [cmake] support setting log level (#5433) 2020-08-20 10:37:54 -07:00
Yakun Xu 1a1dd31089 [cmake] use OT_CONFIG for OPENTHREAD_CONFIG_FILE (#5421)
OT_CONFIG was used to specify a customized OpenThread core config file
which is only included by OpenThread core library. This commit changes
the behavior so that it specifies the OPENTHREAD_CONFIG_FILE which is
used by all components of OpenThread including the core library.
2020-08-19 08:49:05 -07:00
Yakun Xu 89cd4b59f8 [url] move url to library (#5233)
This commit moves the URL parser to src/lib.

Also includes the following changes:
- Split URL on initialization.
- Make a GetValue() const method.
- Check aLastValue.
- Add some negative tests.
2020-07-15 23:39:02 -07:00
Yakun Xu b9a7903f19 [github-action] check with cmake version 3.10 (#5229) 2020-07-13 08:22:00 -07:00
Jonathan Hui 6dd57816ee [cmake] move minimum version to 3.10.2 (#5208)
To support automated armv7 docker builds.
2020-07-08 10:42:09 -07:00
Yakun Xu b66ac5d907 [logging] remove NCP_SPINEL output (#5104)
This commit removes log output NCP_SPINEL and update the original log
output APP to use NCP_SPINEL behavior.
2020-06-19 10:02:53 -07:00
Yakun Xu 55790fb960 [cmake] use ot-config to umbrella private includes (#5079)
- add include directories to ot-config
- remove unused OT_PRIVATE_INCLUDES
2020-06-10 17:03:49 -07:00
Yakun Xu dce84a77fb [cmake] add posix in platform list (#5071)
- rename "none" to NO, which computes to false in if()
- sort platform names
- add "posix" into the platform list so that it can be selected from cmake-gui
2020-06-09 16:14:10 -07:00
Yakun Xu 9a3c2dc3b3 [cmake] add ot-config (#5003)
This commit adds an interface target ot-config for collecting compile definitions.
2020-05-26 10:24:22 -07:00
Yakun Xu f7a4d05219 [cmake] add project version (#4929)
* use an older version for better compatibility
* add version to project
* only use cpack when OpenThread is the top-level project
* exclude posix apps when BUILD_EXECUTABLES is OFF
* exclude all third_party
2020-05-06 17:46:13 -07:00
Yakun Xu 47ebcbd184 [cmake] add log output option (#4914)
This is required for running commissioning related tests for the
commissioning messages are retrieved from logs.
2020-04-30 10:45:14 -07:00
kangping 509807e377 [cmake] enable user specified mbedtls target (#4812)
This commit allows users to specify the mbedtls target by a
OT_EXTERNAL_MBEDTLS option.

The native cmake build system of mbedtls is not so "modern" (for
backward compatibility, it maybe hard to change it soon) and
applications using mbedtls are likely to write wrapper cmake files and
targets by themselves.
2020-04-28 11:28:09 -07:00
Yakun Xu 7c428118f0 [cmake] detect big endian (#4892) 2020-04-27 12:58:46 -07:00
Yakun Xu 32f8274395 [cmake] enhancements for supporting cmake in ot-br-posix (#4876) 2020-04-24 16:21:06 -07:00
Li Cao e839100be1 [cmake] enable running simulation unit tests using cmake (#4842)
In this commit, we would be able to run all the simulation unit tests
easier with cmake:

./script/test clean build unit_tests
2020-04-20 20:52:38 -07:00
Markus Becker 8e932e8c77 [cmake] disable -pedantic-errors together with -Werror (#4775)
This allows to work-around a compile error that is happening in Zephyr
<https://github.com/zephyrproject-rtos/openthread/pull/9>.

Signed-off-by: Markus Becker <markus.becker@tridonic.com>
2020-04-15 17:41:22 -07:00
Jonathan Hui 9e3e8e0980 [cmake] add pedantic-errors flag (#4808) 2020-04-15 15:32:26 -07:00