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

Add cmake CI test and fix pthread detection #389

Merged
merged 1 commit into from
Jan 4, 2024
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
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
Loading