Skip to content

[mosquitto] Overhaul #46849

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

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
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
12 changes: 0 additions & 12 deletions ports/mosquitto/0003-add-find_package-libwebsockets.patch

This file was deleted.

42 changes: 0 additions & 42 deletions ports/mosquitto/0004-support-static-build.patch

This file was deleted.

13 changes: 0 additions & 13 deletions ports/mosquitto/0005-websocket-shared-lib-name.patch

This file was deleted.

147 changes: 147 additions & 0 deletions ports/mosquitto/linkage-and-export.diff
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 9e1c58d..6fa9392 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -71,7 +71,7 @@ option(WITH_PIC "Build the static library with PIC (Position Independent Code) e
option(WITH_THREADING "Include client library threading support?" ON)
if (WITH_THREADING)
add_definitions("-DWITH_THREADING")
- if(WIN32)
+ if(WIN32 AND NOT MINGW)
find_package(Pthreads4W REQUIRED)
endif()
endif (WITH_THREADING)
diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt
index 21b6149..051dffe 100644
--- a/lib/CMakeLists.txt
+++ b/lib/CMakeLists.txt
@@ -60,7 +60,7 @@ set(C_SRC
util_mosq.c util_topic.c util_mosq.h
will_mosq.c will_mosq.h)

-set (LIBRARIES OpenSSL::SSL)
+set (LIBRARIES PRIVATE OpenSSL::SSL)

if (UNIX AND NOT APPLE AND NOT ANDROID)
find_library(LIBRT rt)
@@ -90,7 +90,7 @@ set_target_properties(libmosquitto PROPERTIES
)

if (WITH_THREADING)
- if(WIN32)
+ if(WIN32 AND NOT MINGW)
set (LIBRARIES ${LIBRARIES} PThreads4W::PThreads4W)
else()
set(THREADS_PREFER_PTHREAD_FLAG ON)
@@ -115,11 +115,6 @@ if(UNIX AND NOT APPLE)
)
endif()

-install(TARGETS libmosquitto
- RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
- ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
- LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}")
-
if (WITH_STATIC_LIBRARIES)
add_library(libmosquitto_static STATIC ${C_SRC})
if (WITH_PIC)
@@ -136,8 +131,28 @@ if (WITH_STATIC_LIBRARIES)
)

target_compile_definitions(libmosquitto_static PUBLIC "LIBMOSQUITTO_STATIC")
- install(TARGETS libmosquitto_static ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}")
+
+ set(install_target libmosquitto_static)
+ set_target_properties(libmosquitto PROPERTIES EXCLUDE_FROM_ALL 1)
+else ()
+ set(install_target libmosquitto)
endif (WITH_STATIC_LIBRARIES)

+target_include_directories(${install_target} PUBLIC $<INSTALL_INTERFACE:include>)
+set_target_properties(${install_target} PROPERTIES EXPORT_NAME mosquitto)
+install(TARGETS ${install_target}
+ EXPORT mosquitto
+ RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
+ ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
+ LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
+)
+install(EXPORT mosquitto
+ NAMESPACE unofficial::mosquitto::
+ FILE unofficial-mosquitto-targets.cmake
+ DESTINATION "share/unofficial-mosquitto"
+)
+configure_file("${CMAKE_CURRENT_SOURCE_DIR}/unofficial-mosquitto-config.cmake" "${CMAKE_CURRENT_BINARY_DIR}/unofficial-mosquitto-config.cmake" @ONLY)
+install(FILES "${CMAKE_CURRENT_BINARY_DIR}/unofficial-mosquitto-config.cmake" DESTINATION "share/unofficial-mosquitto")
+
install(FILES ../include/mosquitto.h DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}")
install(FILES ../include/mqtt_protocol.h DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}")
diff --git a/lib/cpp/CMakeLists.txt b/lib/cpp/CMakeLists.txt
index 882b662..5959a96 100644
--- a/lib/cpp/CMakeLists.txt
+++ b/lib/cpp/CMakeLists.txt
@@ -9,15 +9,11 @@ add_library(mosquittopp SHARED ${CPP_SRC})
set_target_properties(mosquittopp PROPERTIES
POSITION_INDEPENDENT_CODE 1
)
-target_link_libraries(mosquittopp libmosquitto)
+target_link_libraries(mosquittopp PUBLIC libmosquitto)
set_target_properties(mosquittopp PROPERTIES
VERSION ${VERSION}
SOVERSION 1
)
-install(TARGETS mosquittopp
- RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
- ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
- LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}")

