Skip to content

Commit

Permalink
Merge pull request #389 from embhorn/zd17139
Browse files Browse the repository at this point in the history
Add cmake CI test and fix pthread detection
  • Loading branch information
lealem47 committed Jan 4, 2024
2 parents d2bd509 + 0f4b84c commit c6c93ce
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 3 deletions.
44 changes: 44 additions & 0 deletions .github/workflows/cmake-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: wolfMQTT CMake Build Tests

on:
push:
branches: [ 'master', 'main', 'release/**' ]
pull_request:
branches: [ '*' ]

jobs:
build:

runs-on: ubuntu-latest

steps:
# Install cmake
- name: Install cmake
run: |
sudo apt-get update
sudo apt-get install -y cmake
#pull and build wolfssl
- uses: actions/checkout@master
with:
repository: wolfssl/wolfssl
path: wolfssl
- name: Build wolfssl
working-directory: ./wolfssl
run: |
mkdir build
cd build
cmake ..
cmake --build .
sudo cmake --install .
#pull wolfMQTT
- uses: actions/checkout@master

#build wolfMQTT
- name: Build wolfMQTT
run: |
mkdir build
cd build
cmake ..
cmake --build .
9 changes: 6 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)

include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/functions.cmake)

find_package(Threads)

set(MQTT_SOURCES
src/mqtt_client.c
src/mqtt_packet.c
Expand Down Expand Up @@ -147,6 +145,7 @@ add_option(WOLFMQTT_MT
"no" "yes;no")
if (WOLFMQTT_MT)
list(APPEND WOLFMQTT_DEFINITIONS "-DWOLFMQTT_MULTITHREAD")
find_package(Threads REQUIRED)
endif()

add_option(WOLFMQTT_CURL
Expand Down Expand Up @@ -227,7 +226,11 @@ if (WOLFMQTT_EXAMPLES)
examples/mqttexample.c
examples/mqttnet.c
)
target_link_libraries(mqtt_test_lib wolfmqtt)
if (WOLFMQTT_MT)
target_link_libraries(mqtt_test_lib wolfmqtt pthread)
else()
target_link_libraries(mqtt_test_lib wolfmqtt)
endif()

function(add_mqtt_example name src)
add_executable(${name}
Expand Down

0 comments on commit c6c93ce

Please sign in to comment.