Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into librepcb-patches
Browse files Browse the repository at this point in the history
  • Loading branch information
ubruhin committed Mar 4, 2024
2 parents dab1c52 + fb4b59b commit a313cb8
Show file tree
Hide file tree
Showing 42 changed files with 1,026 additions and 782 deletions.
120 changes: 91 additions & 29 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,41 +6,103 @@ on:

name: CI

env:
# Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
BUILD_TYPE: Release

jobs:

ubuntu:
name: "cmake on ${{ matrix.runner }}"
runs-on: "ubuntu-20.04"
container:
image: "${{ matrix.runner }}"
build:
runs-on: ubuntu-${{ matrix.ubuntu_version }}
name: Ubuntu-${{ matrix.ubuntu_version }}-Qt-${{ matrix.qt_version }}-shared-${{ matrix.shared }}
strategy:
fail-fast: false
matrix:
runner:
- "ubuntu:16.04" # cmake 3.5, qt 5.5
- "ubuntu:18.04" # cmake 3.10, qt 5.9
- "ubuntu:20.04" # cmake 3.16, qt 5.12
- "ubuntu:20.10" # cmake 3.16, qt 5.14
env:
DEBIAN_FRONTEND: noninteractive
ubuntu_version: [20.04, 22.04]
qt_version: [5.12.12, 5.15.2, 6.4.0]
shared: [ON, OFF]

steps:
- name: Show OS info
run: cat /etc/os-release
- uses: actions/checkout@v2
- name: Install qt and build tools
run: |
apt-get update &&
apt-get install -y --no-install-recommends \
g++ make cmake zlib1g-dev qt5-default qttools5-dev-tools
- name: Show cmake version
run: cmake --version
- name: Run cmake
run: mkdir build && cd build && cmake .. -DQUAZIP_ENABLE_TESTS=ON
- name: Build quazip
run: cd build && VERBOSE=1 make -j8
- name: Build tests
run: cd build/qztest && VERBOSE=1 make -j8
- name: Checkout
uses: actions/checkout@v3

- name: Install Qt6
if: "startsWith(matrix.qt_version, '6.')"
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'

- name: Install Qt5
if: "startsWith(matrix.qt_version, '5.')"
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

- name: Install libraries
run: |
sudo apt-get update &&
sudo apt-get install -y --no-install-recommends \
zlib1g-dev libbz2-dev
- name: Configure CMake
run: cmake -DCMAKE_BUILD_TYPE="${{env.BUILD_TYPE}}" -DBUILD_SHARED_LIBS=${{ matrix.shared }} -DQUAZIP_ENABLE_TESTS=ON -B "${{github.workspace}}/build"

- name: Build
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}}

- name: Run tests
working-directory: ${{github.workspace}}/build
run: "ctest --verbose"

macos:
runs-on: macos-${{ matrix.macos_version }}
name: macos-${{ matrix.macos_version }}-Qt-${{ matrix.qt_version }}-shared-${{ matrix.shared }}
strategy:
fail-fast: false
matrix:
macos_version: [11, 12]
qt_version: [5.15.2, 6.4.0]
shared: [ON, OFF]

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

- name: Install Qt6
if: "startsWith(matrix.qt_version, '6.')"
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'

- name: Install Qt5
if: "startsWith(matrix.qt_version, '5.')"
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

- name: Configure CMake
run: cmake -DCMAKE_BUILD_TYPE="${{env.BUILD_TYPE}}" -DBUILD_SHARED_LIBS=${{ matrix.shared }} -DQUAZIP_ENABLE_TESTS=ON -B "${{github.workspace}}/build"

- name: Build
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}}

- name: Run tests
run: build/qztest/qztest
working-directory: ${{github.workspace}}/build
run: "ctest --verbose"

alpine:
name: "cmake on ${{ matrix.runner }}"
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
/doc
/build
/lib
*.tags
*.user
*.swp
195 changes: 167 additions & 28 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,65 @@
# so CMake 3.5+ should work fine.
cmake_minimum_required(VERSION 3.5...3.18)

project(QuaZip VERSION 1.1)
project(QuaZip VERSION 1.4)

set(CMAKE_CXX_STANDARD 14)
include(cmake/clone-repo.cmake)

