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?

Parents Reply
  • 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

Children
Related