Topics

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,

 


Sigvart Hovland
 

Maybe adding

target_link_libraries(DL PRIVATE zephyr_interface)

To your 2nd CMake file  could help?

 

From: devel@... [mailto:devel@...] On Behalf Of Florian Fouillet
Sent: Tuesday, November 27, 2018 9:53 PM
To: devel@...
Subject: [Zephyr-devel] cmake application project architecture

 

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,

 


Florian Fouillet <Florian.Fouillet@...>
 

Hi,

 

By adding target_link_libraries(DL PRIVATE zephyr_interface)

 

I still have the following issue

 

fatal error: syscall_list.h: No such file or directory

 

From: Hovland, Sigvart [mailto:Sigvart.Hovland@...]
Sent: Wednesday, November 28, 2018 4:26 AM
To: Florian Fouillet <Florian.Fouillet@...>; devel@...
Subject: RE: cmake application project architecture

 

[External email: Use caution with links and attachments]


 

Maybe adding

target_link_libraries(DL PRIVATE zephyr_interface)

To your 2nd CMake file  could help?

 

From: devel@... [mailto:devel@...] On Behalf Of Florian Fouillet
Sent: Tuesday, November 27, 2018 9:53 PM
To: devel@...
Subject: [Zephyr-devel] cmake application project architecture

 

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,

 


______________________________________________________________________
This email has been scanned by the Symantec Email Security.cloud service.
______________________________________________________________________


Sebastian Boe
 

You also need

add_dependencies(DL offsets_h)

________________________________________
From: devel@... <devel@...> on behalf of Florian Fouillet <Florian.Fouillet@...>
Sent: Wednesday, November 28, 2018 3:42:54 PM
To: Hovland, Sigvart; devel@...
Subject: Re: [Zephyr-devel] cmake application project architecture

Hi,

By adding target_link_libraries(DL PRIVATE zephyr_interface)

I still have the following issue

fatal error: syscall_list.h: No such file or directory

From: Hovland, Sigvart [mailto:@siho]
Sent: Wednesday, November 28, 2018 4:26 AM
To: Florian Fouillet <Florian.Fouillet@...>; devel@...
Subject: RE: cmake application project architecture


[External email: Use caution with links and attachments]

________________________________


Maybe adding

target_link_libraries(DL PRIVATE zephyr_interface)


To your 2nd CMake file could help?

From: devel@...<mailto:devel@...> [mailto:devel@...] On Behalf Of Florian Fouillet
Sent: Tuesday, November 27, 2018 9:53 PM
To: devel@...<mailto:devel@...>
Subject: [Zephyr-devel] cmake application project architecture

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,


______________________________________________________________________
This email has been scanned by the Symantec Email Security.cloud service.
______________________________________________________________________


Florian Fouillet <Florian.Fouillet@...>
 

Hi,

Thank you for your reply. It's working.

What does add_dependencies(DL offsets_h) do?

Is there any zephyr cmake example using multiple CMakeLists I can read?

Thanks for your help!

-----Original Message-----
From: Bøe, Sebastian [mailto:Sebastian.Boe@...]
Sent: Wednesday, November 28, 2018 9:45 AM
To: Florian Fouillet <Florian.Fouillet@...>; Hovland, Sigvart <@siho>; devel@...
Subject: Re: [Zephyr-devel] cmake application project architecture

[External email: Use caution with links and attachments]

________________________________



You also need

add_dependencies(DL offsets_h)

________________________________________
From: devel@... <devel@...> on behalf of Florian Fouillet <Florian.Fouillet@...>
Sent: Wednesday, November 28, 2018 3:42:54 PM
To: Hovland, Sigvart; devel@...
Subject: Re: [Zephyr-devel] cmake application project architecture

Hi,

By adding target_link_libraries(DL PRIVATE zephyr_interface)

I still have the following issue

fatal error: syscall_list.h: No such file or directory

From: Hovland, Sigvart [mailto:@siho]
Sent: Wednesday, November 28, 2018 4:26 AM
To: Florian Fouillet <Florian.Fouillet@...>; devel@...
Subject: RE: cmake application project architecture


[External email: Use caution with links and attachments]

________________________________


Maybe adding

target_link_libraries(DL PRIVATE zephyr_interface)


To your 2nd CMake file could help?

From: devel@...<mailto:devel@...> [mailto:devel@...] On Behalf Of Florian Fouillet
Sent: Tuesday, November 27, 2018 9:53 PM
To: devel@...<mailto:devel@...>
Subject: [Zephyr-devel] cmake application project architecture

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,


______________________________________________________________________
This email has been scanned by the Symantec Email Security.cloud service.
______________________________________________________________________


______________________________________________________________________
This email has been scanned by the Symantec Email Security.cloud service.
______________________________________________________________________


Sebastian Boe
 

It adds a dependency between DL and offsets_h.

offsets_h is a target that happens to depend on various kernel headers,
including syscall_list.h, which evidently was used by the application
library.

I'm not aware of any such example.

________________________________________
From: Florian Fouillet <Florian.Fouillet@...>
Sent: Wednesday, November 28, 2018 3:49:43 PM
To: Bøe, Sebastian; Hovland, Sigvart; devel@...
Subject: RE: [Zephyr-devel] cmake application project architecture

