From 70d04b0bca1645ee6d30f66a3af103ac888ceb3e Mon Sep 17 00:00:00 2001 From: cjee21 <77721854+cjee21@users.noreply.github.com> Date: Wed, 1 Oct 2025 21:24:37 +0800 Subject: [PATCH 1/2] CMake: Enable ZLIBSTATIC --- Project/CMake/CMakeLists.txt | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/Project/CMake/CMakeLists.txt b/Project/CMake/CMakeLists.txt index 165f40cafc..29a9db7e5c 100644 --- a/Project/CMake/CMakeLists.txt +++ b/Project/CMake/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.5.0) +cmake_minimum_required(VERSION 3.5.0...3.31) project(MediaInfoLib) @@ -23,6 +23,10 @@ else() option(BUILD_ZENLIB "Build bundled ZenLib" ON) endif() +if (MSVC) + string(APPEND CMAKE_CXX_FLAGS " /EHsc") +endif() + set(LIB_SUFFIX "" CACHE STRING "Define suffix of directory name (32/64)" ) set(BIN_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/bin" CACHE STRING "Directory where binary will install") set(LIB_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX}" CACHE STRING "Directory where library will install") @@ -57,10 +61,10 @@ if (NOT BUILD_ZLIB) else() add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../../../zlib ${CMAKE_CURRENT_BINARY_DIR}/zlib) if(NOT BUILD_SHARED_LIBS) - set(ZLIB_LIBRARIES "${LIB_INSTALL_DIR}/$") + set(ZLIB_LIBRARIES ZLIB::ZLIBSTATIC) endif() if(UNIX AND BUILD_SHARED_LIBS) - target_compile_options(zlibstatic PRIVATE -fPIC) + target_compile_options(ZLIB::ZLIBSTATIC PRIVATE -fPIC) endif() set(ZLIB_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/../../../zlib ${CMAKE_CURRENT_BINARY_DIR}/zlib) endif() @@ -383,7 +387,7 @@ add_library(mediainfo ${MediaInfoLib_SRCS}) target_include_directories(mediainfo INTERFACE ${INCLUDE_INSTALL_DIR}) if(BUILD_ZLIB) - add_dependencies(mediainfo zlibstatic) + add_dependencies(mediainfo ZLIB::ZLIBSTATIC) endif() # disable some features. Maybe it should be enabled. From b33f6f4cdf5aeff393625c2d414212d187fb216b Mon Sep 17 00:00:00 2001 From: cjee21 <77721854+cjee21@users.noreply.github.com> Date: Wed, 1 Oct 2025 21:51:39 +0800 Subject: [PATCH 2/2] CI: Build CMake on Windows --- .github/workflows/MediaInfoLib_Checks.yml | 37 +++++++++++++++++------ 1 file changed, 28 insertions(+), 9 deletions(-) diff --git a/.github/workflows/MediaInfoLib_Checks.yml b/.github/workflows/MediaInfoLib_Checks.yml index 25c75ce72b..a3df4add15 100644 --- a/.github/workflows/MediaInfoLib_Checks.yml +++ b/.github/workflows/MediaInfoLib_Checks.yml @@ -3,10 +3,10 @@ name: Checks on: [push, pull_request] jobs: - Unix: + Build: strategy: matrix: - os: [ubuntu-latest, macos-latest] + os: [ubuntu-latest, macos-latest, windows-latest] environement: [gcc, utf8, minified, minimal, minimal-with-xml, cmake] exclude: - os: macos-latest @@ -15,6 +15,16 @@ jobs: environement: minimal - os: macos-latest environement: minimal-with-xml + - os: windows-latest + environement: gcc + - os: windows-latest + environement: utf8 + - os: windows-latest + environement: minified + - os: windows-latest + environement: minimal + - os: windows-latest + environement: minimal-with-xml include: - environement: gcc CXXFLAGS: "" @@ -40,8 +50,9 @@ jobs: RUN_TESTS: ${{ matrix.RUN_TESTS }} steps: - name: Checkout - uses: actions/checkout@v4 + uses: actions/checkout@v5 - name: Dependencies + if: ${{ runner.os != 'Windows' }} run: | if [ "$RUNNER_OS" == "Linux" ]; then sudo apt-get update -y @@ -50,6 +61,10 @@ jobs: if [ "$RUNNER_OS" == "macOS" ]; then brew install libtool automake fi + - name: zlib + if: ${{ runner.os == 'Windows' }} + run: | + git -C .. clone --depth=1 https://github.com/MediaArea/zlib.git - name: ZenLib run: | git -C .. clone --depth=1 https://github.com/MediaArea/ZenLib.git @@ -82,13 +97,17 @@ jobs: make check - name: CMake Build if: ${{ matrix.environement == 'cmake' }} + shell: bash run: | + if [ "$RUNNER_OS" == "Windows" ]; then + export CXXFLAGS="/std:c++20 /WX /MP" + fi mkdir Project/CMake/Build cd Project/CMake/Build - cmake -DBUILD_ZENLIB=1 .. - make -j4 + cmake -DBUILD_ZENLIB=1 -DZLIB_BUILD_TESTING=OFF -DCMAKE_BUILD_TYPE=Release .. + cmake --build . ${{ runner.os == 'Windows' && '--config Release' || '-j4' }} - Windows: + MSBuild: runs-on: windows-latest strategy: matrix: @@ -96,17 +115,17 @@ jobs: fail-fast: false steps: - name: Checkout zlib - uses: actions/checkout@v4 + uses: actions/checkout@v5 with: repository: MediaArea/zlib path: zlib - name: Checkout ZenLib - uses: actions/checkout@v4 + uses: actions/checkout@v5 with: repository: MediaArea/ZenLib path: ZenLib - name: Checkout MediaInfoLib - uses: actions/checkout@v4 + uses: actions/checkout@v5 with: path: MediaInfoLib - name: Add msbuild to PATH