aboutsummaryrefslogtreecommitdiff
path: root/vcpkg/ports/mosquitto
diff options
context:
space:
mode:
Diffstat (limited to 'vcpkg/ports/mosquitto')
-rw-r--r--vcpkg/ports/mosquitto/linkage-and-export.diff147
-rw-r--r--vcpkg/ports/mosquitto/mosquitto-config.cmake12
-rw-r--r--vcpkg/ports/mosquitto/portfile.cmake42
-rw-r--r--vcpkg/ports/mosquitto/unofficial-mosquitto-config.cmake10
-rw-r--r--vcpkg/ports/mosquitto/usage15
-rw-r--r--vcpkg/ports/mosquitto/vcpkg.json22
6 files changed, 248 insertions, 0 deletions
diff --git a/vcpkg/ports/mosquitto/linkage-and-export.diff b/vcpkg/ports/mosquitto/linkage-and-export.diff
new file mode 100644
index 0000000..a4ae479
--- /dev/null
+++ b/vcpkg/ports/mosquitto/linkage-and-export.diff
@@ -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
diff --git a/vcpkg/ports/mosquitto/mosquitto-config.cmake b/vcpkg/ports/mosquitto/mosquitto-config.cmake
new file mode 100644
index 0000000..e0f0027
--- /dev/null
+++ b/vcpkg/ports/mosquitto/mosquitto-config.cmake
@@ -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)
diff --git a/vcpkg/ports/mosquitto/portfile.cmake b/vcpkg/ports/mosquitto/portfile.cmake
new file mode 100644
index 0000000..59c778c
--- /dev/null
+++ b/vcpkg/ports/mosquitto/portfile.cmake
@@ -0,0 +1,42 @@
+vcpkg_from_github(
+ OUT_SOURCE_PATH SOURCE_PATH
+ REPO eclipse/mosquitto
+ HEAD_REF master
+ REF "v${VERSION}"
+ SHA512 ca8bdcb10fea751e655e2de393479b2f863287b396b13e441de46c32918229c1f80a386fdd6d0daf3b0161f640702b6d8a87f2278c9baf2150e2c533cb59e57a
+ PATCHES
+ 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)
+
+vcpkg_cmake_configure(
+ SOURCE_PATH "${SOURCE_PATH}"
+ OPTIONS
+ -DWITH_STATIC_LIBRARIES=${STATIC_LINKAGE}
+ -DWITH_SRV=OFF
+ -DWITH_TLS=ON
+ -DWITH_TLS_PSK=ON
+ -DWITH_THREADING=ON
+ -DDOCUMENTATION=OFF
+ -DWITH_PLUGINS=OFF
+ -DWITH_CJSON=OFF
+ -DWITH_CLIENTS=OFF
+ -DWITH_APPS=OFF
+ -DWITH_BROKER=OFF
+ -DWITH_BUNDLED_DEPS=OFF
+)
+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")
+
+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")
diff --git a/vcpkg/ports/mosquitto/unofficial-mosquitto-config.cmake b/vcpkg/ports/mosquitto/unofficial-mosquitto-config.cmake
new file mode 100644
index 0000000..57c6cb2
--- /dev/null
+++ b/vcpkg/ports/mosquitto/unofficial-mosquitto-config.cmake
@@ -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")
diff --git a/vcpkg/ports/mosquitto/usage b/vcpkg/ports/mosquitto/usage
new file mode 100644
index 0000000..0c64e1d
--- /dev/null
+++ b/vcpkg/ports/mosquitto/usage
@@ -0,0 +1,15 @@
+mosquitto provides CMake targets:
+
+ 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
diff --git a/vcpkg/ports/mosquitto/vcpkg.json b/vcpkg/ports/mosquitto/vcpkg.json
new file mode 100644
index 0000000..b1c24eb
--- /dev/null
+++ b/vcpkg/ports/mosquitto/vcpkg.json
@@ -0,0 +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": "!uwp",
+ "dependencies": [
+ "openssl",
+ "pthreads",
+ "uthash",
+ {
+ "name": "vcpkg-cmake",
+ "host": true
+ },
+ {
+ "name": "vcpkg-cmake-config",
+ "host": true
+ }
+ ]
+}