Commit f7d45916 authored by Brad King's avatar Brad King
Browse files

ENH: Patch from Clinton Stimpson for improved Qt3/Qt4 support. It has been...

ENH: Patch from Clinton Stimpson for improved Qt3/Qt4 support.  It has been tested with CMake 2.0 and 2.3 (which is very close to 2.2).
parent f88cf1e4
......@@ -10,8 +10,14 @@ INCLUDE(${VTK_USE_FILE})
SET(QT_QMAKE_EXECUTABLE ${VTK_QT_QMAKE_EXECUTABLE} CACHE FILEPATH "")
SET(QT_MOC_EXECUTABLE ${VTK_QT_MOC_EXECUTABLE} CACHE FILEPATH "")
SET(QT_UIC_EXECUTABLE ${VTK_QT_UIC_EXECUTABLE} CACHE FILEPATH "")
SET(QT_MAX_VERSION "4.9.9")
SET(DESIRED_QT_VERSION ${VTK_DESIRED_QT_VERSION} CACHE FILEPATH "")
FIND_PACKAGE(Qt)
IF(QT_USE_FILE)
SET(QT_USE_QT3SUPPORT TRUE)
INCLUDE(${QT_USE_FILE})
ELSE(QT_USE_FILE)
SET(QT_LIBRARIES ${QT_QT_LIBRARY})
ENDIF(QT_USE_FILE)
SET (SRCS
main.cxx
......@@ -20,18 +26,14 @@ SET (SRCS
# Use the include path and library for Qt that is used by VTK.
INCLUDE_DIRECTORIES(
${QT_INCLUDE_DIR}
${QT_QTGUI_INCLUDE_DIR}
${QT_QTCORE_INCLUDE_DIR}
${QT_QT3SUPPORT_INCLUDE_DIR}
${CMAKE_CURRENT_BINARY_DIR}
${CMAKE_CURRENT_SOURCE_DIR}
)
IF(QT_INST_MAJOR_VERSION GREATER 3)
IF(DESIRED_QT_VERSION MATCHES 4)
# instead of a complete port to Qt4, lets try out uic3 and Qt3Support
ADD_DEFINITIONS(-DQT_GUI_LIBS -DQT_CORE_LIB -DQT3_SUPPORT)
STRING(REGEX REPLACE "uic" "uic3" QT_UIC3_EXECUTABLE "${QT_UIC_EXECUTABLE}")
ADD_CUSTOM_COMMAND(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/GUI.h
COMMAND ${QT_UIC3_EXECUTABLE}
......@@ -60,12 +62,12 @@ IF(QT_INST_MAJOR_VERSION GREATER 3)
DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/GUI.h)
SET(UI_SRCS GUI.cxx moc_GUI.cxx)
ELSE(QT_INST_MAJOR_VERSION GREATER 3)
ELSE(DESIRED_QT_VERSION MATCHES 4)
QT_WRAP_UI( qtevents UI_HDRS UI_SRCS GUI.ui )
# help cmake with Qt depends
SET_SOURCE_FILES_PROPERTIES(main.cxx PROPERTIES
OBJECT_DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/GUI.h)
ENDIF(QT_INST_MAJOR_VERSION GREATER 3)
ENDIF(DESIRED_QT_VERSION MATCHES 4)
SET_SOURCE_FILES_PROPERTIES(GUI.cxx PROPERTIES
......@@ -73,38 +75,9 @@ SET_SOURCE_FILES_PROPERTIES(GUI.cxx PROPERTIES
ADD_EXECUTABLE( qtevents MACOSX_BUNDLE ${SRCS} ${UI_SRCS})
# note: if you use Mesa in VTK and get link errors about opengl symbols,
# those errors are coming from the Qt library needing to link with OpenGL.
# Either link OpenGL in, configure Qt to dlopen the GL library,
# or configure Qt without OpenGL support.
IF(QT_INST_MAJOR_VERSION GREATER 3)
IF(APPLE)
SET(QT_LIBS "-framework Qt3Support -framework QtGui" "-framework QtCore")
SET_TARGET_PROPERTIES(qtevents PROPERTIES LINK_FLAGS "-F${QT_LIBRARY_DIR}")
ELSE(APPLE)
IF(CMAKE_BUILD_TYPE)
SET(QT_LIBS optimized ${QT_QT3SUPPORT_LIBRARY} debug ${QT_QT3SUPPORT_LIBRARY_DEBUG}
optimized ${QT_QTGUI_LIBRARY} debug ${QT_QTGUI_LIBRARY_DEBUG}
optimized ${QT_QTCORE_LIBRARY} debug ${QT_QTCORE_LIBRARY_DEBUG} )
ELSE(CMAKE_BUILD_TYPE)
IF(CMAKE_CONFIGURATION_TYPES)
SET(QT_LIBS optimized ${QT_QT3SUPPORT_LIBRARY} debug ${QT_QT3SUPPORT_LIBRARY_DEBUG}
optimized ${QT_QTGUI_LIBRARY} debug ${QT_QTGUI_LIBRARY_DEBUG}
optimized ${QT_QTCORE_LIBRARY} debug ${QT_QTCORE_LIBRARY_DEBUG} )
ELSE(CMAKE_CONFIGURATION_TYPES)
SET(QT_LIBS ${QT_QT3SUPPORT_LIBRARY} ${QT_QTGUI_LIBRARY} ${QT_QTCORE_LIBRARY})
ENDIF(CMAKE_CONFIGURATION_TYPES)
ENDIF(CMAKE_BUILD_TYPE)
ENDIF(APPLE)
ELSE(QT_INST_MAJOR_VERSION GREATER 3)
SET(QT_LIBS ${QT_QT_LIBRARY})
ENDIF(QT_INST_MAJOR_VERSION GREATER 3)
TARGET_LINK_LIBRARIES( qtevents
QVTK
${QT_LIBS}
${QT_LIBRARIES}
vtkRendering
vtkGraphics
vtkIO
......
......@@ -9,7 +9,13 @@ INCLUDE(${VTK_USE_FILE})
SET(QT_QMAKE_EXECUTABLE ${VTK_QT_QMAKE_EXECUTABLE} CACHE FILEPATH "")
SET(QT_MOC_EXECUTABLE ${VTK_QT_MOC_EXECUTABLE} CACHE FILEPATH "")
SET(QT_UIC_EXECUTABLE ${VTK_QT_UIC_EXECUTABLE} CACHE FILEPATH "")
SET(DESIRED_QT_VERSION ${VTK_DESIRED_QT_VERSION} CACHE FILEPATH "")
FIND_PACKAGE(Qt)
IF(QT_USE_FILE)
INCLUDE(${QT_USE_FILE})
ELSE(QT_USE_FILE)
SET(QT_LIBRARIES ${QT_QT_LIBRARY})
ENDIF(QT_USE_FILE)
SET (SRCS
main.cxx
......@@ -21,35 +27,9 @@ INCLUDE_DIRECTORIES( ${QT_INCLUDE_DIR} ${QT_QTGUI_INCLUDE_DIR}
ADD_EXECUTABLE( qtimageviewer MACOSX_BUNDLE ${SRCS})
# note: if you use Mesa in VTK and get link errors about opengl symbols
# they are coming from Qt. Either link OpenGL in, configure Qt to
# dlopen the GL library, or configure Qt without OpenGL support.
IF(QT_INST_MAJOR_VERSION GREATER 3)
IF(APPLE)
SET(QT_LIBS "-framework QtGui" "-framework QtCore")
SET_TARGET_PROPERTIES(qtimageviewer PROPERTIES LINK_FLAGS "-F${QT_LIBRARY_DIR}")
ELSE(APPLE)
IF(CMAKE_BUILD_TYPE)
SET(QT_LIBS optimized ${QT_QTGUI_LIBRARY} debug ${QT_QTGUI_LIBRARY_DEBUG}
optimized ${QT_QTCORE_LIBRARY} debug ${QT_QTCORE_LIBRARY_DEBUG} )
ELSE(CMAKE_BUILD_TYPE)
IF(CMAKE_CONFIGURATION_TYPES)
SET(QT_LIBS optimized ${QT_QTGUI_LIBRARY} debug ${QT_QTGUI_LIBRARY_DEBUG}
optimized ${QT_QTCORE_LIBRARY} debug ${QT_QTCORE_LIBRARY_DEBUG} )
ELSE(CMAKE_CONFIGURATION_TYPES)
SET(QT_LIBS ${QT_QTGUI_LIBRARY} ${QT_QTCORE_LIBRARY})
ENDIF(CMAKE_CONFIGURATION_TYPES)
ENDIF(CMAKE_BUILD_TYPE)
ENDIF(APPLE)
ELSE(QT_INST_MAJOR_VERSION GREATER 3)
SET(QT_LIBS ${QT_QT_LIBRARY})
ENDIF(QT_INST_MAJOR_VERSION GREATER 3)
TARGET_LINK_LIBRARIES( qtimageviewer
QVTK
${QT_LIBS}
${QT_LIBRARIES}
vtkRendering
vtkGraphics
vtkIO
......
......@@ -10,8 +10,13 @@ INCLUDE(${VTK_USE_FILE})
SET(QT_MOC_EXECUTABLE ${VTK_QT_MOC_EXECUTABLE} CACHE FILEPATH "")
SET(QT_UIC_EXECUTABLE ${VTK_QT_UIC_EXECUTABLE} CACHE FILEPATH "")
SET(QT_QMAKE_EXECUTABLE ${VTK_QT_QMAKE_EXECUTABLE} CACHE FILEPATH "")
SET(QT_MAX_VERSION "4.9.9")
SET(DESIRED_QT_VERSION ${VTK_DESIRED_QT_VERSION} CACHE FILEPATH "")
FIND_PACKAGE(Qt)
IF(QT_USE_FILE)
INCLUDE(${QT_USE_FILE})
ELSE(QT_USE_FILE)
SET(QT_LIBRARIES ${QT_QT_LIBRARY})
ENDIF(QT_USE_FILE)
SET (SimpleViewSrcs
main.cxx
......@@ -20,13 +25,11 @@ SET (SimpleViewSrcs
# Use the include path and library for Qt that is used by VTK.
INCLUDE_DIRECTORIES(
${QT_INCLUDE_DIR}
${QT_QTGUI_INCLUDE_DIR}
${QT_QTCORE_INCLUDE_DIR}
${CMAKE_CURRENT_BINARY_DIR}
${CMAKE_CURRENT_SOURCE_DIR}
)
IF(QT_INST_MAJOR_VERSION GREATER 3)
IF(DESIRED_QT_VERSION MATCHES 4)
SET(SimpleViewSrcs ${SimpleViewSrcs} SimpleView4.cxx)
SET(UIS uiSimpleView4.ui)
......@@ -37,7 +40,7 @@ IF(QT_INST_MAJOR_VERSION GREATER 3)
SET_SOURCE_FILES_PROPERTIES(${SimpleViewSrcs} PROPERTIES
OBJECT_DEPENDS "${UIHeaders}")
ELSE(QT_INST_MAJOR_VERSION GREATER 3)
ELSE(DESIRED_QT_VERSION MATCHES 4)
SET(SimpleViewSrcs ${SimpleViewSrcs} SimpleView3.cxx)
SET(UIS uiSimpleView3.ui)
......@@ -47,7 +50,7 @@ ELSE(QT_INST_MAJOR_VERSION GREATER 3)
SET_SOURCE_FILES_PROPERTIES(${SimpleViewSrcs} PROPERTIES
OBJECT_DEPENDS "${UIHeaders}")
ENDIF(QT_INST_MAJOR_VERSION GREATER 3)
ENDIF(DESIRED_QT_VERSION MATCHES 4)
# It's nice to have the ui in the windows project file...just double click on it
# and designer comes up on that ui file :)
......@@ -60,34 +63,9 @@ ENDIF (${CMAKE_BUILD_TOOL} MATCHES "devenv")
ADD_EXECUTABLE( qtsimpleview MACOSX_BUNDLE ${SimpleViewSrcs} ${UISrcs} ${MOCSrcs})
# note: if you use Mesa in VTK and get link errors about opengl symbols
# they are coming from Qt. Either link OpenGL in, configure Qt to
# dlopen the GL library, or configure Qt without OpenGL support.
IF(QT_INST_MAJOR_VERSION GREATER 3)
IF(APPLE)
SET(QT_LIBS "-framework QtGui" "-framework QtCore")
SET_TARGET_PROPERTIES(qtsimpleview PROPERTIES LINK_FLAGS "-F${QT_LIBRARY_DIR}")
ELSE(APPLE)
IF(CMAKE_BUILD_TYPE)
SET(QT_LIBS optimized ${QT_QTGUI_LIBRARY} debug ${QT_QTGUI_LIBRARY_DEBUG}
optimized ${QT_QTCORE_LIBRARY} debug ${QT_QTCORE_LIBRARY_DEBUG} )
ELSE(CMAKE_BUILD_TYPE)
IF(CMAKE_CONFIGURATION_TYPES)
SET(QT_LIBS optimized ${QT_QTGUI_LIBRARY} debug ${QT_QTGUI_LIBRARY_DEBUG}
optimized ${QT_QTCORE_LIBRARY} debug ${QT_QTCORE_LIBRARY_DEBUG} )
ELSE(CMAKE_CONFIGURATION_TYPES)
SET(QT_LIBS ${QT_QTGUI_LIBRARY} ${QT_QTCORE_LIBRARY})
ENDIF(CMAKE_CONFIGURATION_TYPES)
ENDIF(CMAKE_BUILD_TYPE)
ENDIF(APPLE)
ELSE(QT_INST_MAJOR_VERSION GREATER 3)
SET(QT_LIBS ${QT_QT_LIBRARY})
ENDIF(QT_INST_MAJOR_VERSION GREATER 3)
TARGET_LINK_LIBRARIES( qtsimpleview
QVTK
${QT_LIBS}
${QT_LIBRARIES}
vtkRendering
vtkGraphics
vtkIO
......
# we need Qt3 or Qt4
SET(QT_MAX_VERSION "4.9.9")
INCLUDE( ${CMAKE_ROOT}/Modules/FindQt.cmake )
# set up sources to build
......@@ -15,12 +14,11 @@ SET ( QVTKMocHeaders
INCLUDE_DIRECTORIES ( ${CMAKE_CURRENT_BINARY_DIR} )
IF(QT_INST_MAJOR_VERSION GREATER 3)
# Qt4 settings
INCLUDE_DIRECTORIES ( ${QT_INCLUDE_DIR} ${QT_QTCORE_INCLUDE_DIR} ${QT_QTGUI_INCLUDE_DIR})
ADD_DEFINITIONS(-DQT_GUI_LIB -DQT_CORE_LIB -DQT_DLL)
IF(DESIRED_QT_VERSION MATCHES 4)
# import Qt4 build settings
INCLUDE(${QT_USE_FILE})
SET ( PluginLibSrcs
Q4VTKWidgetPlugin.cxx
QVTKWidget.cxx)
......@@ -36,24 +34,9 @@ IF(QT_INST_MAJOR_VERSION GREATER 3)
QT4_WRAP_CPP ( QVTKLibMocSrcs ${QVTKMocHeaders} )
QT4_WRAP_CPP ( PluginMocSrcs ${PluginMocHeaders} )
IF(APPLE)
# assume Qt framework
SET(QT_LIBS "-framework QtGui" "-framework QtCore")
ELSE(APPLE)
IF(CMAKE_BUILD_TYPE)
SET(QT_LIBS optimized ${QT_QTGUI_LIBRARY} debug ${QT_QTGUI_LIBRARY_DEBUG}
optimized ${QT_QTCORE_LIBRARY} debug ${QT_QTCORE_LIBRARY_DEBUG} )
ELSE(CMAKE_BUILD_TYPE)
IF(CMAKE_CONFIGURATION_TYPES)
SET(QT_LIBS optimized ${QT_QTGUI_LIBRARY} debug ${QT_QTGUI_LIBRARY_DEBUG}
optimized ${QT_QTCORE_LIBRARY} debug ${QT_QTCORE_LIBRARY_DEBUG} )
ELSE(CMAKE_CONFIGURATION_TYPES)
SET(QT_LIBS ${QT_QTGUI_LIBRARY} ${QT_QTCORE_LIBRARY})
ENDIF(CMAKE_CONFIGURATION_TYPES)
ENDIF(CMAKE_BUILD_TYPE)
ENDIF(APPLE)
SET(QT_LIBS "${QT_LIBRARIES}")
ELSE(QT_INST_MAJOR_VERSION GREATER 3)
ELSE(DESIRED_QT_VERSION MATCHES 4)
# Qt3 settings
INCLUDE_DIRECTORIES ( ${QT_INCLUDE_DIR} )
......@@ -81,7 +64,7 @@ ELSE(QT_INST_MAJOR_VERSION GREATER 3)
SET(QT_LIBS ${QT_QT_LIBRARY} )
ENDIF(QT_INST_MAJOR_VERSION GREATER 3)
ENDIF(DESIRED_QT_VERSION MATCHES 4)
SET_SOURCE_FILES_PROPERTIES(vtkEventQtSlotConnect.cxx PROPERTIES
OBJECT_DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/moc_vtkEventQtSlotConnect.cxx)
......@@ -93,13 +76,6 @@ IF(VTK_LIBRARY_PROPERTIES)
SET_TARGET_PROPERTIES(QVTK PROPERTIES ${VTK_LIBRARY_PROPERTIES})
ENDIF(VTK_LIBRARY_PROPERTIES)
# give Qt framework directory for linking
IF(APPLE)
IF(QT_INST_MAJOR_VERSION GREATER 3)
SET_TARGET_PROPERTIES(QVTK PROPERTIES LINK_FLAGS "-F${QT_LIBRARY_DIR}")
ENDIF(QT_INST_MAJOR_VERSION GREATER 3)
ENDIF(APPLE)
TARGET_LINK_LIBRARIES( QVTK
${QT_LIBS}
vtkRendering
......@@ -123,14 +99,14 @@ ENDIF(NOT BUILD_SHARED_LIBS)
IF(BUILD_QVTK_PLUGIN)
ADD_DEFINITIONS(-DQT_PLUGIN)
IF(QT_INST_MAJOR_VERSION GREATER 3)
IF(DESIRED_QT_VERSION MATCHES 4)
# A release build of the designer must have
# a release build of this plugin to work properly
# if the QtGui exists, a release build of the designer is assumed
IF(QT_QTGUI_LIBRARY)
ADD_DEFINITIONS(-DQT_NO_DEBUG)
ENDIF(QT_QTGUI_LIBRARY)
ENDIF(QT_INST_MAJOR_VERSION GREATER 3)
ENDIF(DESIRED_QT_VERSION MATCHES 4)
# add QVTK plugin from sources
# stand-alone as it doesn't depend on QVTK library
......@@ -140,12 +116,6 @@ IF(BUILD_QVTK_PLUGIN)
${PluginMocSrcs}
)
IF(APPLE)
IF(QT_INST_MAJOR_VERSION GREATER 3)
SET_TARGET_PROPERTIES(QVTKWidgetPlugin PROPERTIES LINK_FLAGS "-F${QT_LIBRARY_DIR}")
ENDIF(QT_INST_MAJOR_VERSION GREATER 3)
ENDIF(APPLE)
# link with release version of Qt libs
TARGET_LINK_LIBRARIES( QVTKWidgetPlugin
${QT_LIBS}
......
......@@ -12,6 +12,7 @@ SET(VTK_QT_QASSISTANTCLIENT_LIBRARY "@QT_QASSISTANTCLIENT_LIBRARY@")
# exports for Qt4
SET(VTK_QT_RCC_EXECUTABLE "@QT_RCC_EXECUTABLE@")
SET(VTK_DESIRED_QT_VERSION "@DESIRED_QT_VERSION@")
# exports for Qt3/Qt4
SET(VTK_QT_MOC_EXECUTABLE "@QT_MOC_EXECUTABLE@")
......
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