CMake: support fir linking against qt5
This commit is contained in:
parent
05f46011eb
commit
d7a962c055
5 changed files with 199 additions and 30 deletions
|
@ -71,8 +71,18 @@ IF(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")
|
|||
ADD_DEFINITIONS("-DSFMT_MEXP=19937")
|
||||
ENDIF()
|
||||
|
||||
#Find Qt4 and enable the needed features
|
||||
FIND_PACKAGE(Qt4 REQUIRED)
|
||||
#Find Qt and enable the needed features
|
||||
FIND_PACKAGE(Qt5Widgets)
|
||||
IF(Qt5Widgets_FOUND)
|
||||
MESSAGE(STATUS "Found Qt ${Qt5Widgets_VERSION_STRING}")
|
||||
ELSE()
|
||||
FIND_PACKAGE(Qt4 REQUIRED)
|
||||
IF(Qt4_FOUND)
|
||||
MESSAGE(STATUS "Found Qt ${QT_VERSION_MAJOR}.${QT_VERSION_MINOR}.${QT_VERSION_PATCH}")
|
||||
ELSE()
|
||||
MESSAGE(FATAL_ERROR "No Qt4 or Qt5 found!")
|
||||
ENDIF()
|
||||
ENDIF()
|
||||
|
||||
set(CMAKE_AUTOMOC TRUE)
|
||||
|
||||
|
|
|
@ -125,36 +125,101 @@ if(APPLE)
|
|||
set(cockatrice_SOURCES ${cockatrice_SOURCES} ${CMAKE_CURRENT_SOURCE_DIR}/resources/appicon.icns)
|
||||
ENDIF(APPLE)
|
||||
|
||||
if (NOT QT_QTMULTIMEDIA_FOUND)
|
||||
FIND_PACKAGE(QtMobility REQUIRED)
|
||||
endif (NOT QT_QTMULTIMEDIA_FOUND)
|
||||
set(COCKATRICE_LIBS)
|
||||
|
||||
SET(QT_USE_QTNETWORK TRUE)
|
||||
SET(QT_USE_QTMULTIMEDIA TRUE)
|
||||
SET(QT_USE_QTXML TRUE)
|
||||
SET(QT_USE_QTSVG TRUE)
|
||||
# Qt4 stuff
|
||||
if(Qt4_FOUND)
|
||||
if (NOT QT_QTMULTIMEDIA_FOUND)
|
||||
FIND_PACKAGE(QtMobility REQUIRED)
|
||||
endif (NOT QT_QTMULTIMEDIA_FOUND)
|
||||
|
||||
SET(QT_USE_QTNETWORK TRUE)
|
||||
SET(QT_USE_QTMULTIMEDIA TRUE)
|
||||
SET(QT_USE_QTXML TRUE)
|
||||
SET(QT_USE_QTSVG TRUE)
|
||||
|
||||
# Include directories
|
||||
INCLUDE(${QT_USE_FILE})
|
||||
INCLUDE_DIRECTORIES(${QT_INCLUDES})
|
||||
INCLUDE_DIRECTORIES(${QT_MOBILITY_INCLUDE_DIR})
|
||||
INCLUDE_DIRECTORIES(${QT_MOBILITY_MULTIMEDIAKIT_INCLUDE_DIR})
|
||||
LIST(APPEND COCKATRICE_LIBS ${QT_LIBRARIES})
|
||||
LIST(APPEND COCKATRICE_LIBS ${QT_QTMAIN_LIBRARY})
|
||||
LIST(APPEND COCKATRICE_LIBS ${QT_MOBILITY_MULTIMEDIAKIT_LIBRARY})
|
||||
|
||||
# Let cmake chew Qt4's translations and resource files
|
||||
# Note: header files are MOC-ed automatically by cmake
|
||||
QT4_ADD_TRANSLATION(cockatrice_QM ${cockatrice_TS})
|
||||
QT4_ADD_RESOURCES(cockatrice_RESOURCES_RCC ${cockatrice_RESOURCES})
|
||||
endif()
|
||||
|
||||
# qt5 stuff
|
||||
if(Qt5Widgets_FOUND)
|
||||
include_directories(${Qt5Widgets_INCLUDE_DIRS})
|
||||
list(APPEND COCKATRICE_LIBS Widgets)
|
||||
|
||||
# QtNetwork
|
||||
find_package(Qt5Network)
|
||||
if(Qt5Network_FOUND)
|
||||
include_directories(${Qt5Network_INCLUDE_DIRS})
|
||||
list(APPEND COCKATRICE_LIBS Network)
|
||||
endif()
|
||||
|
||||
# QtMultimedia
|
||||
find_package(Qt5Multimedia)
|
||||
if(Qt5Multimedia_FOUND)
|
||||
include_directories(${Qt5Multimedia_INCLUDE_DIRS})
|
||||
list(APPEND COCKATRICE_LIBS Multimedia)
|
||||
endif()
|
||||
|
||||
# QtXml
|
||||
find_package(Qt5Xml)
|
||||
if(Qt5Xml_FOUND)
|
||||
include_directories(${Qt5Xml_INCLUDE_DIRS})
|
||||
list(APPEND COCKATRICE_LIBS Xml)
|
||||
endif()
|
||||
|
||||
# QtSvg
|
||||
find_package(Qt5Svg)
|
||||
if(Qt5Svg_FOUND)
|
||||
include_directories(${Qt5Svg_INCLUDE_DIRS})
|
||||
list(APPEND COCKATRICE_LIBS Svg)
|
||||
endif()
|
||||
|
||||
# Qt5LinguistTools
|
||||
find_package(Qt5LinguistTools)
|
||||
if(Qt5LinguistTools_FOUND)
|
||||
include_directories(${Qt5LinguistTools_INCLUDE_DIRS})
|
||||
list(APPEND COCKATRICE_LIBS LinguistTools)
|
||||
endif()
|
||||
|
||||
# Let cmake chew Qt4's translations and resource files
|
||||
# Note: header files are MOC-ed automatically by cmake
|
||||
QT5_ADD_TRANSLATION(cockatrice_QM ${cockatrice_TS})
|
||||
QT5_ADD_RESOURCES(cockatrice_RESOURCES_RCC ${cockatrice_RESOURCES})
|
||||
endif()
|
||||
|
||||
# Declare path variables
|
||||
set(ICONDIR share/icons CACHE STRING "icon dir")
|
||||
set(DESKTOPDIR share/applications CACHE STRING "desktop file destination")
|
||||
|
||||
# Let cmake chew Qt4's translations and resource files
|
||||
# Note: header files are MOC-ed automatically by cmake
|
||||
QT4_ADD_TRANSLATION(cockatrice_QM ${cockatrice_TS})
|
||||
QT4_ADD_RESOURCES(cockatrice_RESOURCES_RCC ${cockatrice_RESOURCES})
|
||||
|
||||
# Include directories
|
||||
INCLUDE(${QT_USE_FILE})
|
||||
INCLUDE_DIRECTORIES(../common)
|
||||
INCLUDE_DIRECTORIES(${PROTOBUF_INCLUDE_DIR})
|
||||
INCLUDE_DIRECTORIES(${CMAKE_BINARY_DIR}/common)
|
||||
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR})
|
||||
INCLUDE_DIRECTORIES(${QT_MOBILITY_INCLUDE_DIR})
|
||||
INCLUDE_DIRECTORIES(${QT_MOBILITY_MULTIMEDIAKIT_INCLUDE_DIR})
|
||||
|
||||
# Build cockatrice binary and link it
|
||||
ADD_EXECUTABLE(cockatrice WIN32 MACOSX_BUNDLE ${cockatrice_SOURCES} ${cockatrice_QM} ${cockatrice_RESOURCES_RCC} ${cockatrice_MOC_SRCS})
|
||||
TARGET_LINK_LIBRARIES(cockatrice cockatrice_common ${QT_QTMAIN_LIBRARY} ${QT_LIBRARIES} ${QT_MOBILITY_MULTIMEDIAKIT_LIBRARY})
|
||||
|
||||
if(Qt4_FOUND)
|
||||
TARGET_LINK_LIBRARIES(cockatrice cockatrice_common ${COCKATRICE_LIBS})
|
||||
endif()
|
||||
if(Qt5Widgets_FOUND)
|
||||
TARGET_LINK_LIBRARIES(cockatrice cockatrice_common)
|
||||
qt5_use_modules(cockatrice ${COCKATRICE_LIBS})
|
||||
endif()
|
||||
|
||||
|
||||
if(MSVC)
|
||||
set_target_properties(cockatrice PROPERTIES LINK_FLAGS "/SUBSYSTEM:WINDOWS")
|
||||
|
|
|
@ -28,7 +28,20 @@ SET(common_SOURCES
|
|||
sfmt/SFMT.c
|
||||
)
|
||||
|
||||
INCLUDE(${QT_USE_FILE})
|
||||
set(ORACLE_LIBS)
|
||||
|
||||
# Qt4 stuff
|
||||
if(Qt4_FOUND)
|
||||
# Include directories
|
||||
INCLUDE(${QT_USE_FILE})
|
||||
include_directories(${QT_INCLUDES})
|
||||
endif()
|
||||
|
||||
# qt5 stuff
|
||||
if(Qt5Widgets_FOUND)
|
||||
include_directories(${Qt5Widgets_INCLUDE_DIRS})
|
||||
endif()
|
||||
|
||||
INCLUDE_DIRECTORIES(pb)
|
||||
INCLUDE_DIRECTORIES(sfmt)
|
||||
INCLUDE_DIRECTORIES(${PROTOBUF_INCLUDE_DIR})
|
||||
|
|
|
@ -15,17 +15,59 @@ SET(oracle_SOURCES
|
|||
../cockatrice/src/settingscache.cpp
|
||||
)
|
||||
|
||||
SET(QT_USE_QTNETWORK TRUE)
|
||||
SET(QT_USE_QTXML TRUE)
|
||||
SET(QT_USE_QTSVG TRUE)
|
||||
set(ORACLE_LIBS)
|
||||
|
||||
# Qt4 stuff
|
||||
if(Qt4_FOUND)
|
||||
SET(QT_USE_QTNETWORK TRUE)
|
||||
SET(QT_USE_QTXML TRUE)
|
||||
SET(QT_USE_QTSVG TRUE)
|
||||
|
||||
# Include directories
|
||||
INCLUDE(${QT_USE_FILE})
|
||||
include_directories(${QT_INCLUDES})
|
||||
LIST(APPEND ORACLE_LIBS ${QT_QTMAIN_LIBRARY})
|
||||
LIST(APPEND ORACLE_LIBS ${QT_LIBRARIES})
|
||||
endif()
|
||||
|
||||
# qt5 stuff
|
||||
if(Qt5Widgets_FOUND)
|
||||
include_directories(${Qt5Widgets_INCLUDE_DIRS})
|
||||
list(APPEND ORACLE_LIBS Widgets)
|
||||
|
||||
# QtNetwork
|
||||
find_package(Qt5Network)
|
||||
if(Qt5Network_FOUND)
|
||||
include_directories(${Qt5Network_INCLUDE_DIRS})
|
||||
list(APPEND ORACLE_LIBS Network)
|
||||
endif()
|
||||
|
||||
# QtXml
|
||||
find_package(Qt5Xml)
|
||||
if(Qt5Xml_FOUND)
|
||||
include_directories(${Qt5Xml_INCLUDE_DIRS})
|
||||
list(APPEND ORACLE_LIBS Xml)
|
||||
endif()
|
||||
|
||||
# QtSvg
|
||||
find_package(Qt5Svg)
|
||||
if(Qt5Svg_FOUND)
|
||||
include_directories(${Qt5Svg_INCLUDE_DIRS})
|
||||
list(APPEND ORACLE_LIBS Svg)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# Include directories
|
||||
INCLUDE(${QT_USE_FILE})
|
||||
INCLUDE_DIRECTORIES(../cockatrice/src)
|
||||
|
||||
# Build oracle binary and link it
|
||||
ADD_EXECUTABLE(oracle WIN32 MACOSX_BUNDLE ${oracle_SOURCES} ${oracle_MOC_SRCS})
|
||||
TARGET_LINK_LIBRARIES(oracle ${QT_QTMAIN_LIBRARY} ${QT_LIBRARIES})
|
||||
|
||||
if(Qt4_FOUND)
|
||||
TARGET_LINK_LIBRARIES(oracle ${ORACLE_LIBS})
|
||||
endif()
|
||||
if(Qt5Widgets_FOUND)
|
||||
qt5_use_modules(oracle ${ORACLE_LIBS})
|
||||
endif()
|
||||
|
||||
if(MSVC)
|
||||
set_target_properties(oracle PROPERTIES LINK_FLAGS "/SUBSYSTEM:WINDOWS")
|
||||
|
|
|
@ -20,12 +20,42 @@ SET(servatrice_SOURCES
|
|||
${CMAKE_CURRENT_BINARY_DIR}/version_string.cpp
|
||||
)
|
||||
|
||||
SET(QT_DONTUSE_QTGUI)
|
||||
SET(QT_USE_QTNETWORK TRUE)
|
||||
SET(QT_USE_QTSQL TRUE)
|
||||
set(SERVATRICE_LIBS)
|
||||
|
||||
# Qt4 stuff
|
||||
if(Qt4_FOUND)
|
||||
SET(QT_USE_QTNETWORK TRUE)
|
||||
SET(QT_USE_QTSQL TRUE)
|
||||
|
||||
# Include directories
|
||||
INCLUDE(${QT_USE_FILE})
|
||||
include_directories(${QT_INCLUDES})
|
||||
LIST(APPEND SERVATRICE_LIBS ${QT_LIBRARIES})
|
||||
endif()
|
||||
|
||||
# qt5 stuff
|
||||
if(Qt5Widgets_FOUND)
|
||||
include_directories(${Qt5Widgets_INCLUDE_DIRS})
|
||||
list(APPEND SERVATRICE_LIBS Widgets)
|
||||
|
||||
# QtNetwork
|
||||
find_package(Qt5Network)
|
||||
if(Qt5Network_FOUND)
|
||||
include_directories(${Qt5Network_INCLUDE_DIRS})
|
||||
list(APPEND SERVATRICE_LIBS Network)
|
||||
endif()
|
||||
|
||||
# QtSql
|
||||
find_package(Qt5Sql)
|
||||
if(Qt5Sql_FOUND)
|
||||
include_directories(${Qt5Sql_INCLUDE_DIRS})
|
||||
list(APPEND SERVATRICE_LIBS Sql)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
SET(QT_DONT_USE_QTGUI TRUE)
|
||||
|
||||
# Include directories
|
||||
INCLUDE(${QT_USE_FILE})
|
||||
INCLUDE_DIRECTORIES(../common)
|
||||
INCLUDE_DIRECTORIES(${LIBGCRYPT_INCLUDE_DIR})
|
||||
INCLUDE_DIRECTORIES(${PROTOBUF_INCLUDE_DIR})
|
||||
|
@ -34,7 +64,16 @@ INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR})
|
|||
|
||||
# Build servatrice binary and link it
|
||||
ADD_EXECUTABLE(servatrice MACOSX_BUNDLE ${servatrice_SOURCES} ${servatrice_MOC_SRCS})
|
||||
TARGET_LINK_LIBRARIES(servatrice cockatrice_common ${QT_LIBRARIES} ${LIBGCRYPT_LIBRARY} ${CMAKE_THREAD_LIBS_INIT})
|
||||
|
||||
if(Qt4_FOUND)
|
||||
TARGET_LINK_LIBRARIES(servatrice cockatrice_common ${SERVATRICE_LIBS} ${LIBGCRYPT_LIBRARY} ${CMAKE_THREAD_LIBS_INIT})
|
||||
endif()
|
||||
if(Qt5Widgets_FOUND)
|
||||
TARGET_LINK_LIBRARIES(servatrice cockatrice_common ${LIBGCRYPT_LIBRARY} ${CMAKE_THREAD_LIBS_INIT})
|
||||
qt5_use_modules(servatrice ${SERVATRICE_LIBS})
|
||||
endif()
|
||||
|
||||
|
||||
|
||||
#add_custom_target(versionheader ALL DEPENDS version_header)
|
||||
add_custom_command(
|
||||
|
|
Loading…
Reference in a new issue