Including custom zephyr module

Hello,

We are developing a custom Zephyr module that we would like to include into multiple projects.

After a lot of testing and debugging we ran into a very weird issue that we cannot explain.  

The module looks like this:

Fullscreen
1
2
3
4
5
6
7
8
9
10
C:/path-to-my-module/test-module/
library/
include/
test_module.h
src/
test_module.c
Kconfig
zephyr/
module.yml
CMakeLists.txt
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX


Where the CMakeLists.txt looks like this:

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
cmake_minimum_required(VERSION 3.20.0)
# Define the project as library
zephyr_library_named()
# Include the library headers
zephyr_include_directories(library/include)
# Add the source files to the library
file(GLOB_RECURSE SRC "library/src/*.c")
zephyr_library_sources(${SRC})
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

And the zephyr/module.yml like this:

Fullscreen
1
2
3
4
5
name: test-module
build:
cmake: .
kconfig: ./library/Kconfig
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

The project's CMakeLists.txt looks like this:

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
cmake_minimum_required(VERSION 3.20.0)
set(EXTRA_ZEPHYR_MODULES ${CMAKE_CURRENT_SOURCE_DIR}/../modules/test-module)
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
project(test-app VERSION 0.0.1)
zephyr_include_directories(include)
target_include_directories(app PRIVATE
include
)
file(GLOB_RECURSE SRC "src/*.c")
target_sources(app PRIVATE ${SRC})
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

The module is added to the project using west, like this:

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
manifest:
remotes:
- <remotes>
projects:
- name: test-module
path: modules/test-module
remote: <remote>
revision: 0.0.1
- name: sdk-nrf
path: nrf
remote: ncs
revision: v2.5.0
import:
name-whitelist:
- cmsis
- hal_nordic
- mcuboot
- mcumgr
- segger
- tinycrypt
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

This all works fine and all the modules are correctly loaded after using 'west update'. However, when building the project I get a lot of errors that the module cannot find certain configs and files (just a small part of the error):

Fullscreen
1
2
3
4
5
6
7
8
error: 'CONFIG_LWM2M_ENGINE_MAX_PENDING' undeclared here (not in a function)
147 | struct coap_pending pendings[CONFIG_LWM2M_ENGINE_MAX_PENDING + 1];
error: 'CONFIG_LWM2M_ENGINE_MAX_REPLIES' undeclared here (not in a function)
148 | struct coap_reply replies[CONFIG_LWM2M_ENGINE_MAX_REPLIES + 1];
error: 'DT_N_ALIAS_isp_P_gpios_IDX_0_VAL_pin' undeclared here (not in a function); did you mean 'DT_N_S_leds_S_led_0_P_gpios_IDX_0_VAL_pin'?
237 | #define DT_ALIAS(alias) DT_CAT(DT_N_ALIAS_, alias)
error: '__device_dts_ord_DT_N_ALIAS_isp_P_gpios_IDX_0_PH_ORD' undeclared here (not in a function)
85 | #define DEVICE_NAME_GET(dev_id) _CONCAT(__device_, dev_id)
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

However, now the weird part which took me a lot of time and mainly luck to figure out. When I only remove the module lines from the west.yml file (not the module files themselves) and execute the 'west update' command again the build succeeds. As soon as I configure the module again in the west.yml file and use 'west update', (so the exact same files are checked out) the build fails again with the same errors.

How does the west.yml influence the build process and how can I solve this problem?

Thank you.