Programming

CLion 2025.3 Zephyr RTOS Setup: Fix CMake DTS Error

Fix CMake error 'file COPY_FILE failed to copy zephyr.dts.new' in CLion 2025.3 for Zephyr RTOS projects. Configure west build, CMake toolchain, ZEPHYR_BASE, and board options for STM32. Step-by-step guide with exact commands.

1 answer 1 view

How to set up CLion 2025.3 with Zephyr RTOS project? CMake Error: ‘file COPY_FILE failed to copy zephyr.dts.new to zephyr.dts’ when opening app/CMakeLists.txt

I’m trying to configure CLion 2025.3 for a Zephyr RTOS project that builds successfully from the console using west. However, opening app/CMakeLists.txt in the IDE triggers this CMake error:

-- Found devicetree overlay: /home/max/sources/bare-metal/zephyr-ws/zephyr/boards/others/stm32_min_dev/stm32_min_dev_stm32f103xb_blue.overlay
CMake Error at /home/max/sources/bare-metal/zephyr-ws/zephyr/cmake/modules/extensions.cmake:2995 (file):
 file COPY_FILE failed to copy

 /home/max/sources/bare-metal/zephyr-ws/app/build/zephyr/zephyr.dts.new

 to

 /home/max/sources/bare-metal/zephyr-ws/app/build/zephyr/zephyr.dts

 because: No such file or directory (input)

Call Stack (most recent call first):

Project structure (from workspace root ~/sources/bare-metal/zephyr-ws):

$ ls -l
total 24
drwxrwxr-x 1 max max 158 Jan 5 20:33 app
drwxrwxr-x 1 max max 14 Jan 5 20:21 bootloader
drwxrwxr-x 1 max max 416 Jan 5 21:07 build
drwxrwxr-x 1 max max 72 Jan 5 20:24 modules
drwxrwxr-x 1 max max 26 Jan 5 20:21 tools
drwxrwxr-x 1 max max 74 Nov 29 15:30 venv
-rw-rw-r-- 1 max max 24417 Nov 29 16:03 west-completion.sh
drwxrwxr-x 1 max max 956 Jan 5 19:57 zephyr

app/west.yml:

# Example T2 west.yml, using manifest imports.
manifest:
 remotes:
 - name: zephyrproject-rtos
 url-base: https://github.com/zephyrproject-rtos
 projects:
 - name: zephyr
 remote: zephyrproject-rtos
 revision: v4.3.0
 import: true
 self:
 path: app

.west/config:

[manifest]
path = app
file = west.yml

[zephyr]
base = zephyr

[build]
board = stm32_min_dev@blue/stm32f103xb

What configuration is needed in CLion for proper Zephyr project integration, and how to resolve this devicetree file copy error?

Run a west build that targets the same build directory CLion will use (or configure CLion to run west before CMake), and make sure your CMake profile points to Zephyr’s toolchain and board options. In CLion 2025.3 set CMake options like -DCMAKE_TOOLCHAIN_FILE=<zephyr>/cmake/toolchain.cmake and -DBOARD=stm32_min_dev@blue/stm32f103xb, export ZEPHYR_BASE (and SDK vars if needed), and align the IDE’s build directory with where west produced zephyr.dts.new. That resolves the CMake error “file COPY_FILE failed to copy … zephyr.dts.new to zephyr.dts” because the generated DTS file will exist where CMake expects it.


Contents


Quick fix and what went wrong (zephyr rtos)

Short answer: CMake is trying to copy a generated devicetree file that doesn’t exist yet. Zephyr’s devicetree files (for example zephyr.dts.new) are produced during the build step (the west build/CMake configure+build flow), not simply by opening app/CMakeLists.txt. When CLion configures the project it runs CMake early; if you haven’t run west build (or if west put the build files in a different directory than CLion expects) the file copy fails with “No such file or directory (input).”

Why does that happen in your setup? Two common mismatches:

  • You opened app/CMakeLists.txt and CLion configured using an app/build path, but you previously ran west build from the workspace root and generated build/zephyr/… (a different location). CMake then looks in app/build/zephyr/ and can’t find zephyr.dts.new.
  • Or you never ran west build at all before CLion’s first configure, so nothing generated the DTS files yet.

Fix in the short term: run the correct west build so zephyr.dts.new exists in the same build directory CLion will use, then re-open or re-run CMake inside CLion.


CLion 2025.3 configuration for Zephyr RTOS projects (clion zephyr)

CLion 2025.3 improved West support (see JetBrains notes), but you still need to give the IDE the right CMake options and environment before configuration. Recommended CLion settings (create/modify a CMake profile for this project):

  • CMake options (single-line):
    -DCMAKE_TOOLCHAIN_FILE=/home/max/sources/bare-metal/zephyr-ws/zephyr/cmake/toolchain.cmake -DBOARD=stm32_min_dev@blue/stm32f103xb
    Replace the absolute path with your Zephyr checkout path.

  • Environment variables (CMake profile -> Environment):
    ZEPHYR_BASE=/home/max/sources/bare-metal/zephyr-ws/zephyr
    Add ZEPHYR_SDK_INSTALL_DIR if you use the Zephyr SDK, and any toolchain PATHs you need.

  • Build directory: match where west generates files (see next section). If you will run cd app && west build ... set CLion’s build directory to /home/max/sources/bare-metal/zephyr-ws/app/build. If you built in the workspace root, set it to /home/max/sources/bare-metal/zephyr-ws/build.

  • Open the right CMake root: either open the workspace root or open app/CMakeLists.txt — but do the open after the initial west build (or after you add the pre-build step described below). JetBrains specifically recommends setting the toolchain file in the profile before opening to avoid early CMake failures; see the CLion release notes for the West improvements for background: https://blog.jetbrains.com/clion/2025/04/clion-2025-1-release/ and roadmap notes: https://blog.jetbrains.com/clion/2025/08/2025-3-roadmap/.

