| 1 |
project (QuaZip) |
| 2 |
cmake_minimum_required(VERSION 2.6) |
| 3 |
|
| 4 |
option(BUILD_WITH_QT4 "Build QuaZip with Qt4 no matter if Qt5 was found" OFF) |
| 5 |
|
| 6 |
if( NOT BUILD_WITH_QT4 ) |
| 7 |
# try Qt5 first, and prefer that if found |
| 8 |
find_package(Qt5Core QUIET) |
| 9 |
endif() |
| 10 |
|
| 11 |
if (Qt5Core_FOUND) |
| 12 |
set(QTCORE_LIBRARIES ${Qt5Core_LIBRARIES}) |
| 13 |
set(QUAZIP_LIB_VERSION_SUFFIX 5) |
| 14 |
# if there is no QT_ROOT, try to deduce it from Qt QtCore include |
| 15 |
if ("${QT_ROOT}" STREQUAL "") |
| 16 |
set(QT_ROOT ${QT_QTCORE_INCLUDE_DIR}/../..) |
| 17 |
endif() |
| 18 |
include_directories(${Qt5Core_INCLUDE_DIRS}) |
| 19 |
|
| 20 |
macro(qt_wrap_cpp) |
| 21 |
qt5_wrap_cpp(${ARGN}) |
| 22 |
endmacro() |
| 23 |
else() |
| 24 |
set(qt_min_version "4.5.0") |
| 25 |
find_package(Qt4 REQUIRED) |
| 26 |
set(QT_USE_QTGUI false) |
| 27 |
include(${QT_USE_FILE}) |
| 28 |
include_directories(${QT_INCLUDES}) |
| 29 |
set(QTCORE_LIBRARIES ${QT_QTCORE_LIBRARY}) |
| 30 |
|
| 31 |
macro(qt_wrap_cpp) |
| 32 |
qt4_wrap_cpp(${ARGN}) |
| 33 |
endmacro() |
| 34 |
endif() |
| 35 |
|
| 36 |
# Use system zlib on unix and Qt ZLIB on Windows |
| 37 |
IF(UNIX OR MINGW) |
| 38 |
find_package(ZLIB REQUIRED) |
| 39 |
ELSE(UNIX) |
| 40 |
SET(ZLIB_INCLUDE_DIRS "${QT_ROOT}/src/3rdparty/zlib" CACHE STRING "Path to ZLIB headers of Qt") |
| 41 |
SET(ZLIB_LIBRARIES "") |
| 42 |
IF(NOT EXISTS "${ZLIB_INCLUDE_DIRS}/zlib.h") |
| 43 |
MESSAGE("Please specify a valid zlib include dir") |
| 44 |
ENDIF(NOT EXISTS "${ZLIB_INCLUDE_DIRS}/zlib.h") |
| 45 |
ENDIF(UNIX) |
| 46 |
|
| 47 |
# All build libraries are moved to this directory |
| 48 |
SET(LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR}) |
| 49 |
|
| 50 |
set(LIB_SUFFIX "" CACHE STRING "Define suffix of directory name (32/64)") |
| 51 |
set(LIB_DESTINATION "${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX}" CACHE STRING "Library directory name" FORCE) |
| 52 |
set(QUAZIP_LIB_TARGET_NAME quazip${QUAZIP_LIB_VERSION_SUFFIX} CACHE |
| 53 |
INTERNAL "Target name of libquazip" FORCE) |
| 54 |
|
| 55 |
add_subdirectory(quazip) |
| 56 |
|
| 57 |
install(FILES FindQuaZip.cmake RENAME FindQuaZip${QUAZIP_LIB_VERSION_SUFFIX}.cmake DESTINATION ${CMAKE_ROOT}/Modules) |