Commit bd18b798 authored by jcfr's avatar jcfr

COMP: Update SlicerBlockFindQtAndCheckVersion, and also reorganize VTK, CTK and Qt discovery

VTK and CTK should be found first, then using the block SlicerBlockFindQtAndCheckVersion
it's easy to make sure the Qt version used to build both CTK and VTK are equal
and satisfy Slicer_REQUIRED_QT_VERSION condition.

git-svn-id: http://svn.slicer.org/Slicer4/trunk@16371 3bd1e089-480b-0410-8dfb-8563597acbee
parent 6524eb1c
......@@ -23,6 +23,30 @@
# it can be used in both Slicer/CMakelists.txt and Slicer/UseSlicer.cmake
#
MACRO(__SlicerBlockFindQtAndCheckVersion_find_qt)
FIND_PACKAGE(Qt4)
IF(NOT QT4_FOUND)
MESSAGE(FATAL_ERROR "error: Qt >= ${Slicer_REQUIRED_QT_VERSION} was not found on your system. You probably need to set the QT_QMAKE_EXECUTABLE variable.")
ENDIF()
# Check version
IF("${QT_VERSION_MAJOR}.${QT_VERSION_MINOR}.${QT_VERSION_PATCH}" VERSION_LESS "${Slicer_REQUIRED_QT_VERSION}")
MESSAGE(FATAL_ERROR "error: Slicer requires Qt >= ${Slicer_REQUIRED_QT_VERSION} -- you cannot use Qt ${QT_VERSION_MAJOR}.${QT_VERSION_MINOR}.${QT_VERSION_PATCH}. ${extra_error_message}")
ENDIF()
set(command_separated_module_list)
# Check if all expected Qt modules have been discovered
FOREACH(module ${Slicer_REQUIRED_QT_MODULES})
IF(NOT ${QT_QT${module}_FOUND})
MESSAGE(FATAL_ERROR "error: ")
ENDIF()
IF(NOT ${module} STREQUAL "CORE" AND NOT ${module} STREQUAL "GUI")
SET(QT_USE_QT${module} ON)
ENDIF()
set(command_separated_module_list "${command_separated_module_list}${module}, ")
ENDFOREACH()
ENDMACRO()
# Sanity checks - Check if variable are defined
SET(expected_defined_vars
Slicer_REQUIRED_QT_VERSION
......@@ -34,33 +58,32 @@ FOREACH(v ${expected_defined_vars})
ENDIF()
ENDFOREACH()
# Check QT_QMAKE_EXECUTABLE provided by VTK
SET(extra_error_message)
IF(NOT DEFINED QT_QMAKE_EXECUTABLE AND EXISTS "${VTK_QT_QMAKE_EXECUTABLE}")
IF(DEFINED VTK_QT_QMAKE_EXECUTABLE)
MESSAGE(STATUS "Checking VTK_QT_QMAKE_EXECUTABLE ...")
IF(NOT EXISTS "${VTK_QT_QMAKE_EXECUTABLE}")
MESSAGE(FATAL_ERROR "error: You should probably re-configure VTK. VTK_QT_QMAKE_EXECUTABLE points to a nonexistent executable: ${VTK_QT_QMAKE_EXECUTABLE}")
ENDIF()
SET(QT_QMAKE_EXECUTABLE ${VTK_QT_QMAKE_EXECUTABLE})
SET(extra_error_message "You should probably reconfigure VTK.")
__SlicerBlockFindQtAndCheckVersion_find_qt()
SET(qt_version_discovered_using_vtk "${QT_VERSION_MAJOR}.${QT_VERSION_MINOR}.${QT_VERSION_PATCH}")
ENDIF()
FIND_PACKAGE(Qt4)
IF(NOT QT4_FOUND)
MESSAGE(FATAL_ERROR "error: Qt >= ${Slicer_REQUIRED_QT_VERSION} was not found on your system. You probably need to set the QT_QMAKE_EXECUTABLE variable.")
ENDIF()
# Check version, note that ${QT_VERSION_PATCH} could also be used
IF("${QT_VERSION_MAJOR}.${QT_VERSION_MINOR}.${QT_VERSION_PATCH}" VERSION_LESS "${Slicer_REQUIRED_QT_VERSION}")
MESSAGE(FATAL_ERROR "error: Slicer requires Qt >= ${Slicer_REQUIRED_QT_VERSION} -- you cannot use Qt ${QT_VERSION_MAJOR}.${QT_VERSION_MINOR}.${QT_VERSION_PATCH}. ${extra_error_message}")
# Check QT_QMAKE_EXECUTABLE provided by CTK
IF(DEFINED CTK_QT_QMAKE_EXECUTABLE)
MESSAGE(STATUS "Checking CTK_QT_QMAKE_EXECUTABLE ...")
IF(NOT EXISTS "${CTK_QT_QMAKE_EXECUTABLE}")
MESSAGE(FATAL_ERROR "error: You should probably re-configure CTK. CTK_QT_QMAKE_EXECUTABLE points to a nonexistent executable: ${CTK_QT_QMAKE_EXECUTABLE}")
ENDIF()
SET(QT_QMAKE_EXECUTABLE ${CTK_QT_QMAKE_EXECUTABLE})
SET(extra_error_message "You should probably reconfigure VTK.")
__SlicerBlockFindQtAndCheckVersion_find_qt()
SET(qt_version_discovered_using_ctk "${QT_VERSION_MAJOR}.${QT_VERSION_MINOR}.${QT_VERSION_PATCH}")
ENDIF()
set(command_separated_module_list)
# Check if all expected Qt modules have been discovered
FOREACH(module ${Slicer_REQUIRED_QT_MODULES})
IF(NOT ${QT_QT${module}_FOUND})
MESSAGE(FATAL_ERROR "error: ")
ENDIF()
IF(NOT ${module} STREQUAL "CORE" AND NOT ${module} STREQUAL "GUI")
SET(QT_USE_QT${module} ON)
ENDIF()
set(command_separated_module_list "${command_separated_module_list}${module}, ")
ENDFOREACH()
__SlicerBlockFindQtAndCheckVersion_find_qt()
INCLUDE(${QT_USE_FILE})
......
......@@ -71,6 +71,9 @@ IF(NOT GIT_FOUND)
MESSAGE(FATAL_ERROR "error: Install Git and try to re-configure")
ENDIF()
#-----------------------------------------------------------------------------
# Qt - Slicer_REQUIRED_QT_VERSION
#-----------------------------------------------------------------------------
SET(Slicer_REQUIRED_QT_VERSION "4.6.2")
#-----------------------------------------------------------------------------
......@@ -233,6 +236,16 @@ SET(Slicer_INSTALL_ITKFACTORIES_DIR "${Slicer_INSTALL_LIB_DIR}/ITKFactories")
# Set to create Bundle in a directory
SET(Slicer_BUNDLE_LOCATION ".")
#-----------------------------------------------------------------------------
# Qt - Slicer_REQUIRED_QT_MODULES
#-----------------------------------------------------------------------------
# Module name should be specified as they appear in FindQt4.cmake
# For example, the module name associated with the variable QT_USE_QTXML is XML.
SET(Slicer_REQUIRED_QT_MODULES CORE GUI NETWORK)
IF(BUILD_TESTING)
LIST(APPEND Slicer_REQUIRED_QT_MODULES TEST)
ENDIF()
#-----------------------------------------------------------------------------
# Superbuild script
#-----------------------------------------------------------------------------
......@@ -396,25 +409,19 @@ ENDIF()
INCLUDE(${VTK_USE_FILE})
#-----------------------------------------------------------------------------
# Qt
# CTK
#-----------------------------------------------------------------------------
# Module name should be specified as they appear in FindQt4.cmake
# For example, the module name associated with the variable QT_USE_QTXML is XML.
SET(Slicer_REQUIRED_QT_MODULES CORE GUI NETWORK)
IF(BUILD_TESTING)
LIST(APPEND Slicer_REQUIRED_QT_MODULES TEST)
ENDIF()
INCLUDE(SlicerBlockFindQtAndCheckVersion)
FIND_PACKAGE(CTK REQUIRED)
INCLUDE(${CTK_USE_FILE})
#-----------------------------------------------------------------------------
# CTK
# Qt
#-----------------------------------------------------------------------------
INCLUDE(SlicerBlockFindQtAndCheckVersion)
FIND_PACKAGE(CTK REQUIRED)
INCLUDE(${CTK_USE_FILE})
#-----------------------------------------------------------------------------
# Update CMake module path
#-----------------------------------------------------------------------------
SET(CMAKE_MODULE_PATH
${VTK_CMAKE_DIR}
${CTK_CMAKE_DIR}
......
......@@ -33,15 +33,7 @@ endif()
#-----------------------------------------------------------------------------
# Qt - Let's check if a valid version of Qt is available
#-----------------------------------------------------------------------------
FIND_PACKAGE(Qt4)
IF(QT_FOUND)
IF("${QT_VERSION_MAJOR}.${QT_VERSION_MINOR}.${QT_VERSION_PATCH}" VERSION_LESS "${minimum_required_qt_version}")
MESSAGE(FATAL_ERROR "error: Slicer requires Qt >= ${minimum_required_qt_version} -- you cannot use Qt ${QT_VERSION_MAJOR}.${QT_VERSION_MINOR}.${QT_VERSION_PATCH}.")
ENDIF()
ELSE()
MESSAGE(FATAL_ERROR "error: Qt4 was not found on your system. You probably need to set the QT_QMAKE_EXECUTABLE variable")
ENDIF()
INCLUDE(SlicerBlockFindQtAndCheckVersion)
#-----------------------------------------------------------------------------
# Enable and setup External project global properties
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment