diff --git a/.github/docker/README.md b/.github/docker/README.md new file mode 100644 index 0000000..aa0ad87 --- /dev/null +++ b/.github/docker/README.md @@ -0,0 +1,5 @@ +# Minimal Qt build images for CI + +These include minimal Qt built from source with `-qt-zlib` option to test `-DQUAZIP_USE_QT_ZLIB=ON` builds. + +`jurplel/install-qt-action` is essentially a binary downloader from Qt and does not have all options available. \ No newline at end of file diff --git a/.github/docker/qt-5.15.12-ubuntu-static/Dockerfile b/.github/docker/qt-5.15.12-ubuntu-static/Dockerfile new file mode 100644 index 0000000..609ad82 --- /dev/null +++ b/.github/docker/qt-5.15.12-ubuntu-static/Dockerfile @@ -0,0 +1,67 @@ +FROM ubuntu:22.04 as builder + +WORKDIR /build + +RUN apt-get -y update && apt-get -y install build-essential cmake tar wget python3 + +RUN wget -qO- https://ftp.fau.de/qtproject/archive/qt/5.15/5.15.12/single/qt-everywhere-opensource-src-5.15.12.tar.xz | tar xJ + +RUN qt-everywhere-src-5.15.12/configure -qt-zlib \ +-static \ +-opensource \ +-confirm-license \ +-optimize-size \ +-nomake examples \ +-nomake tests \ +-no-dbus \ +-no-fontconfig \ +-no-opengl \ +-no-openssl \ +-no-gui \ +-skip qtconnectivity \ +-skip qtdatavis3d \ +-skip qtdeclarative \ +-skip qtdoc \ +-skip qtactiveqt \ +-skip qt3d \ +-skip qtimageformats \ +-skip qtlocation \ +-skip qtmultimedia \ +-skip qtopcua \ +-skip qtremoteobjects \ +-skip qtscxml \ +-skip qtsensors \ +-skip qtserialbus \ +-skip qtserialport \ +-skip qtspeech \ +-skip qtsvg \ +-skip qttools \ +-skip qttranslations \ +-skip qtwebchannel \ +-skip qtwebengine \ +-skip qtwebsockets \ +-skip qtwebview \ +-skip qtcharts \ +-skip qtcoap \ +-skip qtlottie \ +-skip qtmqtt \ +-skip qtnetworkauth \ +-skip qtquick3d \ +-skip qtquicktimeline \ +-skip qtvirtualkeyboard \ +-skip qtwayland \ +-skip qtcanvas3d \ +-skip qtgamepad \ +-skip qtpurchasing \ +-skip qtscript + +RUN make -j$(nproc) && make install + +FROM ubuntu:22.04 + +RUN apt-get -y update && apt-get -y install git build-essential cmake + +COPY --from=builder /usr/local/Qt-5.15.12 /usr/local/Qt-5.15.12 + +# Temporary workaround for https://github.com/stachenov/quazip/issues/127 +ENV LC_ALL=C.UTF-8 \ No newline at end of file diff --git a/.github/docker/qt-6.4.3-ubuntu-static/Dockerfile b/.github/docker/qt-6.4.3-ubuntu-static/Dockerfile new file mode 100644 index 0000000..a861d2f --- /dev/null +++ b/.github/docker/qt-6.4.3-ubuntu-static/Dockerfile @@ -0,0 +1,72 @@ +FROM ubuntu:22.04 AS builder + +WORKDIR /build + +RUN apt-get -y update && apt-get -y install build-essential cmake tar wget python3 + +RUN wget -qO- https://ftp.fau.de/qtproject/archive/qt/6.4/6.4.3/single/qt-everywhere-src-6.4.3.tar.xz | tar xJ + +RUN qt-everywhere-src-6.4.3/configure -qt-zlib \ +-static \ +-opensource \ +-confirm-license \ +-optimize-size \ +-nomake examples \ +-nomake tests \ +-no-dbus \ +-no-fontconfig \ +-no-opengl \ +-no-openssl \ +-no-gui \ +-skip qtconnectivity \ +-skip qtdatavis3d \ +-skip qtdeclarative \ +-skip qtdoc \ +-skip qtactiveqt \ +-skip qt3d \ +-skip qtgraphs \ +-skip qtgrpc \ +-skip qtimageformats \ +-skip qtlanguageserver \ +-skip qtlocation \ +-skip qthttpserver \ +-skip qtmultimedia \ +-skip qtopcua \ +-skip qtpositioning \ +-skip qtremoteobjects \ +-skip qtscxml \ +-skip qtsensors \ +-skip qtserialbus \ +-skip qtserialport \ +-skip qtshadertools \ +-skip qtspeech \ +-skip qtsvg \ +-skip qttools \ +-skip qttranslations \ +-skip qtwebchannel \ +-skip qtwebengine \ +-skip qtwebsockets \ +-skip qtwebview \ +-skip qtcharts \ +-skip qtcoap \ +-skip qtlottie \ +-skip qtmqtt \ +-skip qtnetworkauth \ +-skip qtquick3d \ +-skip qtquick3dphysics \ +-skip qtquickeffectmaker \ +-skip qtquicktimeline \ +-skip qtvirtualkeyboard \ +-skip qtwayland \ +-skip qtcanvas3d \ +-skip qtgamepad \ +-skip qtpurchasing \ +-skip qtscript + +RUN cmake --build . --parallel --target install + +FROM ubuntu:22.04 + +RUN apt-get -y update && apt-get -y install build-essential cmake + +COPY --from=builder /usr/local/Qt-6.4.3 /usr/local/Qt-6.4.3 diff --git a/.github/docker/qt-6.6.2-ubuntu-static/Dockerfile b/.github/docker/qt-6.6.2-ubuntu-static/Dockerfile new file mode 100644 index 0000000..29635da --- /dev/null +++ b/.github/docker/qt-6.6.2-ubuntu-static/Dockerfile @@ -0,0 +1,72 @@ +FROM ubuntu:22.04 as builder + +WORKDIR /build + +RUN apt-get -y update && apt-get -y install build-essential cmake tar wget python3 + +RUN wget -qO- https://ftp.fau.de/qtproject/archive/qt/6.6/6.6.2/single/qt-everywhere-src-6.6.2.tar.xz | tar xJ + +RUN qt-everywhere-src-6.6.2/configure -qt-zlib \ +-static \ +-opensource \ +-confirm-license \ +-optimize-size \ +-nomake examples \ +-nomake tests \ +-no-dbus \ +-no-fontconfig \ +-no-opengl \ +-no-openssl \ +-no-gui \ +-skip qtconnectivity \ +-skip qtdatavis3d \ +-skip qtdeclarative \ +-skip qtdoc \ +-skip qtactiveqt \ +-skip qt3d \ +-skip qtgraphs \ +-skip qtgrpc \ +-skip qtimageformats \ +-skip qtlanguageserver \ +-skip qtlocation \ +-skip qthttpserver \ +-skip qtmultimedia \ +-skip qtopcua \ +-skip qtpositioning \ +-skip qtremoteobjects \ +-skip qtscxml \ +-skip qtsensors \ +-skip qtserialbus \ +-skip qtserialport \ +-skip qtshadertools \ +-skip qtspeech \ +-skip qtsvg \ +-skip qttools \ +-skip qttranslations \ +-skip qtwebchannel \ +-skip qtwebengine \ +-skip qtwebsockets \ +-skip qtwebview \ +-skip qtcharts \ +-skip qtcoap \ +-skip qtlottie \ +-skip qtmqtt \ +-skip qtnetworkauth \ +-skip qtquick3d \ +-skip qtquick3dphysics \ +-skip qtquickeffectmaker \ +-skip qtquicktimeline \ +-skip qtvirtualkeyboard \ +-skip qtwayland \ +-skip qtcanvas3d \ +-skip qtgamepad \ +-skip qtpurchasing \ +-skip qtscript + +RUN cmake --build . --parallel --target install + +FROM ubuntu:22.04 + +RUN apt-get -y update && apt-get -y install build-essential cmake + +COPY --from=builder /usr/local/Qt-6.6.2 /usr/local/Qt-6.6.2 \ No newline at end of file diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 409892b..568ff12 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -10,6 +10,7 @@ permissions: read-all env: # Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.) + # All aqt options: https://ddalcino.github.io/aqt-list-server/ BUILD_TYPE: Release jobs: @@ -22,7 +23,7 @@ jobs: fail-fast: false matrix: ubuntu_version: [20.04, 22.04] - qt_version: [5.12.12, 5.15.2, 6.4.0] + qt_version: [5.12.12, 5.15.2, 6.6.2] shared: [ON, OFF] steps: @@ -111,7 +112,7 @@ jobs: fail-fast: false matrix: macos_version: [11, 12] - qt_version: [5.15.2, 6.4.0] + qt_version: [5.15.2, 6.6.2] shared: [ON, OFF] steps: diff --git a/.github/workflows/qt-zlib.yml b/.github/workflows/qt-zlib.yml new file mode 100644 index 0000000..8ca2ff5 --- /dev/null +++ b/.github/workflows/qt-zlib.yml @@ -0,0 +1,319 @@ +on: + push: + branches: + - master + - feature/* + pull_request: + +name: qt-zlib + +env: + BUILD_TYPE: Release + +jobs: + + use-qt-zlib-ubuntu: + if: true + runs-on: ubuntu-22.04 + name: use-qt-zlib-ubuntu-${{ matrix.qt_version }} + container: ghcr.io/cen1/qt:${{ matrix.qt_version }} + strategy: + fail-fast: false + matrix: + qt_version: [ 5.15.12, 6.4.3, 6.6.2 ] + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Configure CMake + run: cmake -DCMAKE_BUILD_TYPE="${{env.BUILD_TYPE}}" -DBUILD_SHARED_LIBS=OFF -DQUAZIP_ENABLE_TESTS=ON -DQUAZIP_USE_QT_ZLIB=ON -DCMAKE_PREFIX_PATH="/usr/local/Qt-${{ matrix.qt_version }}" -B build + + - name: Build + run: cmake --build build --config ${{env.BUILD_TYPE}} + + - name: Run tests + working-directory: build + run: ctest --verbose -C Release + + use-qt6-zlib-windows: + if: true + runs-on: windows-latest + name: use-qt6-zlib-windows-${{ matrix.qt_version }} + strategy: + fail-fast: false + matrix: + qt_version: [ 6.6.2 ] + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - uses: TheMrMilchmann/setup-msvc-dev@v3 + with: + arch: x64 + + - name: Restore Qt build cache + id: cache-qt-restore + uses: actions/cache@v4 + with: + key: windows-qt-${{ matrix.qt_version }} + path: qt-everywhere-src-${{ matrix.qt_version }} + + - name: Restore Qt zip + if: steps.cache-qt-restore.outputs.cache-hit != 'true' + id: cache-qt-zip-restore + uses: actions/cache@v4 + with: + key: windows-qt-${{ matrix.qt_version }}-zip + path: qt-everywhere-src-${{ matrix.qt_version }}.zip + + - name: Download Qt 6 + if: steps.cache-qt-restore.outputs.cache-hit != 'true' && steps.cache-qt-zip-restore.outputs.cache-hit != 'true' + shell: bash + run: | + curl https://ftp.fau.de/qtproject/archive/qt/6.6/${{ matrix.qt_version }}/single/qt-everywhere-src-${{ matrix.qt_version }}.zip --output qt-everywhere-src-${{ matrix.qt_version }}.zip + + - name: Save Qt zip + if: steps.cache-qt-restore.outputs.cache-hit != 'true' && steps.cache-qt-zip-restore.outputs.cache-hit != 'true' + id: cache-qt-zip-save + uses: actions/cache/save@v4 + with: + path: qt-everywhere-src-${{ matrix.qt_version }}.zip + key: windows-qt-${{ matrix.qt_version }}-zip + + - name: Extract Qt zip + if: steps.cache-qt-restore.outputs.cache-hit != 'true' + shell: bash + run: | + unzip -q qt-everywhere-src-${{ matrix.qt_version }}.zip + ls -la + + - name: Configure Qt + if: steps.cache-qt-restore.outputs.cache-hit != 'true' + shell: cmd + working-directory: qt-everywhere-src-${{ matrix.qt_version }} + run: ./configure.bat -prefix "${{github.workspace}}/Qt" -qt-zlib \ + -static \ + -opensource \ + -confirm-license \ + -optimize-size \ + -nomake examples \ + -nomake tests \ + -no-dbus \ + -no-icu \ + -no-fontconfig \ + -no-opengl \ + -no-openssl \ + -no-gui \ + -skip qtconnectivity \ + -skip qtdatavis3d \ + -skip qtdeclarative \ + -skip qtdoc \ + -skip qtactiveqt \ + -skip qt3d \ + -skip qtgraphs \ + -skip qtgrpc \ + -skip qtimageformats \ + -skip qtlanguageserver \ + -skip qtlocation \ + -skip qthttpserver \ + -skip qtmultimedia \ + -skip qtopcua \ + -skip qtpositioning \ + -skip qtremoteobjects \ + -skip qtscxml \ + -skip qtsensors \ + -skip qtserialbus \ + -skip qtserialport \ + -skip qtshadertools \ + -skip qtspeech \ + -skip qtsvg \ + -skip qttools \ + -skip qttranslations \ + -skip qtwebchannel \ + -skip qtwebengine \ + -skip qtwebsockets \ + -skip qtwebview \ + -skip qtcharts \ + -skip qtcoap \ + -skip qtlottie \ + -skip qtmqtt \ + -skip qtnetworkauth \ + -skip qtquick3d \ + -skip qtquick3dphysics \ + -skip qtquickeffectmaker \ + -skip qtquicktimeline \ + -skip qtvirtualkeyboard \ + -skip qtwayland \ + -skip qtcanvas3d \ + -skip qtgamepad \ + -skip qtpurchasing \ + -skip qtscript + + - name: Build Qt + if: steps.cache-qt-restore.outputs.cache-hit != 'true' + shell: cmd + working-directory: qt-everywhere-src-${{ matrix.qt_version }} + run: cmake --build . --parallel + + - name: Cache Qt + if: steps.cache-qt-restore.outputs.cache-hit != 'true' + id: cache-qt + uses: actions/cache/save@v4 + with: + path: qt-everywhere-src-${{ matrix.qt_version }} + key: windows-qt-${{ matrix.qt_version }} + + - name: Install Qt + shell: cmd + working-directory: qt-everywhere-src-${{ matrix.qt_version }} + run: cmake --install . + + - name: Configure CMake + run: cmake -DCMAKE_BUILD_TYPE="${{env.BUILD_TYPE}}" -DQUAZIP_QT_MAJOR_VERSION=6 -DBUILD_SHARED_LIBS=OFF -DQUAZIP_ENABLE_TESTS=ON -DQUAZIP_USE_QT_ZLIB=ON -B "${{github.workspace}}/build" -DCMAKE_PREFIX_PATH="${{github.workspace}}\Qt" + + - name: Build + shell: cmd + run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} + + - name: Run tests + shell: cmd + working-directory: ${{github.workspace}}/build + run: ctest --verbose -C Release + + use-qt5-zlib-windows: + if: true + runs-on: windows-latest + name: use-qt5-zlib-windows-${{ matrix.qt_version }} + strategy: + fail-fast: false + matrix: + qt_version: [ 5.15.12 ] + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - uses: TheMrMilchmann/setup-msvc-dev@v3 + with: + arch: x64 + + - name: Restore Qt build cache + id: cache-qt-restore + uses: actions/cache@v4 + with: + key: windows-qt-${{ matrix.qt_version }} + path: qt-everywhere-src-${{ matrix.qt_version }} + + - name: Restore Qt zip + if: steps.cache-qt-restore.outputs.cache-hit != 'true' + id: cache-qt-zip-restore + uses: actions/cache@v4 + with: + key: windows-qt-${{ matrix.qt_version }}-zip + path: qt-everywhere-src-${{ matrix.qt_version }}.zip + + - name: Download Qt 5 + if: steps.cache-qt-restore.outputs.cache-hit != 'true' && steps.cache-qt-zip-restore.outputs.cache-hit != 'true' + shell: bash + run: | + curl https://ftp.fau.de/qtproject/archive/qt/5.15/${{ matrix.qt_version }}/single/qt-everywhere-opensource-src-${{ matrix.qt_version }}.zip --output qt-everywhere-src-${{ matrix.qt_version }}.zip + + - name: Save Qt zip + if: steps.cache-qt-restore.outputs.cache-hit != 'true' && steps.cache-qt-zip-restore.outputs.cache-hit != 'true' + id: cache-qt-zip-save + uses: actions/cache/save@v4 + with: + path: qt-everywhere-src-${{ matrix.qt_version }}.zip + key: windows-qt-${{ matrix.qt_version }}-zip + + - name: Extract Qt zip + if: steps.cache-qt-restore.outputs.cache-hit != 'true' + shell: bash + run: | + unzip -q qt-everywhere-src-${{ matrix.qt_version }}.zip + ls -la + + - name: Configure Qt + if: steps.cache-qt-restore.outputs.cache-hit != 'true' + shell: cmd + working-directory: qt-everywhere-src-${{ matrix.qt_version }} + run: ./configure.bat -prefix "${{github.workspace}}/Qt" -qt-zlib ^ + -static ^ + -opensource ^ + -confirm-license ^ + -optimize-size ^ + -nomake examples ^ + -nomake tests ^ + -no-dbus ^ + -no-fontconfig ^ + -no-opengl ^ + -no-openssl ^ + -no-gui ^ + -skip qtconnectivity ^ + -skip qtdatavis3d ^ + -skip qtdeclarative ^ + -skip qtdoc ^ + -skip qtactiveqt ^ + -skip qt3d ^ + -skip qtimageformats ^ + -skip qtlocation ^ + -skip qtmultimedia ^ + -skip qtopcua ^ + -skip qtremoteobjects ^ + -skip qtscxml ^ + -skip qtsensors ^ + -skip qtserialbus ^ + -skip qtserialport ^ + -skip qtspeech ^ + -skip qtsvg ^ + -skip qttools ^ + -skip qttranslations ^ + -skip qtwebchannel ^ + -skip qtwebengine ^ + -skip qtwebsockets ^ + -skip qtwebview ^ + -skip qtcharts ^ + -skip qtcoap ^ + -skip qtlottie ^ + -skip qtmqtt ^ + -skip qtnetworkauth ^ + -skip qtquick3d ^ + -skip qtquicktimeline ^ + -skip qtvirtualkeyboard ^ + -skip qtwayland ^ + -skip qtcanvas3d ^ + -skip qtgamepad ^ + -skip qtpurchasing ^ + -skip qtscript + + - name: Build Qt + if: steps.cache-qt-restore.outputs.cache-hit != 'true' + shell: cmd + working-directory: qt-everywhere-src-${{ matrix.qt_version }} + run: nmake + + - name: Cache Qt + if: steps.cache-qt-restore.outputs.cache-hit != 'true' + id: cache-qt + uses: actions/cache/save@v4 + with: + path: qt-everywhere-src-${{ matrix.qt_version }} + key: windows-qt-${{ matrix.qt_version }} + + - name: Install Qt + shell: cmd + working-directory: qt-everywhere-src-${{ matrix.qt_version }} + run: nmake install + + - name: Configure CMake + run: cmake -DCMAKE_BUILD_TYPE="${{env.BUILD_TYPE}}" -DQUAZIP_QT_MAJOR_VERSION=5 -DBUILD_SHARED_LIBS=OFF -DQUAZIP_ENABLE_TESTS=ON -DQUAZIP_USE_QT_ZLIB=ON -B build -DCMAKE_PREFIX_PATH="${{github.workspace}}\Qt" + + - name: Build + run: cmake --build build --config ${{env.BUILD_TYPE}} + + - name: Run tests + shell: cmd + working-directory: build + run: ctest --extra-verbose -C Release \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt index 0a71a82..c6f8d7e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -31,6 +31,10 @@ 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) +if (QUAZIP_USE_QT_ZLIB AND BUILD_SHARED_LIBS) + message(FATAL_ERROR "Using BUILD_SHARED_LIBS=ON together with QUAZIP_USE_QT_ZLIB=ON is not supported." ) +endif() + # 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. @@ -74,33 +78,29 @@ set(QUAZIP_DIR_NAME QuaZip-Qt${QUAZIP_QT_MAJOR_VERSION}-${QUAZIP_LIB_VERSION}) set(QUAZIP_PACKAGE_NAME QuaZip-Qt${QUAZIP_QT_MAJOR_VERSION}) 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")) + find_package(Qt6 REQUIRED COMPONENTS Core Core5Compat + OPTIONAL_COMPONENTS Network Test) + message(STATUS "Found Qt version ${Qt6_VERSION} at ${Qt6_DIR}") 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 "zlib, Qt6Core") + set(QUAZIP_QT_ZLIB_HEADER_COMPONENT ZlibPrivate) + 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 "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 "zlib, Qt5Core") + find_package(Qt5 REQUIRED COMPONENTS Core + OPTIONAL_COMPONENTS Network Test) + message(STATUS "Found Qt version ${Qt5_VERSION} at ${Qt5_DIR}") + 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 "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 "zlib, QtCore") + 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 "zlib, QtCore") else() message(FATAL_ERROR "Qt version ${QUAZIP_QT_MAJOR_VERSION} is not supported") endif() @@ -110,9 +110,23 @@ 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_QT_ZLIB_COMPONENT_FOUND Qt${QUAZIP_QT_MAJOR_VERSION}${QUAZIP_QT_ZLIB_COMPONENT}_FOUND) + if (DEFINED QUAZIP_QT_ZLIB_HEADER_COMPONENT) + find_package(Qt${QUAZIP_QT_MAJOR_VERSION} OPTIONAL_COMPONENTS ${QUAZIP_QT_ZLIB_HEADER_COMPONENT}) + set(QUAZIP_QT_ZLIB_HEADER_COMPONENT_FOUND Qt${QUAZIP_QT_MAJOR_VERSION}${QUAZIP_QT_ZLIB_HEADER_COMPONENT}_FOUND) + else() + set(QUAZIP_QT_ZLIB_HEADER_COMPONENT_FOUND ON) + endif() + if(QUAZIP_QT_ZLIB_COMPONENT_FOUND AND QUAZIP_QT_ZLIB_HEADER_COMPONENT_FOUND) + message(STATUS "Qt component ${QUAZIP_QT_ZLIB_COMPONENT} found") set(QUAZIP_LIB_LIBRARIES ${QUAZIP_LIB_LIBRARIES} Qt${QUAZIP_QT_MAJOR_VERSION}::${QUAZIP_QT_ZLIB_COMPONENT}) + if(DEFINED QUAZIP_QT_ZLIB_HEADER_COMPONENT) + message(STATUS "Qt component ${QUAZIP_QT_ZLIB_HEADER_COMPONENT} found") + set(QUAZIP_LIB_LIBRARIES ${QUAZIP_LIB_LIBRARIES} Qt${QUAZIP_QT_MAJOR_VERSION}::${QUAZIP_QT_ZLIB_HEADER_COMPONENT}) + endif() set(QUAZIP_QT_ZLIB_USED ON) + else() + message(FATAL_ERROR "QUAZIP_USE_QT_ZLIB was set but bundled zlib was not found. Terminating to prevent accidental linking to system libraries.") endif() endif() diff --git a/README.md b/README.md index a1222a6..b90d1d2 100644 --- a/README.md +++ b/README.md @@ -99,13 +99,13 @@ cmake --build . --target clean CMake options -| Option | Description | Default | -|--------------------------|-------------------------------------------------------------------------------------------------------------------|---------| -| `QUAZIP_QT_MAJOR_VERSION`| Specifies which major Qt version should be searched for (6, 5 or 4). By default it tries to find the most recent. | | -| `BUILD_SHARED_LIBS` | Build QuaZip as a shared library | `ON` | -| `QUAZIP_INSTALL` | Enable installation | `ON` | -| `QUAZIP_USE_QT_ZLIB` | Use Qt's bundled zlib instead of system zlib (**not recommended**). Qt must be built with `-qt-zlib`. | `OFF` | -| `QUAZIP_ENABLE_TESTS` | Build QuaZip tests | `OFF` | -| `QUAZIP_BZIP2` | Enable BZIP2 compression | `ON` | -| `QUAZIP_BZIP2_STDIO` | Output BZIP2 errors to stdio when BZIP2 compression is enabled | `ON` | +| Option | Description | Default | +|--------------------------|---------------------------------------------------------------------------------------------------------------------|---------| +| `QUAZIP_QT_MAJOR_VERSION`| Specifies which major Qt version should be searched for (6, 5 or 4). By default it tries to find the most recent. | | +| `BUILD_SHARED_LIBS` | Build QuaZip as a shared library | `ON` | +| `QUAZIP_INSTALL` | Enable installation | `ON` | +| `QUAZIP_USE_QT_ZLIB` | Use Qt's bundled zlib instead of system zlib (**not recommended**). Qt must be built with `-qt-zlib` and `-static`. | `OFF` | +| `QUAZIP_ENABLE_TESTS` | Build QuaZip tests | `OFF` | +| `QUAZIP_BZIP2` | Enable BZIP2 compression | `ON` | +| `QUAZIP_BZIP2_STDIO` | Output BZIP2 errors to stdio when BZIP2 compression is enabled | `ON` | diff --git a/qztest/CMakeLists.txt b/qztest/CMakeLists.txt index ce0f5b9..0ad2fd6 100644 --- a/qztest/CMakeLists.txt +++ b/qztest/CMakeLists.txt @@ -24,6 +24,7 @@ set(QZTEST_SOURCES add_executable(qztest ${QZTEST_SOURCES} qztest.qrc) set_target_properties(qztest PROPERTIES AUTORCC ON) target_include_directories(qztest PRIVATE ${QUAZIP_INC}) + target_link_libraries(qztest ${QUAZIP_TEST_QT_LIBRARIES} QuaZip::QuaZip @@ -35,8 +36,8 @@ add_test(NAME qztest_test ) 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) +# TODO: Copy all Qt dlls to qztest bin so we can run it in CI +if (WIN32 AND BUILD_SHARED_LIBS) message(STATUS "Setting up windeployqt") set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${PROJECT_SOURCE_DIR}/cmake") include(windeployqt)