diff --git a/CMakeLists.txt b/CMakeLists.txt index 9624bdbc..d8448bdf 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -79,10 +79,8 @@ endif() option(WITH_DLT "Include DLT support?" OFF) message(STATUS "WITH_DLT = ${WITH_DLT}") if(WITH_DLT) - #find_package(DLT REQUIRED) find_package(PkgConfig) - pkg_check_modules(DLT "automotive-dlt >= 2.11") - add_definitions("-DWITH_DLT") + pkg_check_modules(DLT "automotive-dlt >= 2.11" REQUIRED) endif() option(WITH_CJSON "Build with cJSON support (required for dynamic security plugin and useful for mosquitto_sub)?" ON) diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt index e5c26f03..606a18a0 100644 --- a/lib/CMakeLists.txt +++ b/lib/CMakeLists.txt @@ -101,18 +101,18 @@ if(WITH_WEBSOCKETS AND WITH_WEBSOCKETS_BUILTIN) "${mosquitto_SOURCE_DIR}/deps/picohttpparser") endif() -target_include_directories(libmosquitto PRIVATE - "${OPENSSL_INCLUDE_DIR}" - "${STDBOOL_H_PATH}" - "${STDINT_H_PATH}" - "${mosquitto_SOURCE_DIR}" - "${mosquitto_SOURCE_DIR}/common" - "${mosquitto_SOURCE_DIR}/include" - "${mosquitto_SOURCE_DIR}/lib" +target_include_directories(libmosquitto + PUBLIC + "${mosquitto_SOURCE_DIR}/include" + "${OPENSSL_INCLUDE_DIR}" + PRIVATE + "${STDBOOL_H_PATH}" + "${STDINT_H_PATH}" + "${mosquitto_SOURCE_DIR}" + "${mosquitto_SOURCE_DIR}/common" + "${mosquitto_SOURCE_DIR}/lib" ) -link_directories("${mosquitto_SOURCE_DIR}/lib") - if(WITH_BUNDLED_DEPS) target_include_directories(libmosquitto PRIVATE "${mosquitto_SOURCE_DIR}/deps" diff --git a/lib/cpp/CMakeLists.txt b/lib/cpp/CMakeLists.txt index 03329d7c..c7fe00c4 100644 --- a/lib/cpp/CMakeLists.txt +++ b/lib/cpp/CMakeLists.txt @@ -8,16 +8,16 @@ set_target_properties(mosquittopp PROPERTIES POSITION_INDEPENDENT_CODE 1 ) -target_include_directories(mosquittopp PRIVATE - "${STDBOOL_H_PATH}" - "${STDINT_H_PATH}" - "${mosquitto_SOURCE_DIR}/include" - "${mosquitto_SOURCE_DIR}/lib" - "${mosquitto_SOURCE_DIR}/lib/cpp" +target_include_directories(mosquittopp + PUBLIC + "${mosquitto_SOURCE_DIR}/include" + PRIVATE + "${STDBOOL_H_PATH}" + "${STDINT_H_PATH}" + "${mosquitto_SOURCE_DIR}/lib" + "${mosquitto_SOURCE_DIR}/lib/cpp" ) -link_directories(${mosquitto_BINARY_DIR}/lib) - target_link_libraries(mosquittopp PRIVATE libmosquitto) if (WITH_THREADING AND NOT WIN32) diff --git a/plugins/dynamic-security/CMakeLists.txt b/plugins/dynamic-security/CMakeLists.txt index fd5b542f..cda3945d 100644 --- a/plugins/dynamic-security/CMakeLists.txt +++ b/plugins/dynamic-security/CMakeLists.txt @@ -47,7 +47,6 @@ if(CJSON_FOUND AND WITH_TLS) "${mosquitto_SOURCE_DIR}/deps" ) endif() - link_directories(${CLIENT_DIR} "${mosquitto_SOURCE_DIR}") set_target_properties(mosquitto_dynamic_security PROPERTIES PREFIX "" @@ -59,8 +58,8 @@ if(CJSON_FOUND AND WITH_TLS) cJSON OpenSSL::SSL ) + target_link_libraries(mosquitto_dynamic_security PRIVATE mosquitto) if(WIN32) - target_link_libraries(mosquitto_dynamic_security PRIVATE mosquitto) install(TARGETS mosquitto_dynamic_security DESTINATION "${CMAKE_INSTALL_BINDIR}") else() diff --git a/plugins/examples/add-properties/CMakeLists.txt b/plugins/examples/add-properties/CMakeLists.txt index 88f7e4dd..afc4d4ef 100644 --- a/plugins/examples/add-properties/CMakeLists.txt +++ b/plugins/examples/add-properties/CMakeLists.txt @@ -16,9 +16,7 @@ set_target_properties(${PLUGIN_NAME} PROPERTIES POSITION_INDEPENDENT_CODE 1 ) -if(WIN32) - target_link_libraries(${PLUGIN_NAME} PRIVATE mosquitto) -endif() +target_link_libraries(${PLUGIN_NAME} PRIVATE mosquitto) # Don't install, these are example plugins only. #install(TARGETS ${PLUGIN_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}") diff --git a/plugins/examples/auth-by-ip/CMakeLists.txt b/plugins/examples/auth-by-ip/CMakeLists.txt index 23390bdf..340c2429 100644 --- a/plugins/examples/auth-by-ip/CMakeLists.txt +++ b/plugins/examples/auth-by-ip/CMakeLists.txt @@ -16,9 +16,7 @@ set_target_properties(${PLUGIN_NAME} PROPERTIES POSITION_INDEPENDENT_CODE 1 ) -if(WIN32) - target_link_libraries(${PLUGIN_NAME} PRIVATE mosquitto) -endif() +target_link_libraries(${PLUGIN_NAME} PRIVATE mosquitto) # Don't install, these are example plugins only. #install(TARGETS ${PLUGIN_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}") diff --git a/plugins/examples/client-lifetime-stats/CMakeLists.txt b/plugins/examples/client-lifetime-stats/CMakeLists.txt index ddabc98b..6e4fe0fb 100644 --- a/plugins/examples/client-lifetime-stats/CMakeLists.txt +++ b/plugins/examples/client-lifetime-stats/CMakeLists.txt @@ -5,7 +5,6 @@ add_library(${PLUGIN_NAME} MODULE ) target_include_directories(${PLUGIN_NAME} PRIVATE - "${OPENSSL_INCLUDE_DIR}" "${STDBOOL_H_PATH}" "${STDINT_H_PATH}" "${mosquitto_SOURCE_DIR}" @@ -13,15 +12,12 @@ target_include_directories(${PLUGIN_NAME} PRIVATE "${mosquitto_SOURCE_DIR}/include" ) -link_directories(${mosquitto_SOURCE_DIR}) - set_target_properties(${PLUGIN_NAME} PROPERTIES PREFIX "" POSITION_INDEPENDENT_CODE 1 ) -if(WIN32) - target_link_libraries(${PLUGIN_NAME} PRIVATE mosquitto) -endif() + +target_link_libraries(${PLUGIN_NAME} PRIVATE mosquitto) # Don't install, these are example plugins only. #install(TARGETS ${PLUGIN_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}") diff --git a/plugins/examples/client-properties/CMakeLists.txt b/plugins/examples/client-properties/CMakeLists.txt index 39121881..7b262bff 100644 --- a/plugins/examples/client-properties/CMakeLists.txt +++ b/plugins/examples/client-properties/CMakeLists.txt @@ -11,16 +11,12 @@ target_include_directories(${PLUGIN_NAME} PRIVATE "${mosquitto_SOURCE_DIR}/include" ) -link_directories(${mosquitto_SOURCE_DIR}) - set_target_properties(${PLUGIN_NAME} PROPERTIES PREFIX "" POSITION_INDEPENDENT_CODE 1 ) -if(WIN32) - target_link_libraries(${PLUGIN_NAME} PRIVATE mosquitto) -endif() +target_link_libraries(${PLUGIN_NAME} PRIVATE mosquitto) # Don't install, these are example plugins only. #install(TARGETS ${PLUGIN_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}") diff --git a/plugins/examples/connection-state/CMakeLists.txt b/plugins/examples/connection-state/CMakeLists.txt index b2cc2a46..3a6f4996 100644 --- a/plugins/examples/connection-state/CMakeLists.txt +++ b/plugins/examples/connection-state/CMakeLists.txt @@ -16,9 +16,7 @@ set_target_properties(${PLUGIN_NAME} PROPERTIES POSITION_INDEPENDENT_CODE 1 ) -if(WIN32) - target_link_libraries(${PLUGIN_NAME} PRIVATE mosquitto) -endif() +target_link_libraries(${PLUGIN_NAME} PRIVATE mosquitto) # Don't install, these are example plugins only. #install(TARGETS ${PLUGIN_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}") diff --git a/plugins/examples/delayed-auth/CMakeLists.txt b/plugins/examples/delayed-auth/CMakeLists.txt index e2811968..903db900 100644 --- a/plugins/examples/delayed-auth/CMakeLists.txt +++ b/plugins/examples/delayed-auth/CMakeLists.txt @@ -22,9 +22,7 @@ set_target_properties(${PLUGIN_NAME} PROPERTIES POSITION_INDEPENDENT_CODE 1 ) -if(WIN32) - target_link_libraries(${PLUGIN_NAME} PRIVATE mosquitto) -endif() +target_link_libraries(${PLUGIN_NAME} PRIVATE mosquitto) # Don't install, these are example plugins only. #install(TARGETS ${PLUGIN_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}") diff --git a/plugins/examples/force-retain/CMakeLists.txt b/plugins/examples/force-retain/CMakeLists.txt index b8984c65..d4d872ef 100644 --- a/plugins/examples/force-retain/CMakeLists.txt +++ b/plugins/examples/force-retain/CMakeLists.txt @@ -12,15 +12,12 @@ target_include_directories(${PLUGIN_NAME} PRIVATE "${mosquitto_SOURCE_DIR}/include" ) -link_directories(${mosquitto_SOURCE_DIR}) - set_target_properties(${PLUGIN_NAME} PROPERTIES PREFIX "" POSITION_INDEPENDENT_CODE 1 ) -if(WIN32) - target_link_libraries(${PLUGIN_NAME} PRIVATE mosquitto) -endif() + +target_link_libraries(${PLUGIN_NAME} PRIVATE mosquitto) # Don't install, these are example plugins only. #install(TARGETS ${PLUGIN_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}") diff --git a/plugins/examples/message-timestamp/CMakeLists.txt b/plugins/examples/message-timestamp/CMakeLists.txt index e40f528c..8a674285 100644 --- a/plugins/examples/message-timestamp/CMakeLists.txt +++ b/plugins/examples/message-timestamp/CMakeLists.txt @@ -5,7 +5,6 @@ add_library(${PLUGIN_NAME} MODULE ) target_include_directories(${PLUGIN_NAME} PRIVATE - "${OPENSSL_INCLUDE_DIR}" "${STDBOOL_H_PATH}" "${STDINT_H_PATH}" "${mosquitto_SOURCE_DIR}" @@ -17,9 +16,7 @@ set_target_properties(${PLUGIN_NAME} PROPERTIES POSITION_INDEPENDENT_CODE 1 ) -if(WIN32) - target_link_libraries(${PLUGIN_NAME} PRIVATE mosquitto) -endif() +target_link_libraries(${PLUGIN_NAME} PRIVATE mosquitto) # Don't install, these are example plugins only. #install(TARGETS ${PLUGIN_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}") diff --git a/plugins/examples/payload-modification/CMakeLists.txt b/plugins/examples/payload-modification/CMakeLists.txt index dbeaa4dc..0c9ad1c1 100644 --- a/plugins/examples/payload-modification/CMakeLists.txt +++ b/plugins/examples/payload-modification/CMakeLists.txt @@ -5,22 +5,18 @@ add_library(${PLUGIN_NAME} MODULE ) target_include_directories(${PLUGIN_NAME} PRIVATE - "${OPENSSL_INCLUDE_DIR}" "${STDBOOL_H_PATH}" "${STDINT_H_PATH}" "${mosquitto_SOURCE_DIR}" "${mosquitto_SOURCE_DIR}/include" ) -link_directories(${mosquitto_SOURCE_DIR}) - set_target_properties(${PLUGIN_NAME} PROPERTIES PREFIX "" POSITION_INDEPENDENT_CODE 1 ) -if(WIN32) - target_link_libraries(${PLUGIN_NAME} PRIVATE mosquitto) -endif() + +target_link_libraries(${PLUGIN_NAME} PRIVATE mosquitto) # Don't install, these are example plugins only. #install(TARGETS ${PLUGIN_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}") diff --git a/plugins/examples/payload-size-stats/CMakeLists.txt b/plugins/examples/payload-size-stats/CMakeLists.txt index f504f52b..f3c62875 100644 --- a/plugins/examples/payload-size-stats/CMakeLists.txt +++ b/plugins/examples/payload-size-stats/CMakeLists.txt @@ -5,22 +5,18 @@ add_library(${PLUGIN_NAME} MODULE ) target_include_directories(${PLUGIN_NAME} PRIVATE - "${OPENSSL_INCLUDE_DIR}" "${STDBOOL_H_PATH}" "${STDINT_H_PATH}" "${mosquitto_SOURCE_DIR}" "${mosquitto_SOURCE_DIR}/include" ) -link_directories(${mosquitto_SOURCE_DIR}) - set_target_properties(${PLUGIN_NAME} PROPERTIES PREFIX "" POSITION_INDEPENDENT_CODE 1 ) -if(WIN32) - target_link_libraries(${PLUGIN_NAME} PRIVATE mosquitto) -endif() + +target_link_libraries(${PLUGIN_NAME} PRIVATE mosquitto) # Don't install, these are example plugins only. #install(TARGETS ${PLUGIN_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}") diff --git a/plugins/examples/plugin-event-stats/CMakeLists.txt b/plugins/examples/plugin-event-stats/CMakeLists.txt index d12adce8..972994a3 100644 --- a/plugins/examples/plugin-event-stats/CMakeLists.txt +++ b/plugins/examples/plugin-event-stats/CMakeLists.txt @@ -5,22 +5,18 @@ add_library(${PLUGIN_NAME} MODULE ) target_include_directories(${PLUGIN_NAME} PRIVATE - "${OPENSSL_INCLUDE_DIR}" "${STDBOOL_H_PATH}" "${STDINT_H_PATH}" "${mosquitto_SOURCE_DIR}" "${mosquitto_SOURCE_DIR}/include" ) -link_directories(${mosquitto_SOURCE_DIR}) - set_target_properties(${PLUGIN_NAME} PROPERTIES PREFIX "" POSITION_INDEPENDENT_CODE 1 ) -if(WIN32) - target_link_libraries(${PLUGIN_NAME} PRIVATE mosquitto) -endif() + +target_link_libraries(${PLUGIN_NAME} PRIVATE mosquitto) # Don't install, these are example plugins only. #install(TARGETS ${PLUGIN_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}") diff --git a/plugins/examples/print-ip-on-publish/CMakeLists.txt b/plugins/examples/print-ip-on-publish/CMakeLists.txt index 2528f75e..1cf4b30d 100644 --- a/plugins/examples/print-ip-on-publish/CMakeLists.txt +++ b/plugins/examples/print-ip-on-publish/CMakeLists.txt @@ -5,22 +5,18 @@ add_library(${PLUGIN_NAME} MODULE ) target_include_directories(${PLUGIN_NAME} PRIVATE - "${OPENSSL_INCLUDE_DIR}" "${STDBOOL_H_PATH}" "${STDINT_H_PATH}" "${mosquitto_SOURCE_DIR}" "${mosquitto_SOURCE_DIR}/include" ) -link_directories(${mosquitto_SOURCE_DIR}) - set_target_properties(${PLUGIN_NAME} PROPERTIES PREFIX "" POSITION_INDEPENDENT_CODE 1 ) -if(WIN32) - target_link_libraries(${PLUGIN_NAME} PRIVATE mosquitto) -endif() + +target_link_libraries(${PLUGIN_NAME} PRIVATE mosquitto) # Don't install, these are example plugins only. #install(TARGETS ${PLUGIN_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}") diff --git a/plugins/examples/topic-modification/CMakeLists.txt b/plugins/examples/topic-modification/CMakeLists.txt index 361d7433..1063ddee 100644 --- a/plugins/examples/topic-modification/CMakeLists.txt +++ b/plugins/examples/topic-modification/CMakeLists.txt @@ -5,22 +5,18 @@ add_library(${PLUGIN_NAME} MODULE ) target_include_directories(${PLUGIN_NAME} PRIVATE - "${OPENSSL_INCLUDE_DIR}" "${STDBOOL_H_PATH}" "${STDINT_H_PATH}" "${mosquitto_SOURCE_DIR}" "${mosquitto_SOURCE_DIR}/include" ) -link_directories(${mosquitto_SOURCE_DIR}) - set_target_properties(${PLUGIN_NAME} PROPERTIES PREFIX "" POSITION_INDEPENDENT_CODE 1 ) -if(WIN32) - target_link_libraries(${PLUGIN_NAME} PRIVATE mosquitto) -endif() + +target_link_libraries(${PLUGIN_NAME} PRIVATE mosquitto) # Don't install, these are example plugins only. #install(TARGETS ${PLUGIN_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}") diff --git a/plugins/examples/wildcard-temp/CMakeLists.txt b/plugins/examples/wildcard-temp/CMakeLists.txt index 9e74e568..ff41a8a8 100644 --- a/plugins/examples/wildcard-temp/CMakeLists.txt +++ b/plugins/examples/wildcard-temp/CMakeLists.txt @@ -23,9 +23,7 @@ set_target_properties(${PLUGIN_NAME} PROPERTIES POSITION_INDEPENDENT_CODE 1 ) -if(WIN32) - target_link_libraries(${PLUGIN_NAME} PRIVATE mosquitto) -endif() +target_link_libraries(${PLUGIN_NAME} PRIVATE mosquitto) # Don't install, these are example plugins only. #install(TARGETS ${PLUGIN_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}") diff --git a/plugins/persist-sqlite/CMakeLists.txt b/plugins/persist-sqlite/CMakeLists.txt index 89b551ee..1489908b 100644 --- a/plugins/persist-sqlite/CMakeLists.txt +++ b/plugins/persist-sqlite/CMakeLists.txt @@ -26,7 +26,6 @@ if(SQLITE3_FOUND AND CJSON_FOUND) target_include_directories(mosquitto_persist_sqlite PRIVATE ${CLIENT_INC} ${SQLITE3_INCLUDE_DIR} ) - link_directories(${CLIENT_DIR} "${mosquitto_SOURCE_DIR}") set_target_properties(mosquitto_persist_sqlite PROPERTIES PREFIX "" @@ -38,9 +37,7 @@ if(SQLITE3_FOUND AND CJSON_FOUND) ${SQLITE3_LIBRARIES} cJSON ) - if(WIN32) - target_link_libraries(mosquitto_persist_sqlite PRIVATE mosquitto) - endif() + target_link_libraries(mosquitto_persist_sqlite PRIVATE mosquitto) install(TARGETS mosquitto_persist_sqlite RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 711c1fed..250bcfd5 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -148,12 +148,6 @@ endif() add_definitions (-DWITH_BROKER) -if(WITH_DLT) - message(STATUS "DLT_LIBDIR = ${DLT_LIBDIR}") - link_directories(${DLT_LIBDIR}) - set (MOSQ_LIBS ${MOSQ_LIBS} ${DLT_LIBRARIES}) -endif() - set (MOSQ_LIBS ${MOSQ_LIBS} ${OPENSSL_LIBRARIES}) # Check for getaddrinfo_a include(CheckLibraryExists) @@ -210,7 +204,6 @@ if(WITH_WEBSOCKETS) set (MOSQ_LIBS ${MOSQ_LIBS} websockets_static) if(WIN32) set (MOSQ_LIBS ${MOSQ_LIBS} iphlpapi) - link_directories(${mosquitto_SOURCE_DIR}) endif() else(STATIC_WEBSOCKETS) set (MOSQ_LIBS ${MOSQ_LIBS} websockets) @@ -218,19 +211,28 @@ if(WITH_WEBSOCKETS) endif() endif() +if(WITH_DLT) + message(STATUS "DLT_LIBDIR = ${DLT_LIBDIR}") + target_link_directories(mosquitto PRIVATE ${DLT_LIBDIR}) + set (MOSQ_LIBS ${MOSQ_LIBS} ${DLT_LIBRARIES}) + target_compile_definitions(mosquitto PRIVATE "WITH_DLT") +endif() + if(CJSON_FOUND) target_link_libraries(mosquitto PRIVATE cJSON) endif() -target_include_directories(mosquitto PRIVATE - "${OPENSSL_INCLUDE_DIR}" - "${STDBOOL_H_PATH}" - "${STDINT_H_PATH}" - "${mosquitto_SOURCE_DIR}" - "${mosquitto_SOURCE_DIR}/common" - "${mosquitto_SOURCE_DIR}/include" - "${mosquitto_SOURCE_DIR}/lib" - "${mosquitto_SOURCE_DIR}/src" +target_include_directories(mosquitto + PUBLIC + "${mosquitto_SOURCE_DIR}/include" + "${OPENSSL_INCLUDE_DIR}" + PRIVATE + "${STDBOOL_H_PATH}" + "${STDINT_H_PATH}" + "${mosquitto_SOURCE_DIR}" + "${mosquitto_SOURCE_DIR}/common" + "${mosquitto_SOURCE_DIR}/lib" + "${mosquitto_SOURCE_DIR}/src" ) if(WITH_BUNDLED_DEPS) target_include_directories(mosquitto PRIVATE @@ -250,11 +252,9 @@ if (WITH_THREADING AND NOT WIN32) target_link_libraries(mosquitto PRIVATE Threads::Threads) endif() -if(WIN32) - set_target_properties(mosquitto PROPERTIES - ENABLE_EXPORTS 1 - ) -endif() +set_target_properties(mosquitto PROPERTIES + ENABLE_EXPORTS 1 +) if(UNIX) if(APPLE)