Application build from multiple libs.


tomasz.sleboda@...
 

Hi,
I'm trying to port our application to run under Zephyr.
Application itself is build as a set of different libraries (e.g. libComm, libMeasurements...and libapp).
All libs are compiled and linked together with build success, but.. application crashes.

Digging deeper into compile process sims that objects under libapp target has proper includes, defines and compile options.
Rest of objects are wrongly compiled.

Is there way to populate build options from 'app' target to other libs (subcomponents) and objects via cmake functions?

-Tomasz S.


Raúl Sánchez Siles
 

El lunes, 5 de julio de 2021 12:36:36 (CEST) tomasz.sleboda via lists.zephyrproject.org escribió:

 

Hi,
I'm trying to port our application to run under Zephyr.
Application itself is build as a set of different libraries (e.g. libComm, libMeasurements...and libapp).
All libs are compiled and linked together with build success, but.. application crashes.

 

Digging deeper into compile process sims that objects under libapp target has proper includes, defines and compile options.
Rest of objects are wrongly compiled.

 

Is there way to populate build options from 'app' target to other libs (subcomponents) and objects via cmake functions?

 

-Tomasz S.


--

Raúl Sánchez Siles


SW Engineer


K-LAGAN EID


tomasz.sleboda@...
 

Hi,

I've just followed mentioned example.
Using extensions.cmake functions I was able to fetch needed variables:
zephyr_get_include_directories_for_lang_as_string(       C PROJECT_INCLUDE)
zephyr_get_system_include_directories_for_lang_as_string(C SYSTEM_INCLUDE)
zephyr_get_compile_definitions_for_lang_as_string(       C COMPILE_DEFINITIONS)
zephyr_get_compile_options_for_lang_as_string(           C COMPILE_OPTIONS)

Then applied them into sub-libs CMakeLists.txt :

target_include_directories(${LIB_NAME}
    PUBLIC
        $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
    PRIVATE
        ${PROJECT_INCLUDE}
    SYSTEM
        ${SYSTEM_INCLUDE}
    )

target_compile_definitions(${LIB_NAME}
    PUBLIC
        ${COMPILE_DEFINITIONS}
    )

target_compile_options(${LIB_NAME}
    PUBLIC
        ${COMPILE_OPTIONS}
    )