Skip to content

Use a specific version of zlib and bzip2 #223

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ if(NOT QUAZIP_QT_ZLIB_USED)

set(QUAZIP_LIB_LIBRARIES ${QUAZIP_LIB_LIBRARIES} ${ZLIB_LIBRARY})
else()
find_package(ZLIB REQUIRED)
find_package(ZLIB 1.3.1 EXACT REQUIRED)
set(QUAZIP_LIB_LIBRARIES ${QUAZIP_LIB_LIBRARIES} ZLIB::ZLIB)
endif()
endif()
Expand All @@ -162,7 +162,7 @@ if(QUAZIP_BZIP2)
set(QUAZIP_BZIP2 ON)

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

if(BZIP2_FOUND AND NOT QUAZIP_FORCE_FETCH_LIBS)
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ some guidelines.

1. Changes should be backwards-compatible. Don't just change method names
and their signatures randomly. Don't just remove deprecated features—some
of them are there to keep compatibility with old Qt versions. Even Qt 4 is
of them are there to keep compatibility with old Qt versions. Even Qt 5 is
still supported! Unless you're working on some sort of `pre2.0` branch
or something like that, you should keep ABI compatibility as well! Meaning,
no adding virtual functions, no changing parameter types, even if it's
Expand Down
56 changes: 45 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,32 @@ quazip/(un)zip.h files for details, but basically it's the zlib license.

## Dependencies
You need at least the following dependencies:
- zlib
- `cmake>=3.15`
- Qt6 or Qt5 (searched in that order)
- Optional dependencies (choose one):
* `miniconda`
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If using miniconda isn't something that is preferred, I think that the CMakeLists.txt should be updated to use ZLIB_ROOT and if it's not found clone the git repo, similar to how it is done for bzip2

* `conan`
* `vcpkg`

## Linux
Using miniconda
```
sudo apt-get install zlib1g-dev libbz2-dev
cmake -B build
cmake --build build
conda env create -f dependencies.yml --prefix zlib
cmake -DZLIB_ROOT=/quazip_project_root_dir/zlib/Library -B build
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cmake recognizes ZLIB_ROOT and finds the include and library directories respective to that path. See here for a full explanation: https://cmake.org/cmake/help/v3.1/module/FindZLIB.html#findzlib

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
```

Using vcpkg
```
cmake -B build --preset vcpkg
cmake --build build --config Release
```

## Windows
Expand All @@ -54,9 +72,10 @@ If you don't use a package manager you will have to add library and include dire
Qt is not installed as a dependency of either vcpkg or conan.

### x64
Using vcpkg
Using miniconda
```
cmake --preset vcpkg
conda env create -f dependencies.yml --prefix dependencies
cmake -DZLIB_ROOT=quazip_project_root_dir\dependencies\Library -B build
cmake --build build --config Release
```

Expand All @@ -67,29 +86,44 @@ cmake --preset conan
cmake --build build --config Release
```

Using vcpkg
```
cmake -B build --preset vcpkg
cmake --build build --config Release
```

### x86
Only Qt5 is tested on x86.

Using vcpkg
```
cmake --preset vcpkg_x86
cmake -B build --preset vcpkg_x86
cmake --build build --config Release
```

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

## 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.8.2"`.
Alternatively, if you did not install the source build it might look something like: `-DCMAKE_PREFIX_PATH="/home/you/qt-everywhere-src-6.8.2/qtbase/lib/cmake"`.
Replace `qtbase` if you used a custom prefix at `configure` step.
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.8.2"`. Alternatively, if you did not install the source build it might look something like: `-DCMAKE_PREFIX_PATH="/home/you/qt-everywhere-src-6.8.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.

If you wish to build in debug mode, then in the cmake configuration command add: `-DCMAKE_BUILD_TYPE=Debug` and in the cmake build command and change `Release` to `Debug`: `cmake --build build --config Debug`.

You may also build without BZIP2 when configuring the project with cmake: `-DQUAZIP_BZIP2=OFF`.

Specifying a directory to install the build is also possible when running the cmake configure and build commands, like so:

```
cmake -DCMAKE_INSTALL_PREFIX=/path/to/install
cmake --build build --config Release --target install
```

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

```
Expand Down
2 changes: 1 addition & 1 deletion cmake/clone-repo.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ macro(clone_repo name url)
set(${name_upper}_REPOSITORY ${url})
endif()
if(NOT ${name_upper}_TAG)
set(${name_upper}_TAG master)
set(${name_upper}_TAG bzip2-1.0.8)
endif()

message(STATUS "Fetching ${name} ${${name_upper}_REPOSITORY} ${${name_upper}_TAG}")
Expand Down
2 changes: 2 additions & 0 deletions dependencies.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
dependencies:
- zlib=1.3.1.
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only pinning zlib here since bzip2 gets cloned in CMakeLists.txt if the user wants to build with it

4 changes: 2 additions & 2 deletions vcpkg.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
"version": "1.5",
"name": "quazip",
"dependencies": [
"zlib",
"bzip2"
{"name": "zlib", "version": "1.3.1"},
{"name": "bzip2", "version": "1.0.8"}
],
"vcpkg-configuration": {
"default-registry": {
Expand Down