Commit 1e4cc629 authored by jcfr's avatar jcfr

COMP: Update build system removing support for C++98/Qt4/VTK7

This commit updates the build system removing support for building
Slicer with C++98, VTK7 and Qt4.

It is based on work done in PR #1060.
Co-authored-by: Hans Johnson's avatarHans Johnson <hans-johnson@uiowa.edu>
Co-authored-by: Jean-Christophe Fillion-Robin's avatarJean-Christophe Fillion-Robin <jchris.fillionr@kitware.com>
Co-authored-by: phcerdan's avatarPablo Hernandez-Cerdan <pablo.hernandez.cerdan@outlook.com>

From: Pablo Hernandez-Cerdan <pablo.hernandez@kitware.com>

git-svn-id: http://svn.slicer.org/Slicer4/trunk@28000 3bd1e089-480b-0410-8dfb-8563597acbee
parent 29be7973
......@@ -52,15 +52,9 @@ if(BUILD_TESTING)
endif()
set(KIT_TEST_TARGET_LIBRARIES ${KIT})
if(CTK_QT_VERSION VERSION_LESS "5")
QT4_GENERATE_MOCS(${KIT_TEST_GENERATE_MOC_SRCS})
QT4_ADD_RESOURCES(Tests Resources/${KIT}Testing.qrc)
list(APPEND KIT_TEST_TARGET_LIBRARIES Qt4::QtTest)
else()
QT5_GENERATE_MOCS(${KIT_TEST_GENERATE_MOC_SRCS})
QT5_ADD_RESOURCES(Tests Resources/${KIT}Testing.qrc)
list(APPEND KIT_TEST_TARGET_LIBRARIES Qt5::Test)
endif()
if(Slicer_USE_PYTHONQT)
list(APPEND KIT_TEST_TARGET_LIBRARIES
......
......@@ -72,17 +72,10 @@ if(BUILD_TESTING)
)
endif()
if(CTK_QT_VERSION VERSION_LESS "5")
if(KIT_TEST_GENERATE_MOC_SRCS)
QT4_GENERATE_MOCS(${KIT_TEST_GENERATE_MOC_SRCS})
endif()
QT4_ADD_RESOURCES(Tests Resources/${KIT}Testing.qrc)
else()
if(KIT_TEST_GENERATE_MOC_SRCS)
QT5_GENERATE_MOCS(${KIT_TEST_GENERATE_MOC_SRCS})
endif()
QT5_ADD_RESOURCES(Tests Resources/${KIT}Testing.qrc)
endif()
add_executable(${KIT}CxxTests ${Tests})
target_link_libraries(${KIT}CxxTests ${KIT})
......
......@@ -24,15 +24,6 @@
#
macro(__SlicerBlockFindQtAndCheckVersion_find_qt)
if(Slicer_REQUIRED_QT_VERSION VERSION_LESS "5")
find_package(Qt4)
set(_found_var QT4_FOUND)
set(_error_details "You probably need to set the QT_QMAKE_EXECUTABLE variable.")
set(_major ${QT_VERSION_MAJOR})
set(_minor ${QT_VERSION_MINOR})
set(_patch ${QT_VERSION_PATCH})
set(_found_prefix "QT_")
else()
find_package(Qt5 COMPONENTS ${Slicer_REQUIRED_QT_MODULES})
set(_found_var Qt5_FOUND)
set(_error_details "You probably need to set the Qt5_DIR variable.")
......@@ -40,7 +31,6 @@ macro(__SlicerBlockFindQtAndCheckVersion_find_qt)
set(_minor ${Qt5_VERSION_MINOR})
set(_patch ${Qt5_VERSION_PATCH})
set(_found_prefix "Qt5")
endif()
if(NOT ${_found_var})
message(FATAL_ERROR "error: Qt ${Slicer_REQUIRED_QT_VERSION} was not found on your system."
"${_error_details}")
......@@ -58,12 +48,6 @@ macro(__SlicerBlockFindQtAndCheckVersion_find_qt)
if(NOT "${${_found_prefix}${module}_FOUND}")
message(FATAL_ERROR "error: Missing Qt module named \"${module}\"")
endif()
if(NOT ${module} STREQUAL "QTCORE"
AND NOT ${module} STREQUAL "QTGUI"
AND Slicer_REQUIRED_QT_VERSION VERSION_LESS "5"
)
set(QT_USE_${module} ON)
endif()
set(command_separated_module_list "${command_separated_module_list}${module}, ")
endforeach()
endmacro()
......@@ -81,38 +65,12 @@ endforeach()
# Check QT_QMAKE_EXECUTABLE provided by VTK
set(extra_error_message)
if(DEFINED VTK_QT_QMAKE_EXECUTABLE AND Slicer_REQUIRED_QT_VERSION VERSION_LESS "5")
#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()
endif()
# Check QT_QMAKE_EXECUTABLE provided by CTK
if(DEFINED CTK_QT_QMAKE_EXECUTABLE AND Slicer_REQUIRED_QT_VERSION VERSION_LESS "5")
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 CTK.")
__SlicerBlockFindQtAndCheckVersion_find_qt()
endif()
if(Slicer_REQUIRED_QT_VERSION VERSION_GREATER "4.9")
if(DEFINED CTK_Qt5_DIR AND NOT EXISTS "${CTK_Qt5_DIR}")
message(FATAL_ERROR "error: You should probably re-configure CTK. CTK_Qt5_DIR points to a nonexistent directory: ${CTK_Qt5_DIR}")
endif()
endif()
__SlicerBlockFindQtAndCheckVersion_find_qt()
if(Slicer_REQUIRED_QT_VERSION VERSION_LESS "5")
include(${QT_USE_FILE})
endif()
set(_project_name ${Slicer_MAIN_PROJECT_APPLICATION_NAME})
if(NOT Slicer_SOURCE_DIR)
set(_project_name ${PROJECT_NAME})
......@@ -121,7 +79,6 @@ message(STATUS "Configuring ${_project_name} with Qt ${_major}.${_minor}.${_patc
# Since Qt5 does not set CMake variables for plugins and binary directories,
# we explicitly set them here.
if(Slicer_REQUIRED_QT_VERSION VERSION_GREATER "4.9")
set(QT_PLUGINS_DIR "${Qt5_DIR}/../../../plugins")
get_filename_component(QT_PLUGINS_DIR ${QT_PLUGINS_DIR} ABSOLUTE)
message(STATUS "Setting QT_PLUGINS_DIR: ${QT_PLUGINS_DIR}")
......@@ -129,4 +86,3 @@ if(Slicer_REQUIRED_QT_VERSION VERSION_GREATER "4.9")
set(QT_BINARY_DIR "${Qt5_DIR}/../../../bin")
get_filename_component(QT_BINARY_DIR ${QT_BINARY_DIR} ABSOLUTE)
message(STATUS "Setting QT_BINARY_DIR: ${QT_BINARY_DIR}")
endif()
......@@ -4,11 +4,7 @@ if(NOT APPLE)
endif()
# Install VTK python module
if(Slicer_VTK_VERSION_MAJOR VERSION_GREATER "7")
set(VTK_PYTHON_MODULE "${VTK_DIR}/lib/python2.7/site-packages")
else()
set(VTK_PYTHON_MODULE "${VTK_DIR}/Wrapping/Python")
endif()
set(VTK_PYTHON_MODULE "${VTK_DIR}/lib/python2.7/site-packages")
set(_vtk_package "vtk")
if(EXISTS ${VTK_PYTHON_MODULE}/vtkmodules)
set(_vtk_package "vtkmodules") # Introduced in VTK9 kitware/vtk@2404228 on 2017.12.15
......@@ -30,11 +26,7 @@ if(EXISTS ${VTK_PYTHON_MODULE}/vtk.py)
endif()
# Install external python runtime libraries that we don't link to (fixupbundle won't copy them)
if(Slicer_VTK_VERSION_MAJOR VERSION_GREATER "7")
set(vtk_python_library_subdir "lib/python2.7/site-packages/${_vtk_package}")
else()
set(vtk_python_library_subdir "lib")
endif()
set(vtk_python_library_subdir "lib/python2.7/site-packages/${_vtk_package}")
file(GLOB vtk_python_modules "${VTK_DIR}/${vtk_python_library_subdir}/*Python.so")
install(FILES ${vtk_python_modules}
DESTINATION ${Slicer_INSTALL_LIB_DIR}
......
......@@ -3,33 +3,6 @@
# -------------------------------------------------------------------------
set(QT_INSTALL_LIB_DIR ${Slicer_INSTALL_LIB_DIR})
if(Slicer_REQUIRED_QT_VERSION VERSION_LESS "5")
foreach(qtlib ${Slicer_REQUIRED_QT_MODULES})
if(QT_${qtlib}_LIBRARY_RELEASE)
if(APPLE)
install(DIRECTORY "${QT_${qtlib}_LIBRARY_RELEASE}"
DESTINATION ${QT_INSTALL_LIB_DIR} COMPONENT Runtime)
elseif(UNIX)
# Install .so and versioned .so.x.y
get_filename_component(QT_LIB_DIR_tmp ${QT_${qtlib}_LIBRARY_RELEASE} PATH)
get_filename_component(QT_LIB_NAME_tmp ${QT_${qtlib}_LIBRARY_RELEASE} NAME)
install(DIRECTORY ${QT_LIB_DIR_tmp}/
DESTINATION ${QT_INSTALL_LIB_DIR} COMPONENT Runtime
FILES_MATCHING PATTERN "${QT_LIB_NAME_tmp}*"
PATTERN "${QT_LIB_NAME_tmp}*.debug" EXCLUDE)
elseif(WIN32)
get_filename_component(QT_DLL_PATH_tmp ${QT_QMAKE_EXECUTABLE} PATH)
if(EXISTS "${QT_DLL_PATH_tmp}/${qtlib}4.dll")
install(FILES ${QT_DLL_PATH_tmp}/${qtlib}4.dll
DESTINATION bin COMPONENT Runtime)
endif()
endif()
endif()
endforeach()
else()
list(APPEND QT_LIBRARIES
"Qt5::Gui"
)
......@@ -194,4 +167,3 @@ else()
RENAME designer-real${CMAKE_EXECUTABLE_SUFFIX}
)
endif()
endif()
......@@ -36,11 +36,6 @@ if(NOT Slicer_USE_SYSTEM_QT)
imageformats
sqldrivers
)
if(Slicer_REQUIRED_QT_VERSION VERSION_LESS "5")
list(APPEND SlicerBlockInstallQtPlugins_subdirectories
designer:qwebview
)
else()
list(APPEND SlicerBlockInstallQtPlugins_subdirectories
designer:webengineview
)
......@@ -58,7 +53,6 @@ if(NOT Slicer_USE_SYSTEM_QT)
platforms:windows
)
endif()
endif()
include(${Slicer_CMAKE_DIR}/SlicerBlockInstallQtPlugins.cmake)
endif()
......@@ -67,7 +61,7 @@ if(Slicer_BUILD_DICOM_SUPPORT AND NOT Slicer_USE_SYSTEM_DCMTK)
endif()
# Install Qt designer launcher
if(Slicer_BUILD_QT_DESIGNER_PLUGINS AND ${Slicer_REQUIRED_QT_VERSION} VERSION_GREATER_EQUAL 5)
if(Slicer_BUILD_QT_DESIGNER_PLUGINS)
set(executablename "SlicerDesigner")
set(build_designer_executable "${QT_BINARY_DIR}/designer${CMAKE_EXECUTABLE_SUFFIX}")
if(APPLE)
......@@ -182,12 +176,9 @@ else()
set(VTK_LIBRARY_DIRS "${VTK_DIR}/lib")
# Get Qt root directory
set(qt_root_dir "")
if(Slicer_REQUIRED_QT_VERSION VERSION_GREATER "4")
get_property(_filepath TARGET "Qt5::Core" PROPERTY LOCATION_RELEASE)
get_filename_component(_dir ${_filepath} PATH)
set(qt_root_dir "${_dir}/..")
endif()
get_property(_filepath TARGET "Qt5::Core" PROPERTY LOCATION_RELEASE)
get_filename_component(_dir ${_filepath} PATH)
set(qt_root_dir "${_dir}/..")
#------------------------------------------------------------------------------
# <ExtensionName>_FIXUP_BUNDLE_LIBRARY_DIRECTORIES
......
......@@ -35,11 +35,7 @@ dashboard_set(Slicer_BUILD_CLI ON)
dashboard_set(Slicer_USE_PYTHONQT ON)
dashboard_set(QT_VERSION "5.10.0")
if(QT_VERSION VERSION_LESS 5)
dashboard_set(QT_QMAKE_EXECUTABLE "${DASHBOARDS_DIR}/Support/qt/qt-everywhere-opensource-build-${QT_VERSION}/bin/qmake")
else()
dashboard_set(Qt5_DIR "${DASHBOARDS_DIR}/Support/Qt${QT_VERSION}/${QT_VERSION}/gcc_64/lib/cmake/Qt5")
endif()
dashboard_set(Qt5_DIR "${DASHBOARDS_DIR}/Support/Qt${QT_VERSION}/${QT_VERSION}/gcc_64/lib/cmake/Qt5")
# Source directory : <DASHBOARDS_DIR>/<Slicer_DASHBOARD_SUBDIR>/<Slicer_DIRECTORY_BASENAME>-<Slicer_DIRECTORY_IDENTIFIER>
# Build directory : <DASHBOARDS_DIR>/<Slicer_DASHBOARD_SUBDIR>/<Slicer_DIRECTORY_BASENAME>-<Slicer_DIRECTORY_IDENTIFIER>-build
......
......@@ -124,13 +124,11 @@ if(APPLE)
endif()
endif()
if(DEFINED Slicer_SOURCE_DIR AND ("${Slicer_VTK_VERSION_MAJOR}" STREQUAL "8" OR DEFINED Qt5_DIR))
if(DEFINED Slicer_SOURCE_DIR)
# Require minimum deployment target of 10.9. In 10.9 libc++ replaces libstdc++
# as the default runtime. Requiring this minimum ensures that all libraries
# use libc++.
set(required_deployment_target "10.9")
else()
set(required_deployment_target "10.6")
endif()
if(CMAKE_OSX_DEPLOYMENT_TARGET VERSION_LESS ${required_deployment_target})
message(FATAL_ERROR "CMAKE_OSX_DEPLOYMENT_TARGET must be ${required_deployment_target} or greater.")
......
......@@ -141,17 +141,6 @@ macro(slicerMacroBuildAppLibrary)
#-----------------------------------------------------------------------------
# Sources
# --------------------------------------------------------------------------
if(CTK_QT_VERSION VERSION_LESS "5")
set(_moc_options)
if(Slicer_HAVE_WEBKIT_SUPPORT)
set(_moc_options OPTIONS -DSlicer_HAVE_WEBKIT_SUPPORT)
endif()
QT4_WRAP_CPP(SLICERAPPLIB_MOC_OUTPUT ${SLICERAPPLIB_MOC_SRCS} ${_moc_options})
QT4_WRAP_UI(SLICERAPPLIB_UI_CXX ${SLICERAPPLIB_UI_SRCS})
if(DEFINED SLICERAPPLIB_RESOURCES)
QT4_ADD_RESOURCES(SLICERAPPLIB_QRC_SRCS ${SLICERAPPLIB_RESOURCES})
endif()
else()
set(_moc_options OPTIONS -DSlicer_HAVE_QT5)
if(Slicer_HAVE_WEBKIT_SUPPORT)
set(_moc_options OPTIONS -DSlicer_HAVE_WEBKIT_SUPPORT)
......@@ -161,7 +150,6 @@ macro(slicerMacroBuildAppLibrary)
if(DEFINED SLICERAPPLIB_RESOURCES)
QT5_ADD_RESOURCES(SLICERAPPLIB_QRC_SRCS ${SLICERAPPLIB_RESOURCES})
endif()
endif()
set_source_files_properties(
${SLICERAPPLIB_UI_CXX}
......@@ -540,7 +528,7 @@ macro(slicerMacroBuildApplication)
# within the build tree
set(extraApplicationToLaunchListForBuildTree)
if(${Slicer_REQUIRED_QT_VERSION} VERSION_GREATER_EQUAL 5 AND NOT QT_DESIGNER_EXECUTABLE)
if(NOT QT_DESIGNER_EXECUTABLE)
# Since Qt only provides a CMake module to find the designer library, we work
# around this limitation by finding the designer executable.
find_program(QT_DESIGNER_EXECUTABLE designer Designer HINTS "${QT_BINARY_DIR}" NO_DEFAULT_PATH)
......@@ -604,7 +592,7 @@ macro(slicerMacroBuildApplication)
endif()
endforeach()
if(${Slicer_REQUIRED_QT_VERSION} VERSION_GREATER_EQUAL 5 AND EXISTS ${QT_DESIGNER_EXECUTABLE} AND NOT APPLE)
if(EXISTS ${QT_DESIGNER_EXECUTABLE} AND NOT APPLE)
ctkAppLauncherAppendExtraAppToLaunchToList(
LONG_ARG designer
HELP "Start Qt designer using Slicer plugins"
......
......@@ -138,19 +138,6 @@ macro(SlicerMacroBuildBaseQtLibrary)
#-----------------------------------------------------------------------------
# Sources
# --------------------------------------------------------------------------
if(CTK_QT_VERSION VERSION_LESS "5")
set(_moc_options)
if(Slicer_HAVE_WEBKIT_SUPPORT)
set(_moc_options OPTIONS -DSlicer_HAVE_WEBKIT_SUPPORT)
endif()
QT4_WRAP_CPP(SLICERQTBASELIB_MOC_OUTPUT ${SLICERQTBASELIB_MOC_SRCS} ${_moc_options})
QT4_WRAP_UI(SLICERQTBASELIB_UI_CXX ${SLICERQTBASELIB_UI_SRCS})
if(DEFINED SLICERQTBASELIB_RESOURCES)
QT4_ADD_RESOURCES(SLICERQTBASELIB_QRC_SRCS ${SLICERQTBASELIB_RESOURCES})
endif()
QT4_ADD_RESOURCES(SLICERQTBASELIB_QRC_SRCS ${Slicer_SOURCE_DIR}/Resources/qSlicer.qrc)
else()
set(_moc_options OPTIONS -DSlicer_HAVE_QT5)
if(Slicer_HAVE_WEBKIT_SUPPORT)
set(_moc_options OPTIONS -DSlicer_HAVE_WEBKIT_SUPPORT)
......@@ -162,7 +149,6 @@ macro(SlicerMacroBuildBaseQtLibrary)
endif()
QT5_ADD_RESOURCES(SLICERQTBASELIB_QRC_SRCS ${Slicer_SOURCE_DIR}/Resources/qSlicer.qrc)
endif()
set_source_files_properties(
${SLICERQTBASELIB_UI_CXX}
......
......@@ -131,18 +131,6 @@ macro(slicerMacroBuildLoadableModule)
message("Warning, Slicer_LOGOS_RESOURCE doesn't exist: ${Slicer_LOGOS_RESOURCE}")
endif()
if(CTK_QT_VERSION VERSION_LESS "5")
set(_moc_options)
if(Slicer_HAVE_WEBKIT_SUPPORT)
set(_moc_options OPTIONS -DSlicer_HAVE_WEBKIT_SUPPORT)
endif()
QT4_WRAP_CPP(LOADABLEMODULE_MOC_OUTPUT ${LOADABLEMODULE_MOC_SRCS} ${_moc_options})
QT4_WRAP_UI(LOADABLEMODULE_UI_CXX ${LOADABLEMODULE_UI_SRCS})
if(DEFINED LOADABLEMODULE_RESOURCES)
QT4_ADD_RESOURCES(LOADABLEMODULE_QRC_SRCS ${LOADABLEMODULE_RESOURCES})
endif()
QT4_ADD_RESOURCES(LOADABLEMODULE_QRC_SRCS ${Slicer_LOGOS_RESOURCE})
else()
set(_moc_options OPTIONS -DSlicer_HAVE_QT5)
if(Slicer_HAVE_WEBKIT_SUPPORT)
set(_moc_options OPTIONS -DSlicer_HAVE_WEBKIT_SUPPORT)
......@@ -153,7 +141,6 @@ macro(slicerMacroBuildLoadableModule)
QT5_ADD_RESOURCES(LOADABLEMODULE_QRC_SRCS ${LOADABLEMODULE_RESOURCES})
endif()
QT5_ADD_RESOURCES(LOADABLEMODULE_QRC_SRCS ${Slicer_LOGOS_RESOURCE})
endif()
set_source_files_properties(
${LOADABLEMODULE_SRCS} # For now, let's prevent the module widget from being wrapped
......
......@@ -119,18 +119,6 @@ macro(SlicerMacroBuildModuleQtLibrary)
message("Warning, Slicer_LOGOS_RESOURCE doesn't exist: ${Slicer_LOGOS_RESOURCE}")
endif()
if(CTK_QT_VERSION VERSION_LESS "5")
set(_moc_options)
if(Slicer_HAVE_WEBKIT_SUPPORT)
set(_moc_options OPTIONS -DSlicer_HAVE_WEBKIT_SUPPORT)
endif()
QT4_WRAP_CPP(MODULEQTLIBRARY_MOC_OUTPUT ${MODULEQTLIBRARY_MOC_SRCS} ${_moc_options})
QT4_WRAP_UI(MODULEQTLIBRARY_UI_CXX ${MODULEQTLIBRARY_UI_SRCS})
if(DEFINED MODULEQTLIBRARY_RESOURCES AND NOT MODULEQTLIBRARY_RESOURCES STREQUAL "")
QT4_ADD_RESOURCES(MODULEQTLIBRARY_QRC_SRCS ${MODULEQTLIBRARY_RESOURCES})
endif()
QT4_ADD_RESOURCES(MODULEQTLIBRARY_QRC_SRCS ${Slicer_LOGOS_RESOURCE})
else()
set(_moc_options OPTIONS -DSlicer_HAVE_QT5)
if(Slicer_HAVE_WEBKIT_SUPPORT)
set(_moc_options OPTIONS -DSlicer_HAVE_WEBKIT_SUPPORT)
......@@ -141,7 +129,6 @@ macro(SlicerMacroBuildModuleQtLibrary)
QT5_ADD_RESOURCES(MODULEQTLIBRARY_QRC_SRCS ${MODULEQTLIBRARY_RESOURCES})
endif()
QT5_ADD_RESOURCES(MODULEQTLIBRARY_QRC_SRCS ${Slicer_LOGOS_RESOURCE})
endif()
set_source_files_properties(
${MODULEQTLIBRARY_UI_CXX}
......
......@@ -83,19 +83,11 @@ function(SlicerMacroTranslation)
# UPDATE or ADD translation
# ---------------------------------------------------------------------------------
if(CTK_QT_VERSION VERSION_LESS "5")
if(Slicer_UPDATE_TRANSLATION)
QT4_CREATE_TRANSLATION(QM_OUTPUT_FILES ${FILES_TO_TRANSLATE} ${TS_FILES})
else()
QT4_ADD_TRANSLATION(QM_OUTPUT_FILES ${TS_FILES})
endif()
else()
if(Slicer_UPDATE_TRANSLATION)
QT5_CREATE_TRANSLATION(QM_OUTPUT_FILES ${FILES_TO_TRANSLATE} ${TS_FILES})
else()
QT5_ADD_TRANSLATION(QM_OUTPUT_FILES ${TS_FILES})
endif()
endif()
# ---------------------------------------------------------------------------------
# Set the variable qm_output_dir
......
......@@ -5,16 +5,15 @@ cmake_minimum_required(VERSION 3.13.4)
#-----------------------------------------------------------------------------
set(_msg "Setting C++ standard")
message(STATUS "${_msg}")
if(NOT DEFINED CMAKE_CXX_STANDARD)
if("${Slicer_VTK_VERSION_MAJOR}" STREQUAL "8" OR DEFINED Qt5_DIR)
set(CMAKE_CXX_STANDARD 11)
else()
set(CMAKE_CXX_STANDARD 98)
endif()
if(NOT CMAKE_CXX_STANDARD)
set(CMAKE_CXX_STANDARD 11)
endif()
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
message(STATUS "${_msg} - C++${CMAKE_CXX_STANDARD}")
if(NOT CMAKE_CXX_STANDARD MATCHES "^(11|14|17)$")
message(FATAL_ERROR "CMAKE_CXX_STANDARD must be set to 11, 14 or 17")
endif()
#-----------------------------------------------------------------------------
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/CMake" ${CMAKE_MODULE_PATH})
......@@ -160,10 +159,7 @@ mark_as_superbuild(Patch_EXECUTABLE)
# Qt requirements
#-----------------------------------------------------------------------------
if(NOT DEFINED Slicer_REQUIRED_QT_VERSION)
set(_required_qt_version "4.7.4")
if(DEFINED Qt5_DIR OR "${Slicer_VTK_VERSION_MAJOR}" MATCHES "^(8|9)$" OR CMAKE_CXX_STANDARD MATCHES "^([1][0-9])$")
set(_required_qt_version "5.6.0")
endif()
set(_required_qt_version "5.6.0")
set(Slicer_REQUIRED_QT_VERSION ${_required_qt_version} CACHE STRING "Minimum required Qt version" FORCE)
endif()
mark_as_superbuild(Slicer_REQUIRED_QT_VERSION)
......@@ -302,18 +298,15 @@ mark_as_superbuild(Slicer_INSTALL_ITKPython)
option(Slicer_BUILD_PARAMETERSERIALIZER_SUPPORT "Build Slicer with parameter serializer support" ON)
mark_as_superbuild(Slicer_BUILD_PARAMETERSERIALIZER_SUPPORT)
set(_default_vtk "7")
if(DEFINED Qt5_DIR OR CMAKE_CXX_STANDARD MATCHES "^([1][0-9])$")
set(_default_vtk "8")
endif()
set(Slicer_VTK_VERSION_MAJOR ${_default_vtk} CACHE STRING "The VTK major version (7 or 8).")
set_property(CACHE Slicer_VTK_VERSION_MAJOR PROPERTY STRINGS "7" "8")
if(NOT "${Slicer_VTK_VERSION_MAJOR}" MATCHES "^(7|8)$")
set(_default_vtk "8")
set(Slicer_VTK_VERSION_MAJOR ${_default_vtk} CACHE STRING "VTK major version")
set_property(CACHE Slicer_VTK_VERSION_MAJOR PROPERTY STRINGS "8")
if(NOT "${Slicer_VTK_VERSION_MAJOR}" MATCHES "^(8)$")
if("${Slicer_VTK_VERSION_MAJOR}" STREQUAL "9")
set(Slicer_VTK_VERSION_MAJOR 8 CACHE STRING "The VTK major version (7 or 8)." FORCE)
message(WARNING "Forcing Slicer_VTK_VERSION_MAJOR to 8 because VTK version was changed from 9.0 to 8.2. See http://vtk.1045678.n5.nabble.com/Discussion-OK-to-change-VTK-s-version-number-from-9-0-to-8-2-tt5748702.html")
else()
message(FATAL_ERROR "error: Slicer_VTK_VERSION_MAJOR must be 7 or 8.")
message(FATAL_ERROR "error: Slicer_VTK_VERSION_MAJOR must be 8.")
endif()
endif()
mark_as_superbuild(Slicer_VTK_VERSION_MAJOR)
......@@ -466,11 +459,7 @@ endif()
#-----------------------------------------------------------------------------
# Slicer VTK Options
#-----------------------------------------------------------------------------
if(Slicer_VTK_VERSION_MAJOR STREQUAL "7")
set(_backend "OpenGL")
else()
set(_backend "OpenGL2")
endif()
set(_backend "OpenGL2")
set(Slicer_VTK_RENDERING_BACKEND "${_backend}" CACHE STRING "Rendering backend." FORCE)
mark_as_superbuild(Slicer_VTK_RENDERING_BACKEND)
set(Slicer_VTK_RENDERING_USE_${Slicer_VTK_RENDERING_BACKEND}_BACKEND 1)
......@@ -535,12 +524,6 @@ if(UNIX AND NOT APPLE)
if(FONTCONFIG_FOUND)
list(APPEND Slicer_VTK_COMPONENTS
vtkRenderingFreeTypeFontConfig
# vtkRenderingFreeTypeOpenGL # Since commit 4f7460a5 (> 6.2.0), vtkRenderingFreeTypeOpenGL
# has been removed. This mean Slicer will not compile
# against version of VTK folder than 6.3.0 having FontConfig
# capabilities.
# If this is needed, a configure test would have to
# be added to check if the module is available or not.
)
if(TARGET vtkRenderingFreeTypeOpenGL)
list(APPEND VTK_LIBRARIES vtkRenderingFreeTypeOpenGL)
......@@ -551,28 +534,9 @@ endif()
#-----------------------------------------------------------------------------
# Qt - Slicer_REQUIRED_QT_MODULES
#-----------------------------------------------------------------------------
# Module name should be specified as they appear in FindQt4.cmake or
# Module name should be specified as they appear in FindQt5.cmake.
# For example, the module name associated with the variable QT_USE_QTXML is QTXML.
# Note that the modules will be installed when packaging.
if(Slicer_REQUIRED_QT_VERSION VERSION_LESS "5")
set(Slicer_REQUIRED_QT_MODULES
QTCORE QTGUI
QTNETWORK QTOPENGL
QTUITOOLS #no dll
QTXML QTXMLPATTERNS
QTWEBKIT
QTSVG QTSQL
)
if(WIN32)
list(APPEND Slicer_REQUIRED_QT_MODULES PHONON) # webkit requires phonon
endif()
if(Slicer_BUILD_EXTENSIONMANAGER_SUPPORT)
list(APPEND Slicer_REQUIRED_QT_MODULES QTSCRIPT)
endif()
if(BUILD_TESTING)
list(APPEND Slicer_REQUIRED_QT_MODULES QTTEST)
endif()
else()
set(Slicer_REQUIRED_QT_MODULES
Core Widgets
Multimedia
......@@ -603,10 +567,8 @@ else()
if(BUILD_TESTING)
list(APPEND Slicer_REQUIRED_QT_MODULES Test)
endif()
endif()
list(APPEND Slicer_REQUIRED_QT_MODULES ${Slicer_ADDITIONAL_REQUIRED_QT_MODULES})
if(Slicer_REQUIRED_QT_VERSION VERSION_GREATER "4.9")
set(QT_LIBRARIES)
foreach(lib IN LISTS Slicer_REQUIRED_QT_MODULES)
if(lib MATCHES "^(LinguistTools)$")
......@@ -614,7 +576,6 @@ if(Slicer_REQUIRED_QT_VERSION VERSION_GREATER "4.9")
endif()
list(APPEND QT_LIBRARIES Qt5::${lib})
endforeach()
endif()
if(DEFINED Slicer_ADDITIONAL_REQUIRED_QT_MODULES)
mark_as_superbuild(Slicer_ADDITIONAL_REQUIRED_QT_MODULES:STRING)
......@@ -632,23 +593,14 @@ set(Slicer_INSTALL_QtPlugins_DIR "${Slicer_INSTALL_ROOT}${Slicer_QtPlugins_DIR}"
# Qt
#-----------------------------------------------------------------------------
include(SlicerBlockFindQtAndCheckVersion)
if(Slicer_REQUIRED_QT_VERSION VERSION_LESS "5")
mark_as_superbuild(VARS QT_QMAKE_EXECUTABLE LABELS "FIND_PACKAGE")
else()
mark_as_superbuild(VARS Qt5_DIR LABELS "FIND_PACKAGE")
endif()
set(Slicer_HAVE_QT5 1)
if(Slicer_REQUIRED_QT_VERSION VERSION_LESS "5")
set(Slicer_HAVE_QT5 0)
endif()
set(Slicer_HAVE_WEBKIT_SUPPORT 1)
if(Slicer_REQUIRED_QT_VERSION VERSION_GREATER "4.9")
if(Qt5_VERSION VERSION_GREATER "5.5.0")
set(Slicer_HAVE_WEBKIT_SUPPORT 0)
endif()
endif()
#
# If qmake or Qt5Config are associated with a system location, explicitly mark Qt as such. Doing so
......@@ -658,7 +610,6 @@ endif()
#
# See https://issues.slicer.org/view.php?id=3574
#
if(Slicer_HAVE_QT5)
foreach(_path IN ITEMS
"/usr/lib/"
"/usr/lib32/"
......@@ -678,34 +629,9 @@ if(Slicer_HAVE_QT5)
break()
endif()
endforeach()
else()
foreach(_path IN ITEMS
"/bin"
"/usr/bin/"
"/usr/local/bin"
# homebrew
"/usr/local/Cellar"
# macport
"/opt/bin"
"/opt/local/bin"
)
if("${QT_QMAKE_EXECUTABLE}" MATCHES "^${_path}")
set(Slicer_USE_SYSTEM_QT ON)
message(STATUS "")
message(STATUS "Forcing Slicer_USE_SYSTEM_QT to ON (qmake [${QT_QMAKE_EXECUTABLE}] found in a system location: ${_path})")
message(STATUS "")
break()
endif()
endforeach()
endif()
# Prefer QVTKOpenGLWidget to QVTKWidget when supported
# Always use QVTKOpenGLWidget (instead of QVTKWidget)
set(Slicer_VTK_USE_QVTKOPENGLWIDGET 1)
if(Slicer_REQUIRED_QT_VERSION VERSION_LESS "5"
OR Slicer_VTK_VERSION_MAJOR VERSION_LESS "8"
OR NOT Slicer_VTK_RENDERING_USE_OpenGL2_BACKEND)
set(Slicer_VTK_USE_QVTKOPENGLWIDGET 0)
endif()
#-----------------------------------------------------------------------------
# Testing
......@@ -853,13 +779,10 @@ find_package(VTK ${Slicer_VTK_VERSION_MAJOR} COMPONENTS ${Slicer_VTK_COMPONENTS}
if(NOT TARGET vtkGUISupportQt)
message(FATAL_ERROR "error: VTK was not configured to use QT, you probably need "
"to recompile it with VTK_USE_GUISUPPORT ON, VTK_Group_Qt ON, "
"DESIRED_QT_VERSION 4 and QT_QMAKE_EXECUTABLE set appropriately. "
"Note that Qt >= ${Slicer_REQUIRED_QT_VERSION} is *required*")
endif()
include(${VTK_USE_FILE})
if(NOT DEFINED VTK_RENDERING_BACKEND)
set(VTK_RENDERING_BACKEND "OpenGL")
endif()
set(VTK_RENDERING_BACKEND "${Slicer_VTK_RENDERING_BACKEND}")
#-----------------------------------------------------------------------------
# CTK
......
if(Slicer_REQUIRED_QT_VERSION VERSION_LESS "5")
set(Slicer_QT_VERSION_MAJOR "${QT_VERSION_MAJOR}")
set(Slicer_QT_VERSION_MINOR "${QT_VERSION_MINOR}")
else()
set(Slicer_QT_VERSION_MAJOR "${Qt5_VERSION_MAJOR}")
set(Slicer_QT_VERSION_MINOR "${Qt5_VERSION_MINOR}")
endif()
#-----------------------------------------------------------------------------
# Sanity checks
......
......@@ -46,16 +46,11 @@ endif()
# Configure headers
# --------------------------------------------------------------------------
set(MRML_WIDGETS_HAVE_QT5 1)
if(CTK_QT_VERSION VERSION_LESS "5")
set(MRML_WIDGETS_HAVE_QT5 0)
endif()
set(MRML_WIDGETS_HAVE_WEBKIT_SUPPORT 1)
if(CTK_QT_VERSION VERSION_GREATER "4")
if(Qt5_VERSION VERSION_GREATER "5.5.0")
set(MRML_WIDGETS_HAVE_WEBKIT_SUPPORT 0)
endif()
endif()
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/qMRMLWidgetsConfigure.h.in
......@@ -400,15 +395,6 @@ if(Slicer_USE_QtTesting)
)
endif()
if(CTK_QT_VERSION VERSION_LESS "5")
set(_moc_options)
if(MRML_WIDGETS_HAVE_WEBKIT_SUPPORT)
set(_moc_options OPTIONS -DMRML_WIDGETS_HAVE_WEBKIT_SUPPORT)
endif()
QT4_WRAP_CPP(MRMLWidgets_MOC_CXX ${MRMLWidgets_MOC_SRCS} OPTIONS ${_moc_options})
QT4_WRAP_UI(MRMLWidgets_UI_CXX ${MRMLWidgets_UI_SRCS})
QT4_ADD_RESOURCES(MRMLWidgets_QRC_CXX ${MRMLWidgets_QRC_SRCS})
else()
set(_moc_options OPTIONS -DMRML_WIDGETS_HAVE_QT5)
if(MRML_WIDGETS_HAVE_WEBKIT_SUPPORT)
set(_moc_options OPTIONS -DMRML_WIDGETS_HAVE_WEBKIT_SUPPORT)
......@@ -416,7 +402,6 @@ else()
QT5_WRAP_CPP(MRMLWidgets_MOC_CXX ${MRMLWidgets_MOC_SRCS} ${_moc_options})
QT5_WRAP_UI(MRMLWidgets_UI_CXX ${MRMLWidgets_UI_SRCS})
QT5_ADD_RESOURCES(MRMLWidgets_QRC_CXX ${MRMLWidgets_QRC_SRCS})
endif()
source_group("Resources" FILES
${MRMLWidgets_UI_SRCS}
......
......@@ -149,21 +149,12 @@ set(KIT_TEST_GENERATE_MOC_SRCS
qMRMLSceneModelTest.cxx
qMRMLSliceControllerWidgetTest.cxx
)
if(CTK_QT_VERSION VERSION_LESS "5")
set(_moc_options)
if(MRML_WIDGETS_HAVE_WEBKIT_SUPPORT)
set(_moc_options OPTIONS -DMRML_WIDGETS_HAVE_WEBKIT_SUPPORT)
endif()
QT4_WRAP_CPP(Tests_MOC_CXX ${Tests_MOC_SRCS} ${_moc_options})
QT4_GENERATE_MOCS(${KIT_TEST_GENERATE_MOC_SRCS})
else()
set(_moc_options OPTIONS -DMRML_WIDGETS_HAVE_QT5)
if(MRML_WIDGETS_HAVE_WEBKIT_SUPPORT)
set(_moc_options OPTIONS -DMRML_WIDGETS_HAVE_WEBKIT_SUPPORT)
endif()
QT5_WRAP_CPP(Tests_MOC_CXX ${Tests_MOC_SRCS} ${_moc_options})
QT5_GENERATE_MOCS(${KIT_TEST_GENERATE_MOC_SRCS})
endif()
include_directories( ${CMAKE_CURRENT_BINARY_DIR})
include_directories( ${CMAKE_CURRENT_SOURCE_DIR})
......
......@@ -16,11 +16,7 @@ set(KIT_TEST_SRCS
set(KIT_TEST_GENERATE_MOC_SRCS
qSlicer${MODULE_NAME}ModuleWidgetTest.cxx
)
if(CTK_QT_VERSION VERSION_LESS "5")
QT4_GENERATE_MOCS(${KIT_TEST_GENERATE_MOC_SRCS})
else()
QT5_GENERATE_MOCS(${KIT_TEST_GENERATE_MOC_SRCS})
endif()
include_directories( ${CMAKE_CURRENT_BINARY_DIR})
......
......@@ -9,11 +9,7 @@ set(KIT_TEST_SRCS
set(KIT_TEST_GENERATE_MOC_SRCS
qSlicer${MODULE_NAME}ModuleWidgetTest.cxx
)
if(CTK_QT_VERSION VERSION_LESS "5")
QT4_GENERATE_MOCS(${KIT_TEST_GENERATE_MOC_SRCS})
else()
QT5_GENERATE_MOCS(${KIT_TEST_GENERATE_MOC_SRCS})
endif()
include_directories(${CMAKE_CURRENT_BINARY_DIR})
#-----------------------------------------------------------------------------
......
......@@ -36,11 +36,7 @@ set(KIT_TEST_SRCS
set(KIT_TEST_GENERATE_MOC_SRCS
qSlicerPresetComboBoxTest.cxx
)
if(CTK_QT_VERSION VERSION_LESS "5")
QT4_GENERATE_MOCS(${KIT_TEST_GENERATE_MOC_SRCS})
else()
QT5_GENERATE_MOCS(${KIT_TEST_GENERATE_MOC_SRCS})
endif()
QT5_GENERATE_MOCS(${KIT_TEST_GENERATE_MOC_SRCS})
include_directories(${CMAKE_CURRENT_BINARY_DIR})