From 33e5b13ea7e096b10419a3eb3dd5cbdce3452883 Mon Sep 17 00:00:00 2001 From: Lukas Woodtli Date: Wed, 28 Aug 2024 16:22:09 +0200 Subject: [PATCH] cmake: Add Wakaama static library 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. --- wakaama.cmake | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/wakaama.cmake b/wakaama.cmake index ddc9e649..365c1398 100644 --- a/wakaama.cmake +++ b/wakaama.cmake @@ -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