I am trying to separate part of my application into static library and link it to the app. I have read https://docs.zephyrproject.org/latest/application/index.html and cmake documentation.
In my app folder I have CMakeLists.txt
cmake_minimum_required(VERSION 3.13.1) find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE}) project(test) add_subdirectory(src/mylib) target_sources(app PRIVATE src/main.c) target_link_libraries(app PUBLIC mylib)
in src/mylib I have CMakeLists.txt
cmake_minimum_required(VERSION 3.13.1) add_library(mylib STATIC libfile.c)
Now build process is picking up it needs to build static library and link it to app. The problem is compiler flags are not passed to mylib build process and this end up with unlinkable mylib.a.
How do I pass CFLAGS and defines to the mylib build?
/home/wodz/Datasheet/nordic/gcc-arm-none-eabi-9-2019-q4-major/bin/../lib/gcc/arm-none-eabi/9.2.1/../../../../arm-none-eabi/bin/ld.bfd: failed to merge target specific data of file src/mylib/libmylib.a(libfile.c.obj)
collect2: error: ld returned 1 exit status
ninja: build stopped: subcommand failed.