diff --git a/.github/workflows/libzedmd.yml b/.github/workflows/libzedmd.yml index ba41d92..26954dc 100644 --- a/.github/workflows/libzedmd.yml +++ b/.github/workflows/libzedmd.yml @@ -46,9 +46,9 @@ jobs: fail-fast: false matrix: include: - - { os: windows-2025, platform: win, arch: x64, type: Release } - - { os: windows-2025, platform: win, arch: x64, type: Debug } - - { os: windows-2025, platform: win, arch: x86, type: Release } + - { os: windows-2025-vs2026, platform: win, arch: x64, type: Release } + - { os: windows-2025-vs2026, platform: win, arch: x64, type: Debug } + - { os: windows-2025-vs2026, platform: win, arch: x86, type: Release } - { os: windows-2025, platform: win-mingw, arch: x64, type: Release } - { os: macos-15, platform: macos, arch: arm64, type: Release } - { os: macos-15, platform: macos, arch: x64, type: Release } @@ -64,7 +64,22 @@ jobs: # install dependencies # - if: (matrix.platform == 'win') - uses: microsoft/setup-msbuild@v2 + uses: microsoft/setup-msbuild@v3 + - if: (matrix.platform == 'win') + run: | + if [[ "${{ matrix.arch }}" == "x64" ]]; then + /c/msys64/usr/bin/bash.exe -l -c "pacman -S --noconfirm \ + make diffutils autoconf automake libtool \ + mingw-w64-ucrt-x86_64-gcc \ + mingw-w64-ucrt-x86_64-libwinpthread \ + mingw-w64-ucrt-x86_64-cmake" + else + /c/msys64/usr/bin/bash.exe -l -c "pacman -S --noconfirm \ + make diffutils autoconf automake libtool \ + mingw-w64-i686-gcc \ + mingw-w64-i686-libwinpthread \ + mingw-w64-i686-cmake" + fi - if: (matrix.platform == 'win-mingw') run: | /c/msys64/usr/bin/bash.exe -l -c "pacman -S --noconfirm \ @@ -87,13 +102,13 @@ jobs: ./platforms/${{ matrix.platform }}/${{ matrix.arch }}/external.sh if [[ "${{ matrix.arch }}" == "x64" ]]; then cmake \ - -G "Visual Studio 17 2022" \ + -G "Visual Studio 18 2026" \ -DPLATFORM=${{ matrix.platform }} \ -DARCH=${{ matrix.arch }} \ -B build else cmake \ - -G "Visual Studio 17 2022" \ + -G "Visual Studio 18 2026" \ -A Win32 \ -DPLATFORM=${{ matrix.platform }} \ -DARCH=${{ matrix.arch }} \ diff --git a/CMakeLists.txt b/CMakeLists.txt index b7becf7..c33a202 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -339,18 +339,24 @@ if(POST_BUILD_COPY_EXT_LIBS AND (PLATFORM STREQUAL "win" OR PLATFORM STREQUAL "w COMMAND "${CMAKE_COMMAND}" -E copy "${CMAKE_SOURCE_DIR}/third-party/build-libs/${PLATFORM}/${ARCH}/cargs64.lib" "${CMAKE_BINARY_DIR}" COMMAND "${CMAKE_COMMAND}" -E copy "${CMAKE_SOURCE_DIR}/third-party/runtime-libs/${PLATFORM}/${ARCH}/cargs64.dll" "${CMAKE_BINARY_DIR}" COMMAND "${CMAKE_COMMAND}" -E copy "${CMAKE_SOURCE_DIR}/third-party/build-libs/${PLATFORM}/${ARCH}/libserialport64.lib" "${CMAKE_BINARY_DIR}" - COMMAND "${CMAKE_COMMAND}" -E copy "${CMAKE_SOURCE_DIR}/third-party/runtime-libs/${PLATFORM}/${ARCH}/libserialport64.dll" "${CMAKE_BINARY_DIR}" + COMMAND "${CMAKE_COMMAND}" -E copy "${CMAKE_SOURCE_DIR}/third-party/runtime-libs/${PLATFORM}/${ARCH}/libserialport64-0.dll" "${CMAKE_BINARY_DIR}" COMMAND "${CMAKE_COMMAND}" -E copy "${CMAKE_SOURCE_DIR}/third-party/build-libs/${PLATFORM}/${ARCH}/sockpp64.lib" "${CMAKE_BINARY_DIR}" COMMAND "${CMAKE_COMMAND}" -E copy "${CMAKE_SOURCE_DIR}/third-party/runtime-libs/${PLATFORM}/${ARCH}/sockpp64.dll" "${CMAKE_BINARY_DIR}" + COMMAND "${CMAKE_COMMAND}" -E copy "${CMAKE_SOURCE_DIR}/third-party/runtime-libs/${PLATFORM}/${ARCH}/libgcc_s_seh-1.dll" "${CMAKE_BINARY_DIR}" + COMMAND "${CMAKE_COMMAND}" -E copy "${CMAKE_SOURCE_DIR}/third-party/runtime-libs/${PLATFORM}/${ARCH}/libstdc++-6.dll" "${CMAKE_BINARY_DIR}" + COMMAND "${CMAKE_COMMAND}" -E copy "${CMAKE_SOURCE_DIR}/third-party/runtime-libs/${PLATFORM}/${ARCH}/libwinpthread-1.dll" "${CMAKE_BINARY_DIR}" ) else() add_custom_command(TARGET copy_ext_libs POST_BUILD COMMAND "${CMAKE_COMMAND}" -E copy "${CMAKE_SOURCE_DIR}/third-party/build-libs/${PLATFORM}/${ARCH}/cargs.lib" "${CMAKE_BINARY_DIR}" COMMAND "${CMAKE_COMMAND}" -E copy "${CMAKE_SOURCE_DIR}/third-party/runtime-libs/${PLATFORM}/${ARCH}/cargs.dll" "${CMAKE_BINARY_DIR}" COMMAND "${CMAKE_COMMAND}" -E copy "${CMAKE_SOURCE_DIR}/third-party/build-libs/${PLATFORM}/${ARCH}/libserialport.lib" "${CMAKE_BINARY_DIR}" - COMMAND "${CMAKE_COMMAND}" -E copy "${CMAKE_SOURCE_DIR}/third-party/runtime-libs/${PLATFORM}/${ARCH}/libserialport.dll" "${CMAKE_BINARY_DIR}" + COMMAND "${CMAKE_COMMAND}" -E copy "${CMAKE_SOURCE_DIR}/third-party/runtime-libs/${PLATFORM}/${ARCH}/libserialport-0.dll" "${CMAKE_BINARY_DIR}" COMMAND "${CMAKE_COMMAND}" -E copy "${CMAKE_SOURCE_DIR}/third-party/build-libs/${PLATFORM}/${ARCH}/sockpp.lib" "${CMAKE_BINARY_DIR}" COMMAND "${CMAKE_COMMAND}" -E copy "${CMAKE_SOURCE_DIR}/third-party/runtime-libs/${PLATFORM}/${ARCH}/sockpp.dll" "${CMAKE_BINARY_DIR}" + COMMAND "${CMAKE_COMMAND}" -E copy "${CMAKE_SOURCE_DIR}/third-party/runtime-libs/${PLATFORM}/${ARCH}/libgcc_s_dw2-1.dll" "${CMAKE_BINARY_DIR}" + COMMAND "${CMAKE_COMMAND}" -E copy "${CMAKE_SOURCE_DIR}/third-party/runtime-libs/${PLATFORM}/${ARCH}/libstdc++-6.dll" "${CMAKE_BINARY_DIR}" + COMMAND "${CMAKE_COMMAND}" -E copy "${CMAKE_SOURCE_DIR}/third-party/runtime-libs/${PLATFORM}/${ARCH}/libwinpthread-1.dll" "${CMAKE_BINARY_DIR}" ) endif() elseif(PLATFORM STREQUAL "win-mingw") diff --git a/README.md b/README.md index 36a6d8f..254cc48 100644 --- a/README.md +++ b/README.md @@ -7,19 +7,35 @@ https://ppuc.github.io/libzedmd/docs/html/class_ze_d_m_d.html ## Compiling -#### Windows x64 (MSVC) +#### Windows (x64) + +Requires MSYS2 for building external dependencies: + +```shell +pacman -S --noconfirm make diffutils \ + mingw-w64-ucrt-x86_64-gcc mingw-w64-ucrt-x86_64-libwinpthread \ + mingw-w64-ucrt-x86_64-cmake +``` ```shell platforms/win/x64/external.sh -cmake -G "Visual Studio 17 2022" -DPLATFORM=win -DARCH=x64 -B build +cmake -G "Visual Studio 18 2026" -DPLATFORM=win -DARCH=x64 -B build cmake --build build --config Release ``` -#### Windows x86 (MSVC) +#### Windows (x86) + +Requires MSYS2 for building external dependencies: + +```shell +pacman -S --noconfirm make diffutils \ + mingw-w64-i686-gcc mingw-w64-i686-libwinpthread \ + mingw-w64-i686-cmake +``` ```shell platforms/win/x86/external.sh -cmake -G "Visual Studio 17 2022" -A Win32 -DPLATFORM=win -DARCH=x86 -B build +cmake -G "Visual Studio 18 2026" -A Win32 -DPLATFORM=win -DARCH=x86 -B build cmake --build build --config Release ``` diff --git a/platforms/win/x64/external.sh b/platforms/win/x64/external.sh index df5643f..93f27f6 100755 --- a/platforms/win/x64/external.sh +++ b/platforms/win/x64/external.sh @@ -2,6 +2,13 @@ set -e +if [ -z "${MSYS2_PATH}" ]; then + MSYS2_PATH="/c/msys64" +fi + +echo "MSYS2_PATH: ${MSYS2_PATH}" +echo "" + source ./platforms/config.sh echo "Building libraries..." @@ -25,7 +32,7 @@ mv cargs-${CARGS_SHA} cargs cd cargs sed -i.bak 's/set_target_properties(cargs PROPERTIES DEFINE_SYMBOL CAG_EXPORTS)/set_target_properties(cargs PROPERTIES DEFINE_SYMBOL CAG_EXPORTS)\nset_target_properties(cargs PROPERTIES OUTPUT_NAME cargs64)/' CMakeLists.txt cmake \ - -G "Visual Studio 17 2022" \ + -G "Visual Studio 18 2026" \ -DBUILD_SHARED_LIBS=ON \ -B build cmake --build build --config ${BUILD_TYPE} @@ -43,13 +50,16 @@ tar xzf libserialport-${LIBSERIALPORT_SHA}.tar.gz mv libserialport-${LIBSERIALPORT_SHA} libserialport cd libserialport cp libserialport.h ../../third-party/include -msbuild.exe libserialport.sln \ - -p:PlatformToolset=v143 \ - -p:TargetName=libserialport64 \ - -p:Platform=x64 \ - -p:Configuration=Release -cp x64/Release/libserialport64.lib ../../third-party/build-libs/win/x64 -cp x64/Release/libserialport64.dll ../../third-party/runtime-libs/win/x64 +sed -i.bak 's/libserialport\.la/libserialport64.la/g; s/libserialport_la/libserialport64_la/g' Makefile.am +CURRENT_DIR="$(pwd)" +MSYSTEM=UCRT64 "${MSYS2_PATH}/usr/bin/bash.exe" -l -c " + cd \"${CURRENT_DIR}\" && + ./autogen.sh && + ./configure && + make -j\$(nproc) +" +cp .libs/libserialport64.dll.a ../../third-party/build-libs/win/x64/libserialport64.lib +cp .libs/libserialport64-0.dll ../../third-party/runtime-libs/win/x64/ cd .. # @@ -73,10 +83,20 @@ mv sockpp-${SOCKPP_SHA} sockpp cd sockpp sed -i.bak 's/set(SOCKPP_SHARED_LIBRARY sockpp)/set(SOCKPP_SHARED_LIBRARY sockpp64)/' CMakeLists.txt cmake \ - -G "Visual Studio 17 2022" \ + -G "Visual Studio 18 2026" \ -B build cmake --build build --config ${BUILD_TYPE} cp -r include/sockpp ../../third-party/include/ cp build/${BUILD_TYPE}/sockpp64.lib ../../third-party/build-libs/win/x64/ cp build/${BUILD_TYPE}/sockpp64.dll ../../third-party/runtime-libs/win/x64/ cd .. + +# +# copy UCRT64 runtime DLLs (needed by MinGW-built DLLs) +# + +UCRT64_BIN="${MSYS2_PATH}/ucrt64/bin" + +cp "${UCRT64_BIN}/libgcc_s_seh-1.dll" ../third-party/runtime-libs/win/x64/ +cp "${UCRT64_BIN}/libstdc++-6.dll" ../third-party/runtime-libs/win/x64/ +cp "${UCRT64_BIN}/libwinpthread-1.dll" ../third-party/runtime-libs/win/x64/ diff --git a/platforms/win/x86/external.sh b/platforms/win/x86/external.sh index b916df3..d82f7b4 100755 --- a/platforms/win/x86/external.sh +++ b/platforms/win/x86/external.sh @@ -2,6 +2,13 @@ set -e +if [ -z "${MSYS2_PATH}" ]; then + MSYS2_PATH="/c/msys64" +fi + +echo "MSYS2_PATH: ${MSYS2_PATH}" +echo "" + source ./platforms/config.sh echo "Building libraries..." @@ -24,7 +31,7 @@ tar xzf cargs-${CARGS_SHA}.tar.gz mv cargs-${CARGS_SHA} cargs cd cargs cmake \ - -G "Visual Studio 17 2022" \ + -G "Visual Studio 18 2026" \ -DBUILD_SHARED_LIBS=ON \ -A Win32 \ -B build @@ -43,12 +50,15 @@ tar xzf libserialport-${LIBSERIALPORT_SHA}.tar.gz mv libserialport-${LIBSERIALPORT_SHA} libserialport cd libserialport cp libserialport.h ../../third-party/include -msbuild.exe libserialport.sln \ - -p:Platform=x86 \ - -p:PlatformToolset=v143 \ - -p:Configuration=Release -cp Release/libserialport.lib ../../third-party/build-libs/win/x86 -cp Release/libserialport.dll ../../third-party/runtime-libs/win/x86 +CURRENT_DIR="$(pwd)" +MSYSTEM=MINGW32 "${MSYS2_PATH}/usr/bin/bash.exe" -l -c " + cd \"${CURRENT_DIR}\" && + ./autogen.sh && + ./configure && + make -j\$(nproc) +" +cp .libs/libserialport.dll.a ../../third-party/build-libs/win/x86/libserialport.lib +cp .libs/libserialport-0.dll ../../third-party/runtime-libs/win/x86/ cd .. # @@ -71,7 +81,7 @@ tar xzf sockpp-${SOCKPP_SHA}.tar.gz mv sockpp-${SOCKPP_SHA} sockpp cd sockpp cmake \ - -G "Visual Studio 17 2022" \ + -G "Visual Studio 18 2026" \ -A Win32 \ -B build cmake --build build --config ${BUILD_TYPE} @@ -79,3 +89,13 @@ cp -r include/sockpp ../../third-party/include/ cp build/${BUILD_TYPE}/sockpp.lib ../../third-party/build-libs/win/x86/ cp build/${BUILD_TYPE}/sockpp.dll ../../third-party/runtime-libs/win/x86/ cd .. + +# +# copy MINGW32 runtime DLLs (needed by MinGW-built DLLs) +# + +MINGW32_BIN="${MSYS2_PATH}/mingw32/bin" + +cp "${MINGW32_BIN}/libgcc_s_dw2-1.dll" ../third-party/runtime-libs/win/x86/ +cp "${MINGW32_BIN}/libstdc++-6.dll" ../third-party/runtime-libs/win/x86/ +cp "${MINGW32_BIN}/libwinpthread-1.dll" ../third-party/runtime-libs/win/x86/