cmake: allow to specifically select the Qt version.

This commit is contained in:
suter_a 2018-05-26 20:12:56 +02:00
parent 1258e1a0cb
commit eab0f2d626

View File

@ -10,6 +10,9 @@ option(BMWlibs "build optional BMWlibs" OFF)
option(BNMRlibs "build optional beta-NMR libs" OFF) option(BNMRlibs "build optional beta-NMR libs" OFF)
option(qt_based_tools "try to install Qt based tools (musredit, musrWiz, musrStep, mupp)" ON) option(qt_based_tools "try to install Qt based tools (musredit, musrWiz, musrStep, mupp)" ON)
option(try_OpenMP "try to use OpenMP if available" ON) option(try_OpenMP "try to use OpenMP if available" ON)
# define qt_version with possible values 'auto' or version '3', '4', '5'
set(qt_version AUTO CACHE STRING "provide a specific Qt version to be used.")
set_property(CACHE qt_version PROPERTY STRINGS AUTO 3 4 5)
#--- perform some checks and generate the config.h ---------------------------- #--- perform some checks and generate the config.h ----------------------------
include(CheckTypeSize) include(CheckTypeSize)
@ -88,6 +91,8 @@ endif (try_OpenMP)
#--- check for Qt ------------------------------------------------------------- #--- check for Qt -------------------------------------------------------------
if (qt_based_tools) if (qt_based_tools)
# check for any Qt, i.e. AUTO
if (qt_version STREQUAL AUTO)
# first try Qt5 # first try Qt5
# Find the QtCore library # Find the QtCore library
find_package(Qt5Core) find_package(Qt5Core)
@ -115,6 +120,43 @@ if (qt_based_tools)
find_package(Qt3) find_package(Qt3)
endif (NOT Qt4_FOUND) endif (NOT Qt4_FOUND)
endif (NOT Qt5Core_FOUND) endif (NOT Qt5Core_FOUND)
endif (qt_version STREQUAL AUTO)
# check specifically for Qt5
if (qt_version STREQUAL 5)
# Find the QtCore library
find_package(Qt5Core)
if (Qt5Core_FOUND)
# Find the QtWidgets library
find_package(Qt5Widgets CONFIG REQUIRED)
# Find the QtXml library
find_package(Qt5Xml CONFIG REQUIRED)
# Find the QtNetwork library
find_package(Qt5Network CONFIG REQUIRED)
# Find the QtSvg library
find_package(Qt5Svg CONFIG REQUIRED)
# Fing the QtPrintSupport
find_package(Qt5PrintSupport CONFIG REQUIRED)
else (Qt5Core_FOUND)
message(FATAL_ERROR "Couldn't find the specifically requested Qt5 version.")
endif (Qt5Core_FOUND)
endif (qt_version STREQUAL 5)
# check specifically for Qt4
if (qt_version STREQUAL 4)
find_package(Qt4 COMPONENTS QtGui QtWebKit QtXml)
if (NOT Qt4_FOUND)
message(FATAL_ERROR "Couldn't find the specifically requested Qt4 version.")
endif (NOT Qt4_FOUND)
endif (qt_version STREQUAL 4)
# check specifically for Qt3
if (qt_version STREQUAL 3)
find_package(Qt3)
if (NOT QT_FOUND)
message(FATAL_ERROR "Couldn't find the specifically requested Qt3 version.")
endif (NOT QT_FOUND)
endif (qt_version STREQUAL 3)
endif (qt_based_tools) endif (qt_based_tools)
#--- if NeXus check also for HDF4, HDF5, and MXML ----------------------------- #--- if NeXus check also for HDF4, HDF5, and MXML -----------------------------