Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
1e04c3c
updating CMakeLists.txt files according to new module layout
viacheslauK Feb 25, 2026
448cd8d
changes to prevent warnings
viacheslauK Feb 26, 2026
648bfab
boost as a dependency
viacheslauK Feb 26, 2026
5a5a54c
changes to build with preinstalled openDAQ
viacheslauK Feb 26, 2026
f196492
ref-dev-mqtt-pub building only if daq::ref_device_module target is pr…
viacheslauK Feb 26, 2026
9c65fd7
preventing rapidjson target re-declaration
viacheslauK Feb 26, 2026
8a6507f
custom rapidjson lib aligned with openDAQ rapidjson lib
viacheslauK Feb 26, 2026
bb0179b
gtest as an external dependency
viacheslauK Feb 26, 2026
c3eeb07
CMake calls updating
viacheslauK Feb 26, 2026
12a11e3
opendaq_ref updating
viacheslauK Mar 3, 2026
70698dd
OPENDAQ_ALWAYS_FETCH_PAHO_MQTT_C
viacheslauK Mar 3, 2026
bd15f93
module_version updating
viacheslauK Mar 3, 2026
bcb8377
updated ci
viacheslauK Mar 3, 2026
51c61ce
unused variables
viacheslauK Mar 4, 2026
ce16a79
remove compile definition
viacheslauK Mar 4, 2026
d8483cb
cast fix
viacheslauK Mar 4, 2026
81b2f49
Param tests reworking (SignalHelper is moved inside tests)
viacheslauK Mar 5, 2026
bf41a55
uninitialized field
viacheslauK Mar 5, 2026
100e65c
std::async for SignalHelper::send in tests
viacheslauK Mar 5, 2026
c1fdfe2
uninitialized bool
viacheslauK Mar 6, 2026
5efcb2e
disable msvc warnings for paho lib
viacheslauK Mar 6, 2026
102413c
Update .github/workflows/ci.yml
viacheslauK Mar 9, 2026
63c0ffc
unused variables
viacheslauK Mar 9, 2026
3a2da60
Fix false positive memleak detection and extend CI (#12)
NikolaiShipilov Mar 9, 2026
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
106 changes: 103 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
name: Build and Test

on:
workflow_dispatch:
inputs:
opendaq_ref:
description: "openDAQ SDK commit, branch or tag"
required: false
default: ""
pull_request:
types: [opened, reopened, synchronize, ready_for_review]

Expand All @@ -12,8 +18,16 @@ jobs:
include:
- os: ubuntu-latest
generator: Ninja
build_type: Debug
- os: windows-latest
generator: "Visual Studio 17 2022"
build_type: Debug
- os: ubuntu-latest
generator: Ninja
build_type: Release
- os: windows-latest
generator: "Visual Studio 17 2022"
build_type: Release

runs-on: ${{ matrix.os }}

Expand All @@ -28,11 +42,15 @@ jobs:
with:
ref: ${{ github.event.inputs.branch || github.event.client_payload.branch || github.ref }}

- name: Overwrite opendaq_ref
if: ${{ github.event.inputs.opendaq_ref != '' }}
run: echo "${{ github.event.inputs.opendaq_ref }}" > opendaq_ref

- name: Configure project with CMake
run: cmake -B build/output -S . -G "${{ matrix.generator }}" -DOPENDAQ_MQTT_ENABLE_TESTS=ON -DCMAKE_BUILD_TYPE=Debug
run: cmake -B build/output -S . -G "${{ matrix.generator }}" -DDAQMODULES_MQTT_ENABLE_TESTS=ON -DDAQMODULES_MQTT_DEBUG_WARNINGS_AS_ERRORS=ON -DOPENDAQ_DEBUG_WARNINGS_AS_ERRORS=ON -DCMAKE_BUILD_TYPE="${{ matrix.build_type }}"

- name: Build project with CMake
run: cmake --build build/output --config Debug
run: cmake --build build/output --config "${{ matrix.build_type }}"

- name: Install and run mosquitto Linux
if: matrix.os == 'ubuntu-latest'
Expand All @@ -41,4 +59,86 @@ jobs:

- name: Run project tests with CMake
if: matrix.os == 'ubuntu-latest'
run: ctest --test-dir build/output --output-on-failure -C Debug
run: ctest --test-dir build/output --output-on-failure -C "${{ matrix.build_type }}"

install-build-and-test:
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
generator: Ninja
build_type: Debug
- os: windows-latest
generator: "Visual Studio 17 2022"
build_type: Debug
- os: ubuntu-latest
generator: Ninja
build_type: Release
- os: windows-latest
generator: "Visual Studio 17 2022"
build_type: Release

runs-on: ${{ matrix.os }}
env:
INSTALL_PREFIX: ${{ github.workspace }}/opendaq_install

steps:
- name: Install additional dependencies
if: matrix.os == 'ubuntu-latest'
run: |
sudo apt-get install -y --no-install-recommends mono-runtime libmono-system-json-microsoft4.0-cil libmono-system-data4.0-cil

- name: Checkout module
uses: actions/checkout@v4
with:
ref: ${{ github.event.inputs.branch || github.event.client_payload.branch || github.ref }}
path: module

- name: Overwrite opendaq_ref
if: ${{ github.event.inputs.opendaq_ref != '' }}
working-directory: module
run: echo "${{ github.event.inputs.opendaq_ref }}" > opendaq_ref

- name: Read openDAQ version
shell: bash
working-directory: module
run: |
opendaq_ref=$(cat opendaq_ref)
echo "OPENDAQ_REF=$opendaq_ref" >> $GITHUB_ENV

- name: Checkout openDAQ
uses: actions/checkout@v4
with:
repository: openDAQ/openDAQ
ref: ${{ env.OPENDAQ_REF }}
path: opendaq

- name: Configure, build and install openDAQ
working-directory: opendaq
run: |
cmake -B build/output -S . -G "${{ matrix.generator }}" -DOPENDAQ_ENABLE_TESTS=OFF -DCMAKE_BUILD_TYPE="${{ matrix.build_type }}" -DCMAKE_INSTALL_PREFIX="${{ env.INSTALL_PREFIX }}"
cmake --build build/output --config "${{ matrix.build_type }}"
cmake --install build/output --config "${{ matrix.build_type }}"

- name: Add DLL path (Windows only)
if: matrix.os == 'windows-latest'
run: echo "${{ env.INSTALL_PREFIX }}/lib" >> $env:GITHUB_PATH

- name: Configure project with CMake
working-directory: module
run: cmake -B build/output -S . -G "${{ matrix.generator }}" -DDAQMODULES_MQTT_ENABLE_TESTS=ON -DDAQMODULES_MQTT_DEBUG_WARNINGS_AS_ERRORS=ON -DCMAKE_BUILD_TYPE="${{ matrix.build_type }}" -DopenDAQ_DIR="${{ env.INSTALL_PREFIX }}/lib/cmake/opendaq/"

- name: Build project with CMake
working-directory: module
run: cmake --build build/output --config "${{ matrix.build_type }}"

- name: Install and run mosquitto Linux
if: matrix.os == 'ubuntu-latest'
run: |
sudo apt-get install -y --no-install-recommends mosquitto

- name: Run project tests with CMake
if: matrix.os == 'ubuntu-latest'
working-directory: module
run: ctest --test-dir build/output --output-on-failure -C "${{ matrix.build_type }}"
106 changes: 62 additions & 44 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,77 +1,95 @@
# CMakeList.txt : CMake project for MQTTStreamingModule, include source and define
# project specific logic here.
#
set(CMAKE_POLICY_VERSION_MINIMUM 3.5)
set(CMAKE_POLICY_VERSION_MINIMUM 3.5)
cmake_minimum_required(VERSION 3.25)

set(SDK_TARGET_NAMESPACE daq)
set(REPO_NAME mqtt_module)
set(REPO_OPTION_PREFIX MQTT_MODULE)
set(REPO_NAME MqttModule)
set(REPO_OPTION_PREFIX DAQMODULES_MQTT)
set(CMAKE_FOLDER "${CMAKE_FOLDER}/${REPO_NAME}")

project (${REPO_NAME} CXX)
list(APPEND CMAKE_MESSAGE_CONTEXT ${REPO_NAME})
add_subdirectory(cmake)

# Enable Hot Reload for MSVC compilers if supported.
if (POLICY CMP0141)
cmake_policy(SET CMP0141 NEW)
set(CMAKE_MSVC_DEBUG_INFORMATION_FORMAT "$<IF:$<AND:$<C_COMPILER_ID:MSVC>,$<CXX_COMPILER_ID:MSVC>>,$<$<CONFIG:Debug,RelWithDebInfo>:EditAndContinue>,$<$<CONFIG:Debug,RelWithDebInfo>:ProgramDatabase>>")
endif()
opendaq_read_file_contents("${CMAKE_CURRENT_LIST_DIR}/module_version" module_version)
opendaq_get_version_major_minor_patch("${module_version}" ${REPO_OPTION_PREFIX}_VERSION)

if (POLICY CMP0135)
cmake_policy(SET CMP0135 NEW)
# the following section is required if module-project being built standalone with 32bit arch, it is "temporary" workaround, though - the correct one would be using `-DCMAKE_TOOLCHAIN_FILE`
# 32-bit Linux cross-compilation setup (must be before any project())
if (NOT DEFINED PROJECT_SOURCE_DIR AND OPENDAQ_FORCE_COMPILE_32BIT AND CMAKE_HOST_SYSTEM_NAME STREQUAL "Linux")
opendaq_32bit_build_linux_early_setup()
endif()

if (POLICY CMP0077)
cmake_policy(SET CMP0077 NEW)
endif()
project(${REPO_NAME} VERSION ${${REPO_OPTION_PREFIX}_VERSION} LANGUAGES CXX)

set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
list(APPEND CMAKE_MESSAGE_CONTEXT ${REPO_NAME})
set(CMAKE_MESSAGE_CONTEXT_SHOW ON CACHE BOOL "Show CMake message context")
opendaq_common_early_setup()

list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
if (PROJECT_IS_TOP_LEVEL)
message(STATUS "Building ${REPO_NAME} version ${${REPO_OPTION_PREFIX}_VERSION} standalone")
else()
message(STATUS "Building ${REPO_NAME} version ${${REPO_OPTION_PREFIX}_VERSION} as submodule")
endif()

option(OPENDAQ_MQTT_MODULE_ENABLE_SSL "Enable building with openSSL" OFF)
option(OPENDAQ_DEVICE_EXAMPLE_ENABLE_EXAMPLE_APPS "Enable building example applications" OFF)
# options
opendaq_setup_common_build_options()
opendaq_setup_project_specific_build_options(${REPO_OPTION_PREFIX})
option(${REPO_OPTION_PREFIX}_ENABLE_EXAMPLE_APP "Enable ${REPO_NAME} example applications" ${PROJECT_IS_TOP_LEVEL})
option(${REPO_OPTION_PREFIX}_ENABLE_TESTS "Enable ${REPO_NAME} testing" ${PROJECT_IS_TOP_LEVEL})
option(${REPO_OPTION_PREFIX}_ENABLE_SSL "Enable building with openSSL" OFF)

if ((CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_CLANGXX) AND NOT MSVC)
if (NOT WIN32)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread")
endif()
add_compile_options(-Wno-deprecated-declarations)
endif()
opendaq_common_compile_targets_settings()
opendaq_setup_compiler_flags(${REPO_OPTION_PREFIX})

include(CommonUtils)
setup_repo(${REPO_OPTION_PREFIX})
if (${REPO_OPTION_PREFIX}_ENABLE_TESTS)
message(STATUS "Unit tests in ${REPO_NAME} are ENABLED")
enable_testing()
else()
message(STATUS "Unit tests in ${REPO_NAME} are DISABLED")
endif()

if(OPENDAQ_DEVICE_EXAMPLE_ENABLE_EXAMPLE_APPS)
if(${REPO_OPTION_PREFIX}_ENABLE_EXAMPLE_APP)
set(DAQMODULES_REF_DEVICE_MODULE ON CACHE BOOL "" FORCE)
endif()

option(OPENDAQ_MQTT_ENABLE_TESTS "Enable module testing" OFF)
option(OPENDAQ_MQTT_ENABLE_EXAMPLE_APPS "Enable example applications building" OFF)

if(OPENDAQ_MQTT_MODULE_ENABLE_SSL)
if(${REPO_OPTION_PREFIX}_ENABLE_SSL)
find_package(OpenSSL REQUIRED)
if (OPENSSL_FOUND)
message(STATUS "Found OpenSSL ${OPENSSL_VERSION}")
else()
message(FATAL_ERROR "OpenSSL Not Found")
endif()
add_compile_definitions(OPENDAQ_MQTT_MODULE_ENABLE_SSL)
add_compile_definitions(${REPO_OPTION_PREFIX}_ENABLE_SSL)
endif()

set(MQTT_MODULE_VERSION "0.1.0" CACHE STRING "MQTT module version" FORCE)

if(OPENDAQ_MQTT_ENABLE_TESTS)
enable_testing()
if (NOT TARGET "${OPENDAQ_SDK_TARGET_NAMESPACE}::${OPENDAQ_SDK_TARGET_NAME}")
if (PROJECT_IS_TOP_LEVEL)
find_package(${OPENDAQ_SDK_NAME} GLOBAL)
endif()
if (NOT ${OPENDAQ_SDK_NAME}_FOUND)
include(FetchContent)
set(OPENDAQ_ENABLE_TESTS OFF CACHE BOOL "")

opendaq_read_file_contents("${CMAKE_CURRENT_LIST_DIR}/opendaq_ref" OPENDAQ_REF)
opendaq_get_custom_fetch_content_params(${OPENDAQ_SDK_NAME} FC_PARAMS)

FetchContent_Declare(
${OPENDAQ_SDK_NAME}
GIT_REPOSITORY https://github.com/openDAQ/openDAQ.git
GIT_TAG ${OPENDAQ_REF}
GIT_PROGRESS ON
${FC_PARAMS}
)
FetchContent_MakeAvailable(${OPENDAQ_SDK_NAME})
else()
message(STATUS "Found installed ${OPENDAQ_SDK_NAME} version: ${${OPENDAQ_SDK_NAME}_VERSION}")
set(OPENDAQ_PACKAGE_VERSION "${${OPENDAQ_SDK_NAME}_VERSION}" CACHE INTERNAL "${OPENDAQ_SDK_NAME} SDK version")
endif()
endif()

add_subdirectory(external)
add_subdirectory(shared)
add_subdirectory(modules)

if(OPENDAQ_DEVICE_EXAMPLE_ENABLE_EXAMPLE_APPS)
message(STATUS "Example applications have been enabled")
if(${REPO_OPTION_PREFIX}_ENABLE_EXAMPLE_APP)
message(STATUS "Example applications in ${REPO_NAME} are ENABLED")
add_subdirectory(examples)
else()
message(STATUS "Example applications in ${REPO_NAME} are DISABLED")
endif()
5 changes: 2 additions & 3 deletions CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,8 @@
"name": "full",
"hidden": true,
"cacheVariables": {
"OPENDAQ_DEVICE_EXAMPLE_ENABLE_EXAMPLE_APPS": "true",
"OPENDAQ_MQTT_ENABLE_TESTS": "true",
"OPENDAQ_MQTT_ENABLE_EXAMPLE_APPS": "true"
"DAQMODULES_MQTT_ENABLE_EXAMPLE_APP": "true",
"DAQMODULES_MQTT_ENABLE_TESTS": "true"
}
},
{
Expand Down
14 changes: 14 additions & 0 deletions cmake/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
set(CMAKE_FOLDER "cmake")

list(APPEND CMAKE_MESSAGE_CONTEXT cmake)
set(CURR_MESSAGE_CONTEXT ${CMAKE_MESSAGE_CONTEXT})

message(STATUS "Import functions and macro from opendaq-cmake-utils repo")
include(FetchContent)
FetchContent_Declare(
opendaq-cmake-utils
GIT_REPOSITORY https://github.com/openDAQ/opendaq-cmake-utils.git
GIT_TAG v1.0.0
GIT_PROGRESS ON
)
FetchContent_MakeAvailable(opendaq-cmake-utils)
Loading