Skip to content

Commit

Permalink
WIP: adapt cmake to find mosquitto on windows
Browse files Browse the repository at this point in the history
  • Loading branch information
marcothaller committed Nov 8, 2024
1 parent b6a44d2 commit 59270cd
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 13 deletions.
18 changes: 9 additions & 9 deletions cmake/dependencies.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,17 @@
# remove this as soon as we support build of libmosquitto on all OSes
# and we are always able to build mqtt integration in case
# BUILD_INTEGRATION_MQTT is set to ON.
find_package(PkgConfig)
# find_package(PkgConfig)

if (UNIX AND PKG_CONFIG_FOUND)
pkg_check_modules(Mosquitto IMPORTED_TARGET libmosquitto REQUIRED)
endif()
# if (UNIX AND PKG_CONFIG_FOUND)
# pkg_check_modules(Mosquitto IMPORTED_TARGET libmosquitto REQUIRED)
# endif()

if (Mosquitto_FOUND AND BUILD_INTEGRATION_MQTT)
set(BUILD_INTEGRATION_MQTT ON)
else ()
set(BUILD_INTEGRATION_MQTT OFF)
endif()
# if (Mosquitto_FOUND AND BUILD_INTEGRATION_MQTT)
# set(BUILD_INTEGRATION_MQTT ON)
# else ()
# set(BUILD_INTEGRATION_MQTT OFF)
# endif()
###########################################################################

include(FetchContent)
Expand Down
45 changes: 41 additions & 4 deletions cmake/dependencies/mosquitto.cmake
Original file line number Diff line number Diff line change
@@ -1,9 +1,46 @@
#include(ExternalProject)

#find_package(PkgConfig)
#if(UNIX AND PKG_CONFIG_FOUND)
#pkg_check_modules(Mosquitto IMPORTED_TARGET libmosquittopp REQUIRED)
#endif()
find_package(PkgConfig)
if(UNIX AND PKG_CONFIG_FOUND)
pkg_check_modules(Mosquitto IMPORTED_TARGET libmosquittopp REQUIRED)
elseif(WIN32)
# Look for libmosquitto library
find_library(MOSQUITTO_LIB mosquitto HINTS "C:/Program Files/mosquitto/devel")

# Look for mosquitto header files
find_path(MOSQUITTO_INCLUDE mosquitto.h HINTS "C:/Program Files/mosquitto/devel")

if (MOSQUITTO_LIB AND MOSQUITTO_INCLUDE)
message(STATUS "libmosquitto found on Windows!")
# include_directories(${MOSQUITTO_INCLUDE})
# target_link_libraries(app ${MOSQUITTO_LIB})
else()
message(FATAL_ERROR "libmosquitto not found on Windows!")
endif()
endif()

if (WIN32)
add_custom_command(TARGET app POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different
"C:/Program Files/mosquitto/mosquitto.dll"
$<TARGET_FILE_DIR:app>)
add_custom_command(TARGET app POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different
"C:/Program Files/mosquitto/mosquittopp.dll"
$<TARGET_FILE_DIR:app>)
add_custom_command(TARGET app POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different
"C:/Program Files/mosquitto/libcrypto-3-x64.dll"
$<TARGET_FILE_DIR:app>)
add_custom_command(TARGET app POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different
"C:/Program Files/mosquitto/libssl-3-x64.dll"
$<TARGET_FILE_DIR:app>)
add_custom_command(TARGET app POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different
"C:/Program Files/mosquitto/pthreadVC3.dll"
$<TARGET_FILE_DIR:app>)
endif()

file (DOWNLOAD
https://test.mosquitto.org/ssl/mosquitto.org.crt
Expand Down

0 comments on commit 59270cd

Please sign in to comment.