ITADN

cmake library components zipcmp, zipmerge, ziptool should be optional

#499Closedaral-matrix 创建于 2025-07-31
enhancement
A
aral-matrixcommented
> **Description** I would like to use cmake `find_package` to link my project against an existing installation of `libzip`, equivalent to linker flag `-lzip`. Currently, the following statement in a `CMakeLists.txt` file ``` find_package(LibZip 1.7 CONFIG COMPONENTS zip QUIET OPTIONAL_COMPONENTS zipcmp zipmerge ziptool # requires the following tools to be installed: zipcmp zipmerge ziptool ) ``` produces a CMake Error if any of the components `zipcmp`, `zipmerge`, `ziptool` are not installed on the system, even though they are absolutely unnecessary for my project. The `QUIET` setting as well as the `OPTIONAL_COMPONENTS` flag get ignored and the error persists. I think it would be quite beneficial if users could use `find_package` with libzip while being able to ignore all components that they do not need, as opposed to introducing unused dependencies. > Also, have you checked whether the feature is already mentioned in TODO.md? I have checked, nothing of that sorts is in TODO.md. > **Solution** Make all components of the library optional that are not required. Specifically, `zipcmp`, `zipmerge`, `ziptool` should be optional and exclusible from `find_package` > **Describe alternatives you've considered** - installing the dependencies: current solution, but not suitable for packaging our library for linux, as it would introduce unneeded dependencies - using ZLIB: interface not compatible, I'd have to rewrite a bigger part of code than I'd wish to - not using `find_package`, and instead adding a linker flag `-lzip` - works as desired, but would break automatic dependency resolution via cmake > **Additional context** Project in question: https://github.com/troldal/OpenXLSX/commit/17aee0e496fb19fe30906693086d69ee7c8690ee
关闭于 2025-08-14 3 条评论