Skip to content

Commit 7eab9c4

Browse files
lizard123137soburi
authored andcommitted
CMakeLists: add support for external overlays
Allow users who pull ArduinoCore as a module (via west) to provide their own Zephyr overlay files in the application repository instead of modifying ArduinoCore/variants. This enables board-specific overlays (for example when using an AtomS3 board) to live in the consuming project. If an overlay is not provided the build will fail due to the missing zephyr,user section, which is the expected behavior. Signed-off-by: Michal Gagos <lizard123137@gmail.com>
1 parent 750e711 commit 7eab9c4

File tree

3 files changed

+14
-1
lines changed

3 files changed

+14
-1
lines changed

CMakeLists.txt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,11 @@ if (CONFIG_ARDUINO_API)
88
elseif (IS_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/variants/${NORMALIZED_BOARD_TARGET})
99
set(variant_dir variants/${NORMALIZED_BOARD_TARGET})
1010
else()
11-
message(FATAL_ERROR "Variant dir not found: variants/${BOARD}, variants/${NORMALIZED_BOARD_TARGET}")
11+
message(WARNING
12+
"Variant dir not found: variants/${BOARD}, variants/${NORMALIZED_BOARD_TARGET}\n"
13+
"Your board is currently not supported. To use it you must create a DTS overlay."
14+
)
15+
set(variant_dir variants/default)
1216
endif()
1317

1418
add_subdirectory(cores)

documentation/variants.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ variants/
3838
│   ├── variant.h
3939
```
4040

41+
It is possible to apply the overlay outside of the `variants` folder. In that case `cmake` will show a warning and a default empty `variant.h` file will be used. The `zephyr,user` section will still need to be defined somewhere in your project, as described in the [Guide to Writing Overlays section](#guide-to-writing-overlays).
42+
4143
## Guide to Writing Overlays
4244

4345
### DeviceTree Overlay files for Arduino boards

variants/default/variant.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
/*
2+
* Copyright (c) 2026 Michal Gagos
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
#pragma once

0 commit comments

Comments
 (0)