diff options
author | Iru Cai <mytbk920423@gmail.com> | 2015-07-13 13:19:05 +0800 |
---|---|---|
committer | Iru Cai <mytbk920423@gmail.com> | 2015-07-13 13:19:05 +0800 |
commit | b806d39091b432389e906146b10f16aa707cae17 (patch) | |
tree | 9c09641cbedcc25a12b26300d55b7fd39ffb1eb1 | |
parent | 2cd2984086f726856126d878e943b9870cef293d (diff) | |
download | fqterm-b806d39091b432389e906146b10f16aa707cae17.tar.xz |
Qt4 and Qt5 in one CMakeList: CMakeLists.txt{,.linux}
-rw-r--r-- | CMakeLists.txt | 72 | ||||
-rw-r--r-- | CMakeLists.txt.linux | 27 |
2 files changed, 66 insertions, 33 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index ed6cede..b8d3dd2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,7 +2,7 @@ project(fqterm) set(FQTERM_VERSION "0.9.8") -cmake_minimum_required( VERSION 2.4.2 FATAL_ERROR ) +cmake_minimum_required( VERSION 2.8.11 FATAL_ERROR ) if(COMMAND cmake_policy) cmake_policy(SET CMP0003 NEW) @@ -22,19 +22,31 @@ include(GetGitRevisionDescription) git_describe(MCGGIT_WC_REVISION) message("Git revision: " ${MCGGIT_WC_REVISION}) -find_package(Qt4 COMPONENTS QtCore QtGui QtNetwork QtScript QtXml REQUIRED) -IF(APPLE) -ELSE(APPLE) -include(${QT_USE_FILE}) -ENDIF(APPLE) - -qt4_add_translation(fqterm_qm_files - ${CMAKE_SOURCE_DIR}/res/dict/fqterm_zh_CN.ts - ${CMAKE_SOURCE_DIR}/res/dict/ui_zh_CN.ts - ${CMAKE_SOURCE_DIR}/res/dict/protocol_zh_CN.ts - ${CMAKE_SOURCE_DIR}/res/dict/common_zh_CN.ts -) - +SET(USE_QT5 OFF CACHE PATH "Do the Qt5 build") + +IF(USE_QT5) + set(CMAKE_INCLUDE_CURRENT_DIR ON) + set(CMAKE_AUTOMOC ON) + find_package(Qt5Core REQUIRED) + find_package(Qt5Widgets REQUIRED) + find_package(Qt5LinguistTools REQUIRED) + qt5_add_translation(fqterm_qm_files + ${CMAKE_SOURCE_DIR}/res/dict/fqterm_zh_CN.ts + ${CMAKE_SOURCE_DIR}/res/dict/ui_zh_CN.ts + ${CMAKE_SOURCE_DIR}/res/dict/protocol_zh_CN.ts + ${CMAKE_SOURCE_DIR}/res/dict/common_zh_CN.ts + ) +ELSE(USE_QT5) + find_package(Qt4 COMPONENTS QtCore QtGui QtNetwork QtScript QtXml REQUIRED) + include(${QT_USE_FILE}) + qt4_add_translation(fqterm_qm_files + ${CMAKE_SOURCE_DIR}/res/dict/fqterm_zh_CN.ts + ${CMAKE_SOURCE_DIR}/res/dict/ui_zh_CN.ts + ${CMAKE_SOURCE_DIR}/res/dict/protocol_zh_CN.ts + ${CMAKE_SOURCE_DIR}/res/dict/common_zh_CN.ts + ) +ENDIF(USE_QT5) + add_custom_target(fqterm_qm_target DEPENDS ${fqterm_qm_files} ) @@ -47,21 +59,23 @@ else (PYTHONLIBS_FOUND) SET(PYTHON_LIB) endif (PYTHONLIBS_FOUND) -IF(WIN32) - FILE(READ ${QT_LIBRARY_DIR}/QtCore.prl FQ_CORE_QT_CONFIG) -ELSE(WIN32) - IF(APPLE) - FILE(READ ${QT_LIBRARY_DIR}/QtCore.framework/QtCore.prl FQ_CORE_QT_CONFIG) - ELSE(APPLE) - FILE(READ ${QT_LIBRARY_DIR}/libQtCore.prl FQ_CORE_QT_CONFIG) - ENDIF(APPLE) -ENDIF(WIN32) - -IF(NOT FQ_CORE_QT_CONFIG MATCHES "static") - SET(FQTERM_USE_STATIC_QT false) -ELSE(NOT FQ_CORE_QT_CONFIG MATCHES "static") - SET(FQTERM_USE_STATIC_QT true) -ENDIF(NOT FQ_CORE_QT_CONFIG MATCHES "static") +if (NOT USE_QT5) + IF(WIN32) + FILE(READ ${QT_LIBRARY_DIR}/QtCore.prl FQ_CORE_QT_CONFIG) + ELSE(WIN32) + IF(APPLE) + FILE(READ ${QT_LIBRARY_DIR}/QtCore.framework/QtCore.prl FQ_CORE_QT_CONFIG) + ELSE(APPLE) + FILE(READ ${QT_LIBRARY_DIR}/libQtCore.prl FQ_CORE_QT_CONFIG) + ENDIF(APPLE) + ENDIF(WIN32) + + IF(NOT FQ_CORE_QT_CONFIG MATCHES "static") + SET(FQTERM_USE_STATIC_QT false) + ELSE(NOT FQ_CORE_QT_CONFIG MATCHES "static") + SET(FQTERM_USE_STATIC_QT true) + ENDIF(NOT FQ_CORE_QT_CONFIG MATCHES "static") +endif(NOT USE_QT5) SET(SUB_CMAKELIST "UNKNOWN") diff --git a/CMakeLists.txt.linux b/CMakeLists.txt.linux index 28e7546..ad28fb1 100644 --- a/CMakeLists.txt.linux +++ b/CMakeLists.txt.linux @@ -23,6 +23,7 @@ endif(ALSA_FOUND) ADD_DEFINITIONS(-Wall) ADD_DEFINITIONS(-D_OS_LINUX_) ADD_DEFINITIONS(-D "FQTERM_VERSION_STRING=\\\"${FQTERM_VERSION}\\\"") +ADD_DEFINITIONS(--std=c++11) add_subdirectory(src) @@ -30,10 +31,24 @@ ADD_EXECUTABLE(fqterm.bin src/fqterm/main.cpp ) +IF(USE_QT5) + find_package(Qt5Core REQUIRED) + find_package(Qt5Widgets REQUIRED) + find_package(Qt5Network REQUIRED) + find_package(Qt5Script REQUIRED) + find_package(Qt5Multimedia REQUIRED) + find_package(Qt5Xml REQUIRED) +ELSE(USE_QT5) +ENDIF(USE_QT5) + +IF(NOT USE_QT5) + include_directories( + ${QT_INCLUDE_DIR} + ${QT_QTCORE_INCLUDE_DIR} + ${QT_QTGUI_INCLUDE_DIR} + ) +ENDIF(NOT USE_QT5) include_directories( - ${QT_INCLUDE_DIR} - ${QT_QTCORE_INCLUDE_DIR} - ${QT_QTGUI_INCLUDE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/src/common ${CMAKE_CURRENT_SOURCE_DIR}/src/protocol ${CMAKE_CURRENT_SOURCE_DIR}/src/terminal @@ -68,7 +83,7 @@ target_link_libraries(fqterm.bin fqterm_utilities fqterm_ui fqterm_common - fqterm_unite + fqterm_unite ${QT_QTNETWORK_LIBRARIES} ${QT_QTXML_LIBRARIES} ${QT_QTSCRIPT_LIBRARIES} @@ -81,6 +96,10 @@ target_link_libraries(fqterm.bin X11 ) +IF(USE_QT5) + target_link_libraries(fqterm.bin Qt5::Core Qt5::Widgets) +ENDIF(USE_QT5) + add_dependencies(fqterm.bin fqterm_main fqterm_common |