if (WITH_STATIC_LIBRARIES)
add_library(mosquittopp_static STATIC
@@ -30,7 +26,7 @@ if (WITH_STATIC_LIBRARIES)
)
endif (WITH_PIC)

- target_link_libraries(mosquittopp_static ${LIBRARIES})
+ target_link_libraries(mosquittopp_static PUBLIC libmosquitto_static)

set_target_properties(mosquittopp_static PROPERTIES
OUTPUT_NAME mosquittopp_static
@@ -38,7 +34,19 @@ if (WITH_STATIC_LIBRARIES)
)

target_compile_definitions(mosquittopp_static PUBLIC "LIBMOSQUITTO_STATIC")
- install(TARGETS mosquittopp_static ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}")
+
+ set(install_target mosquittopp_static)
+ set_target_properties(mosquittopp PROPERTIES EXCLUDE_FROM_ALL 1)
+else ()
+ set(install_target mosquittopp)
endif (WITH_STATIC_LIBRARIES)

+set_target_properties(${install_target} PROPERTIES EXPORT_NAME mosquittopp)
+install(TARGETS ${install_target}
+ EXPORT mosquitto
+ RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
+ ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
+ LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
+)
+
install(FILES mosquittopp.h DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}")
diff --git a/libmosquitto.pc.in b/libmosquitto.pc.in
index 101a125..0747b43 100644
--- a/libmosquitto.pc.in
+++ b/libmosquitto.pc.in
@@ -8,3 +8,5 @@ Description: mosquitto MQTT library (C bindings)
Version: @VERSION@
Cflags: -I${includedir}
Libs: -L${libdir} -lmosquitto
+Libs.private: @CMAKE_THREAD_LIBS_INIT@
+Requires.private: libssl
diff --git a/libmosquittopp.pc.in b/libmosquittopp.pc.in
index 6070f44..4edde61 100644
--- a/libmosquittopp.pc.in
+++ b/libmosquittopp.pc.in
@@ -8,3 +8,4 @@ Description: mosquitto MQTT library (C++ bindings)
Version: @VERSION@
Cflags: -I${includedir}
Libs: -L${libdir} -lmosquittopp
+Requires.private: libmosquitto
12 changes: 12 additions & 0 deletions ports/mosquitto/mosquitto-config.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
message(AUTHOR_WARNING "find_package(${PACKAGE_NAME}) is deprecated.\n${usage}")

include(CMakeFindDependencyMacro)
find_dependency(unofficial-mosquitto CONFIG)

# legacy, ported from wrapper
find_path(MOSQUITTO_INCLUDE_DIR mosquitto.h)
set(MOSQUITTO_INCLUDE_DIRS ${MOSQUITTO_INCLUDE_DIR})

# legacy, both vars included the C++ target
set(MOSQUITTO_LIBRARIES unofficial::mosquitto::mosquittopp)
set(MOSQUITTOPP_LIBRARIES unofficial::mosquitto::mosquittopp)
45 changes: 6 additions & 39 deletions ports/mosquitto/portfile.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ vcpkg_from_github(
REF "v${VERSION}"
SHA512 ca8bdcb10fea751e655e2de393479b2f863287b396b13e441de46c32918229c1f80a386fdd6d0daf3b0161f640702b6d8a87f2278c9baf2150e2c533cb59e57a
PATCHES
0003-add-find_package-libwebsockets.patch
0004-support-static-build.patch
0005-websocket-shared-lib-name.patch
linkage-and-export.diff
)
file(REMOVE_RECURSE "${SOURCE_PATH}/deps")
file(COPY "${CURRENT_PORT_DIR}/unofficial-mosquitto-config.cmake" DESTINATION "${SOURCE_PATH}/lib")

string(COMPARE EQUAL "${VCPKG_LIBRARY_LINKAGE}" "static" STATIC_LINKAGE)

