diff --git a/.github/workflows/cmake-build.yml b/.github/workflows/cmake-build.yml new file mode 100644 index 00000000..40486d84 --- /dev/null +++ b/.github/workflows/cmake-build.yml @@ -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 . diff --git a/CMakeLists.txt b/CMakeLists.txt index 482f71cc..27658aea 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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 @@ -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 @@ -224,7 +223,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}