gdraheim / zziplib

The ZZIPlib provides read access on ZIP-archives and unpacked data. It features an additional simplified API following the standard Posix API for file access
Other
60 stars 50 forks source link

CMake build using Android toolchain (and vcpkg) fails #133

Closed vividos closed 1 year ago

vividos commented 2 years ago

I'm using zziplib in the Underworld Adventures project and until now was building zziplib using my own Visual Studio project. I'm now switching to CMake based builds. I also use vcpkg to build and include zziplib for the Android platform using a custom triplet arm64-android.

Currently the build fails with this error: Could NOT find UnixCommands (missing: BASH CP GZIP MV RM)

The error comes from this line: https://github.com/gdraheim/zziplib/blob/ec0364a245d869a509481d80fc19c70cf945cee7/zzip/CMakeLists.txt#L44 and is triggered via: https://github.com/gdraheim/zziplib/blob/ec0364a245d869a509481d80fc19c70cf945cee7/zzip/CMakeLists.txt#L21

I think from reading the CMake docs, the if(UNIX ... line is wrong, as it checks if the cross-compiling target system is a Unix-like system (which Android is), but the unix tools are required on the build host, which is a Windows one in my case. So the fix would be to check for if(CMAKE_HOST_UNIX ... instead.

See also the vcpkg issue that I opened for the current zziplib port: https://github.com/microsoft/vcpkg/issues/25187

I can open a PR with the necessary change if required.