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 Children
  • If I do pristine build from Vs code, I get the same error.
    If I delete the build directory and run the west command from terminal opened from the toolchain manager, then I get the original error I mentioned previously:

    WARNING: This looks like a fresh build and BOARD is unknown; so it probably won't work. To fix, use --board=<your-board>.
    Note: to silence the above message, run 'west config build.board_warn false'
    -- west build: generating a build system
    Loading Zephyr default modules (Zephyr base).
    -- Application: /home/ernesto/ncs/bike_finder
    -- Using NCS Toolchain 2.2.0-rc1 for building. (/home/ernesto/ncs/toolchains/v2.2.0-rc1/cmake)
    -- Found Python3: /home/ernesto/ncs/toolchains/v2.2.0-rc1/usr/local/bin/python3 (found suitable exact version "3.8.2") found components: Interpreter 
    -- Cache files will be written to: /home/ernesto/.cache/zephyr
    -- Zephyr version: 3.2.99 (/home/ernesto/ncs/v2.2.0-rc1/zephyr)
    -- Found west (found suitable version "0.14.0", minimum required is "0.7.1")
    CMake Error at /home/ernesto/ncs/v2.2.0-rc1/zephyr/cmake/modules/extensions.cmake:2520 (message):
      BOARD is not being defined on the CMake command-line, in the environment or
      by the app.
    Call Stack (most recent call first):
      /home/ernesto/ncs/v2.2.0-rc1/zephyr/cmake/modules/boards.cmake:52 (zephyr_check_cache)
      /home/ernesto/ncs/v2.2.0-rc1/zephyr/cmake/modules/zephyr_default.cmake:108 (include)
      /home/ernesto/ncs/v2.2.0-rc1/zephyr/share/zephyr-package/cmake/ZephyrConfig.cmake:66 (include)
      /home/ernesto/ncs/v2.2.0-rc1/zephyr/share/zephyr-package/cmake/ZephyrConfig.cmake:92 (include_boilerplate)
      CMakeLists.txt:6 (find_package)
    
    
    -- Configuring incomplete, errors occurred!
    FATAL ERROR: command exited with status 1: /home/ernesto/ncs/toolchains/v2.2.0-rc1/usr/local/bin/cmake -DWEST_PYTHON=/home/ernesto/ncs/toolchains/v2.2.0-rc1/usr/local/bin/python3.8 -B/home/ernesto/ncs/bike_finder/build -GNinja -S/home/ernesto/ncs/bike_finder
    

  •   

    Ok, looks like I was right.
    If instead of "#include <zephyr.h>" I write "#include<zephyr/zephyr.h>" then I get a different warning about this header file being deprecated and that I should use <zephyr/kernel.h> instead.

    This is happening because the build command, as I said in a previous response to you, is only including the zephyr directories up to .../include, which is the reason why all my headers work now if I prepend an extra "zephyr/" in my includes.

    However, I got a lot of includes, so my final question to you is:

    How can I add the directories up to .../include/zephyr so that I don't have prepend "zephyr/" in each of my includes? Is there a way to set this in VS Code?

  • Hi,

    Prepending zephyr to includes is introduced with Zephyr v3.x.x namespace change. It is not recommended to use old include paths. Having said that, there is a KConfig configuration option CONFIG_LEGACY_INCLUDE_PATH but it is deprecated and expected to be removed. You could use Python script migrate_includes.py which is located in zephyr/scripts/utils/ to perform conversion.

    Best regards,
    Dejan

  • Hi,

    It is great to know that your issue has been resolved.

    Best regards,
    Dejan

Related