boilerplate.cmake not found because ZEPHYR_BASE isn't set

Hi,

I'm very confused by this error.

I have a project with the following CMakeLists.txt file

cmake_minimum_required(VERSION 3.20.0)

include($ENV{ZEPHYR_BASE}/cmake/app/boilerplate.cmake NO_POLICY_SCOPE)
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
project(bike_finder)

target_sources(app PRIVATE src/main.c)
//... more target sources

# NORDIC SDK APP END
zephyr_library_include_directories(.)

When the project is tried to be built at the startup of VScode, I get the following error message

When I open a terminal, I ran echo $ZEPHYR_BASE, but it came out empty.
Therefore, I go into the nRF Connect SDK folder that I'm using (v2.2.0-rc1), run source zephyr/zephyr-env.sh and then the terminal finally recognizes where ZEPHYR_BASE is.

To rebuild, I just do a dummy modification to the file (use :w since I'm using vim within vscode), and then application tries to rebuild again, but I keep the same error.

If I go to the nRF Connect extension section, I see my folder under applications, but it's followed by "no build configurations", because of this problem.

What should I do?

  • Hi,

    ZEPHYR_BASE should be set correctly if you use VS Code with the nRF Connect for VS Code extension and has selected the correct SDK and toolchain. If you go to the welcome page of the extension and Quick Setup, what is nRF Connect SDK and nRF Connect Toolchain set to?

    You can also set ZEPHYR_BASE in your environment variables. The path of this should be the zephyr directory of your nRF Connect SDK installation, so for example something like /home/ernesto/ncs/v2.1.0/zephyr.

    Best regards,

    Marte

  • Quick setup

    Welcome to nRF - Quick Setup

    Settings in workspace

    Should I replace the settings in the workspace by the absolute path?

  • Hi,

    No, you do not have to replace the workspace settings. The settings there, in your second picture, is inherited from the settings in quick setup, and are correct.

    Try to move your include line to be under find_package:

    cmake_minimum_required(VERSION 3.20.0)
    
    find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
    include($ENV{ZEPHYR_BASE}/cmake/app/boilerplate.cmake NO_POLICY_SCOPE)
    project(bike_finder)
    
    target_sources(app PRIVATE src/main.c)
    //... more target sources
    
    # NORDIC SDK APP END
    zephyr_library_include_directories(.)

    Best regards,

    Marte

  • Hi Marte,

    Thank your reply. It helped moving forward, but it has uncovered other issues.
    My settings in the workspace (as I showed in my previous reply) remain the same.

    However, now, my main.c and other files do not recognize, for instance, "<zephyr.h>". I guess I could probably work around this by writing the absolute path to the file, but that'd imply changing many other include statements, which is not very practical.

    Also, I also include a path that is in my application folder.

    And if I want to build my application, I get the following error:

    What should I do?

  • Hi,

    I can see from your initial screenshot that NCS Toolchain v2.1.0 was used for building. However, now in the first screenshot (first out of 3) I see that you use NCS v2.2.0-rc1. Is there a reason that NCS and Toolchain versions are not the same? Has anything been changed?

    Regarding the inability to see the output of $ZEPHYR_BASE, you should be able to see the output if you open bash from Toolchain Manager.

    Best regards,
    Dejan

Related