Hi,

Thank you for your reply. It's working.

What does add_dependencies(DL offsets_h) do?

Is there any zephyr cmake example using multiple CMakeLists I can read?

Thanks for your help!



-----Original Message-----
From: Bøe, Sebastian [mailto:Sebastian.Boe@...]
Sent: Wednesday, November 28, 2018 9:45 AM
To: Florian Fouillet <Florian.Fouillet@...>; Hovland, Sigvart <@siho>; devel@...
Subject: Re: [Zephyr-devel] cmake application project architecture

[External email: Use caution with links and attachments]

________________________________



You also need

add_dependencies(DL offsets_h)

________________________________________
From: devel@... <devel@...> on behalf of Florian Fouillet <Florian.Fouillet@...>
Sent: Wednesday, November 28, 2018 3:42:54 PM
To: Hovland, Sigvart; devel@...
Subject: Re: [Zephyr-devel] cmake application project architecture

Hi,

By adding target_link_libraries(DL PRIVATE zephyr_interface)

I still have the following issue

fatal error: syscall_list.h: No such file or directory

From: Hovland, Sigvart [mailto:@siho]
Sent: Wednesday, November 28, 2018 4:26 AM
To: Florian Fouillet <Florian.Fouillet@...>; devel@...
Subject: RE: cmake application project architecture


[External email: Use caution with links and attachments]

________________________________


Maybe adding

target_link_libraries(DL PRIVATE zephyr_interface)


To your 2nd CMake file could help?

From: devel@...<mailto:devel@...> [mailto:devel@...] On Behalf Of Florian Fouillet
Sent: Tuesday, November 27, 2018 9:53 PM
To: devel@...<mailto:devel@...>
Subject: [Zephyr-devel] cmake application project architecture

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,


______________________________________________________________________
This email has been scanned by the Symantec Email Security.cloud service.
______________________________________________________________________


______________________________________________________________________
This email has been scanned by the Symantec Email Security.cloud service.
______________________________________________________________________


Florian Fouillet <Florian.Fouillet@...>
 

I understand, thank you very much.

-----Original Message-----
From: Bøe, Sebastian [mailto:Sebastian.Boe@...]
Sent: Wednesday, November 28, 2018 9:53 AM
To: Florian Fouillet <Florian.Fouillet@...>; Hovland, Sigvart <@siho>; devel@...
Subject: Re: [Zephyr-devel] cmake application project architecture

[External email: Use caution with links and attachments]

________________________________



It adds a dependency between DL and offsets_h.

offsets_h is a target that happens to depend on various kernel headers, including syscall_list.h, which evidently was used by the application library.

I'm not aware of any such example.

________________________________________
From: Florian Fouillet <Florian.Fouillet@...>
Sent: Wednesday, November 28, 2018 3:49:43 PM
To: Bøe, Sebastian; Hovland, Sigvart; devel@...
Subject: RE: [Zephyr-devel] cmake application project architecture

Hi,

Thank you for your reply. It's working.

What does add_dependencies(DL offsets_h) do?

Is there any zephyr cmake example using multiple CMakeLists I can read?

Thanks for your help!



-----Original Message-----
From: Bøe, Sebastian [mailto:Sebastian.Boe@...]
Sent: Wednesday, November 28, 2018 9:45 AM
To: Florian Fouillet <Florian.Fouillet@...>; Hovland, Sigvart <@siho>; devel@...
Subject: Re: [Zephyr-devel] cmake application project architecture

[External email: Use caution with links and attachments]

________________________________



You also need

add_dependencies(DL offsets_h)

________________________________________
From: devel@... <devel@...> on behalf of Florian Fouillet <Florian.Fouillet@...>
Sent: Wednesday, November 28, 2018 3:42:54 PM
To: Hovland, Sigvart; devel@...
Subject: Re: [Zephyr-devel] cmake application project architecture

Hi,

By adding target_link_libraries(DL PRIVATE zephyr_interface)

I still have the following issue

fatal error: syscall_list.h: No such file or directory

From: Hovland, Sigvart [mailto:@siho]
Sent: Wednesday, November 28, 2018 4:26 AM
To: Florian Fouillet <Florian.Fouillet@...>; devel@...
Subject: RE: cmake application project architecture


[External email: Use caution with links and attachments]

________________________________


Maybe adding

target_link_libraries(DL PRIVATE zephyr_interface)


To your 2nd CMake file could help?

From: devel@...<mailto:devel@...> [mailto:devel@...] On Behalf Of Florian Fouillet
Sent: Tuesday, November 27, 2018 9:53 PM
To: devel@...<mailto:devel@...>
Subject: [Zephyr-devel] cmake application project architecture

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,


______________________________________________________________________
This email has been scanned by the Symantec Email Security.cloud service.
______________________________________________________________________


______________________________________________________________________
This email has been scanned by the Symantec Email Security.cloud service.
______________________________________________________________________

______________________________________________________________________
This email has been scanned by the Symantec Email Security.cloud service.
______________________________________________________________________