Fixed CMakeLists.txt to work with Qt5

Signed-off-by: Patrick Valsecchi <patrick@thus.ch>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Patrick Valsecchi 2015-02-02 16:52:35 +01:00 committed by Dirk Hohndel
parent 343d06fa5c
commit 7e0ff8c1e4
2 changed files with 28 additions and 38 deletions

View file

@ -1,8 +1,5 @@
project(Subsurface) project(Subsurface)
cmake_minimum_required(VERSION 2.8) cmake_minimum_required(VERSION 2.8.11)
#options
SET(SUBSURFACE_QT_VERSION "4")
SET(CMAKE_AUTOMOC ON) SET(CMAKE_AUTOMOC ON)
SET(CMAKE_AUTOUIC ON) SET(CMAKE_AUTOUIC ON)
@ -42,23 +39,20 @@ IF(NOT (insource OR insourcedir))
add_custom_target(link_marble_data ALL COMMAND rm -f marbledata && ln -s ${${PROJECT_NAME}_SOURCE_DIR}/marbledata ${${PROJECT_NAME}_BINARY_DIR}/marbledata) add_custom_target(link_marble_data ALL COMMAND rm -f marbledata && ln -s ${${PROJECT_NAME}_SOURCE_DIR}/marbledata ${${PROJECT_NAME}_BINARY_DIR}/marbledata)
ENDIF() ENDIF()
#configure Qt version. #configure Qt.
IF(${SUBSURFACE_QT_VERSION} MATCHES "4") FIND_PACKAGE(Qt5Core REQUIRED)
SET(QT_USE_QTNETWORK TRUE) FIND_PACKAGE(Qt5Concurrent REQUIRED)
SET(QT_USE_QTXML TRUE) FIND_PACKAGE(Qt5Widgets REQUIRED)
SET(QT_USE_QTSVG TRUE) FIND_PACKAGE(Qt5Network REQUIRED)
SET(QT_USE_QTTEST TRUE) FIND_PACKAGE(Qt5WebKitWidgets REQUIRED)
SET(QT_USE_QTWEBKIT TRUE) FIND_PACKAGE(Qt5PrintSupport REQUIRED)
FIND_PACKAGE(Qt4 REQUIRED) FIND_PACKAGE(Qt5Svg REQUIRED)
INCLUDE(${QT_USE_FILE}) FIND_PACKAGE(Qt5Test REQUIRED)
ADD_DEFINITIONS(${QT_DEFINITIONS}) SET(QT_LIBRARIES Qt5::Core Qt5::Concurrent Qt5::Widgets Qt5::Network Qt5::WebKitWidgets Qt5::PrintSupport Qt5::Svg)
FIND_PACKAGE(Marble REQUIRED) SET(QT_TEST_LIBRARIES ${QT_LIBRARIES} Qt5::Test)
INCLUDE_DIRECTORIES(${MARBLE_INCLUDE_DIR})
ELSEIF(${SUBSURFACE_QT_VERSION} MATCHES "5") FIND_PACKAGE(Marble REQUIRED)
ADD_DEFINITIONS(-DNO_MARBLE) INCLUDE_DIRECTORIES(${MARBLE_INCLUDE_DIR})
ELSE()
message( FATAL_ERROR "Qt version should be 4 or 5" )
ENDIF()
# Generate the ssrf-config.h every 'make' # Generate the ssrf-config.h every 'make'
FILE(WRITE ${CMAKE_BINARY_DIR}/version.h.in "\#define VERSION_STRING \"4.1.\"@VERSION@\n") FILE(WRITE ${CMAKE_BINARY_DIR}/version.h.in "\#define VERSION_STRING \"4.1.\"@VERSION@\n")
@ -186,29 +180,25 @@ SET(SUBSURFACE_APP
) )
FILE(GLOB SUBSURFACE_UI qt-ui/*.ui) FILE(GLOB SUBSURFACE_UI qt-ui/*.ui)
# to be replaced by QT_WRAP_UI on CMake 3. QT5_WRAP_UI( SUBSURFACE_UI_HDRS ${SUBSURFACE_UI} )
IF(${SUBSURFACE_QT_VERSION} MATCHES "4")
QT4_WRAP_UI( SUBSURFACE_UI_HDRS ${SUBSURFACE_UI} )
QT4_ADD_RESOURCES( SUBSURFACE_QRC_HRDS subsurface.qrc )
ELSEIF(${SUBSURFACE_QT_VERSION} MATCHES "5")
QT5_WRAP_UI( SUBSURFACE_UI_HDRS ${SUBSURFACE_UI} )
ENDIF()
ADD_LIBRARY(subsurface_corelib STATIC ${SUBSURFACE_CORE_LIB_SRCS} ) ADD_LIBRARY(subsurface_corelib STATIC ${SUBSURFACE_CORE_LIB_SRCS} )
TARGET_LINK_LIBRARIES(subsurface_corelib ${QT_LIBRARIES})
ADD_LIBRARY(subsurface_profile STATIC ${SUBSURFACE_PROFILE_LIB_SRCS}) ADD_LIBRARY(subsurface_profile STATIC ${SUBSURFACE_PROFILE_LIB_SRCS})
TARGET_LINK_LIBRARIES(subsurface_profile ${QT_LIBRARIES})
ADD_LIBRARY(subsurface_statistics STATIC ${SUBSURFACE_STATISTICS_LIB_SRCS}) ADD_LIBRARY(subsurface_statistics STATIC ${SUBSURFACE_STATISTICS_LIB_SRCS})
TARGET_LINK_LIBRARIES(subsurface_statistics ${QT_LIBRARIES})
ADD_LIBRARY(subsurface_generated_ui STATIC ${SUBSURFACE_UI_HDRS}) ADD_LIBRARY(subsurface_generated_ui STATIC ${SUBSURFACE_UI_HDRS})
ADD_LIBRARY(subsurface_interface STATIC ${SUBSURFACE_INTERFACE}) ADD_LIBRARY(subsurface_interface STATIC ${SUBSURFACE_INTERFACE})
ADD_EXECUTABLE(subsurface ${SUBSURFACE_APP} ${SUBSURFACE_QRC_HRDS} ) TARGET_LINK_LIBRARIES(subsurface_interface ${QT_LIBRARIES} ${MARBLE_LIBRARIES})
ADD_EXECUTABLE(subsurface ${SUBSURFACE_APP} ${SUBSURFACE_QRC_HRDS} )
target_link_libraries( subsurface target_link_libraries( subsurface
subsurface_generated_ui subsurface_generated_ui
subsurface_interface subsurface_interface
subsurface_profile subsurface_profile
subsurface_statistics subsurface_statistics
subsurface_corelib subsurface_corelib
${QT_LIBRARIES}
${MARBLE_LIBRARIES}
${SUBSURFACE_LINK_LIBRARIES} ${SUBSURFACE_LINK_LIBRARIES}
-ldivecomputer -ldivecomputer
-lzip -lzip
@ -221,10 +211,10 @@ ADD_DEPENDENCIES(subsurface_generated_ui version)
ADD_DEPENDENCIES(subsurface_corelib version) ADD_DEPENDENCIES(subsurface_corelib version)
ENABLE_TESTING() ENABLE_TESTING()
ADD_EXECUTABLE( TestUnitConversion tests/testunitconversion.cpp ) ADD_EXECUTABLE(TestUnitConversion tests/testunitconversion.cpp)
TARGET_LINK_LIBRARIES( TestUnitConversion ${QT_LIBRARIES} ${SUBSURFACE_LINK_LIBRARIES} -lzip -ldivecomputer subsurface_corelib) TARGET_LINK_LIBRARIES(TestUnitConversion subsurface_corelib ${QT_TEST_LIBRARIES} ${SUBSURFACE_LINK_LIBRARIES} -lzip -ldivecomputer)
ADD_TEST( NAME TestUnitConversion COMMAND TestUnitConversion) ADD_TEST(NAME TestUnitConversion COMMAND TestUnitConversion)
ADD_EXECUTABLE( TestProfile tests/testprofile.cpp ) ADD_EXECUTABLE(TestProfile tests/testprofile.cpp)
TARGET_LINK_LIBRARIES( TestProfile ${QT_LIBRARIES} ${SUBSURFACE_LINK_LIBRARIES} -lzip -ldivecomputer subsurface_corelib) TARGET_LINK_LIBRARIES(TestProfile subsurface_corelib ${QT_TEST_LIBRARIES} ${SUBSURFACE_LINK_LIBRARIES} -lzip -ldivecomputer)
ADD_TEST( NAME TestProfile COMMAND TestProfile) ADD_TEST(NAME TestProfile COMMAND TestProfile)

View file

@ -86,7 +86,7 @@ void PreferencesDialog::facebookLoggedIn()
void PreferencesDialog::facebookDisconnect() void PreferencesDialog::facebookDisconnect()
{ {
#if !defined(Q_OS_ANDROID) && defined(FBSUPPORT) #if !defined(Q_OS_ANDROID) && defined(FBSUPPORT)
// remove the disconnect button // remove the connect/disconnect button
// and instead add the login view // and instead add the login view
ui.fbLayout->removeItem(ui.fbLayout->itemAt(1)); ui.fbLayout->removeItem(ui.fbLayout->itemAt(1));
ui.fbLayout->addWidget(facebookWebView); ui.fbLayout->addWidget(facebookWebView);