diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index b9a96fe7..962f9928 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -3,66 +3,38 @@ name: Windows build on: workflow_dispatch: push: - branches: [ "master", "fixes" ] + branches: [ "master", "fixes", "develop" ] tags: [ "v[0-9]+.*" ] pull_request: - branches: [ "master", "fixes" ] + branches: [ "master", "fixes", "develop" ] env: # Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.) BUILD_TYPE: Release jobs: - - cjson: - runs-on: windows-2022 - steps: - - uses: actions/checkout@v3 - with: - repository: DaveGamble/cJSON - ref: v1.7.15 - - - name: Configure CMake cJSON - run: cmake -B ${{github.workspace}}/build64 -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DENABLE_CJSON_TEST=OFF -DBUILD_SHARED_LIBS=OFF -DBUILD_SHARED_AND_STATIC_LIBS=OFF -DCJSON_BUILD_SHARED_LIBS=OFF -DCJSON_OVERRIDE_BUILD_SHARED_LIBS=OFF -DCMAKE_GENERATOR_PLATFORM=x64 - - - name: Build cJSON - run: cmake --build ${{github.workspace}}/build64 --config ${{env.BUILD_TYPE}} - - - name: Install cJSON - run: cmake --install ${{github.workspace}}/build64 --config ${{env.BUILD_TYPE}} - - - name: Upload cJSON - uses: actions/upload-artifact@v3 - with: - name: cjson-bin - path: C:\Program Files\cJSON - mosquitto: runs-on: windows-2022 - needs: - - cjson - env: - CJSON_DIR: C:\Program Files\cJSON steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - - name: install openssl - run: choco install openssl - - name: Download cJSON - uses: actions/download-artifact@v3 + - name: vcpkg build + uses: johnwason/vcpkg-action@v6 + id: vcpkg with: - name: cjson-bin - path: C:\Program Files\cJSON + manifest-dir: ${{ github.workspace }} + triplet: x64-windows-release + token: ${{ github.token }} + github-binarycache: true - name: Configure CMake - run: cmake -B ${{github.workspace}}/build64 -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DWITH_TESTS=OFF -DCMAKE_GENERATOR_PLATFORM=x64 -DCJSON_INCLUDE_DIR="C:/Program Files/cJSON/include" -DCJSON_LIBRARY="C:/Program Files/cJSON/lib/cjson.lib" - + run: cmake -B ${{github.workspace}}/build64 -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DWITH_TESTS=OFF -DCMAKE_GENERATOR_PLATFORM=x64 -DCMAKE_TOOLCHAIN_FILE=${{ github.workspace }}/vcpkg/scripts/buildsystems/vcpkg.cmake -DVCPKG_TARGET_TRIPLET=x64-windows-release -DVCPKG_MANIFEST_MODE=ON - name: Build run: cmake --build ${{github.workspace}}/build64 --config ${{env.BUILD_TYPE}} - - uses: suisei-cn/actions-download-file@v1.0.1 + - uses: suisei-cn/actions-download-file@v1.6.0 id: vcredist name: Download VC redistributable with: @@ -70,12 +42,12 @@ jobs: target: ${{github.workspace}}/installer/ - name: Installer - uses: joncloud/makensis-action@v3.7 + uses: joncloud/makensis-action@v4 with: - script-file: ${{github.workspace}}/installer/mosquitto.nsi + script-file: ${{github.workspace}}/installer/mosquitto64.nsi - name: Upload installer to artifacts - uses: actions/upload-artifact/@v2 + uses: actions/upload-artifact@v4 with: name: installer path: ${{ github.workspace }}/installer/mosquitto*.exe diff --git a/CMakeLists.txt b/CMakeLists.txt index 088e9a92..e275b7f6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -66,25 +66,9 @@ 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) - find_package(Threads REQUIRED) - set (PTHREAD_LIBRARIES Threads::Threads) - set (PTHREAD_INCLUDE_DIR "") - elseif (ANDROID) - set (PTHREAD_LIBRARIES "") - set (PTHREAD_INCLUDE_DIR "") - else (WIN32) - find_library(LIBPTHREAD pthread) - if (LIBPTHREAD) - set (PTHREAD_LIBRARIES pthread) - else (LIBPTHREAD) - set (PTHREAD_LIBRARIES "") - endif() - set (PTHREAD_INCLUDE_DIR "") - endif (WIN32) -else (WITH_THREADING) - set (PTHREAD_LIBRARIES "") - set (PTHREAD_INCLUDE_DIR "") + if(WIN32) + find_package(Pthreads4W REQUIRED) + endif() endif (WITH_THREADING) option(WITH_DLT "Include DLT support?" OFF) diff --git a/ChangeLog.txt b/ChangeLog.txt index a3ab2ebe..78d48216 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -5,6 +5,9 @@ Broker: - Fix assert failure when loading a persistence file that contains subscriptions with no client id. +Build: +- Thread support is re-enabled on Windows. + 2.0.18 - 2023-09-18 =================== diff --git a/installer/mosquitto64.nsi b/installer/mosquitto64.nsi index 7c9a544b..f6ab610c 100644 --- a/installer/mosquitto64.nsi +++ b/installer/mosquitto64.nsi @@ -59,12 +59,15 @@ Section "Files" SecInstall File "..\README.md" File "..\README-windows.txt" File "..\README-letsencrypt.md" - ;File "C:\pthreads\Pre-built.2\dll\x64\pthreadVC2.dll" - File "C:\OpenSSL-Win64\bin\libssl-1_1-x64.dll" - File "C:\OpenSSL-Win64\bin\libcrypto-1_1-x64.dll" + File "..\SECURITY.md" File "..\edl-v10" File "..\epl-v20" + File "..\build64\vcpkg_installed\x64-windows-release\bin\cjson.dll" + File "..\build64\vcpkg_installed\x64-windows-release\bin\libcrypto-3-x64.dll" + File "..\build64\vcpkg_installed\x64-windows-release\bin\libssl-3-x64.dll" + File "..\build64\vcpkg_installed\x64-windows-release\bin\pthreadVC3.dll" + SetOutPath "$INSTDIR\devel" File "..\build64\lib\Release\mosquitto.lib" File "..\build64\lib\cpp\Release\mosquittopp.lib" @@ -88,42 +91,51 @@ Section "Files" SecInstall SendMessage ${HWND_BROADCAST} ${WM_WININICHANGE} 0 "STR:Environment" /TIMEOUT=5000 SectionEnd +Section "Visual Studio Runtime" + SetOutPath "$INSTDIR" + File "VC_redist.x64.exe" + ExecWait '"$INSTDIR\VC_redist.x64.exe" /quiet /norestart' + Delete "$INSTDIR\VC_redist.x64.exe" +SectionEnd + Section "Service" SecService ExecWait '"$INSTDIR\mosquitto.exe" install' SectionEnd Section "Uninstall" ExecWait '"$INSTDIR\mosquitto.exe" uninstall' + Delete "$INSTDIR\mosquitto.dll" Delete "$INSTDIR\mosquitto.exe" Delete "$INSTDIR\mosquitto_ctrl.exe" Delete "$INSTDIR\mosquitto_passwd.exe" Delete "$INSTDIR\mosquitto_pub.exe" - Delete "$INSTDIR\mosquitto_sub.exe" Delete "$INSTDIR\mosquitto_rr.exe" - Delete "$INSTDIR\mosquitto.dll" + Delete "$INSTDIR\mosquitto_sub.exe" Delete "$INSTDIR\mosquittopp.dll" Delete "$INSTDIR\mosquitto_dynamic_security.dll" Delete "$INSTDIR\aclfile.example" Delete "$INSTDIR\ChangeLog.txt" Delete "$INSTDIR\mosquitto.conf" Delete "$INSTDIR\pwfile.example" + Delete "$INSTDIR\NOTICE.md" Delete "$INSTDIR\README.md" Delete "$INSTDIR\README-windows.txt" Delete "$INSTDIR\README-letsencrypt.md" - ;Delete "$INSTDIR\pthreadVC2.dll" - Delete "$INSTDIR\libssl-1_1-x64.dll" - Delete "$INSTDIR\libcrypto-1_1-x64.dll" + Delete "$INSTDIR\SECURITY.md" Delete "$INSTDIR\edl-v10" Delete "$INSTDIR\epl-v20" + Delete "$INSTDIR\cjson.dll" + Delete "$INSTDIR\libcrypto-3-x64.dll" + Delete "$INSTDIR\libssl-3-x64.dll" + Delete "$INSTDIR\pthreadVC3.dll" + Delete "$INSTDIR\devel\mosquitto.h" - Delete "$INSTDIR\devel\mosquitto.lib" Delete "$INSTDIR\devel\mosquitto_broker.h" Delete "$INSTDIR\devel\mosquitto_plugin.h" - Delete "$INSTDIR\devel\mosquitto_plugin.h" Delete "$INSTDIR\devel\mosquittopp.h" - Delete "$INSTDIR\devel\mosquittopp.lib" Delete "$INSTDIR\devel\mqtt_protocol.h" + RMDir "$INSTDIR\devel\mosquitto" RMDir "$INSTDIR\devel" Delete "$INSTDIR\Uninstall.exe" @@ -141,4 +153,3 @@ LangString DESC_SecService ${LANG_ENGLISH} "Install mosquitto as a Windows servi !insertmacro MUI_DESCRIPTION_TEXT ${SecInstall} $(DESC_SecInstall) !insertmacro MUI_DESCRIPTION_TEXT ${SecService} $(DESC_SecService) !insertmacro MUI_FUNCTION_DESCRIPTION_END - diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt index f0f71132..de53e8bd 100644 --- a/lib/CMakeLists.txt +++ b/lib/CMakeLists.txt @@ -5,8 +5,8 @@ endif (WITH_LIB_CPP) include_directories(${mosquitto_SOURCE_DIR} ${mosquitto_SOURCE_DIR}/lib ${mosquitto_SOURCE_DIR}/include - ${STDBOOL_H_PATH} ${STDINT_H_PATH} - ${OPENSSL_INCLUDE_DIR} ${PTHREAD_INCLUDE_DIR}) + ${STDBOOL_H_PATH} ${STDINT_H_PATH}) + link_directories(${mosquitto_SOURCE_DIR}/lib) if (WITH_BUNDLED_DEPS) @@ -59,7 +59,7 @@ set(C_SRC util_mosq.c util_topic.c util_mosq.h will_mosq.c will_mosq.h) -set (LIBRARIES ${OPENSSL_LIBRARIES} ${PTHREAD_LIBRARIES}) +set (LIBRARIES ${OPENSSL_LIBRARIES}) if (UNIX AND NOT APPLE AND NOT ANDROID) find_library(LIBRT rt) @@ -88,7 +88,18 @@ set_target_properties(libmosquitto PROPERTIES POSITION_INDEPENDENT_CODE 1 ) -target_link_libraries(libmosquitto ${LIBRARIES}) +target_link_libraries(libmosquitto PRIVATE ${LIBRARIES}) + +if (WITH_THREADING) + if(WIN32) + target_link_libraries(libmosquitto PRIVATE PThreads4W::PThreads4W) + else() + set(THREADS_PREFER_PTHREAD_FLAG ON) + find_package(Threads REQUIRED) + + target_link_libraries(libmosquitto PRIVATE Threads::Threads) + endif() +endif() set_target_properties(libmosquitto PROPERTIES OUTPUT_NAME mosquitto diff --git a/man/CMakeLists.txt b/man/CMakeLists.txt index 79b419a0..8badb8c2 100644 --- a/man/CMakeLists.txt +++ b/man/CMakeLists.txt @@ -5,7 +5,7 @@ # because the install is optional. find_program(XSLTPROC xsltproc OPTIONAL) -if(XSLTPROC) +if(XSLTPROC AND NOT WIN32) function(compile_manpage page) add_custom_command(OUTPUT ${PROJECT_SOURCE_DIR}/man/${page} COMMAND xsltproc ${PROJECT_SOURCE_DIR}/man/${page}.xml -o ${PROJECT_SOURCE_DIR}/man/ diff --git a/set-version.sh b/set-version.sh index b0a179d3..563accef 100755 --- a/set-version.sh +++ b/set-version.sh @@ -15,3 +15,5 @@ sed -i "s/^set (VERSION .*)/set (VERSION ${MAJOR}.${MINOR}.${REVISION})/" CMakeL sed -i "s/^!define VERSION .*/!define VERSION ${MAJOR}.${MINOR}.${REVISION}/" installer/*.nsi sed -i "s/^version: .*/version: ${MAJOR}.${MINOR}.${REVISION}/" snap/snapcraft.yaml + +sed -i "s/\"version-string\": \".*\",/\"version-string\": \"${MAJOR}.${MINOR}.${REVISION}\",/ vcpkg.json diff --git a/vcpkg.json b/vcpkg.json new file mode 100644 index 00000000..27a73d08 --- /dev/null +++ b/vcpkg.json @@ -0,0 +1,9 @@ +{ + "name": "mosquitto", + "version-string": "2.0.18", + "dependencies": [ + "cjson", + "openssl", + "pthreads" + ] +}