Expand All @@ -17,8 +17,6 @@ vcpkg_cmake_configure(
OPTIONS
-DWITH_STATIC_LIBRARIES=${STATIC_LINKAGE}
-DWITH_SRV=OFF
-DWITH_WEBSOCKETS=ON
-DSTATIC_WEBSOCKETS=${STATIC_LINKAGE}
-DWITH_TLS=ON
-DWITH_TLS_PSK=ON
-DWITH_THREADING=ON
Expand All @@ -29,47 +27,16 @@ vcpkg_cmake_configure(
-DWITH_APPS=OFF
-DWITH_BROKER=OFF
-DWITH_BUNDLED_DEPS=OFF
MAYBE_UNUSED_VARIABLES
WITH_WEBSOCKETS
STATIC_WEBSOCKETS
)

vcpkg_cmake_install()
vcpkg_copy_pdbs()

vcpkg_fixup_pkgconfig()
vcpkg_cmake_config_fixup(PACKAGE_NAME unofficial-mosquitto)

file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include")
file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/share")

if(VCPKG_LIBRARY_LINKAGE STREQUAL "static")
file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/bin" "${CURRENT_PACKAGES_DIR}/debug/bin")

file(REMOVE "${CURRENT_PACKAGES_DIR}/lib/${VCPKG_TARGET_SHARED_LIBRARY_PREFIX}mosquitto${VCPKG_TARGET_SHARED_LIBRARY_SUFFIX}")
file(REMOVE "${CURRENT_PACKAGES_DIR}/lib/${VCPKG_TARGET_SHARED_LIBRARY_PREFIX}mosquittopp${VCPKG_TARGET_SHARED_LIBRARY_SUFFIX}")
file(REMOVE "${CURRENT_PACKAGES_DIR}/debug/lib/${VCPKG_TARGET_SHARED_LIBRARY_PREFIX}mosquitto${VCPKG_TARGET_SHARED_LIBRARY_SUFFIX}")
file(REMOVE "${CURRENT_PACKAGES_DIR}/debug/lib/${VCPKG_TARGET_SHARED_LIBRARY_PREFIX}mosquittopp${VCPKG_TARGET_SHARED_LIBRARY_SUFFIX}")

file(GLOB VERSIONED_LIBRARIES LIST_DIRECTORIES FALSE
"${CURRENT_PACKAGES_DIR}/lib/${VCPKG_TARGET_SHARED_LIBRARY_PREFIX}mosquitto${VCPKG_TARGET_SHARED_LIBRARY_SUFFIX}.*"
"${CURRENT_PACKAGES_DIR}/lib/${VCPKG_TARGET_SHARED_LIBRARY_PREFIX}mosquittopp${VCPKG_TARGET_SHARED_LIBRARY_SUFFIX}.*"
"${CURRENT_PACKAGES_DIR}/debug/lib/${VCPKG_TARGET_SHARED_LIBRARY_PREFIX}mosquitto${VCPKG_TARGET_SHARED_LIBRARY_SUFFIX}.*"
"${CURRENT_PACKAGES_DIR}/debug/lib/${VCPKG_TARGET_SHARED_LIBRARY_PREFIX}mosquittopp${VCPKG_TARGET_SHARED_LIBRARY_SUFFIX}.*"
)

if(NOT "x${VERSIONED_LIBRARIES}x" STREQUAL "xx")
file(REMOVE ${VERSIONED_LIBRARIES})
endif()

if(NOT "x${VCPKG_TARGET_IMPORT_LIBRARY_PREFIX}${VCPKG_TARGET_IMPORT_LIBRARY_SUFFIX}x" STREQUAL "xx")
file(REMOVE "${CURRENT_PACKAGES_DIR}/lib/${VCPKG_TARGET_IMPORT_LIBRARY_PREFIX}mosquitto${VCPKG_TARGET_IMPORT_LIBRARY_SUFFIX}")
file(REMOVE "${CURRENT_PACKAGES_DIR}/lib/${VCPKG_TARGET_IMPORT_LIBRARY_PREFIX}mosquittopp${VCPKG_TARGET_IMPORT_LIBRARY_SUFFIX}")
file(REMOVE "${CURRENT_PACKAGES_DIR}/debug/lib/${VCPKG_TARGET_IMPORT_LIBRARY_PREFIX}mosquitto${VCPKG_TARGET_IMPORT_LIBRARY_SUFFIX}")
file(REMOVE "${CURRENT_PACKAGES_DIR}/debug/lib/${VCPKG_TARGET_IMPORT_LIBRARY_PREFIX}mosquittopp${VCPKG_TARGET_IMPORT_LIBRARY_SUFFIX}")
endif()
endif()

configure_file(${CMAKE_CURRENT_LIST_DIR}/vcpkg-cmake-wrapper.cmake ${CURRENT_PACKAGES_DIR}/share/${PORT}/vcpkg-cmake-wrapper.cmake @ONLY)

file(INSTALL "${CMAKE_CURRENT_LIST_DIR}/mosquitto-config.cmake" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}")
file(INSTALL "${CMAKE_CURRENT_LIST_DIR}/usage" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}")

vcpkg_install_copyright(FILE_LIST "${SOURCE_PATH}/LICENSE.txt")
10 changes: 10 additions & 0 deletions ports/mosquitto/unofficial-mosquitto-config.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
if("@WITH_STATIC_LIBRARIES@")
include(CMakeFindDependencyMacro)
find_dependency(OpenSSL)
if(WIN32 AND NOT MINGW)
find_dependency(Pthreads4W)
else()
find_dependency(Threads)
endif()
endif()
include("${CMAKE_CURRENT_LIST_DIR}/unofficial-mosquitto-targets.cmake")
18 changes: 14 additions & 4 deletions ports/mosquitto/usage
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
The package mosquitto provides CMake targets:
mosquitto provides CMake targets:

find_package(mosquitto REQUIRED)
target_include_directories(main PRIVATE ${MOSQUITTO_INCLUDE_DIRS})
target_link_libraries(main PRIVATE ${MOSQUITTO_LIBRARIES})
find_package(unofficial-mosquitto CONFIG REQUIRED)
# C bindings
target_link_libraries(main PRIVATE unofficial::mosquitto::mosquitto)
# C++ bindings
target_link_libraries(main PRIVATE unofficial::mosquitto::mosquittopp)

mosquitto provides pkg-config modules:

# mosquitto MQTT library (C bindings)
libmosquitto

# mosquitto MQTT library (C++ bindings)
libmosquittopp
15 changes: 0 additions & 15 deletions ports/mosquitto/vcpkg-cmake-wrapper.cmake

This file was deleted.

9 changes: 6 additions & 3 deletions ports/mosquitto/vcpkg.json
Original file line number Diff line number Diff line change
@@ -1,19 +1,22 @@
{
"name": "mosquitto",
"version": "2.0.22",
"port-version": 1,
"description": "Mosquitto is an open source message broker that implements the MQ Telemetry Transport protocol versions 3.1 and 3.1.1, MQTT provides a lightweight method of carrying out messaging using a publish/subscribe model, This makes it suitable for machine to machine messaging such as with low power sensors or mobile devices such as phones, embedded computers or microcontrollers like the Arduino",
"homepage": "https://mosquitto.org/",
"license": "EPL-2.0",
"supports": "!android",
"supports": "!uwp",
"dependencies": [
"c-ares",
"libwebsockets",
"openssl",
"pthreads",
"uthash",
{
"name": "vcpkg-cmake",
"host": true
},
{
"name": "vcpkg-cmake-config",
"host": true
}
]
}
2 changes: 0 additions & 2 deletions scripts/ci.feature.baseline.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1436,8 +1436,6 @@ moos-essential:x64-windows-static = cascade
moos-ui:arm64-uwp = cascade
moos-ui:x64-uwp = cascade
moos-ui:x64-windows-static = cascade
mosquitto:arm64-uwp = cascade
mosquitto:x64-uwp = cascade
mpi:arm64-windows = cascade
mpi:x86-windows = cascade
msix:arm64-uwp = cascade
Expand Down
2 changes: 1 addition & 1 deletion versions/baseline.json
Original file line number Diff line number Diff line change
Expand Up @@ -6374,7 +6374,7 @@
},
"mosquitto": {
"baseline": "2.0.22",
"port-version": 0
"port-version": 1
},
"mozjpeg": {
"baseline": "4.1.5",
Expand Down
Loading