Commit d3a5a226 authored by Sankhesh Jhaveri's avatar Sankhesh Jhaveri

Added support for building against Qt5

One can explicitly enable building against Qt5 by configuring QtTesting with
-DQtTesting_QT_VERSION:STRING="5". To specify custom Qt5 install paths, use
-DCMAKE_PREFIX_PATH:STRING=/home/sankhesh/Projects/qt5/qt5.2.0/5.2.0/gcc_64

Qt5 is built and packaged with the -reduce-relocations configure option as
default. This causes compilations to run with the -Bsymbolic-functions option,
which makes function pointer comparison ineffective, unless the -fPIE flag is
also supplied. Added Qt5 compile flags to support position independent code.
parent a6dd2d60
...@@ -2,9 +2,36 @@ CMAKE_MINIMUM_REQUIRED(VERSION 2.8) ...@@ -2,9 +2,36 @@ CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
PROJECT(QtTesting) PROJECT(QtTesting)
IF(NOT QT_FOUND) SET(QtTesting_QT_VERSION "4" CACHE STRING "Expected Qt version")
FIND_PACKAGE(Qt4 REQUIRED) MARK_AS_ADVANCED(QtTesting_QT_VERSION)
INCLUDE( ${QT_USE_FILE} ) SET_PROPERTY(CACHE QtTesting_QT_VERSION PROPERTY STRINGS 4 5)
IF(NOT (QtTesting_QT_VERSION VERSION_EQUAL "4" OR
QtTesting_QT_VERSION VERSION_EQUAL "5"))
message(FATAL_ERROR "Expected value for QtTesting_QT_VERSION is either '4' or '5'")
ENDIF()
IF(QtTesting_QT_VERSION VERSION_GREATER "4")
IF(NOT Qt5Test_FOUND)
FIND_PACKAGE(Qt5Widgets REQUIRED)
FIND_PACKAGE(Qt5Test REQUIRED)
ADD_DEFINITIONS(
${Qt5Widgets_DEFINITIONS}
${Qt5Test_DEFINITIONS}
)
INCLUDE_DIRECTORIES(
${Qt5Widgets_INCLUDE_DIRS}
${Qt5Test_INCLUDE_DIRS}
)
SET(QT_LIBRARIES
${Qt5Widgets_LIBRARIES}
${Qt5Test_LIBRARIES}
)
ENDIF()
ELSE()
IF(NOT QT_FOUND)
FIND_PACKAGE(Qt4 REQUIRED)
INCLUDE( ${QT_USE_FILE} )
ENDIF()
ENDIF() ENDIF()
IF(NOT DEFINED QT_TESTING_WITH_PYTHON) IF(NOT DEFINED QT_TESTING_WITH_PYTHON)
...@@ -79,7 +106,7 @@ INCLUDE_DIRECTORIES( ...@@ -79,7 +106,7 @@ INCLUDE_DIRECTORIES(
GET_DIRECTORY_PROPERTY(include_dirs_tmp INCLUDE_DIRECTORIES) GET_DIRECTORY_PROPERTY(include_dirs_tmp INCLUDE_DIRECTORIES)
SET_DIRECTORY_PROPERTIES(PROPERTIES INCLUDE_DIRECTORIES "${MOC_INCLUDE_DIRS}") SET_DIRECTORY_PROPERTIES(PROPERTIES INCLUDE_DIRECTORIES "${MOC_INCLUDE_DIRS}")
QT4_WRAP_CPP(MOC_BUILT_SOURCES SET(MOC_SRCS
pq3DViewEventTranslator.h pq3DViewEventTranslator.h
pqAbstractButtonEventTranslator.h pqAbstractButtonEventTranslator.h
pqAbstractItemViewEventTranslator.h pqAbstractItemViewEventTranslator.h
...@@ -106,14 +133,31 @@ QT4_WRAP_CPP(MOC_BUILT_SOURCES ...@@ -106,14 +133,31 @@ QT4_WRAP_CPP(MOC_BUILT_SOURCES
pqTreeViewEventPlayer.h pqTreeViewEventPlayer.h
pqTreeViewEventTranslator.h pqTreeViewEventTranslator.h
pqWidgetEventTranslator.h pqWidgetEventTranslator.h
${PYTHON_MOCS}
) )
IF(QtTesting_QT_VERSION VERSION_GREATER "4")
QT5_WRAP_CPP(MOC_BUILT_SOURCES
${MOC_SRCS}
${PYTHON_MOCS}
)
ELSE()
QT4_WRAP_CPP(MOC_BUILT_SOURCES
${MOC_SRCS}
${PYTHON_MOCS}
)
ENDIF()
SET_DIRECTORY_PROPERTIES(PROPERTIES INCLUDE_DIRECTORIES "${include_dirs_tmp}") SET_DIRECTORY_PROPERTIES(PROPERTIES INCLUDE_DIRECTORIES "${include_dirs_tmp}")
QT4_WRAP_UI(UI_BUILT_SOURCES IF(QtTesting_QT_VERSION VERSION_GREATER "4")
pqRecordEventsDialog.ui QT5_WRAP_UI(UI_BUILT_SOURCES
) pqRecordEventsDialog.ui
)
ELSE()
QT4_WRAP_UI(UI_BUILT_SOURCES
pqRecordEventsDialog.ui
)
ENDIF()
SET(QtTesting_SOURCES SET(QtTesting_SOURCES
pq3DViewEventPlayer.cxx pq3DViewEventPlayer.cxx
......
...@@ -16,8 +16,13 @@ SET (MOC_FILES ...@@ -16,8 +16,13 @@ SET (MOC_FILES
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR}) INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR})
QT4_WRAP_UI (EXAMPLE_UI_BUILT_SOURCES ${UI_FILES}) IF(QtTesting_QT_VERSION VERSION_GREATER "4")
QT4_WRAP_CPP(EXAMPLE_MOC_BUILT_SOURCES ${MOC_FILES}) QT5_WRAP_UI (EXAMPLE_UI_BUILT_SOURCES ${UI_FILES})
QT5_WRAP_CPP(EXAMPLE_MOC_BUILT_SOURCES ${MOC_FILES})
ELSE()
QT4_WRAP_UI (EXAMPLE_UI_BUILT_SOURCES ${UI_FILES})
QT4_WRAP_CPP(EXAMPLE_MOC_BUILT_SOURCES ${MOC_FILES})
ENDIF()
add_executable (TestingDemo add_executable (TestingDemo
${SOURCE_FILES} ${SOURCE_FILES}
...@@ -27,3 +32,5 @@ add_executable (TestingDemo ...@@ -27,3 +32,5 @@ add_executable (TestingDemo
target_link_libraries(TestingDemo target_link_libraries(TestingDemo
QtTesting) QtTesting)
set_target_properties(TestingDemo PROPERTIES
COMPILE_FLAGS "${Qt5Widgets_EXECUTABLE_COMPILE_FLAGS}")
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