CMakeLists.txt

source

add_subdirectory(src)
add_subdirectory(lib)
zephyr_include_directories(include)

library

add common code as part of zephyr library

zephyr_library()
 
add_subdirectory(src_dir_for_common_parts)
add_subdirectory_ifdef(CONFIG_LIB_FEAT1 src_dir_for_feat1)
add_subdirectory_ifdef(CONFIG_LIB_FEAT2 src_dir_for_feat2)
 
zephyr_library_sources_ifdef(CONFIG_LIB_FEAT1 feat1.c)
zephyr_library_sources_ifdef(CONFIG_LIB_FEAT2 feat2.c)
 
zephyr_library_link_libraries_ifdef(CONFIG_LIB_SOME_OTHER_LIB otherlib)