From b033370d8e043eef49ada72182d3a073920293d4 Mon Sep 17 00:00:00 2001 From: Gary Wang Date: Sun, 29 May 2022 01:06:00 +0800 Subject: [PATCH] build: link user32.lib when build with QMake and MSVC (#59) * build(msvc): add test for qmake build with msvc under windows * fix(msvc): should link user32.lib under windows * Update README.md --- .github/workflows/windows.yml | 30 ++++++++++++++++++++++++++++++ README.md | 3 +++ README.zh_CN.md | 3 +++ pineapple-pictures.pro | 5 +++++ 4 files changed, 41 insertions(+) create mode 100644 .github/workflows/windows.yml diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml new file mode 100644 index 0000000..90a44ee --- /dev/null +++ b/.github/workflows/windows.yml @@ -0,0 +1,30 @@ +name: Windows CI + +on: [push, pull_request] + +jobs: + msvc-build: + + strategy: + matrix: + vs: ['2019'] + msvc_arch: ['x64'] + + runs-on: windows-2019 + + steps: + - uses: actions/checkout@v3 + - name: Install Qt + uses: jurplel/install-qt-action@v2 + with: + arch: 'win64_msvc2019_64' + version: '5.15.2' + - name: Build + shell: cmd + run: | + set VS=${{ matrix.vs }} + set VCVARS="C:\Program Files (x86)\Microsoft Visual Studio\%VS%\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" + if not exist %VCVARS% set VCVARS="C:\Program Files\Microsoft Visual Studio\%VS%\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" + call %VCVARS% ${{ matrix.msvc_arch }} + qmake pineapple-pictures.pro + nmake diff --git a/README.md b/README.md index 12f0f0d..35edb71 100644 --- a/README.md +++ b/README.md @@ -48,6 +48,9 @@ The project will try to build with `exiv2` when it's available at build time, if Image formats supports rely on Qt's imageformats plugins, just get the plugins you need from your distro's package manager will be fine. For Windows user, you may need build and install the imageformats plugin manually, read the content below. +> **Note** +> Although there is a `pineapple-pictures.pro` file which can be used for QMake build, it's only for testing purpose and it doesn't have `exiv2` support included. Using QMake to build this project is NOT supported, please use CMake if possible. + ### Linux Just normal build process as other program will be fine. Nothing special ;) diff --git a/README.zh_CN.md b/README.zh_CN.md index 517e7da..2956409 100644 --- a/README.zh_CN.md +++ b/README.zh_CN.md @@ -48,6 +48,9 @@ $ cmake --build . # 如果你使用 Makefile 作为 CMake 生成器,也可以 此应用的图片格式支持依赖于 Qt 的 imageformats 插件,直接从您所用的发行版获取对应的图像格式插件即可。对于 Windows 用户,您可能需要手动构建和使用图像格式插件。下方给出了进一步的说明。 +> **Note** +> 尽管存在一个可用于 QMake 构建的 `pineapple-pictures.pro` 文件,但其仅供简单测试所用且其并不包含 `exiv2` 支持。使用 QMake 构建此项目是 **不受支持** 的,请尽可能考虑使用 CMake。 + ### Linux 常规的构建步骤即可完成构建,不需要额外的处理步骤 ;) diff --git a/pineapple-pictures.pro b/pineapple-pictures.pro index 5b9fefe..eef30bf 100644 --- a/pineapple-pictures.pro +++ b/pineapple-pictures.pro @@ -82,3 +82,8 @@ RC_ICONS = assets/icons/app-icon.ico QMAKE_TARGET_PRODUCT = Pineapple Pictures QMAKE_TARGET_DESCRIPTION = Pineapple Pictures - Image Viewer QMAKE_TARGET_COPYRIGHT = MIT/Expat License - Copyright (C) 2020 Gary Wang + +# MSVC only, since QMake doesn't have a CMAKE_CXX_STANDARD_LIBRARIES or cpp_winlibs similar thing +win32-msvc* { + LIBS += -luser32 +} \ No newline at end of file