diff --git a/CMakeLists.txt b/CMakeLists.txt index 6da85ca2..f33d5630 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,7 +4,7 @@ # To configure the build options either use the CMake gui, or run the command # line utility including the "-i" option. -cmake_minimum_required(VERSION 3.18) +cmake_minimum_required(VERSION 3.24) set (VERSION 2.1.2) project(mosquitto @@ -76,12 +76,34 @@ option_env(WITH_UNIX_SOCKETS "Include Unix Domain Socket support?" ON) option_env(WITH_WEBSOCKETS "Include websockets support?" ON) option_env(WITH_WEBSOCKETS_BUILTIN "Websockets support uses builtin library? Set OFF to use libwebsockets" ON) +set(LIB_TYPE_PLUGIN MODULE) +set(LIB_TYPE_LIBRARY SHARED) + if(WITH_FUZZING) set(WITH_TESTS OFF) - set(WITH_SHARED_LIBRARIES OFF) - set(WITH_STATIC_LIBRARIES ON) + set(LIB_TYPE_LIBRARY STATIC) + set(LIB_TYPE_PLUGIN STATIC) + add_compile_definitions(WITH_FUZZING) endif() +function(custom_add_executable EXE) + if(WITH_FUZZING) + add_library(${EXE} STATIC ${ARGN}) + set_target_properties(${EXE} PROPERTIES + PREFIX "" + POSITION_INDEPENDENT_CODE 1 + ) + else() + add_executable(${EXE} ${ARGN}) + endif() +endfunction() + +function(custom_install) + if(NOT WITH_FUZZING) + install(${NARGS}) + endif() +endfunction() + if(ARGON2_FOUND) # Disable until separate password handling thread is implemented #add_definitions("-DWITH_ARGON2") @@ -222,8 +244,8 @@ endif() # ======================================== if(WITH_BROKER) - install(FILES mosquitto.conf RENAME mosquitto.conf.example DESTINATION "${CMAKE_INSTALL_SYSCONFDIR}/mosquitto") - install(FILES aclfile.example pskfile.example pwfile.example DESTINATION "${CMAKE_INSTALL_SYSCONFDIR}/mosquitto") + custom_install(FILES mosquitto.conf RENAME mosquitto.conf.example DESTINATION "${CMAKE_INSTALL_SYSCONFDIR}/mosquitto") + custom_install(FILES aclfile.example pskfile.example pwfile.example DESTINATION "${CMAKE_INSTALL_SYSCONFDIR}/mosquitto") endif() # ======================================== @@ -231,14 +253,14 @@ endif() # ======================================== configure_file(libmosquitto.pc.in libmosquitto.pc @ONLY) -install(FILES "${CMAKE_CURRENT_BINARY_DIR}/libmosquitto.pc" DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig") +custom_install(FILES "${CMAKE_CURRENT_BINARY_DIR}/libmosquitto.pc" DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig") configure_file(libmosquittopp.pc.in libmosquittopp.pc @ONLY) -install(FILES "${CMAKE_CURRENT_BINARY_DIR}/libmosquittopp.pc" DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig") +custom_install(FILES "${CMAKE_CURRENT_BINARY_DIR}/libmosquittopp.pc" DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig") # ======================================== # Install headers # ======================================== -install( +custom_install( FILES ${mosquitto_SOURCE_DIR}/include/mosquitto.h ${mosquitto_SOURCE_DIR}/include/mosquitto_broker.h @@ -247,7 +269,7 @@ install( ${mosquitto_SOURCE_DIR}/include/mqtt_protocol.h DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}" ) -install( +custom_install( FILES ${mosquitto_SOURCE_DIR}/include/mosquitto/broker.h ${mosquitto_SOURCE_DIR}/include/mosquitto/broker_control.h diff --git a/apps/db_dump/CMakeLists.txt b/apps/db_dump/CMakeLists.txt index fca8f1bc..e9252f5b 100644 --- a/apps/db_dump/CMakeLists.txt +++ b/apps/db_dump/CMakeLists.txt @@ -1,4 +1,4 @@ -add_executable(mosquitto_db_dump +custom_add_executable(mosquitto_db_dump db_dump.c db_dump.h json.c print.c @@ -40,6 +40,6 @@ endif() target_link_libraries(mosquitto_db_dump PRIVATE common-options libmosquitto_common) -install(TARGETS mosquitto_db_dump +custom_install(TARGETS mosquitto_db_dump RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" ) diff --git a/apps/mosquitto_ctrl/CMakeLists.txt b/apps/mosquitto_ctrl/CMakeLists.txt index 37a2b04c..ffcd4bc8 100644 --- a/apps/mosquitto_ctrl/CMakeLists.txt +++ b/apps/mosquitto_ctrl/CMakeLists.txt @@ -51,7 +51,7 @@ if(WITH_TLS) OpenSSL::SSL ) endif() - add_executable(mosquitto_ctrl ${SRC}) + custom_add_executable(mosquitto_ctrl ${SRC}) target_include_directories(mosquitto_ctrl PRIVATE "${mosquitto_SOURCE_DIR}/apps/mosquitto_passwd" @@ -110,7 +110,7 @@ if(WITH_TLS) endif() - install(TARGETS mosquitto_ctrl + custom_install(TARGETS mosquitto_ctrl RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" ) endif() diff --git a/apps/mosquitto_passwd/CMakeLists.txt b/apps/mosquitto_passwd/CMakeLists.txt index 93047c68..bf832bbc 100644 --- a/apps/mosquitto_passwd/CMakeLists.txt +++ b/apps/mosquitto_passwd/CMakeLists.txt @@ -1,5 +1,5 @@ if(WITH_TLS) - add_executable(mosquitto_passwd + custom_add_executable(mosquitto_passwd mosquitto_passwd.c get_password.c get_password.h ) @@ -19,7 +19,7 @@ if(WITH_TLS) OpenSSL::SSL ) - install(TARGETS mosquitto_passwd + custom_install(TARGETS mosquitto_passwd RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" ) endif() diff --git a/apps/mosquitto_signal/CMakeLists.txt b/apps/mosquitto_signal/CMakeLists.txt index c546ebe8..77a7cea6 100644 --- a/apps/mosquitto_signal/CMakeLists.txt +++ b/apps/mosquitto_signal/CMakeLists.txt @@ -8,7 +8,7 @@ else() set(SRC ${SRC} signal_unix.c) endif() -add_executable(mosquitto_signal ${SRC}) +custom_add_executable(mosquitto_signal ${SRC}) target_include_directories(mosquitto_signal PRIVATE "${mosquitto_SOURCE_DIR}" @@ -17,6 +17,6 @@ target_include_directories(mosquitto_signal PRIVATE "${mosquitto_SOURCE_DIR}/src" ) -install(TARGETS mosquitto_signal +custom_install(TARGETS mosquitto_signal RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" ) diff --git a/client/CMakeLists.txt b/client/CMakeLists.txt index 1b7e0723..48c273f7 100644 --- a/client/CMakeLists.txt +++ b/client/CMakeLists.txt @@ -21,9 +21,9 @@ if(WITH_WEBSOCKETS AND WITH_WEBSOCKETS_BUILTIN) target_compile_definitions(client-common INTERFACE "-DWITH_WEBSOCKETS=WS_IS_BUILTIN") endif() -add_executable(mosquitto_pub pub_client.c pub_shared.c) -add_executable(mosquitto_sub sub_client.c sub_client_output.c) -add_executable(mosquitto_rr rr_client.c pub_shared.c sub_client_output.c) +custom_add_executable(mosquitto_pub pub_client.c pub_shared.c) +custom_add_executable(mosquitto_sub sub_client.c sub_client_output.c) +custom_add_executable(mosquitto_rr rr_client.c pub_shared.c sub_client_output.c) if (WITH_THREADING AND NOT WIN32) @@ -51,6 +51,6 @@ target_link_libraries(mosquitto_pub PRIVATE client-common libmosquitto_common) target_link_libraries(mosquitto_sub PRIVATE client-common libmosquitto_common) target_link_libraries(mosquitto_rr PRIVATE client-common libmosquitto_common) -install(TARGETS mosquitto_pub RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}") -install(TARGETS mosquitto_sub RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}") -install(TARGETS mosquitto_rr RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}") +custom_install(TARGETS mosquitto_pub RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}") +custom_install(TARGETS mosquitto_sub RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}") +custom_install(TARGETS mosquitto_rr RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}") diff --git a/fuzzing/CMakeLists.txt b/fuzzing/CMakeLists.txt new file mode 100644 index 00000000..76168b66 --- /dev/null +++ b/fuzzing/CMakeLists.txt @@ -0,0 +1,53 @@ +add_library(fuzzing-common INTERFACE) +if(DEFINED ENV{LIB_FUZZING_ENGINE}) + set(FUZZ_FLAGS "$ENV{LIB_FUZZING_ENGINE}") + target_compile_options(fuzzing-common INTERFACE ${FUZZ_FLAGS}) + target_link_options(fuzzing-common INTERFACE ${FUZZ_FLAGS}) +endif() + +if(DEFINED ENV{OUT}) + set(OUT "$ENV{OUT}") +else() + set(OUT "${CMAKE_BINARY_DIR}") +endif() + +if(DEFINED ENV{SRC} AND EXISTS "$ENV{SRC}/LPM/src/libprotobuf-mutator.a") + set(LPM_DIR "$ENV{SRC}/LPM") + add_library(libprotobuf_mutator INTERFACE) + target_include_directories(libprotobuf_mutator INTERFACE + $ENV{SRC}/libprotobuf-mutator + $ENV{SRC}/LPM/external.protobuf/include + ) + file(GLOB LPM_LIBS + "$ENV{SRC}/LPM/src/libfuzzer/*.a" + "$ENV{SRC}/LPM/src/*.a" + "$ENV{SRC}/LPM/external.protobuf/lib/*.a" + ) + target_link_libraries(libprotobuf_mutator INTERFACE + "$" + ) + set(LPM_PROTOC "$ENV{SRC}/LPM/external.protobuf/bin/protoc") +else() + message(FATAL_ERROR "libprotobuf-mutator not found") +endif() + +function(lpm_protoc name) + message("${name}") + message("${LPM_PROTOC}") + add_custom_command( + OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${name}.pb.cc ${CMAKE_CURRENT_BINARY_DIR}/${name}.pb.h + COMMAND ${LPM_PROTOC} + --cpp_out=${CMAKE_CURRENT_BINARY_DIR} + --proto_path=${CMAKE_CURRENT_SOURCE_DIR} + ${name}.proto + DEPENDS ${name}.proto + COMMENT "protoc ${name}.proto" + VERBATIM + ) +endfunction() + +add_subdirectory(apps) +add_subdirectory(broker) +add_subdirectory(corpora) +add_subdirectory(libcommon) +add_subdirectory(plugins) diff --git a/fuzzing/apps/CMakeLists.txt b/fuzzing/apps/CMakeLists.txt new file mode 100644 index 00000000..507740bc --- /dev/null +++ b/fuzzing/apps/CMakeLists.txt @@ -0,0 +1,2 @@ +add_subdirectory(db_dump) +add_subdirectory(mosquitto_passwd) diff --git a/fuzzing/apps/db_dump/CMakeLists.txt b/fuzzing/apps/db_dump/CMakeLists.txt new file mode 100644 index 00000000..923e4748 --- /dev/null +++ b/fuzzing/apps/db_dump/CMakeLists.txt @@ -0,0 +1,19 @@ +function(add_db_dump_fuzzer name) + add_executable(${name} ${name}.cpp) + target_include_directories(${name} PRIVATE + ${PROJECT_SOURCE_DIR} + ${PROJECT_SOURCE_DIR}/include + ) + target_link_libraries(${name} PUBLIC + fuzzing-common + libmosquitto_common + mosquitto_db_dump + ) + install(TARGETS ${name} + RUNTIME DESTINATION "${OUT}" + ) +endfunction() + +add_db_dump_fuzzer(db_dump_fuzz_load) +add_db_dump_fuzzer(db_dump_fuzz_load_client_stats) +add_db_dump_fuzzer(db_dump_fuzz_load_stats) diff --git a/fuzzing/apps/mosquitto_passwd/CMakeLists.txt b/fuzzing/apps/mosquitto_passwd/CMakeLists.txt new file mode 100644 index 00000000..17ed878c --- /dev/null +++ b/fuzzing/apps/mosquitto_passwd/CMakeLists.txt @@ -0,0 +1,19 @@ +function(add_passwd_fuzzer name) + add_executable(${name} ${name}.cpp) + target_include_directories(${name} PRIVATE + ${PROJECT_SOURCE_DIR} + ${PROJECT_SOURCE_DIR}/include + ${PROJECT_SOURCE_DIR}/lib + ${PROJECT_SOURCE_DIR}/src + ) + target_link_libraries(${name} PUBLIC + fuzzing-common + libmosquitto_common + mosquitto_passwd + ) + install(TARGETS ${name} + RUNTIME DESTINATION "${OUT}" + ) +endfunction() + +add_passwd_fuzzer(mosquitto_passwd_fuzz_load) diff --git a/fuzzing/broker/CMakeLists.txt b/fuzzing/broker/CMakeLists.txt new file mode 100644 index 00000000..5d10433b --- /dev/null +++ b/fuzzing/broker/CMakeLists.txt @@ -0,0 +1,83 @@ +add_library(broker-fuzzing-common INTERFACE) +target_compile_definitions(broker-fuzzing-common INTERFACE + WITH_BRIDGE + WITH_BROKER + WITH_CONTROL + WITH_EPOLL + WITH_MEMORY_TRACKING + WITH_PERSISTENCE + WITH_SOCKS + WITH_SYSTEMD + WITH_SYS_TREE + WITH_TLS + WITH_TLS_PSK + WITH_UNIX_SOCKETS + WITH_WEBSOCKETS=WS_IS_BUILTIN +) + +target_include_directories(broker-fuzzing-common INTERFACE + ${PROJECT_SOURCE_DIR}/include + ${PROJECT_SOURCE_DIR}/lib + ${PROJECT_SOURCE_DIR}/src +) + +target_link_libraries(broker-fuzzing-common INTERFACE + fuzzing-common + libmosquitto_common + mosquitto +) + +add_library(fuzz-packet-read-base OBJECT + fuzz_packet_read_base.c + fuzz_packet_read_base.h +) +target_link_libraries(fuzz-packet-read-base PUBLIC + broker-fuzzing-common +) + +function(add_broker_fuzzer name) + add_executable(${name} ${name}.cpp) + target_link_libraries(${name} PRIVATE + broker-fuzzing-common + ) + install(TARGETS ${name} + RUNTIME DESTINATION "${OUT}" + ) +endfunction() + +function(add_broker_packet_fuzzer name) + add_executable(${name} ${name}.cpp) + target_link_libraries(${name} PRIVATE + broker-fuzzing-common + fuzz-packet-read-base + ) + install(TARGETS ${name} + RUNTIME DESTINATION "${OUT}" + ) +endfunction() + +add_broker_fuzzer(broker_fuzz_acl_file) +add_broker_fuzzer(broker_fuzz_password_file) +add_broker_fuzzer(broker_fuzz_proxy_v1) +add_broker_fuzzer(broker_fuzz_proxy_v2) +add_broker_fuzzer(broker_fuzz_psk_file) +add_broker_fuzzer(broker_fuzz_queue_msg) +add_broker_fuzzer(broker_fuzz_test_config) + +add_broker_packet_fuzzer(broker_fuzz_handle_auth) +add_broker_packet_fuzzer(broker_fuzz_handle_connect) +add_broker_packet_fuzzer(broker_fuzz_handle_publish) +add_broker_packet_fuzzer(broker_fuzz_handle_subscribe) +add_broker_packet_fuzzer(broker_fuzz_handle_unsubscribe) +add_broker_packet_fuzzer(broker_fuzz_read_handle) + +#cp ${R}/fuzzing/corpora/broker_acl_file_seed_corpus.zip ${OUT}/broker_fuzz_acl_file_seed_corpus.zip +#cp ${R}/fuzzing/corpora/broker_acl_file.dict ${OUT}/broker_fuzz_acl_file.dict +#cp ${R}/fuzzing/corpora/broker_password_file_seed_corpus.zip ${OUT}/broker_fuzz_password_file_seed_corpus.zip +#cp ${R}/fuzzing/corpora/broker_fuzz_proxy_v1_seed_corpus.zip ${OUT}/broker_fuzz_proxy_v1_seed_corpus.zip +#cp ${R}/fuzzing/corpora/broker_fuzz_proxy_v2_seed_corpus.zip ${OUT}/broker_fuzz_proxy_v2_seed_corpus.zip +#cp ${R}/fuzzing/corpora/broker_psk_file_seed_corpus.zip ${OUT}/broker_fuzz_psk_file_seed_corpus.zip +#cp ${R}/fuzzing/corpora/broker_queue_msg_seed_corpus.zip ${OUT}/broker_fuzz_queue_msg_seed_corpus.zip +#cp ${R}/fuzzing/corpora/broker_packet_seed_corpus.zip ${OUT}/broker_fuzz_read_handle_seed_corpus.zip +#cp ${R}/fuzzing/corpora/broker_fuzz_test_config_seed_corpus.zip ${OUT}/broker_fuzz_test_config_seed_corpus.zip +#cp ${R}/fuzzing/corpora/broker_conf.dict ${OUT}/broker_fuzz_test_config.dict diff --git a/fuzzing/corpora/CMakeLists.txt b/fuzzing/corpora/CMakeLists.txt new file mode 100644 index 00000000..a65c3523 --- /dev/null +++ b/fuzzing/corpora/CMakeLists.txt @@ -0,0 +1,10 @@ +install(FILES broker_acl_file.dict DESTINATION ${OUT}) +install(FILES broker_acl_file_seed_corpus.zip DESTINATION ${OUT}) +install(FILES broker_conf.dict DESTINATION ${OUT}) +install(FILES broker_fuzz_proxy_v1_seed_corpus.zip DESTINATION ${OUT}) +install(FILES broker_fuzz_proxy_v2_seed_corpus.zip DESTINATION ${OUT}) +install(FILES broker_fuzz_test_config_seed_corpus.zip DESTINATION ${OUT}) +install(FILES broker_password_file_seed_corpus.zip DESTINATION ${OUT}) +install(FILES broker_psk_file_seed_corpus.zip DESTINATION ${OUT}) +install(FILES broker_queue_msg_seed_corpus.zip DESTINATION ${OUT}) +install(FILES dynsec_config_seed_corpus.zip DESTINATION ${OUT}) diff --git a/fuzzing/libcommon/CMakeLists.txt b/fuzzing/libcommon/CMakeLists.txt new file mode 100644 index 00000000..8854e42b --- /dev/null +++ b/fuzzing/libcommon/CMakeLists.txt @@ -0,0 +1,37 @@ +function(add_libcommon_fuzzer name) + add_executable(${name} ${name}.cpp) + target_include_directories(${name} PRIVATE + ${PROJECT_SOURCE_DIR} + ${PROJECT_SOURCE_DIR}/include + ) + target_link_libraries(${name} PUBLIC + fuzzing-common + libmosquitto_common + ) + install(TARGETS ${name} + RUNTIME DESTINATION "${OUT}" + ) +endfunction() + +function(add_libcommon_lpm_fuzzer name) + lpm_protoc(${name}) + add_libcommon_fuzzer(${name}) + target_sources(${name} PRIVATE + ${CMAKE_CURRENT_BINARY_DIR}/${name}.pb.cc + ${CMAKE_CURRENT_BINARY_DIR}/${name}.pb.h + ) + target_include_directories(${name} PRIVATE + ${CMAKE_CURRENT_BINARY_DIR} + ) + target_link_libraries(${name} PUBLIC + libprotobuf_mutator + ) +endfunction() + +add_libcommon_fuzzer(libcommon_fuzz_pub_topic_check2) +add_libcommon_fuzzer(libcommon_fuzz_sub_topic_check2) +add_libcommon_fuzzer(libcommon_fuzz_topic_tokenise) +add_libcommon_fuzzer(libcommon_fuzz_utf8) + +add_libcommon_lpm_fuzzer(libcommon_fuzz_property) +add_libcommon_lpm_fuzzer(libcommon_fuzz_topic_matching) diff --git a/fuzzing/plugins/CMakeLists.txt b/fuzzing/plugins/CMakeLists.txt new file mode 100644 index 00000000..4993500f --- /dev/null +++ b/fuzzing/plugins/CMakeLists.txt @@ -0,0 +1 @@ +add_subdirectory(dynamic-security) diff --git a/fuzzing/plugins/dynamic-security/CMakeLists.txt b/fuzzing/plugins/dynamic-security/CMakeLists.txt new file mode 100644 index 00000000..f9eb5cc8 --- /dev/null +++ b/fuzzing/plugins/dynamic-security/CMakeLists.txt @@ -0,0 +1,36 @@ +function(add_dynsec_fuzzer name) + add_executable(${name} ${name}.cpp) + target_compile_definitions(${name} PRIVATE + WITH_BRIDGE + WITH_BROKER + WITH_CONTROL + WITH_EPOLL + WITH_MEMORY_TRACKING + WITH_PERSISTENCE + WITH_SOCKS + WITH_SYSTEMD + WITH_SYS_TREE + WITH_TLS + WITH_TLS_PSK + WITH_UNIX_SOCKETS + WITH_WEBSOCKETS=WS_IS_BUILTIN + ) + target_include_directories(${name} PRIVATE + ${PROJECT_SOURCE_DIR} + ${PROJECT_SOURCE_DIR}/include + ${PROJECT_SOURCE_DIR}/lib + ${PROJECT_SOURCE_DIR}/src + ) + target_link_libraries(${name} PUBLIC + fuzzing-common + libmosquitto_common + mosquitto_dynamic_security + mosquitto + ) + install(TARGETS ${name} + RUNTIME DESTINATION "${OUT}" + ) +endfunction() + +add_dynsec_fuzzer(dynsec_fuzz_load) +#cp ${R}/fuzzing/corpora/dynsec_config_seed_corpus.zip ${OUT}/$@_seed_corpus.zip diff --git a/fuzzing/scripts/oss-fuzz-dependencies.sh b/fuzzing/scripts/oss-fuzz-dependencies.sh index 34e44d8f..b3eefebd 100755 --- a/fuzzing/scripts/oss-fuzz-dependencies.sh +++ b/fuzzing/scripts/oss-fuzz-dependencies.sh @@ -18,6 +18,9 @@ set -e +export CC=clang +export CXX=clang++ + # Note that sqlite3 is required as a build dep of a plugin which is not # currently part of fuzz testing. Once it is part of fuzz testing, sqlite will # need to be built statically. @@ -41,6 +44,11 @@ if [ ! -d ${SRC}/LPM ]; then mkdir ${SRC}/LPM \ && cd ${SRC}/LPM \ - && cmake ../libprotobuf-mutator -GNinja -DLIB_PROTO_MUTATOR_DOWNLOAD_PROTOBUF=ON -DLIB_PROTO_MUTATOR_TESTING=OFF -DCMAKE_BUILD_TYPE=Release \ + && cmake ../libprotobuf-mutator -GNinja \ + -DCMAKE_POSITION_INDEPENDENT_CODE=ON \ + -DLIB_PROTO_MUTATOR_DOWNLOAD_PROTOBUF=ON \ + -DLIB_PROTO_MUTATOR_TESTING=OFF \ + -DLIB_PROTO_MUTATOR_EXAMPLES=OFF \ + -DCMAKE_BUILD_TYPE=Release \ && ninja fi diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt index c7e93341..44d34dca 100644 --- a/lib/CMakeLists.txt +++ b/lib/CMakeLists.txt @@ -80,7 +80,7 @@ if(WITH_WEBSOCKETS AND WITH_WEBSOCKETS_BUILTIN) ) endif() -add_library(libmosquitto SHARED +add_library(libmosquitto ${LIB_TYPE_LIBRARY} ${C_SRC} ) @@ -119,7 +119,7 @@ if(UNIX AND NOT APPLE AND NOT AIX) ) endif() -install(TARGETS libmosquitto +custom_install(TARGETS libmosquitto RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}" LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}" @@ -154,7 +154,7 @@ if(WITH_STATIC_LIBRARIES) ) target_compile_definitions(libmosquitto_static PUBLIC "LIBMOSQUITTO_STATIC") - install(TARGETS libmosquitto_static + custom_install(TARGETS libmosquitto_static ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}" ) endif() diff --git a/lib/cpp/CMakeLists.txt b/lib/cpp/CMakeLists.txt index c36995aa..d1be91bd 100644 --- a/lib/cpp/CMakeLists.txt +++ b/lib/cpp/CMakeLists.txt @@ -26,7 +26,7 @@ set_target_properties(mosquittopp PROPERTIES VERSION ${VERSION} SOVERSION 1 ) -install(TARGETS mosquittopp +custom_install(TARGETS mosquittopp RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}" LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}" @@ -57,7 +57,7 @@ if(WITH_STATIC_LIBRARIES) ) target_compile_definitions(mosquittopp_static PUBLIC "LIBMOSQUITTO_STATIC") - install(TARGETS mosquittopp_static + custom_install(TARGETS mosquittopp_static ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}" ) endif() diff --git a/libcommon/CMakeLists.txt b/libcommon/CMakeLists.txt index 6c349a20..1cb2d577 100644 --- a/libcommon/CMakeLists.txt +++ b/libcommon/CMakeLists.txt @@ -94,7 +94,7 @@ set_target_properties(libmosquitto_common PROPERTIES POSITION_INDEPENDENT_CODE 1 ) -install(TARGETS libmosquitto_common +custom_install(TARGETS libmosquitto_common RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}" LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}" diff --git a/man/CMakeLists.txt b/man/CMakeLists.txt index 61de6777..45142dc2 100644 --- a/man/CMakeLists.txt +++ b/man/CMakeLists.txt @@ -28,7 +28,7 @@ if(XSLTPROC AND NOT WIN32) compile_manpage("mosquitto_sub.1") compile_manpage("mqtt.7") - install(FILES + custom_install(FILES mosquitto_ctrl.1 mosquitto_ctrl_dynsec.1 mosquitto_ctrl_shell.1 @@ -40,15 +40,15 @@ if(XSLTPROC AND NOT WIN32) DESTINATION ${CMAKE_INSTALL_MANDIR}/man1 OPTIONAL) - install(FILES libmosquitto.3 DESTINATION ${CMAKE_INSTALL_MANDIR}/man3 OPTIONAL) - install(FILES mosquitto.conf.5 DESTINATION ${CMAKE_INSTALL_MANDIR}/man5 OPTIONAL) - install(FILES + custom_install(FILES libmosquitto.3 DESTINATION ${CMAKE_INSTALL_MANDIR}/man3 OPTIONAL) + custom_install(FILES mosquitto.conf.5 DESTINATION ${CMAKE_INSTALL_MANDIR}/man5 OPTIONAL) + custom_install(FILES mosquitto-tls.7 mosquitto.7 mqtt.7 DESTINATION ${CMAKE_INSTALL_MANDIR}/man7 OPTIONAL ) - install(FILES mosquitto.8 DESTINATION ${CMAKE_INSTALL_MANDIR}/man8 OPTIONAL) + custom_install(FILES mosquitto.8 DESTINATION ${CMAKE_INSTALL_MANDIR}/man8 OPTIONAL) elseif(WIN32) message(WARNING "xsltproc not found: manpages cannot be built") diff --git a/plugins/CMakeLists.txt b/plugins/CMakeLists.txt index 52c1fa3a..e460b8f6 100644 --- a/plugins/CMakeLists.txt +++ b/plugins/CMakeLists.txt @@ -1,5 +1,5 @@ function(add_mosquitto_plugin_no_install PLUGIN_NAME SRCLIST INCLIST LINKLIST) - add_library(${PLUGIN_NAME} MODULE ${SRCLIST}) + add_library(${PLUGIN_NAME} ${LIB_TYPE_PLUGIN} ${SRCLIST}) target_include_directories(${PLUGIN_NAME} PRIVATE ${INCLIST} "${mosquitto_SOURCE_DIR}/" @@ -23,10 +23,10 @@ function(add_mosquitto_plugin PLUGIN_NAME SRCLIST INCLIST LINKLIST) add_mosquitto_plugin_no_install("${PLUGIN_NAME}" "${SRCLIST}" "${INCLIST}" "${LINKLIST}") if(WIN32) - install(TARGETS ${PLUGIN_NAME} + custom_install(TARGETS ${PLUGIN_NAME} DESTINATION "${CMAKE_INSTALL_BINDIR}") else() - install(TARGETS ${PLUGIN_NAME} + custom_install(TARGETS ${PLUGIN_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}" ) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index f576ef36..d302b278 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,4 +1,4 @@ -add_executable(mosquitto +custom_add_executable(mosquitto acl_file.c acl_file.h ../plugins/acl-file/acl_check.c ../plugins/acl-file/acl_parse.c @@ -311,6 +311,6 @@ if(UNIX) endif() endif() -install(TARGETS mosquitto +custom_install(TARGETS mosquitto RUNTIME DESTINATION "${CMAKE_INSTALL_SBINDIR}" )