Skip to content

Commit

Permalink
cmake: Add option to disable examples
Browse files Browse the repository at this point in the history
The examples conflict with the logging tests so they can be disabled if
not needed.
  • Loading branch information
LukasWoodtli authored and mlasch committed May 29, 2024
1 parent a5a392b commit df92701
Show file tree
Hide file tree
Showing 6 changed files with 59 additions and 44 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,9 @@ pytest -v tests/integration

## Examples

The examples can be enabled (or disabled) with the CMake cache variable `WAKAAMA_ENABLE_EXAMPLES` (e.g.
`cmake -DWAKAAMA_ENABLE_EXAMPLES=OFF`).

There are some example applications provided to test the server, client and bootstrap capabilities of Wakaama.
The following recipes assume you are on a unix like platform and you have cmake and make installed.

Expand Down
10 changes: 6 additions & 4 deletions examples/bootstrap_server/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ project(bootstrap_server C)

include(../../wakaama.cmake)

add_executable(bootstrap_server bootstrap_info.c bootstrap_server.c bootstrap_info.h bootstrap_server.ini)
target_compile_definitions(bootstrap_server PRIVATE LWM2M_BOOTSTRAP_SERVER_MODE)
target_sources_wakaama(bootstrap_server)
target_sources_shared(bootstrap_server)
if(WAKAAMA_ENABLE_EXAMPLES)
add_executable(bootstrap_server bootstrap_info.c bootstrap_server.c bootstrap_info.h bootstrap_server.ini)
target_compile_definitions(bootstrap_server PRIVATE LWM2M_BOOTSTRAP_SERVER_MODE)
target_sources_wakaama(bootstrap_server)
target_sources_shared(bootstrap_server)
endif()
67 changes: 35 additions & 32 deletions examples/client/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,38 +4,41 @@ project(lwm2mclient C)

include(../../wakaama.cmake)

set(SOURCES
lwm2mclient.c
lwm2mclient.h
object_access_control.c
object_connectivity_moni.c
object_connectivity_stat.c
object_device.c
object_firmware.c
object_location.c
object_security.c
object_server.c
object_test.c
system_api.c
)
if(WAKAAMA_ENABLE_EXAMPLES)
set(SOURCES
lwm2mclient.c
lwm2mclient.h
object_access_control.c
object_connectivity_moni.c
object_connectivity_stat.c
object_device.c
object_firmware.c
object_location.c
object_security.c
object_server.c
object_test.c
system_api.c
)

# Client without DTLS support
add_executable(lwm2mclient ${SOURCES})
target_compile_definitions(lwm2mclient PRIVATE LWM2M_CLIENT_MODE LWM2M_BOOTSTRAP LWM2M_SUPPORT_SENML_JSON)
target_sources_wakaama(lwm2mclient)
target_sources_shared(lwm2mclient)
# Client without DTLS support
add_executable(lwm2mclient ${SOURCES})
target_compile_definitions(lwm2mclient PRIVATE LWM2M_CLIENT_MODE LWM2M_BOOTSTRAP LWM2M_SUPPORT_SENML_JSON)
target_sources_wakaama(lwm2mclient)
target_sources_shared(lwm2mclient)

# Client without raw block 1 requests DTLS support
add_executable(lwm2mclient_raw_block1 ${SOURCES})
target_compile_definitions(
lwm2mclient_raw_block1 PRIVATE LWM2M_CLIENT_MODE LWM2M_BOOTSTRAP LWM2M_SUPPORT_SENML_JSON LWM2M_RAW_BLOCK1_REQUESTS
)
target_sources_wakaama(lwm2mclient_raw_block1)
target_sources_shared(lwm2mclient_raw_block1)
# Client without raw block 1 requests DTLS support
add_executable(lwm2mclient_raw_block1 ${SOURCES})
target_compile_definitions(
lwm2mclient_raw_block1 PRIVATE LWM2M_CLIENT_MODE LWM2M_BOOTSTRAP LWM2M_SUPPORT_SENML_JSON
LWM2M_RAW_BLOCK1_REQUESTS
)
target_sources_wakaama(lwm2mclient_raw_block1)
target_sources_shared(lwm2mclient_raw_block1)

# Client with DTLS support provided by tinydtls
add_executable(lwm2mclient_tinydtls ${SOURCES})
set_target_properties(lwm2mclient_tinydtls PROPERTIES CONNECTION_IMPLEMENTATION "tinydtls")
target_compile_definitions(lwm2mclient_tinydtls PRIVATE LWM2M_CLIENT_MODE LWM2M_BOOTSTRAP LWM2M_SUPPORT_SENML_JSON)
target_sources_wakaama(lwm2mclient_tinydtls)
target_sources_shared(lwm2mclient_tinydtls)
# Client with DTLS support provided by tinydtls
add_executable(lwm2mclient_tinydtls ${SOURCES})
set_target_properties(lwm2mclient_tinydtls PROPERTIES CONNECTION_IMPLEMENTATION "tinydtls")
target_compile_definitions(lwm2mclient_tinydtls PRIVATE LWM2M_CLIENT_MODE LWM2M_BOOTSTRAP LWM2M_SUPPORT_SENML_JSON)
target_sources_wakaama(lwm2mclient_tinydtls)
target_sources_shared(lwm2mclient_tinydtls)
endif()
10 changes: 6 additions & 4 deletions examples/lightclient/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ project(lightclient C)

include(../../wakaama.cmake)

add_executable(lightclient lightclient.c object_device.c object_security.c object_server.c object_test.c)
target_compile_definitions(lightclient PRIVATE LWM2M_CLIENT_MODE)
target_sources_wakaama(lightclient)
target_sources_shared(lightclient)
if(WAKAAMA_ENABLE_EXAMPLES)
add_executable(lightclient lightclient.c object_device.c object_security.c object_server.c object_test.c)
target_compile_definitions(lightclient PRIVATE LWM2M_CLIENT_MODE)
target_sources_wakaama(lightclient)
target_sources_shared(lightclient)
endif()
10 changes: 6 additions & 4 deletions examples/server/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ project(lwm2mserver C)

include(../../wakaama.cmake)

add_executable(lwm2mserver lwm2mserver.c)
target_compile_definitions(lwm2mserver PRIVATE LWM2M_SERVER_MODE)
target_sources_wakaama(lwm2mserver)
target_sources_shared(lwm2mserver)
if(WAKAAMA_ENABLE_EXAMPLES)
add_executable(lwm2mserver lwm2mserver.c)
target_compile_definitions(lwm2mserver PRIVATE LWM2M_SERVER_MODE)
target_sources_wakaama(lwm2mserver)
target_sources_shared(lwm2mserver)
endif()
3 changes: 3 additions & 0 deletions wakaama.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ set(WAKAAMA_LOG_MAX_MSG_TXT_SIZE
CACHE STRING "The buffer size for the log message (without additional data)"
)

# Possibility to disable the examples
option(WAKAAMA_ENABLE_EXAMPLES "Build all the example applications" ON)

# Set the defines for logging configuration
function(set_defines target)
# Logging
Expand Down

0 comments on commit df92701

Please sign in to comment.