Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CMake: platform layer and CLI library #806

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.20)
cmake_minimum_required(VERSION 3.21)

LukasWoodtli marked this conversation as resolved.
Show resolved Hide resolved
project(wakaama C)

Expand Down
8 changes: 7 additions & 1 deletion CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,13 @@
"name": "base",
"description": "Basic preset settings",
"hidden": true,
"binaryDir": "${sourceDir}/build-presets/${presetName}"
"binaryDir": "${sourceDir}/build-presets/${presetName}",
"cacheVariables": {
"WAKAAMA_PLATFORM": {
"type": "STRING",
"value": "POSIX"
}
}
},
{
"name": "server",
Expand Down
16 changes: 15 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,13 +100,27 @@ The logging infrastructure can be configured with CMake cache variables (e.g. `c

If `NONE` is chosen, the user of Wakaama needs to implement a custom transport layer. Check the available implementations for more information.

### Platform

- WAKAAMA_PLATFORM: Select the implementation of the platform abstraction layer, one of:
- POSIX: An implementation using the POSIX API.
- NONE: No platform abstraction layer is provided.

If `NONE` is chosen, the user of Wakaama needs to implement a custom platform abstraction layer. Check the available POSIX implementation for more information.

### Command Line

Wakaama provides a simple CLI library. It can be enabled with:

- WAKAAMA_CLI: If enabled the command line library is added to Wakaama (default: disabled)

## Development

### Dependencies and Tools
- Mandatory:
- Compiler: GCC and/or Clang
- Optional (but strongly recommended):
- Build system generator: CMake 3.13+
- Build system generator: CMake 3.21+
- Version control system: Git (and a GitHub account)
- Git commit message linter: gitlint
- Build system: ninja
Expand Down
2 changes: 1 addition & 1 deletion examples/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.13)
cmake_minimum_required(VERSION 3.21)

# Our examples are designed for POSIX systems
add_compile_definitions(_POSIX_C_SOURCE=200809)
Expand Down
2 changes: 1 addition & 1 deletion examples/bootstrap_server/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.13)
cmake_minimum_required(VERSION 3.21)

project(bootstrap_server C)

Expand Down
2 changes: 1 addition & 1 deletion examples/client/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.13)
cmake_minimum_required(VERSION 3.21)

project(lwm2mclient C)

Expand Down
2 changes: 1 addition & 1 deletion examples/lightclient/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.13)
cmake_minimum_required(VERSION 3.21)

project(lightclient C)

Expand Down
2 changes: 1 addition & 1 deletion examples/server/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.13)
cmake_minimum_required(VERSION 3.21)

project(lwm2mserver C)

Expand Down
2 changes: 1 addition & 1 deletion tests/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.13)
cmake_minimum_required(VERSION 3.21)

project(lwm2munittests C)

Expand Down
3 changes: 2 additions & 1 deletion tools/ci/run_ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,8 @@ function run_build() {
mkdir -p build-wakaama

echo "Default build"
${OPT_WRAPPER_CMD} cmake -GNinja -S ${OPT_SOURCE_DIRECTORY} -B build-wakaama -DWAKAAMA_MODE_SERVER=ON ${CMAKE_ARGS}
${OPT_WRAPPER_CMD} cmake -GNinja -S ${OPT_SOURCE_DIRECTORY} -B build-wakaama \
-DWAKAAMA_MODE_SERVER=ON -DWAKAAMA_PLATFORM=POSIX ${CMAKE_ARGS}
${OPT_WRAPPER_CMD} cmake --build build-wakaama

# CMake presets
Expand Down
18 changes: 17 additions & 1 deletion wakaama.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,16 @@ set(WAKAAMA_TRANSPORT
)
set_property(CACHE WAKAAMA_TRANSPORT PROPERTY STRINGS NONE POSIX_UDP TINYDTLS)

# Platform
set(WAKAAMA_PLATFORM
NONE
CACHE STRING "The platform abstraction layer implementation"
)
set_property(CACHE WAKAAMA_TRANSPORT PROPERTY STRINGS POSIX NONE)

# Command line interface
option(WAKAAMA_CLI "Command line interface library" OFF)

# Endianess
add_compile_definitions("$<IF:$<STREQUAL:${CMAKE_C_BYTE_ORDER},BIG_ENDIAN>,LWM2M_BIG_ENDIAN,LWM2M_LITTLE_ENDIAN>")

Expand Down Expand Up @@ -282,7 +292,13 @@ target_sources(wakaama_transport_testing_fake PRIVATE ${WAKAAMA_TOP_LEVEL_DIRECT
function(target_sources_shared target)
get_target_property(TARGET_PROPERTY_CONN_IMPL ${target} CONNECTION_IMPLEMENTATION)

target_link_libraries(${target} PRIVATE wakaama_command_line wakaama_platform_posix)
if(WAKAAMA_PLATFORM STREQUAL POSIX)
target_link_libraries(${target} PRIVATE wakaama_command_line wakaama_platform_posix)
endif()

if(WAKAAMA_CLI)
target_link_libraries(${target} PRIVATE wakaama_command_line)
endif()

set_defines(${target})

Expand Down
Loading