A few practical tips while you set this up: use the same board identifier you have in .west/config (stm32_min_dev@blue/stm32f103xb) and avoid relative paths that confuse CLion vs west. If CLion still fails, close the project, run the west build as shown below, then re-open.


Pre-build steps: run west build and match build directories (zephyr cmake)

Make sure zephyr.dts.new exists where CMake expects it. The simplest reliable workflow:

  1. From the workspace, build the app so the generated files are created inside app/build:
cd ~/sources/bare-metal/zephyr-ws/app
rm -rf build # optional: clean stale artifacts
west build -b stm32_min_dev@blue/stm32f103xb -p always

Running west build inside app/ produces app/build/zephyr/zephyr.dts.new (so CLion looking at app/CMakeLists.txt will find it).

  1. Verify the file exists:
ls -l build/zephyr/zephyr.dts.new

If it’s present, re-open CLion (or trigger CMake reload). CMake should now copy zephyr.dts.new to zephyr.dts successfully.

If instead you prefer to run west build from the workspace root, be aware west will place its build folder relative to the current working directory. That can create a mismatch (workspace-root build/ vs app/build/). Either build from app/ or set CLion’s build directory to the same location west used.

Why -p always? That forces generation of the intermediate files and overwrites stale outputs so the DTS generation step runs even if timestamps look unchanged.


CLion West options, sysbuild and advanced settings (clion west options)

CLion’s West integration has advanced options (2025.x releases) that let the IDE run west build automatically or pass flags such as --sysbuild / --no-sysbuild when your project uses sysbuild (nRF Connect SDK users often need sysbuild). Two workflow choices:

  • Manual-but-simple: run west build yourself (see previous section), then open app/CMakeLists.txt in CLion after the build completes. This is the least surprising approach.

  • IDE-driven: configure CLion’s West support so it runs west build before CMake configure. In the West/advanced settings add the build flags your workspace needs (for example --sysbuild or --no-sysbuild depending on your setup) and ensure the “run west build before CMake” behavior is enabled. The roadmap and release notes explain how CLion’s West options evolved; see https://blog.jetbrains.com/clion/2025/08/2025-3-roadmap/ and earlier notes at https://blog.jetbrains.com/clion/2024/10/clion-2024-3-eap-4/ for debugging templates.

If you prefer more control, create an External Tool or a Run Configuration in CLion that runs:

west build -b stm32_min_dev@blue/stm32f103xb -p always

and add that tool as a “Before launch” step for your CMake run/debug configuration. That guarantees the devicetree and other generated artifacts are present before CMake tries to copy them.


Verify devicetree and debugging tips (devicetree-debug)

Want to inspect what the generated DTS actually contains? Use the Devicetree viewer workflow:

  • Generate the DTS (CMake configure or west build). You can run a configuration-only step that creates the DTS:
cmake -B build -DBOARD=stm32_min_dev@blue/stm32f103xb

then open build/zephyr/zephyr.dts.

Read the devicetree flow (how board .dts includes .dtsi and how overlays apply) so you know why zephyr.dts.new is created and what must exist for the copy step; Beningo’s guide is a good primer: https://www.beningo.com/mastering-the-zephyr-rtos-devicetree-and-overlays/.

Other gotchas:

  • Wrong build directory — the most common cause. If zephyr.dts.new exists in build/ but CMake looks in app/build/, you’ll see that copy error.
  • File permissions — rare, but ensure the user running CLion has access to the build files.
  • Stale/partially generated files — rm -rf build and rebuild with -p always helps.

Examples and exact commands you can copy (practical-commands)

  1. Clean build inside app and generate devicetree:
cd ~/sources/bare-metal/zephyr-ws/app
rm -rf build
west build -b stm32_min_dev@blue/stm32f103xb -p always
ls -l build/zephyr/zephyr.dts.new
  1. Minimal CLion CMake options (paste into your CMake profile options):
-DCMAKE_TOOLCHAIN_FILE=/home/max/sources/bare-metal/zephyr-ws/zephyr/cmake/toolchain.cmake -DBOARD=stm32_min_dev@blue/stm32f103xb

and set environment:

ZEPHYR_BASE=/home/max/sources/bare-metal/zephyr-ws/zephyr

Set CLion’s build directory to /home/max/sources/bare-metal/zephyr-ws/app/build if you used the commands above.

  1. If you want CLion to run west automatically, create an External Tool or a Run Configuration that executes the west build command (same args as above) and add it as a “Before launch” step for the CMake profile.

  2. If your workspace uses sysbuild (nRF Connect cases), add --sysbuild or --no-sysbuild to CLion’s West advanced options (per JetBrains roadmap notes).


Sources


Conclusion

To stop the CMake error you need two things: (1) generated devicetree files must exist where CMake expects them — run west build from the app/ folder (or configure west to write to the same build directory CLion uses), and (2) configure CLion 2025.3 with Zephyr’s toolchain file, the correct -DBOARD option and ZEPHYR_BASE (or let CLion’s West support run the build first). Do that and your Zephyr RTOS project will index and build inside CLion without the zephyr.dts.new → zephyr.dts copy failure.

Authors
Verified by moderation
Moderation
CLion 2025.3 Zephyr RTOS Setup: Fix CMake DTS Error