|
| 1 | +diff --git a/CMakeLists.txt b/CMakeLists.txt |
| 2 | +index 9e1c58d..6fa9392 100644 |
| 3 | +--- a/CMakeLists.txt |
| 4 | ++++ b/CMakeLists.txt |
| 5 | +@@ -71,7 +71,7 @@ option(WITH_PIC "Build the static library with PIC (Position Independent Code) e |
| 6 | + option(WITH_THREADING "Include client library threading support?" ON) |
| 7 | + if (WITH_THREADING) |
| 8 | + add_definitions("-DWITH_THREADING") |
| 9 | +- if(WIN32) |
| 10 | ++ if(WIN32 AND NOT MINGW) |
| 11 | + find_package(Pthreads4W REQUIRED) |
| 12 | + endif() |
| 13 | + endif (WITH_THREADING) |
| 14 | +diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt |
| 15 | +index 21b6149..051dffe 100644 |
| 16 | +--- a/lib/CMakeLists.txt |
| 17 | ++++ b/lib/CMakeLists.txt |
| 18 | +@@ -60,7 +60,7 @@ set(C_SRC |
| 19 | + util_mosq.c util_topic.c util_mosq.h |
| 20 | + will_mosq.c will_mosq.h) |
| 21 | + |
| 22 | +-set (LIBRARIES OpenSSL::SSL) |
| 23 | ++set (LIBRARIES PRIVATE OpenSSL::SSL) |
| 24 | + |
| 25 | + if (UNIX AND NOT APPLE AND NOT ANDROID) |
| 26 | + find_library(LIBRT rt) |
| 27 | +@@ -90,7 +90,7 @@ set_target_properties(libmosquitto PROPERTIES |
| 28 | + ) |
| 29 | + |
| 30 | + if (WITH_THREADING) |
| 31 | +- if(WIN32) |
| 32 | ++ if(WIN32 AND NOT MINGW) |
| 33 | + set (LIBRARIES ${LIBRARIES} PThreads4W::PThreads4W) |
| 34 | + else() |
| 35 | + set(THREADS_PREFER_PTHREAD_FLAG ON) |
| 36 | +@@ -115,11 +115,6 @@ if(UNIX AND NOT APPLE) |
| 37 | + ) |
| 38 | + endif() |
| 39 | + |
| 40 | +-install(TARGETS libmosquitto |
| 41 | +- RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" |
| 42 | +- ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}" |
| 43 | +- LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}") |
| 44 | +- |
| 45 | + if (WITH_STATIC_LIBRARIES) |
| 46 | + add_library(libmosquitto_static STATIC ${C_SRC}) |
| 47 | + if (WITH_PIC) |
| 48 | +@@ -136,8 +131,28 @@ if (WITH_STATIC_LIBRARIES) |
| 49 | + ) |
| 50 | + |
| 51 | + target_compile_definitions(libmosquitto_static PUBLIC "LIBMOSQUITTO_STATIC") |
| 52 | +- install(TARGETS libmosquitto_static ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}") |
| 53 | ++ |
| 54 | ++ set(install_target libmosquitto_static) |
| 55 | ++ set_target_properties(libmosquitto PROPERTIES EXCLUDE_FROM_ALL 1) |
| 56 | ++else () |
| 57 | ++ set(install_target libmosquitto) |
| 58 | + endif (WITH_STATIC_LIBRARIES) |
| 59 | + |
| 60 | ++target_include_directories(${install_target} PUBLIC $<INSTALL_INTERFACE:include>) |
| 61 | ++set_target_properties(${install_target} PROPERTIES EXPORT_NAME mosquitto) |
| 62 | ++install(TARGETS ${install_target} |
| 63 | ++ EXPORT mosquitto |
| 64 | ++ RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" |
| 65 | ++ ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}" |
| 66 | ++ LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}" |
| 67 | ++) |
| 68 | ++install(EXPORT mosquitto |
| 69 | ++ NAMESPACE unofficial::mosquitto:: |
| 70 | ++ FILE unofficial-mosquitto-targets.cmake |
| 71 | ++ DESTINATION "share/unofficial-mosquitto" |
| 72 | ++) |
| 73 | ++configure_file("${CMAKE_CURRENT_SOURCE_DIR}/unofficial-mosquitto-config.cmake" "${CMAKE_CURRENT_BINARY_DIR}/unofficial-mosquitto-config.cmake" @ONLY) |
| 74 | ++install(FILES "${CMAKE_CURRENT_BINARY_DIR}/unofficial-mosquitto-config.cmake" DESTINATION "share/unofficial-mosquitto") |
| 75 | ++ |
| 76 | + install(FILES ../include/mosquitto.h DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}") |
| 77 | + install(FILES ../include/mqtt_protocol.h DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}") |
| 78 | +diff --git a/lib/cpp/CMakeLists.txt b/lib/cpp/CMakeLists.txt |
| 79 | +index 882b662..5959a96 100644 |
| 80 | +--- a/lib/cpp/CMakeLists.txt |
| 81 | ++++ b/lib/cpp/CMakeLists.txt |
| 82 | +@@ -9,15 +9,11 @@ add_library(mosquittopp SHARED ${CPP_SRC}) |
| 83 | + set_target_properties(mosquittopp PROPERTIES |
| 84 | + POSITION_INDEPENDENT_CODE 1 |
| 85 | + ) |
| 86 | +-target_link_libraries(mosquittopp libmosquitto) |
| 87 | ++target_link_libraries(mosquittopp PUBLIC libmosquitto) |
| 88 | + set_target_properties(mosquittopp PROPERTIES |
| 89 | + VERSION ${VERSION} |
| 90 | + SOVERSION 1 |
| 91 | + ) |
| 92 | +-install(TARGETS mosquittopp |
| 93 | +- RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" |
| 94 | +- ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}" |
| 95 | +- LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}") |
| 96 | + |
| 97 | + if (WITH_STATIC_LIBRARIES) |
| 98 | + add_library(mosquittopp_static STATIC |
| 99 | +@@ -30,7 +26,7 @@ if (WITH_STATIC_LIBRARIES) |
| 100 | + ) |
| 101 | + endif (WITH_PIC) |
| 102 | + |
| 103 | +- target_link_libraries(mosquittopp_static ${LIBRARIES}) |
| 104 | ++ target_link_libraries(mosquittopp_static PUBLIC libmosquitto_static) |
| 105 | + |
| 106 | + set_target_properties(mosquittopp_static PROPERTIES |
| 107 | + OUTPUT_NAME mosquittopp_static |
| 108 | +@@ -38,7 +34,19 @@ if (WITH_STATIC_LIBRARIES) |
| 109 | + ) |
| 110 | + |
| 111 | + target_compile_definitions(mosquittopp_static PUBLIC "LIBMOSQUITTO_STATIC") |
| 112 | +- install(TARGETS mosquittopp_static ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}") |
| 113 | ++ |
| 114 | ++ set(install_target mosquittopp_static) |
| 115 | ++ set_target_properties(mosquittopp PROPERTIES EXCLUDE_FROM_ALL 1) |
| 116 | ++else () |
| 117 | ++ set(install_target mosquittopp) |
| 118 | + endif (WITH_STATIC_LIBRARIES) |
| 119 | + |
| 120 | ++set_target_properties(${install_target} PROPERTIES EXPORT_NAME mosquittopp) |
| 121 | ++install(TARGETS ${install_target} |
| 122 | ++ EXPORT mosquitto |
| 123 | ++ RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" |
| 124 | ++ ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}" |
| 125 | ++ LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}" |
| 126 | ++) |
| 127 | ++ |
| 128 | + install(FILES mosquittopp.h DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}") |
| 129 | +diff --git a/libmosquitto.pc.in b/libmosquitto.pc.in |
| 130 | +index 101a125..0747b43 100644 |
| 131 | +--- a/libmosquitto.pc.in |
| 132 | ++++ b/libmosquitto.pc.in |
| 133 | +@@ -8,3 +8,5 @@ Description: mosquitto MQTT library (C bindings) |
| 134 | + Version: @VERSION@ |
| 135 | + Cflags: -I${includedir} |
| 136 | + Libs: -L${libdir} -lmosquitto |
| 137 | ++Libs.private: @CMAKE_THREAD_LIBS_INIT@ |
| 138 | ++Requires.private: libssl |
| 139 | +diff --git a/libmosquittopp.pc.in b/libmosquittopp.pc.in |
| 140 | +index 6070f44..4edde61 100644 |
| 141 | +--- a/libmosquittopp.pc.in |
| 142 | ++++ b/libmosquittopp.pc.in |
| 143 | +@@ -8,3 +8,4 @@ Description: mosquitto MQTT library (C++ bindings) |
| 144 | + Version: @VERSION@ |
| 145 | + Cflags: -I${includedir} |
| 146 | + Libs: -L${libdir} -lmosquittopp |
| 147 | ++Requires.private: libmosquitto |
0 commit comments