set(QUAZIP_LIB_VERSION ${QuaZip_VERSION})
set(QUAZIP_LIB_SOVERSION 1.0.0)
set(QUAZIP_LIB_SOVERSION 1.4.0)

option(BUILD_SHARED_LIBS "" ON)
option(QUAZIP_INSTALL "" ON)
set(QUAZIP_QT_MAJOR_VERSION 5 CACHE STRING "Qt version to use (4 or 5), defaults to 5")
if(EMSCRIPTEN)
#option(ZLIB_INCLUDE "Path to include dir" "")
#option(ZLIB_LIBRARY "Path to library dir" "")
option(BUILD_SHARED_LIBS "" OFF)
option(QUAZIP_INSTALL "" OFF)
option(QUAZIP_USE_QT_ZLIB "" OFF)
option(QUAZIP_ENABLE_TESTS "Build QuaZip tests" OFF)
else()
option(BUILD_SHARED_LIBS "" ON)
option(QUAZIP_INSTALL "" ON)
option(QUAZIP_USE_QT_ZLIB "" OFF)
option(QUAZIP_ENABLE_TESTS "Build QuaZip tests" OFF)
endif()

# Make BZIP2 optional
option(QUAZIP_BZIP2 "Enables BZIP2 compression" ON)
option(QUAZIP_BZIP2_STDIO "Output BZIP2 errors to stdio" ON)

option(QUAZIP_FETCH_LIBS "Enables fetching third-party libraries if not found" ${WIN32})
option(QUAZIP_FORCE_FETCH_LIBS "Enables fetching third-party libraries always" OFF)

# Set the default value of `${QUAZIP_QT_MAJOR_VERSION}`.
# We search quietly for Qt6, Qt5 and Qt4 in that order.
# Qt6 and Qt5 provide config files for CMake.
# Qt4 relies on `FindQt4.cmake`.
find_package(
QT NAMES Qt6 Qt5
QUIET COMPONENTS Core
)
if (NOT QT_FOUND)
find_package(Qt4 QUIET COMPONENTS QtCore)
if (Qt4_FOUND)
set(QT_VERSION_MAJOR 4)
else()
# If neither 6, 5 nor 4 are found, we default to 5.
# The setup will fail further down.
set(QT_VERSION_MAJOR 5)
endif()
endif()

set(QUAZIP_QT_MAJOR_VERSION ${QT_VERSION_MAJOR} CACHE STRING "Qt version to use (4, 5 or 6), defaults to ${QT_VERSION_MAJOR}")

if (QUAZIP_QT_MAJOR_VERSION EQUAL 6)
set(CMAKE_CXX_STANDARD 17)
else()
set(CMAKE_CXX_STANDARD 14)
endif()

if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE RELEASE)
endif()

