From fe3b72ef618f31ea63ca7f4e53837f15426e58cf Mon Sep 17 00:00:00 2001 From: "Roger A. Light" Date: Thu, 15 Feb 2024 12:26:10 +0000 Subject: [PATCH] Remove a load of cmake boilerplate --- plugins/CMakeLists.txt | 38 ++++++++++++++ plugins/dynamic-security/CMakeLists.txt | 51 ++++--------------- .../examples/add-properties/CMakeLists.txt | 18 +------ plugins/examples/auth-by-env/CMakeLists.txt | 19 +------ plugins/examples/auth-by-ip/CMakeLists.txt | 20 +------- .../client-lifetime-stats/CMakeLists.txt | 24 +-------- .../examples/client-properties/CMakeLists.txt | 19 +------ .../examples/connection-state/CMakeLists.txt | 19 +------ plugins/examples/delayed-auth/CMakeLists.txt | 25 +-------- .../deny-protocol-version/CMakeLists.txt | 20 +------- plugins/examples/force-retain/CMakeLists.txt | 20 +------- .../limit-subscription-qos/CMakeLists.txt | 25 +-------- .../examples/message-timestamp/CMakeLists.txt | 18 +------ plugins/examples/payload-ban/CMakeLists.txt | 26 +--------- .../payload-modification/CMakeLists.txt | 19 +------ .../payload-size-stats/CMakeLists.txt | 18 +------ .../plugin-event-stats/CMakeLists.txt | 18 +------ .../print-ip-on-publish/CMakeLists.txt | 18 +------ plugins/examples/topic-jail/CMakeLists.txt | 20 +------- .../topic-modification/CMakeLists.txt | 19 +------ plugins/examples/wildcard-temp/CMakeLists.txt | 29 +---------- plugins/persist-sqlite/CMakeLists.txt | 36 ++++--------- plugins/sparkplug-aware/CMakeLists.txt | 36 ++----------- 23 files changed, 81 insertions(+), 474 deletions(-) diff --git a/plugins/CMakeLists.txt b/plugins/CMakeLists.txt index 2b3861ed..bed0c1cb 100644 --- a/plugins/CMakeLists.txt +++ b/plugins/CMakeLists.txt @@ -1,3 +1,41 @@ +function(plugin_helper_no_install PLUGIN_NAME SRCLIST INCLIST LINKLIST) + add_library(${PLUGIN_NAME} MODULE ${SRCLIST}) + target_include_directories(${PLUGIN_NAME} PRIVATE + ${INCLIST} + "${mosquitto_SOURCE_DIR}/" + "${mosquitto_SOURCE_DIR}/common" + "${mosquitto_SOURCE_DIR}/include" + ) + if(WITH_BUNDLED_DEPS) + target_include_directories(${PLUGIN_NAME} PRIVATE "${mosquitto_SOURCE_DIR}/deps") + endif() + + set_target_properties(${PLUGIN_NAME} PROPERTIES + PREFIX "" + POSITION_INDEPENDENT_CODE 1 + ) + + target_link_libraries(${PLUGIN_NAME} PRIVATE + ${LINKLIST} + common-options + mosquitto + ) +endfunction() + +function(plugin_helper PLUGIN_NAME SRCLIST INCLIST LINKLIST) + plugin_helper_no_install("${PLUGIN_NAME}" "${SRCLIST}" "${INCLIST}" "${LINKLIST}") + + if(WIN32) + install(TARGETS ${PLUGIN_NAME} + DESTINATION "${CMAKE_INSTALL_BINDIR}") + else() + install(TARGETS ${PLUGIN_NAME} + RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" + LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}" + ) + endif() +endfunction() + add_subdirectory(dynamic-security) add_subdirectory(persist-sqlite) add_subdirectory(examples) diff --git a/plugins/dynamic-security/CMakeLists.txt b/plugins/dynamic-security/CMakeLists.txt index e7cb2e14..37ecb3fe 100644 --- a/plugins/dynamic-security/CMakeLists.txt +++ b/plugins/dynamic-security/CMakeLists.txt @@ -1,18 +1,7 @@ -if(CJSON_FOUND AND WITH_TLS) - set(CLIENT_INC - "${CJSON_INCLUDE_DIRS}" - "${mosquitto_SOURCE_DIR}" - "${mosquitto_SOURCE_DIR}/common" - "${mosquitto_SOURCE_DIR}/deps" - "${mosquitto_SOURCE_DIR}/include" - "${mosquitto_SOURCE_DIR}/lib" - "${mosquitto_SOURCE_DIR}/plugins/common" - "${mosquitto_SOURCE_DIR}/src" - ) +if(WITH_TLS) + set(PLUGIN_NAME mosquitto_dynamic_security) - set(CLIENT_DIR "${mosquitto_BINARY_DIR}/lib" "${CJSON_DIR}") - - add_library(mosquitto_dynamic_security MODULE + set(SRCLIST acl.c auth.c ../../common/base64_mosq.c ../../common/base64_mosq.h @@ -35,34 +24,16 @@ if(CJSON_FOUND AND WITH_TLS) tick.c ) - target_include_directories(mosquitto_dynamic_security PRIVATE - ${CLIENT_INC} - ) - if(WITH_BUNDLED_DEPS) - target_include_directories(mosquitto_dynamic_security PRIVATE - "${mosquitto_SOURCE_DIR}/deps" - ) - endif() - - set_target_properties(mosquitto_dynamic_security PROPERTIES - PREFIX "" - POSITION_INDEPENDENT_CODE 1 + set(INCLIST + "${CJSON_INCLUDE_DIRS}" + "${mosquitto_SOURCE_DIR}/lib" + "${mosquitto_SOURCE_DIR}/src" ) - target_link_libraries(mosquitto_dynamic_security - PRIVATE - common-options - cJSON - OpenSSL::SSL + set(LINKLIST + cJSON + OpenSSL::SSL ) - target_link_libraries(mosquitto_dynamic_security PRIVATE mosquitto) - if(WIN32) - install(TARGETS mosquitto_dynamic_security - DESTINATION "${CMAKE_INSTALL_BINDIR}") - else() - install(TARGETS mosquitto_dynamic_security - RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" - LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}") - endif() + plugin_helper("${PLUGIN_NAME}" "${SRCLIST}" "${INCLIST}" "${LINKLIST}") endif() diff --git a/plugins/examples/add-properties/CMakeLists.txt b/plugins/examples/add-properties/CMakeLists.txt index 78a11d1a..8193d669 100644 --- a/plugins/examples/add-properties/CMakeLists.txt +++ b/plugins/examples/add-properties/CMakeLists.txt @@ -1,19 +1,3 @@ set (PLUGIN_NAME mosquitto_add_properties) -add_library(${PLUGIN_NAME} MODULE - ${PLUGIN_NAME}.c -) - -target_include_directories(${PLUGIN_NAME} PRIVATE - "${mosquitto_SOURCE_DIR}/include" -) - -set_target_properties(${PLUGIN_NAME} PROPERTIES - PREFIX "" - POSITION_INDEPENDENT_CODE 1 -) - -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}") +plugin_helper_no_install("${PLUGIN_NAME}" "${PLUGIN_NAME}.c" "" "") diff --git a/plugins/examples/auth-by-env/CMakeLists.txt b/plugins/examples/auth-by-env/CMakeLists.txt index cf21d7ee..a4afe8cc 100644 --- a/plugins/examples/auth-by-env/CMakeLists.txt +++ b/plugins/examples/auth-by-env/CMakeLists.txt @@ -1,20 +1,3 @@ set (PLUGIN_NAME mosquitto_auth_by_env) -add_library(${PLUGIN_NAME} MODULE - ${PLUGIN_NAME}.c -) - -target_include_directories(${PLUGIN_NAME} PRIVATE - "${mosquitto_SOURCE_DIR}" - "${mosquitto_SOURCE_DIR}/include" -) - -set_target_properties(${PLUGIN_NAME} PROPERTIES - PREFIX "" - POSITION_INDEPENDENT_CODE 1 -) - -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}") +plugin_helper_no_install("${PLUGIN_NAME}" "${PLUGIN_NAME}.c" "" "") diff --git a/plugins/examples/auth-by-ip/CMakeLists.txt b/plugins/examples/auth-by-ip/CMakeLists.txt index f0f6d22e..96c07acf 100644 --- a/plugins/examples/auth-by-ip/CMakeLists.txt +++ b/plugins/examples/auth-by-ip/CMakeLists.txt @@ -1,21 +1,3 @@ set (PLUGIN_NAME mosquitto_auth_by_ip) -add_library(${PLUGIN_NAME} MODULE - ${PLUGIN_NAME}.c -) - -target_include_directories(${PLUGIN_NAME} PRIVATE - "${OPENSSL_INCLUDE_DIR}" - "${mosquitto_SOURCE_DIR}" - "${mosquitto_SOURCE_DIR}/include" -) - -set_target_properties(${PLUGIN_NAME} PROPERTIES - PREFIX "" - POSITION_INDEPENDENT_CODE 1 -) - -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}") +plugin_helper_no_install("${PLUGIN_NAME}" "${PLUGIN_NAME}.c" "" "") diff --git a/plugins/examples/client-lifetime-stats/CMakeLists.txt b/plugins/examples/client-lifetime-stats/CMakeLists.txt index d124864e..ef8996c1 100644 --- a/plugins/examples/client-lifetime-stats/CMakeLists.txt +++ b/plugins/examples/client-lifetime-stats/CMakeLists.txt @@ -1,25 +1,3 @@ set (PLUGIN_NAME mosquitto_client_lifetime_stats) -add_library(${PLUGIN_NAME} MODULE - ${PLUGIN_NAME}.c -) - -target_include_directories(${PLUGIN_NAME} PRIVATE - "${mosquitto_SOURCE_DIR}/include" -) - -if(WITH_BUNDLED_DEPS) - target_include_directories(${PLUGIN_NAME} PRIVATE - "${mosquitto_SOURCE_DIR}/deps" - ) -endif() - -set_target_properties(${PLUGIN_NAME} PROPERTIES - PREFIX "" - POSITION_INDEPENDENT_CODE 1 -) - -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}") +plugin_helper_no_install("${PLUGIN_NAME}" "${PLUGIN_NAME}.c" "" "") diff --git a/plugins/examples/client-properties/CMakeLists.txt b/plugins/examples/client-properties/CMakeLists.txt index b58cb806..3ceefbec 100644 --- a/plugins/examples/client-properties/CMakeLists.txt +++ b/plugins/examples/client-properties/CMakeLists.txt @@ -1,20 +1,3 @@ set (PLUGIN_NAME mosquitto_client_properties) -add_library(${PLUGIN_NAME} MODULE - ${PLUGIN_NAME}.c -) - -target_include_directories(${PLUGIN_NAME} PRIVATE - "${mosquitto_SOURCE_DIR}" - "${mosquitto_SOURCE_DIR}/include" -) - -set_target_properties(${PLUGIN_NAME} PROPERTIES - PREFIX "" - POSITION_INDEPENDENT_CODE 1 -) - -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}") +plugin_helper_no_install("${PLUGIN_NAME}" "${PLUGIN_NAME}.c" "" "") diff --git a/plugins/examples/connection-state/CMakeLists.txt b/plugins/examples/connection-state/CMakeLists.txt index c1e98b0e..769b198e 100644 --- a/plugins/examples/connection-state/CMakeLists.txt +++ b/plugins/examples/connection-state/CMakeLists.txt @@ -1,20 +1,3 @@ set (PLUGIN_NAME mosquitto_connection_state) -add_library(${PLUGIN_NAME} MODULE - ${PLUGIN_NAME}.c -) - -target_include_directories(${PLUGIN_NAME} PRIVATE - "${mosquitto_SOURCE_DIR}" - "${mosquitto_SOURCE_DIR}/include" -) - -set_target_properties(${PLUGIN_NAME} PROPERTIES - PREFIX "" - POSITION_INDEPENDENT_CODE 1 -) - -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}") +plugin_helper_no_install("${PLUGIN_NAME}" "${PLUGIN_NAME}.c" "" "") diff --git a/plugins/examples/delayed-auth/CMakeLists.txt b/plugins/examples/delayed-auth/CMakeLists.txt index 03773a36..7e1ed595 100644 --- a/plugins/examples/delayed-auth/CMakeLists.txt +++ b/plugins/examples/delayed-auth/CMakeLists.txt @@ -1,26 +1,3 @@ set (PLUGIN_NAME mosquitto_delayed_auth) -add_library(${PLUGIN_NAME} MODULE - ${PLUGIN_NAME}.c -) - -target_include_directories(${PLUGIN_NAME} PRIVATE - "${mosquitto_SOURCE_DIR}" - "${mosquitto_SOURCE_DIR}/include" -) - -if(WITH_BUNDLED_DEPS) - target_include_directories(${PLUGIN_NAME} PRIVATE - "${mosquitto_SOURCE_DIR}/deps" - ) -endif() - -set_target_properties(${PLUGIN_NAME} PROPERTIES - PREFIX "" - POSITION_INDEPENDENT_CODE 1 -) - -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}") +plugin_helper_no_install("${PLUGIN_NAME}" "${PLUGIN_NAME}.c" "" "") diff --git a/plugins/examples/deny-protocol-version/CMakeLists.txt b/plugins/examples/deny-protocol-version/CMakeLists.txt index c2ab553d..bb4a9c0c 100644 --- a/plugins/examples/deny-protocol-version/CMakeLists.txt +++ b/plugins/examples/deny-protocol-version/CMakeLists.txt @@ -1,21 +1,3 @@ set (PLUGIN_NAME mosquitto_deny_protocol_version) -add_library(${PLUGIN_NAME} MODULE - ${PLUGIN_NAME}.c -) - -target_include_directories(${PLUGIN_NAME} PRIVATE - "${OPENSSL_INCLUDE_DIR}" - "${mosquitto_SOURCE_DIR}" - "${mosquitto_SOURCE_DIR}/include" -) - -set_target_properties(${PLUGIN_NAME} PROPERTIES - PREFIX "" - POSITION_INDEPENDENT_CODE 1 -) - -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}") +plugin_helper_no_install("${PLUGIN_NAME}" "${PLUGIN_NAME}.c" "" "") diff --git a/plugins/examples/force-retain/CMakeLists.txt b/plugins/examples/force-retain/CMakeLists.txt index 13c4826e..e5b77cbb 100644 --- a/plugins/examples/force-retain/CMakeLists.txt +++ b/plugins/examples/force-retain/CMakeLists.txt @@ -1,21 +1,3 @@ set (PLUGIN_NAME mosquitto_force_retain) -add_library(${PLUGIN_NAME} MODULE - ${PLUGIN_NAME}.c -) - -target_include_directories(${PLUGIN_NAME} PRIVATE - "${OPENSSL_INCLUDE_DIR}" - "${mosquitto_SOURCE_DIR}" - "${mosquitto_SOURCE_DIR}/include" -) - -set_target_properties(${PLUGIN_NAME} PROPERTIES - PREFIX "" - POSITION_INDEPENDENT_CODE 1 -) - -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}") +plugin_helper_no_install("${PLUGIN_NAME}" "${PLUGIN_NAME}.c" "" "") diff --git a/plugins/examples/limit-subscription-qos/CMakeLists.txt b/plugins/examples/limit-subscription-qos/CMakeLists.txt index 68abbb0c..7d8d2d7d 100644 --- a/plugins/examples/limit-subscription-qos/CMakeLists.txt +++ b/plugins/examples/limit-subscription-qos/CMakeLists.txt @@ -1,26 +1,3 @@ set (PLUGIN_NAME mosquitto_limit_subscription_qos) -add_library(${PLUGIN_NAME} MODULE - ${PLUGIN_NAME}.c -) - -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} mosquitto) -endif() - -# Don't install, these are example plugins only. -#install(TARGETS ${PLUGIN_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}") +plugin_helper_no_install("${PLUGIN_NAME}" "${PLUGIN_NAME}.c" "" "") diff --git a/plugins/examples/message-timestamp/CMakeLists.txt b/plugins/examples/message-timestamp/CMakeLists.txt index a212fd11..efae18f5 100644 --- a/plugins/examples/message-timestamp/CMakeLists.txt +++ b/plugins/examples/message-timestamp/CMakeLists.txt @@ -1,19 +1,3 @@ set (PLUGIN_NAME mosquitto_message_timestamp) -add_library(${PLUGIN_NAME} MODULE - ${PLUGIN_NAME}.c -) - -target_include_directories(${PLUGIN_NAME} PRIVATE - "${mosquitto_SOURCE_DIR}/include" -) - -set_target_properties(${PLUGIN_NAME} PROPERTIES - PREFIX "" - POSITION_INDEPENDENT_CODE 1 -) - -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}") +plugin_helper_no_install("${PLUGIN_NAME}" "${PLUGIN_NAME}.c" "" "") diff --git a/plugins/examples/payload-ban/CMakeLists.txt b/plugins/examples/payload-ban/CMakeLists.txt index d8665c91..d6603c2e 100644 --- a/plugins/examples/payload-ban/CMakeLists.txt +++ b/plugins/examples/payload-ban/CMakeLists.txt @@ -1,27 +1,3 @@ set (PLUGIN_NAME mosquitto_payload_ban) -add_library(${PLUGIN_NAME} MODULE - ${PLUGIN_NAME}.c -) - -target_include_directories(${PLUGIN_NAME} PRIVATE - "${OPENSSL_INCLUDE_DIR}" - "${mosquitto_SOURCE_DIR}" - "${mosquitto_SOURCE_DIR}/include" -) - -if(WITH_BUNDLED_DEPS) - target_include_directories(${PLUGIN_NAME} PRIVATE - "${mosquitto_SOURCE_DIR}/deps" - ) -endif() - -set_target_properties(${PLUGIN_NAME} PROPERTIES - PREFIX "" - POSITION_INDEPENDENT_CODE 1 -) - -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}") +plugin_helper_no_install("${PLUGIN_NAME}" "${PLUGIN_NAME}.c" "" "") diff --git a/plugins/examples/payload-modification/CMakeLists.txt b/plugins/examples/payload-modification/CMakeLists.txt index 2530cf47..ab0466a0 100644 --- a/plugins/examples/payload-modification/CMakeLists.txt +++ b/plugins/examples/payload-modification/CMakeLists.txt @@ -1,20 +1,3 @@ set (PLUGIN_NAME mosquitto_payload_modification) -add_library(${PLUGIN_NAME} MODULE - ${PLUGIN_NAME}.c -) - -target_include_directories(${PLUGIN_NAME} PRIVATE - "${mosquitto_SOURCE_DIR}" - "${mosquitto_SOURCE_DIR}/include" -) - -set_target_properties(${PLUGIN_NAME} PROPERTIES - PREFIX "" - POSITION_INDEPENDENT_CODE 1 -) - -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}") +plugin_helper_no_install("${PLUGIN_NAME}" "${PLUGIN_NAME}.c" "" "") diff --git a/plugins/examples/payload-size-stats/CMakeLists.txt b/plugins/examples/payload-size-stats/CMakeLists.txt index 49a07b1a..993246db 100644 --- a/plugins/examples/payload-size-stats/CMakeLists.txt +++ b/plugins/examples/payload-size-stats/CMakeLists.txt @@ -1,19 +1,3 @@ set (PLUGIN_NAME mosquitto_payload_size_stats) -add_library(${PLUGIN_NAME} MODULE - ${PLUGIN_NAME}.c -) - -target_include_directories(${PLUGIN_NAME} PRIVATE - "${mosquitto_SOURCE_DIR}/include" -) - -set_target_properties(${PLUGIN_NAME} PROPERTIES - PREFIX "" - POSITION_INDEPENDENT_CODE 1 -) - -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}") +plugin_helper_no_install("${PLUGIN_NAME}" "${PLUGIN_NAME}.c" "" "") diff --git a/plugins/examples/plugin-event-stats/CMakeLists.txt b/plugins/examples/plugin-event-stats/CMakeLists.txt index 32c1c0e0..038ea17d 100644 --- a/plugins/examples/plugin-event-stats/CMakeLists.txt +++ b/plugins/examples/plugin-event-stats/CMakeLists.txt @@ -1,19 +1,3 @@ set (PLUGIN_NAME mosquitto_plugin_event_stats) -add_library(${PLUGIN_NAME} MODULE - ${PLUGIN_NAME}.c -) - -target_include_directories(${PLUGIN_NAME} PRIVATE - "${mosquitto_SOURCE_DIR}/include" -) - -set_target_properties(${PLUGIN_NAME} PROPERTIES - PREFIX "" - POSITION_INDEPENDENT_CODE 1 -) - -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}") +plugin_helper_no_install("${PLUGIN_NAME}" "${PLUGIN_NAME}.c" "" "") diff --git a/plugins/examples/print-ip-on-publish/CMakeLists.txt b/plugins/examples/print-ip-on-publish/CMakeLists.txt index 23175017..441f6b3d 100644 --- a/plugins/examples/print-ip-on-publish/CMakeLists.txt +++ b/plugins/examples/print-ip-on-publish/CMakeLists.txt @@ -1,19 +1,3 @@ set (PLUGIN_NAME mosquitto_print_ip_on_publish) -add_library(${PLUGIN_NAME} MODULE - ${PLUGIN_NAME}.c -) - -target_include_directories(${PLUGIN_NAME} PRIVATE - "${mosquitto_SOURCE_DIR}/include" -) - -set_target_properties(${PLUGIN_NAME} PROPERTIES - PREFIX "" - POSITION_INDEPENDENT_CODE 1 -) - -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}") +plugin_helper_no_install("${PLUGIN_NAME}" "${PLUGIN_NAME}.c" "" "") diff --git a/plugins/examples/topic-jail/CMakeLists.txt b/plugins/examples/topic-jail/CMakeLists.txt index ebccefce..46032b6c 100644 --- a/plugins/examples/topic-jail/CMakeLists.txt +++ b/plugins/examples/topic-jail/CMakeLists.txt @@ -1,21 +1,3 @@ set (PLUGIN_NAME mosquitto_topic_jail) -add_library(${PLUGIN_NAME} MODULE - ${PLUGIN_NAME}.c -) - -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 -) - -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}") +plugin_helper_no_install("${PLUGIN_NAME}" "${PLUGIN_NAME}.c" "" "") diff --git a/plugins/examples/topic-modification/CMakeLists.txt b/plugins/examples/topic-modification/CMakeLists.txt index a95b1d45..78d5ca1b 100644 --- a/plugins/examples/topic-modification/CMakeLists.txt +++ b/plugins/examples/topic-modification/CMakeLists.txt @@ -1,20 +1,3 @@ set (PLUGIN_NAME mosquitto_topic_modification) -add_library(${PLUGIN_NAME} MODULE - ${PLUGIN_NAME}.c -) - -target_include_directories(${PLUGIN_NAME} PRIVATE - "${mosquitto_SOURCE_DIR}" - "${mosquitto_SOURCE_DIR}/include" -) - -set_target_properties(${PLUGIN_NAME} PROPERTIES - PREFIX "" - POSITION_INDEPENDENT_CODE 1 -) - -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}") +plugin_helper_no_install("${PLUGIN_NAME}" "${PLUGIN_NAME}.c" "" "") diff --git a/plugins/examples/wildcard-temp/CMakeLists.txt b/plugins/examples/wildcard-temp/CMakeLists.txt index a5062248..9f0d005d 100644 --- a/plugins/examples/wildcard-temp/CMakeLists.txt +++ b/plugins/examples/wildcard-temp/CMakeLists.txt @@ -1,30 +1,3 @@ set (PLUGIN_NAME mosquitto_wildcard_temp) -add_library(${PLUGIN_NAME} MODULE - ${PLUGIN_NAME}.c -) - -target_include_directories(${PLUGIN_NAME} PRIVATE - "${mosquitto_SOURCE_DIR}" - "${mosquitto_SOURCE_DIR}/include" - "${CJSON_INCLUDE_DIRS}" -) - -if(WITH_BUNDLED_DEPS) - target_include_directories(${PLUGIN_NAME} PRIVATE - "${mosquitto_SOURCE_DIR}/deps" - ) -endif() - -set_target_properties(${PLUGIN_NAME} PROPERTIES - PREFIX "" - POSITION_INDEPENDENT_CODE 1 -) - -target_link_libraries(${PLUGIN_NAME} PRIVATE - mosquitto - cJSON -) - -# Don't install, these are example plugins only. -#install(TARGETS ${PLUGIN_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}") +plugin_helper_no_install("${PLUGIN_NAME}" "${PLUGIN_NAME}.c" "" "") diff --git a/plugins/persist-sqlite/CMakeLists.txt b/plugins/persist-sqlite/CMakeLists.txt index 41545a99..35a726c3 100644 --- a/plugins/persist-sqlite/CMakeLists.txt +++ b/plugins/persist-sqlite/CMakeLists.txt @@ -1,11 +1,7 @@ -if(SQLITE3_FOUND AND CJSON_FOUND) - set(CLIENT_INC - "${mosquitto_SOURCE_DIR}/deps" - "${mosquitto_SOURCE_DIR}/include" - "${mosquitto_SOURCE_DIR}/src" - ) +if(SQLITE3_FOUND) + set(PLUGIN_NAME "mosquitto_persist_sqlite") - add_library(mosquitto_persist_sqlite MODULE + set(SRCLIST base_msgs.c clients.c client_msgs.c @@ -18,26 +14,12 @@ if(SQLITE3_FOUND AND CJSON_FOUND) tick.c ) - target_include_directories(mosquitto_persist_sqlite PRIVATE - ${CLIENT_INC} - "${mosquitto_SOURCE_DIR}/common" + set(INCLIST ) + + set(LINKLIST + cJSON + SQLite::SQLite3 ) - set_target_properties(mosquitto_persist_sqlite PROPERTIES - PREFIX "" - POSITION_INDEPENDENT_CODE 1 - ) - - target_link_libraries(mosquitto_persist_sqlite - PRIVATE - common-options - SQLite::SQLite3 - cJSON - ) - target_link_libraries(mosquitto_persist_sqlite PRIVATE mosquitto) - - install(TARGETS mosquitto_persist_sqlite - RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" - LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}" - ) + plugin_helper("${PLUGIN_NAME}" "${SRCLIST}" "${INCLIST}" "${LINKLIST}") endif() diff --git a/plugins/sparkplug-aware/CMakeLists.txt b/plugins/sparkplug-aware/CMakeLists.txt index ffeb2f7a..3bdac8d7 100644 --- a/plugins/sparkplug-aware/CMakeLists.txt +++ b/plugins/sparkplug-aware/CMakeLists.txt @@ -1,39 +1,11 @@ set(PLUGIN_NAME mosquitto_sparkplug_aware) -add_library(${PLUGIN_NAME} MODULE +set(SRCLIST on_message.c plugin.c ) -target_compile_definitions(${PLUGIN_NAME} PRIVATE WITH_CJSON) +set(INCLIST ) +set(LINKLIST ) -target_include_directories(${PLUGIN_NAME} PRIVATE - "${mosquitto_SOURCE_DIR}" - "${mosquitto_SOURCE_DIR}/common" - "${mosquitto_SOURCE_DIR}/deps" - "${mosquitto_SOURCE_DIR}/include" -) - -if(WITH_BUNDLED_DEPS) - target_include_directories(${PLUGIN_NAME} PRIVATE - "${mosquitto_SOURCE_DIR}/deps" - ) -endif() - -set_target_properties(${PLUGIN_NAME} PROPERTIES - PREFIX "" -) - -target_link_libraries(${PLUGIN_NAME} PRIVATE - common-options - mosquitto -) - -if(WIN32) - install(TARGETS ${PLUGIN_NAME} - DESTINATION "${CMAKE_INSTALL_BINDIR}") -else() - install(TARGETS ${PLUGIN_NAME} - RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" - LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}") -endif() +plugin_helper("${PLUGIN_NAME}" "${SRCLIST}" "${INCLIST}" "${LINKLIST}")