Adding a costume module to my project #west


Stefan Hristozov
 

Hi,

I want to add a module to my project. My folder structure looks like this:

<top dir>
    |---modules
    |      |---module1
    |      |      |---CMakeLists.txt
    |      |      |---inc
    |      |      |---src
    |      |      |---zephyr
    |      |            |---module.yml
    |      |---module2
    |---app
           |---app1

Where modules/module1/CMakeLists.txt:

zephyr_interface_library_named(test)
target_include_directories(test INTERFACE inc)
zephyr_library()
zephyr_library_sources(
    src/test.c
)
zephyr_library_link_libraries(test)
target_link_libraries(test INTERFACE zephyr_interface)

modules/module1/zephyr/module.yml:

build:
  cmake: .

app/app1/CMakeLists.txt:
cmake_minimum_required(VERSION 3.13.1)
include($ENV{ZEPHYR_BASE}/cmake/app/boilerplate.cmake NO_POLICY_SCOPE)
project(NONE)

set($ENV{ZEPHYR_EXTRA_MODULES} pbs_path/module1)


FILE(GLOB app_sources src/*.c)
target_sources(app PRIVATE ${app_sources})
target_include_directories(app PRIVATE $ENV{ZEPHYR_BASE}/subsys/net/ip)

target_link_libraries(app PRIVATE test)

Unfortunately,  with this set up module1 doesn't get compiled and I get a linker error when I try to use functions from that module. I assume that something goes wrong with ZEPHYR_EXTRA_MODULES but I don't know what.

Best regards
Stefan

Join users@lists.zephyrproject.org to automatically receive all group messages.