enable_testing()
set(CMAKE_AUTOMOC ON)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_DEBUG_POSTFIX d)
Expand All @@ -32,49 +75,145 @@ set(QUAZIP_LIB_FILE_NAME quazip${QuaZip_VERSION_MAJOR}-qt${QUAZIP_QT_MAJOR_VERSI
set(QUAZIP_LIB_TARGET_NAME QuaZip)
set(QUAZIP_DIR_NAME QuaZip-Qt${QUAZIP_QT_MAJOR_VERSION}-${QUAZIP_LIB_VERSION})
set(QUAZIP_PACKAGE_NAME QuaZip-Qt${QUAZIP_QT_MAJOR_VERSION})
set(QUAZIP_ENABLE_TESTS OFF)

if(QUAZIP_QT_MAJOR_VERSION EQUAL 6)
find_package(Qt6 REQUIRED COMPONENTS Core Core5Compat
OPTIONAL_COMPONENTS Network Test)
# Name of the Zlib component has been changed in 6.3.1, and again in 6.6.1...
if((Qt6_VERSION VERSION_GREATER_EQUAL "6.3.1") AND (Qt6_VERSION VERSION_LESS "6.6.1"))
set(QUAZIP_QT_ZLIB_COMPONENT BundledZLIB)
elseif(Qt6_VERSION VERSION_GREATER_EQUAL "6.6.1")
set(QUAZIP_QT_ZLIB_COMPONENT ZlibPrivate)
else()
set(QUAZIP_QT_ZLIB_COMPONENT Zlib)
endif()
set(QUAZIP_LIB_LIBRARIES Qt6::Core Qt6::Core5Compat)
set(QUAZIP_TEST_QT_LIBRARIES Qt6::Core Qt6::Core5Compat Qt6::Network Qt6::Test)
set(QUAZIP_PKGCONFIG_REQUIRES Qt6Core)
if (Qt6Network_FOUND AND Qt6Test_FOUND)
set(QUAZIP_ENABLE_TESTS ON)
endif()
set(QUAZIP_PKGCONFIG_REQUIRES "zlib, Qt6Core")
elseif(QUAZIP_QT_MAJOR_VERSION EQUAL 5)
find_package(Qt5 REQUIRED COMPONENTS Core
OPTIONAL_COMPONENTS Network Test)
set(QUAZIP_QT_ZLIB_COMPONENT Zlib)
set(QUAZIP_LIB_LIBRARIES Qt5::Core)
set(QUAZIP_TEST_QT_LIBRARIES Qt5::Core Qt5::Network Qt5::Test)
set(QUAZIP_PKGCONFIG_REQUIRES Qt5Core)
if (Qt5Network_FOUND AND Qt5Test_FOUND)
set(QUAZIP_ENABLE_TESTS ON)
endif()
set(QUAZIP_PKGCONFIG_REQUIRES "zlib, Qt5Core")
elseif(QUAZIP_QT_MAJOR_VERSION EQUAL 4)
find_package(Qt4 4.5.0 REQUIRED COMPONENTS QtCore
OPTIONAL_COMPONENTS QtNetwork QtTest)
set(QUAZIP_QT_ZLIB_COMPONENT Zlib)
set(QUAZIP_LIB_LIBRARIES Qt4::QtCore)
set(QUAZIP_TEST_QT_LIBRARIES Qt4::QtCore Qt4::QtNetwork Qt4::QtTest)
set(QUAZIP_PKGCONFIG_REQUIRES QtCore)
if (QT_QTNETWORK_FOUND AND QT_QTTEST_FOUND)
set(QUAZIP_ENABLE_TESTS ON)
endif()
set(QUAZIP_PKGCONFIG_REQUIRES "zlib, QtCore")
else()
message(FATAL_ERROR "Qt version ${QUAZIP_QT_MAJOR_VERSION} is not supported")
endif()

find_package(Qt${QUAZIP_QT_MAJOR_VERSION} OPTIONAL_COMPONENTS Zlib)
if (Qt${QUAZIP_QT_MAJOR_VERSION}Zlib_FOUND)
set(QUAZIP_LIB_LIBRARIES ${QUAZIP_LIB_LIBRARIES} Qt${QUAZIP_QT_MAJOR_VERSION}::Zlib)
else()
find_package(ZLIB REQUIRED)
set(QUAZIP_LIB_LIBRARIES ${QUAZIP_LIB_LIBRARIES} ZLIB::ZLIB)
message(STATUS "Using Qt version ${QUAZIP_QT_MAJOR_VERSION}")

set(QUAZIP_QT_ZLIB_USED OFF)
if(QUAZIP_USE_QT_ZLIB)
find_package(Qt${QUAZIP_QT_MAJOR_VERSION} OPTIONAL_COMPONENTS ${QUAZIP_QT_ZLIB_COMPONENT})
if(Qt${QUAZIP_QT_MAJOR_VERSION}${QUAZIP_QT_ZLIB_COMPONENT}_FOUND)
set(QUAZIP_LIB_LIBRARIES ${QUAZIP_LIB_LIBRARIES} Qt${QUAZIP_QT_MAJOR_VERSION}::${QUAZIP_QT_ZLIB_COMPONENT})
set(QUAZIP_QT_ZLIB_USED ON)
endif()
endif()

if(QUAZIP_QT_ZLIB_USED AND QUAZIP_QT_ZLIB_COMPONENT STREQUAL BundledZLIB)
# Qt's new BundledZLIB uses z-prefix in zlib
add_compile_definitions(Z_PREFIX)
endif()

if(NOT QUAZIP_QT_ZLIB_USED)

if(EMSCRIPTEN)
if(NOT DEFINED ZLIB_LIBRARY)
message(WARNING "ZLIB_LIBRARY is not set")
endif()

if(NOT DEFINED ZLIB_INCLUDE)
message(WARNING "ZLIB_INCLUDE is not set")
else()
include_directories(${ZLIB_INCLUDE})
endif()

if(NOT DEFINED ZCONF_INCLUDE)
message(WARNING "ZCONF_INCLUDE is not set")
else()
include_directories(${ZCONF_INCLUDE})
endif()

set(QUAZIP_LIB_LIBRARIES ${QUAZIP_LIB_LIBRARIES} ${ZLIB_LIBRARY})
else()
find_package(ZLIB REQUIRED)
set(QUAZIP_LIB_LIBRARIES ${QUAZIP_LIB_LIBRARIES} ZLIB::ZLIB)
endif()
endif()

set(QUAZIP_DEP)
set(QUAZIP_INC)
set(QUAZIP_LIB)
set(QUAZIP_LBD)

if(QUAZIP_BZIP2)
# Check if bzip2 is present
set(QUAZIP_BZIP2 ON)

if(NOT QUAZIP_FORCE_FETCH_LIBS)
find_package(BZip2 QUIET)
endif()

if(BZIP2_FOUND AND NOT QUAZIP_FORCE_FETCH_LIBS)
message(STATUS "Using BZIP2 ${BZIP2_VERSION_STRING}")

list(APPEND QUAZIP_INC ${BZIP2_INCLUDE_DIRS})
list(APPEND QUAZIP_LIB ${BZIP2_LIBRARIES})
list(APPEND QUAZIP_LBD ${BZIP2_LIBRARY_DIRS})

set(PC_PRIVATE_LIBS "${PC_PRIVATE_LIBS} -lbzip2")
elseif(QUAZIP_FETCH_LIBS)
clone_repo(bzip2 https://sourceware.org/git/bzip2.git)

# BZip2 repository does not support cmake so we have to create
# the bzip2 library ourselves
set(BZIP2_SRC
${BZIP2_SOURCE_DIR}/blocksort.c
${BZIP2_SOURCE_DIR}/bzlib.c
${BZIP2_SOURCE_DIR}/compress.c
${BZIP2_SOURCE_DIR}/crctable.c
${BZIP2_SOURCE_DIR}/decompress.c
${BZIP2_SOURCE_DIR}/huffman.c
${BZIP2_SOURCE_DIR}/randtable.c)

set(BZIP2_HDR
${BZIP2_SOURCE_DIR}/bzlib.h
${BZIP2_SOURCE_DIR}/bzlib_private.h)

add_library(bzip2 STATIC ${BZIP2_SRC} ${BZIP2_HDR})

if(NOT QUAZIP_BZIP2_STDIO)
target_compile_definitions(bzip2 PRIVATE -DBZ_NO_STDIO)
endif()

list(APPEND QUAZIP_DEP bzip2)
list(APPEND QUAZIP_LIB bzip2)
list(APPEND QUAZIP_INC ${BZIP2_SOURCE_DIR})
else()
message(STATUS "BZip2 library not found")

set(QUAZIP_BZIP2 OFF)
endif()

if(QUAZIP_BZIP2)
find_package(BZip2)
add_compile_definitions(HAVE_BZIP2)
endif()
endif()

add_subdirectory(quazip)

if(QUAZIP_ENABLE_TESTS)
add_subdirectory(qztest EXCLUDE_FROM_ALL)
message(STATUS "Building QuaZip tests")
enable_testing()
add_subdirectory(qztest)
endif()

2 changes: 1 addition & 1 deletion Doxyfile
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ PROJECT_NAME = QuaZip
# could be handy for archiving the generated documentation or if some version
# control system is used.

PROJECT_NUMBER = quazip-1-1-x
PROJECT_NUMBER = quazip-1-4

# Using the PROJECT_BRIEF tag one can provide an optional one line description
# for a project that appears at the top of each page and should give viewer a
Expand Down
Loading

0 comments on commit a313cb8

Please sign in to comment.