Cmake scripts refactoring; fix #3225 (#3230)

* fix #3225

* Servatrice: use websockets as an optional component (for qt < 5.3)

* Attempt++
This commit is contained in:
ctrlaltca 2018-05-12 23:28:22 +02:00 committed by GitHub
parent 73fb9ee03e
commit c06fc562a1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 72 additions and 152 deletions

View file

@ -48,50 +48,33 @@ if(APPLE)
set(oracle_SOURCES ${oracle_SOURCES} ${CMAKE_CURRENT_SOURCE_DIR}/resources/appicon.icns)
ENDIF(APPLE)
set(ORACLE_LIBS)
# Qt5
find_package(Qt5 COMPONENTS Concurrent Network Svg Widgets REQUIRED)
include_directories(${Qt5Concurrent_INCLUDE_DIRS} ${Qt5Multimedia_INCLUDE_DIRS} ${Qt5Network_INCLUDE_DIRS} ${Qt5PrintSupport_INCLUDE_DIRS} ${Qt5Svg_INCLUDE_DIRS} ${Qt5Widgets_INCLUDE_DIRS})
set(ORACLE_QT_MODULES Concurrent Multimedia Network PrintSupport Svg Widgets)
# qt5 stuff
if(Qt5Widgets_FOUND)
include_directories(${Qt5Widgets_INCLUDE_DIRS})
list(APPEND ORACLE_LIBS Widgets)
# Qt5LinguistTools
find_package(Qt5LinguistTools)
if(Qt5LinguistTools_FOUND)
include_directories(${Qt5LinguistTools_INCLUDE_DIRS})
list(APPEND ORACLE_LIBS LinguistTools)
# QtConcurrent
find_package(Qt5Concurrent)
if(Qt5Concurrent_FOUND)
include_directories(${Qt5Concurrent_INCLUDE_DIRS})
list(APPEND ORACLE_LIBS Concurrent)
if(NOT Qt5_LRELEASE_EXECUTABLE)
MESSAGE(WARNING "Qt's lrelease not found.")
endif()
# QtNetwork
find_package(Qt5Network)
if(Qt5Network_FOUND)
include_directories(${Qt5Network_INCLUDE_DIRS})
list(APPEND ORACLE_LIBS Network)
endif()
# QtSvg
find_package(Qt5Svg)
if(Qt5Svg_FOUND)
include_directories(${Qt5Svg_INCLUDE_DIRS})
list(APPEND ORACLE_LIBS Svg)
endif()
# Let cmake chew Qt5's translations and resource files
# Note: header files are MOC-ed automatically by cmake
IF(UPDATE_TRANSLATIONS)
if(UPDATE_TRANSLATIONS)
if(NOT Qt5_LUPDATE_EXECUTABLE)
MESSAGE(WARNING "Qt's lupdate not found.")
endif()
QT5_CREATE_TRANSLATION(oracle_QM ${translate_SRCS} ${oracle_TS})
ELSE()
else()
QT5_ADD_TRANSLATION(oracle_QM ${oracle_TS})
ENDIF()
QT5_ADD_RESOURCES(oracle_RESOURCES_RCC ${oracle_RESOURCES})
# guess plugins and libraries directory
set(QT_PLUGINS_DIR "${Qt5Widgets_DIR}/../../../plugins")
get_target_property(QT_LIBRARY_DIR Qt5::Core LOCATION)
get_filename_component(QT_LIBRARY_DIR ${QT_LIBRARY_DIR} PATH)
endif()
endif()
QT5_ADD_RESOURCES(oracle_RESOURCES_RCC ${oracle_RESOURCES})
INCLUDE_DIRECTORIES(../cockatrice/src)
# Libz is required to support zipped files
@ -112,7 +95,7 @@ ENDIF()
# Build oracle binary and link it
ADD_EXECUTABLE(oracle WIN32 MACOSX_BUNDLE ${oracle_SOURCES} ${oracle_QM} ${oracle_RESOURCES_RCC} ${oracle_MOC_SRCS})
qt5_use_modules(oracle ${ORACLE_LIBS})
qt5_use_modules(oracle ${ORACLE_QT_MODULES})
IF(ZLIB_FOUND)
TARGET_LINK_LIBRARIES(oracle ${ZLIB_LIBRARIES})