Skip to content

Commit

Permalink
cmake: Add Wakaama static library
Browse files Browse the repository at this point in the history
The static library can be configured with CMake variables and then be
linked to user applications.

Wakaama became difficult to build and to maintain. Among other things,
there are defines and compiler flags that have to be set, the right set
of source files need to be selected and the correct include directories
have to be provided.

Therefore we rely on CMake and provide the users of Wakaama a static
library, which is relatively simple to build with a given set of
requested features.

This also helps with modularizing Wakaama to improve maintainability.
  • Loading branch information
LukasWoodtli committed Oct 3, 2024
1 parent e73ff3d commit ee0c98d
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions wakaama.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,28 @@ function(target_sources_shared target)
target_include_directories(${target} PUBLIC ${WAKAAMA_EXAMPLE_SHARED_DIRECTORY})
endfunction()

# Static library that users of Wakaama can link against
#
# This library simplifies building and maintaining Wakaama. It handles defines and compiler flags, adding the right
# source files and setting include directories...
add_library(wakaama_static STATIC)
target_sources_wakaama(wakaama_static)
target_include_directories(wakaama_static PUBLIC ${WAKAAMA_TOP_LEVEL_DIRECTORY}/include/)

if(WAKAAMA_TRANSPORT STREQUAL POSIX_UDP)
target_link_libraries(wakaama_static PUBLIC wakaama_transport_posix_udp)
elseif(WAKAAMA_TRANSPORT STREQUAL TINYDTLS)
target_link_libraries(wakaama_static PUBLIC wakaama_transport_tinydtls)
endif()

if(WAKAAMA_PLATFORM STREQUAL POSIX)
target_link_libraries(wakaama_static PUBLIC wakaama_platform_posix)
endif()

if(WAKAAMA_CLI)
target_link_libraries(wakaama_static PUBLIC wakaama_command_line)
endif()

# Enforce a certain level of hygiene
add_compile_options(
-Waggregate-return
Expand Down

0 comments on commit ee0c98d

Please sign in to comment.