From 9561b026fa6f084f59c4dbb131040b6ec4363399 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Gago=C5=9B?= Date: Thu, 5 Feb 2026 09:36:34 +0100 Subject: [PATCH] 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 --- CMakeLists.txt | 6 +++++- documentation/variants.md | 2 ++ variants/default/variant.h | 7 +++++++ 3 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 variants/default/variant.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 53d5f323a..a91368267 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -8,7 +8,11 @@ if (CONFIG_ARDUINO_API) elseif (IS_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/variants/${NORMALIZED_BOARD_TARGET}) set(variant_dir variants/${NORMALIZED_BOARD_TARGET}) else() - message(FATAL_ERROR "Variant dir not found: variants/${BOARD}, variants/${NORMALIZED_BOARD_TARGET}") + message(WARNING + "Variant dir not found: variants/${BOARD}, variants/${NORMALIZED_BOARD_TARGET}\n" + "Your board is currently not supported. To use it you must create a DTS overlay." + ) + set(variant_dir variants/default) endif() add_subdirectory(cores) diff --git a/documentation/variants.md b/documentation/variants.md index 300c6a17a..5f985280d 100644 --- a/documentation/variants.md +++ b/documentation/variants.md @@ -38,6 +38,8 @@ variants/ │   ├── variant.h ``` +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). + ## Guide to Writing Overlays ### DeviceTree Overlay files for Arduino boards diff --git a/variants/default/variant.h b/variants/default/variant.h new file mode 100644 index 000000000..c114d1bdd --- /dev/null +++ b/variants/default/variant.h @@ -0,0 +1,7 @@ +/* + * Copyright (c) 2026 Michal Gagos + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#pragma once \ No newline at end of file