diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6cc0536..ffbe776 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -2,6 +2,7 @@ on: push: branches: - master + - feature/* pull_request: name: CI @@ -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: @@ -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.')" @@ -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: @@ -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.')" @@ -105,6 +108,7 @@ jobs: run: "ctest --verbose" alpine: + if: true name: "cmake on ${{ matrix.runner }}" runs-on: "ubuntu-20.04" container: @@ -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 @@ -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 diff --git a/.gitignore b/.gitignore index 6078d28..7d8b886 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,6 @@ *.swp .idea/ cmake-* +CMakeUserPresets.json +vcpkg_installed/ +Testing/ \ No newline at end of file diff --git a/CMakePresets.json b/CMakePresets.json new file mode 100644 index 0000000..f3263e3 --- /dev/null +++ b/CMakePresets.json @@ -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" + } + } + ] +} \ No newline at end of file diff --git a/README.md b/README.md index 001a8bc..a94a673 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/cmake/windeployqt.cmake b/cmake/windeployqt.cmake new file mode 100644 index 0000000..dcbb2e7 --- /dev/null +++ b/cmake/windeployqt.cmake @@ -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 + \"$\" + COMMENT "Deploying Qt libraries using windeployqt for compilation target '${target}' ..." + ) + +endfunction() \ No newline at end of file diff --git a/conanfile.py b/conanfile.py new file mode 100644 index 0000000..1f501fb --- /dev/null +++ b/conanfile.py @@ -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" + ) \ No newline at end of file diff --git a/qztest/CMakeLists.txt b/qztest/CMakeLists.txt index 34fbbd9..ce0f5b9 100644 --- a/qztest/CMakeLists.txt +++ b/qztest/CMakeLists.txt @@ -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() \ No newline at end of file diff --git a/vcpkg.json b/vcpkg.json new file mode 100644 index 0000000..0abdbe0 --- /dev/null +++ b/vcpkg.json @@ -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" + } + ] + } +}