Skip to content

Commit

Permalink
Feature/windows ci (stachenov#190)
Browse files Browse the repository at this point in the history
Add basic Windows CI, conan, vcpkg, document it
  • Loading branch information
cen1 authored Mar 9, 2024
1 parent 044cb00 commit 3f306dc
Show file tree
Hide file tree
Showing 8 changed files with 184 additions and 8 deletions.
69 changes: 65 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ on:
push:
branches:
- master
- feature/*
pull_request:

name: CI
Expand All @@ -12,7 +13,8 @@ env:

jobs:

build:
ubuntu:
if: true
runs-on: ubuntu-${{ matrix.ubuntu_version }}
name: Ubuntu-${{ matrix.ubuntu_version }}-Qt-${{ matrix.qt_version }}-shared-${{ matrix.shared }}
strategy:
Expand All @@ -24,7 +26,7 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Install Qt6
if: "startsWith(matrix.qt_version, '6.')"
Expand Down Expand Up @@ -62,6 +64,7 @@ jobs:
run: "ctest --verbose"

macos:
if: true
runs-on: macos-${{ matrix.macos_version }}
name: macos-${{ matrix.macos_version }}-Qt-${{ matrix.qt_version }}-shared-${{ matrix.shared }}
strategy:
Expand All @@ -73,7 +76,7 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Install Qt6
if: "startsWith(matrix.qt_version, '6.')"
Expand Down Expand Up @@ -105,6 +108,7 @@ jobs:
run: "ctest --verbose"

alpine:
if: true
name: "cmake on ${{ matrix.runner }}"
runs-on: "ubuntu-20.04"
container:
Expand All @@ -119,7 +123,7 @@ jobs:
steps:
- name: Show OS info
run: cat /etc/os-release
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Install qt and build tools
run: apk add --update g++ make cmake qt5-qtbase-dev
- name: Show cmake version
Expand All @@ -132,3 +136,60 @@ jobs:
run: cd build/qztest && VERBOSE=1 make -j8
- name: Run tests
run: build/qztest/qztest

windows:
if: true
runs-on: windows-latest
strategy:
fail-fast: false
matrix:
package_manager: [ conan, vcpkg ]
qt_version: [ 6.6.2 ]

steps:
- uses: actions/checkout@v4

- name: Install Qt6
uses: jurplel/install-qt-action@v3
with:
version: ${{ matrix.qt_version }}
cache: 'true'
cache-key-prefix: ${{ runner.os }}-Qt-Cache-${{ matrix.qt_version }}
dir: ${{ github.workspace }}/Qt
modules: 'qt5compat'

- uses: TheMrMilchmann/setup-msvc-dev@v3
with:
arch: x64

- name: Install Conan
if: matrix.package_manager == 'conan'
uses: turtlebrowser/get-conan@main

- name: Init conan
if: matrix.package_manager == 'conan'
run: conan profile detect

- name: Install dependencies with conan
if: matrix.package_manager == 'conan'
shell: cmd
run: conan install . -of build -s build_type=Release -o *:shared=False --build=missing

- name: Configure
shell: cmd
run: cmake --preset ${{ matrix.package_manager }} -DQUAZIP_ENABLE_TESTS=ON

- name: Build
shell: cmd
working-directory: ./build
run: cmake --build . --config Release

- name: Debug
shell: cmd
run: dir build\qztest\Release

- name: Test
if: false
shell: cmd
working-directory: ./build
run: ctest --verbose -C Release
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,6 @@
*.swp
.idea/
cmake-*
CMakeUserPresets.json
vcpkg_installed/
Testing/
23 changes: 23 additions & 0 deletions CMakePresets.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"version": 3,
"configurePresets": [
{
"name": "vcpkg",
"binaryDir": "${sourceDir}/build",
"cacheVariables": {
"CMAKE_TOOLCHAIN_FILE": "$env{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake",
"VCPKG_TARGET_ARCHITECTURE": "x64",
"CMAKE_BUILD_TYPE": "Release"
}
},
{
"name": "conan",
"binaryDir": "${sourceDir}/build",
"cacheVariables": {
"CMAKE_TOOLCHAIN_FILE": "${sourceDir}/build/conan_toolchain.cmake",
"CMAKE_POLICY_DEFAULT_CMP0091": "NEW",
"CMAKE_BUILD_TYPE": "Release"
}
}
]
}
36 changes: 32 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,25 +26,53 @@ Distributed under LGPL, full details in the COPYING file.
Original ZIP package is copyrighted by Gilles Vollant, see
quazip/(un)zip.h files for details, but basically it's the zlib license.

## Build
# Build

## Dependencies
You need at least the following dependencies:
- zlib
- Qt6, Qt5 or Qt4 (searched in that order)

## Linux
```
sudo apt-get install zlib1g-dev libbz2-dev
cmake -B build
cmake --build build
```

## Windows
Using vcpkg
```
cmake --preset vcpkg
cmake --build build --config Release
```

Using conan v2
```
conan install . -of build -s build_type=Release -o *:shared=False --build=missing
cmake --preset conan
cmake --build build --config Release
```

If you don't use a package manager you will have to add library and include directories to your PATH or specify them with `CMAKE_PREFIX_PATH`.
Qt is not installed as a dependency of either vcpkg or conan.

## Additional build options
If you built Qt from source and installed it, you might need to tell CMake where to find it, for example: `-DCMAKE_PREFIX_PATH="/usr/local/Qt-6.6.2"`.
Alternatively, if you did not install the source build it might look something like: `-DCMAKE_PREFIX_PATH="/home/you/qt-everywhere-src-6.6.2/qtbase/lib/cmake"`.
Replace `qtbase` if you used a custom prefix at `configure` step.

Qt installed through Linux distribution packages or official Qt online installer should be detected automatically.

CMake is used to configure and build the project.
CMake is used to configure and build the project. A typical configure, build, install and clean is shown below.

```
cmake -B build
cmake -B build -DQUAZIP_QT_MAJOR_VERSION=6 -DBUILD_SHARED_LIBS=ON -DQUAZIP_ENABLE_TESTS=ON
cmake --build build --config Release
sudo cmake --install build
cmake --build build --target clean
cd build
ctest --verbose -C Release
cmake --build . --target clean
```

CMake options
Expand Down
21 changes: 21 additions & 0 deletions cmake/windeployqt.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
get_target_property(_qmake_executable Qt${QUAZIP_QT_MAJOR_VERSION}::qmake IMPORTED_LOCATION)
get_filename_component(_qt_bin_dir "${_qmake_executable}" DIRECTORY)

function(windeployqt target)

# --verbose 1

add_custom_command(TARGET ${target} POST_BUILD
COMMAND "${_qt_bin_dir}/windeployqt.exe"
--verbose 1
--release
--no-plugins
--no-translations
--no-system-d3d-compiler
--no-opengl-sw
--no-compiler-runtime
\"$<TARGET_FILE:${target}>\"
COMMENT "Deploying Qt libraries using windeployqt for compilation target '${target}' ..."
)

endfunction()
10 changes: 10 additions & 0 deletions conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
from conan import ConanFile

class Quazip(ConanFile):
settings = "os", "compiler", "build_type", "arch"
generators = "CMakeDeps", "CMakeToolchain"

requires = (
"zlib/1.3.1",
"bzip2/1.0.8"
)
8 changes: 8 additions & 0 deletions qztest/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,11 @@ add_test(NAME qztest_test
WORKING_DIRECTORY ${QUAZIP_BINARY_DIR}/quazip # preliminary hack to find the dll on windows
)
add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND} --verbose DEPENDS qztest)

# Copy all Qt dlls to qztest bin so we can run it in CI
if (WIN32)
message(STATUS "Setting up windeployqt")
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${PROJECT_SOURCE_DIR}/cmake")
include(windeployqt)
windeployqt(qztest)
endif()
22 changes: 22 additions & 0 deletions vcpkg.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"version": "1.4.1",
"name": "quazip",
"dependencies": [
"zlib",
"bzip2"
],
"vcpkg-configuration": {
"default-registry": {
"kind": "git",
"baseline": "2c401863dd54a640aeb26ed736c55489c079323b",
"repository": "https://github.com/microsoft/vcpkg"
},
"registries": [
{
"kind": "artifact",
"location": "https://github.com/microsoft/vcpkg-ce-catalog/archive/refs/heads/main.zip",
"name": "microsoft"
}
]
}
}

0 comments on commit 3f306dc

Please sign in to comment.