Fix QuaZip find module on macOS and clean up code.

Finding libquazip failed on macOS due to path differences.
This patch also cleans up the find module's code, aligns it
with the coding style of the other CMake files and removes
clutter that is not needed for KeePassXC such as non-Msys
builds on Windows.
This commit is contained in:
Janek Bevendorff 2019-04-27 00:43:43 +02:00 committed by Jonathan White
parent 0f8d2986af
commit 01a3d5b0ba
2 changed files with 23 additions and 40 deletions

View File

@ -1,41 +1,24 @@
# QUAZIP_FOUND - QuaZip library was found # QUAZIP_FOUND - QuaZip library was found
# QUAZIP_INCLUDE_DIR - Path to QuaZip include dir # QUAZIP_INCLUDE_DIR - Path to QuaZip include dir
# QUAZIP_INCLUDE_DIRS - Path to QuaZip and zlib include dir (combined from QUAZIP_INCLUDE_DIR + ZLIB_INCLUDE_DIR) # QUAZIP_INCLUDE_DIRS - Path to QuaZip and zlib include dir (combined from QUAZIP_INCLUDE_DIR + ZLIB_INCLUDE_DIR)
# QUAZIP_LIBRARIES - List of QuaZip libraries # QUAZIP_LIBRARIES - List of QuaZip libraries
# QUAZIP_ZLIB_INCLUDE_DIR - The include dir of zlib headers # QUAZIP_ZLIB_INCLUDE_DIR - The include dir of zlib headers
IF(QUAZIP_INCLUDE_DIRS AND QUAZIP_LIBRARIES) if(MINGW)
# in cache already find_library(QUAZIP_LIBRARIES libquazip5)
SET(QUAZIP_FOUND TRUE) find_path(QUAZIP_INCLUDE_DIR quazip.h PATH_SUFFIXES quazip5)
ELSE(QUAZIP_INCLUDE_DIRS AND QUAZIP_LIBRARIES) find_path(QUAZIP_ZLIB_INCLUDE_DIR zlib.h)
IF(Qt5Core_FOUND) else()
set(QUAZIP_LIB_VERSION_SUFFIX 5) find_library(QUAZIP_LIBRARIES
ENDIF() NAMES quazip5 quazip
IF(WIN32) PATHS /usr/lib /usr/lib64 /usr/local/lib
FIND_PATH(QUAZIP_LIBRARY_DIR
WIN32_DEBUG_POSTFIX d
NAMES libquazip${QUAZIP_LIB_VERSION_SUFFIX}.dll
HINTS "C:/Programme/" "C:/Program Files"
PATH_SUFFIXES QuaZip/lib
) )
FIND_LIBRARY(QUAZIP_LIBRARIES NAMES libquazip${QUAZIP_LIB_VERSION_SUFFIX}.dll HINTS ${QUAZIP_LIBRARY_DIR}) find_path(QUAZIP_INCLUDE_DIR quazip.h
FIND_PATH(QUAZIP_INCLUDE_DIR NAMES quazip.h HINTS ${QUAZIP_LIBRARY_DIR}/../ PATH_SUFFIXES include/quazip5) PATHS /usr/include /usr/local/include
FIND_PATH(QUAZIP_ZLIB_INCLUDE_DIR NAMES zlib.h) PATH_SUFFIXES quazip5 quazip
ELSE(WIN32)
FIND_PACKAGE(PkgConfig)
pkg_check_modules(PC_QUAZIP quazip)
FIND_LIBRARY(QUAZIP_LIBRARIES
WIN32_DEBUG_POSTFIX d
NAMES quazip${QUAZIP_LIB_VERSION_SUFFIX}
HINTS /usr/lib /usr/lib64
) )
FIND_PATH(QUAZIP_INCLUDE_DIR quazip.h find_path(QUAZIP_ZLIB_INCLUDE_DIR zlib.h PATHS /usr/include /usr/local/include)
HINTS /usr/include /usr/local/include endif()
PATH_SUFFIXES quazip${QUAZIP_LIB_VERSION_SUFFIX} include(FindPackageHandleStandardArgs)
) set(QUAZIP_INCLUDE_DIRS ${QUAZIP_INCLUDE_DIR} ${QUAZIP_ZLIB_INCLUDE_DIR})
FIND_PATH(QUAZIP_ZLIB_INCLUDE_DIR zlib.h HINTS /usr/include /usr/local/include) find_package_handle_standard_args(QUAZIP DEFAULT_MSG QUAZIP_LIBRARIES QUAZIP_INCLUDE_DIR QUAZIP_ZLIB_INCLUDE_DIR QUAZIP_INCLUDE_DIRS)
ENDIF(WIN32)
INCLUDE(FindPackageHandleStandardArgs)
SET(QUAZIP_INCLUDE_DIRS ${QUAZIP_INCLUDE_DIR} ${QUAZIP_ZLIB_INCLUDE_DIR})
find_package_handle_standard_args(QUAZIP DEFAULT_MSG QUAZIP_LIBRARIES QUAZIP_INCLUDE_DIR QUAZIP_ZLIB_INCLUDE_DIR QUAZIP_INCLUDE_DIRS)
ENDIF(QUAZIP_INCLUDE_DIRS AND QUAZIP_LIBRARIES)

View File

@ -46,8 +46,8 @@
#include <QStringBuilder> #include <QStringBuilder>
#if defined(WITH_XC_KEESHARE_SECURE) #if defined(WITH_XC_KEESHARE_SECURE)
#include <quazip5/quazip.h> #include <quazip.h>
#include <quazip5/quazipfile.h> #include <quazipfile.h>
#endif #endif
namespace namespace