From 46f4967f6e28cbf52ea157e53c34391ce9a4cc72 Mon Sep 17 00:00:00 2001 From: Julian Smith Date: Sun, 23 Aug 2020 20:11:14 +0100 Subject: [PATCH] Allow use of old zlib-1.2.3 on OpenBSD. As of 2020-08-01, OpenBSD's system zlib is 1.2.3 which doesn't have gzoffset(). However we can get away with this by making gzfilebuf::approxOffset() always return zero. --- CMakeLists.txt | 9 ++++++++- simgear/io/iostreams/gzfstream.cxx | 5 ++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 57a1d89b..55005a45 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -278,7 +278,14 @@ else() endif() endif(SIMGEAR_HEADLESS) -find_package(ZLIB 1.2.4 REQUIRED) +if(${CMAKE_SYSTEM_NAME} MATCHES "OpenBSD") + # As of 2020-08-01, OpenBSD's system zlib is slightly old, but it's usable + # with a workaround in simgear/io/iostreams/gzfstream.cxx. + find_package(ZLIB 1.2.3 REQUIRED) +else() + find_package(ZLIB 1.2.4 REQUIRED) +endif() + find_package(CURL REQUIRED) if (SYSTEM_EXPAT) diff --git a/simgear/io/iostreams/gzfstream.cxx b/simgear/io/iostreams/gzfstream.cxx index 582f389c..da30a724 100644 --- a/simgear/io/iostreams/gzfstream.cxx +++ b/simgear/io/iostreams/gzfstream.cxx @@ -185,6 +185,9 @@ gzfilebuf::setcompressionstrategy( int comp_strategy ) z_off_t gzfilebuf::approxOffset() { + #ifdef __OpenBSD__ + z_off_t res = 0; + #else z_off_t res = gzoffset(file); if (res == -1) { @@ -201,7 +204,7 @@ gzfilebuf::approxOffset() { SG_LOG( SG_GENERAL, SG_ALERT, errMsg ); throw sg_io_exception(errMsg); } - + #endif return res; }