Hello,
The embedded project I am currently working on was configured to be built, and flash with the command line. I want to build it using vscode and the nRF Connect extension.
My project has the following structure folder:
ProjectXZephyr
|________.west
|________config
|________.vscode
|________projectX-bootloader
|________projectX-common
|________projectX-application
|________boards/arm/my_custom_board
|________submodules
|________nrf
|________zephyr
:
:
In projectX-application I have the following CMakeLists.txt where I specified where to find the Zephyr package.
# Find Zephyr. This also loads Zephyr's build system.
cmake_minimum_required(VERSION 3.13.1)
list(APPEND BOARD_ROOT ${CMAKE_CURRENT_SOURCE_DIR})
list(APPEND ZEPHYR_EXTRA_MODULES
${CMAKE_CURRENT_SOURCE_DIR}/projectX_drivers
)
set(ZEPHYR_TOOLCHAIN_VARIANT gnuarmemb)
set(GNUARMEMB_TOOLCHAIN_PATH "C:/Program Files (x86)/GNU Tools ARM Embedded/9 2019-q4-major")
find_package(Zephyr
PATHS
${CMAKE_SOURCE_DIR}/../submodules/zephyr/share/zephyr-package/cmake
)
project(ProjectX3)
# Add your source files to the "app" target. This must come after
# find_package(Zephyr) which defines the target.
add_subdirectory(src)
target_include_directories(app PRIVATE ./legacy/module)
target_include_directories(app PRIVATE ./)
include(legacy.cmake)
target_include_directories(app PRIVATE ./include/)
When I use the west command to build my project the build is successful.
When I use the nrfConnect vscode the build fails (see the terminal output).
Executing task: nRF Connect: Generate config my_custom_board for projectX-application
Building projectX-application
west build --build-dir c:\code\ProjectXZephyr\projectX-application\build_8 c:\code\ProjectXZephyr\projectX-application --pristine --board my_custom_board -- -DNCS_TOOLCHAIN_VERSION:STRING="NONE" -DBOARD_ROOT:STRING="c:/code/ProjectXZephyr/projectX-application"
WARNING: ZEPHYR_BASE=c:\code\ProjectXZephyr\zephyr in the calling environment will be used,
but the zephyr.base config option in c:\code\ProjectXZephyr is "submodules/zephyr"
which implies a different ZEPHYR_BASE=c:\code\ProjectXZephyr\submodules\zephyr
To disable this warning in the future, execute 'west config --global zephyr.base-prefer env'
-- west build: generating a build system
Loading Zephyr default modules (Zephyr base).
CMake Error at C:/ncs/v2.0.0/zephyr/share/zephyr-package/cmake/ZephyrConfig.cmake:51 (include):
include could not find requested file:
zephyr_default
Call Stack (most recent call first):
C:/ncs/v2.0.0/zephyr/share/zephyr-package/cmake/ZephyrConfig.cmake:76 (include_boilerplate)
CMakeLists.txt:9 (find_package)
-- The C compiler identification is Clang 10.0.0 with GNU-like command-line
-- The CXX compiler identification is Clang 10.0.0 with GNU-like command-line
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: C:/Program Files/LLVM/bin/clang.exe - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: C:/Program Files/LLVM/bin/clang++.exe - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
CMake Error at src/CMakeLists.txt:1 (target_include_directories):
Cannot specify include directories for target "app" which is not built by
this project.
CMake Error at src/CMakeLists.txt:2 (target_sources):
Cannot specify sources for target "app" which is not built by this project.
CMake Error at src/ble/CMakeLists.txt:1 (target_sources):
Cannot specify sources for target "app" which is not built by this project.
CMake Error at src/ble/CMakeLists.txt:2 (target_sources):
Cannot specify sources for target "app" which is not built by this project.
CMake Error at src/ble/CMakeLists.txt:3 (target_sources):
Cannot specify sources for target "app" which is not built by this project.
CMake Error at src/system/CMakeLists.txt:1 (target_sources):
Cannot specify sources for target "app" which is not built by this project.
CMake Error at src/system/CMakeLists.txt:2 (target_sources):
Cannot specify sources for target "app" which is not built by this project.
CMake Error at src/power/CMakeLists.txt:1 (target_sources):
Cannot specify sources for target "app" which is not built by this project.
CMake Error at src/pump/CMakeLists.txt:1 (target_sources):
Cannot specify sources for target "app" which is not built by this project.
CMake Error at CMakeLists.txt:18 (target_include_directories):
Cannot specify include directories for target "app" which is not built by
this project.
CMake Error at CMakeLists.txt:19 (target_include_directories):
Cannot specify include directories for target "app" which is not built by
this project.
CMake Error at legacy.cmake:1 (target_sources):
Cannot specify sources for target "app" which is not built by this project.
Call Stack (most recent call first):
CMakeLists.txt:20 (include)
CMake Error at legacy.cmake:2 (target_sources):
Cannot specify sources for target "app" which is not built by this project.
Call Stack (most recent call first):
CMakeLists.txt:20 (include)
CMake Error at CMakeLists.txt:21 (target_include_directories):
Cannot specify include directories for target "app" which is not built by
this project.
-- Configuring incomplete, errors occurred!
See also "C:/code/ProjectXZephyr/projectX-application/build_8/CMakeFiles/CMakeOutput.log".
FATAL ERROR: command exited with status 1: 'C:\Program Files\CMake\bin\cmake.EXE' '-DWEST_PYTHON=c:\users\name.surname\appdata\local\programs\python\python38\python.exe' '-Bc:\code\ProjectXZephyr\projectX-application\build_8' '-Sc:\code\ProjectXZephyr\projectX-application' -GNinja -DBOARD=my_custom_board -DNCS_TOOLCHAIN_VERSION:STRING=NONE -DBOARD_ROOT:STRING=c:/code/ProjectXZephyr/projectX-application
* The terminal process terminated with exit code: 1.
* Terminal will be reused by tasks, press any key to close it.
I don't understand why vscode takes that ZEPHYR_BASE = c:\code\ProjectXZephyr\zephyr which is incorrect instead of the one specified ZEPHYR_BASE=c:\code\ProjectXZephyr\submodules\zephyr.
I guess this can lead to the cascade of errors.
Also I don't understand how to change this path C:/ncs/v2.0.0/zephyr/share/zephyr-package/cmake/ZephyrConfig.cmake:76
in the local one of the project : C:\code\ProjectZephyr\submodules\zephyr\share\zephyr-package\cmake.
I tried to set them in the nrf-connect json, but I always get the same error. Any ideas about how can I fix this?