cmake application project architecture


Florian Fouillet <Florian.Fouillet@...>
 

Hi everyone,

 

I am currently working on the Zephyr OS with a FDRM_K64f board from NXP.

 

I want to create my own application using cmake as recommended by the documentation.

 

However I don’t want to put everything in one CMakeLists.txt. I want to break down my project into libraries (multiple CMakeLists.txt).

 

Do you know if there is any documentation talking about that?

 

My top CMakeLists looks like that:

 

cmake_minimum_required(VERSION 3.8.2)

 

include($ENV{ZEPHYR_BASE}/cmake/app/boilerplate.cmake NO_POLICY_SCOPE)

project(NONE)

 

 

add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/DataLinkLayer

${CMAKE_CURRENT_SOURCE_DIR}/build/${BOARD}/DataLinkLayer)

 

target_sources(app PRIVATE src/main.c)

 

target_link_libraries(app

PRIVATE DL

)

 

 

And my second CMakeLists (under the folder DataLinkLayer) looks like that:

 

include_directories(${CMAKE_CURRENT_SOURCE_DIR}/src)

 

add_library(DL src/DataLinkInterface.c)

 

target_include_directories(DL

INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/Interface)

 

 

 

The issue is I can include the boilerplate.cmake in only one CMakeLists.txt otherwise It’s not working, But, the second CmakeLists doesn’t know the zephyr library..

 

I tried to add: include_directories(/home/user/zephyr/include) in the second CMakeLists but it is not enough. Do you know what should I do?

 

 

Thank you,

 

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