# CMake example settings for QMS and QuaZip compilation 


include("${QMS_MSVC_DIR}\\QMSUser.cfg")

cmake_policy(SET CMP0054 NEW)

set(GISINTERNALS_DEV_PATH "${QMSDIR}/gisinternals/${GISINTERNALS_VER}_231126/release-${GISINTERNALS_VER}-x64" CACHE PATH "gisinternals release path" FORCE)

set(ZLIB_INCLUDE_DIR     ${GISINTERNALS_DEV_PATH}/include CACHE PATH "zlib include dir" FORCE)

set(CMAKE_BUILD_TYPE     "Release" CACHE STRING "compile release only" FORCE)

# QMS-specific settings (${PKG} from cmake command-line!): ------------------------------------------------------------
if(${PKG} STREQUAL "QMS")
    set(ROUT             "routino/routino-${ROUTINO_VER}" CACHE STRING "routino bas dir" FORCE)

    set(CMAKE_INSTALL_PREFIX ${QMSDIR}/${QMSSRC}/install CACHE PATH "template for INSTALL DIR" FORCE)

    # see: https://docs.microsoft.com/en-us/cpp/error-messages/compiler-warnings/compiler-warning-level-3-c4996?view=msvc-170
    set(CMAKE_CXX_FLAGS "/wd4996 /wd4101 /wd4005 /wd4003 ${CMAKE_CXX_FLAGS}" CACHE STRING "suppress some QMS compiler warnings" FORCE)

    set(Qt5Widgets_DIR       "${QTBASE}/${QT5_VER}/msvc${QT_MSVC64_VER}/lib/cmake/Qt5Widgets" CACHE PATH "Qt5Widgets dir" FORCE)
    set(QT_DEV_PATH          "${QTBASE}/${QT5_VER}/msvc${QT_MSVC64_VER}" CACHE PATH "Qt5 base dir for given MSVC version" FORCE)

    set(QuaZip-Qt5_DIR       "${QMSDIR}/quazip/quazip-${QUAZIP_VER}/install/lib/cmake/QuaZip-Qt5-${QUAZIP_VER}" CACHE PATH "Quazip lib dir" FORCE)
    set(QUAZIP_DEV_PATH      "${QMSDIR}/quazip/quazip-${QUAZIP_VER}/install" CACHE PATH "Quazip install dir" FORCE)
    set(QUAZIP_INCLUDE_DIR   "${QMSDIR}/quazip/quazip-${QUAZIP_VER}/install/include" CACHE PATH "Quazip include dir" FORCE)
    set(ROUTINO_DEV_PATH     "${QMSDIR}/${ROUT}/install" CACHE PATH "Routino install dir" FORCE)

    set(GDAL_DEV_PATH ${GISINTERNALS_DEV_PATH} CACHE PATH "gisinternals dev path" FORCE)
    set(JPEG_DEV_PATH ${GISINTERNALS_DEV_PATH} CACHE PATH "gisinternals dev path" FORCE)

    set(PROJ_DEV_PATH ${GISINTERNALS_DEV_PATH} CACHE PATH "gisinternals dev path" FORCE)
    set(PROJ_INCLUDE_DIR     ${GISINTERNALS_DEV_PATH}/include/proj9      CACHE PATH     "no docu" FORCE)
    set(LIBPROJ_LIBRARY      "${GISINTERNALS_DEV_PATH}/lib/proj9.lib"    CACHE FILEPATH "no docu" FORCE)

    set(ZLIB_ROOT ${GISINTERNALS_DEV_PATH} CACHE PATH "gisinternals dev path" FORCE)
    set(ZLIB_LIBRARY         "${GISINTERNALS_DEV_PATH}/lib/zlib.lib" CACHE FILEPATH "zlib lib name" FORCE)

# Quazip-specific settings: ----------------------------------------------------------------
elseif(${PKG} STREQUAL "QUAZIP")

    set(QUAZIP               "quazip/quazip-${QUAZIP_VER}"  CACHE STRING "Quazip base dir"            FORCE)
    set(QUAZIP_ENABLE_TESTS  OFF                            CACHE BOOL   "Don't prepare QuaZip tests" FORCE)
    set(QUAZIP_USE_QT_ZLIB   OFF                            CACHE BOOL   "Use zlib from GISInternals" FORCE)
    set(QUAZIP_QT_MAJOR_VERSION 5                           CACHE STRING "Use Qt5" FORCE)
    set(QUAZIP_BZIP2_STDIO   OFF                            CACHE BOOL   "Don't use bzip2" FORCE)
    set(QUAZIP_BZIP2         OFF                            CACHE BOOL   "Don't use bzip2" FORCE)

    set(CMAKE_INSTALL_PREFIX ${QMSDIR}/${QUAZIP}/install    CACHE PATH   "Quazip install dir" FORCE)

    set(QT_DIR               "${QTBASE}/${QT5_VER}/msvc${QT_MSVC64_VER}/lib/cmake/Qt5" CACHE PATH "Qt5 base dir" FORCE)
    set(Qt5_DIR              "${QT_DIR}" CACHE PATH "Qt5 base dir" FORCE)

    set(ZLIB_LIBRARY_RELEASE "${GISINTERNALS_DEV_PATH}/lib/zlib.lib" CACHE FILEPATH "zlib library name used in GISInternals" FORCE)

endif()