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

  • I'm using now v2.2.0 as I became aware of the new version. Since I'm using the same version for the toolchain and the SDK, I'm not sure how that's relevant to my problem.

    Now, I cannot see $ZEPHYR_BASE in the terminal I open in the bottom.

    What should I do?

  • Hi,

    builder01 said:
    Now, I cannot see $ZEPHYR_BASE in the terminal I open in the bottom.

    What should I do?

    Did you open bash terminal from Toolchain Manager?

    Best regards,
    Dejan

Related