[vlmc-devel] Require Qt5

Hugo Beauzée-Luyssen git at videolan.org
Fri Mar 4 18:07:07 CET 2016


vlmc | branch: master | Hugo Beauzée-Luyssen <hugo at beauzee.fr> | Fri Mar  4 17:28:12 2016 +0100| [04752eca7ffcbcae40c3e7d48052f8a4d3e19089] | committer: Hugo Beauzée-Luyssen

Require Qt5

> https://code.videolan.org/videolan/vlmc/commit/04752eca7ffcbcae40c3e7d48052f8a4d3e19089
---

 CMakeLists.txt     | 72 ++++++------------------------------------------------
 src/CMakeLists.txt | 14 +++++------
 ts/CMakeLists.txt  |  2 +-
 3 files changed, 16 insertions(+), 72 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 1147071..3e76d7f 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -13,8 +13,6 @@ SET(PROJECT_CONTACT      "vlmc-devel at videolan.org")
 SET(PROJECT_VENDOR       "VLMC Team")
 SET(ORG_WEBSITE          "videolan.org")
 
-option(FORCE_QT4 "Forces VLMC to build using Qt4" OFF)
-
 # Configuring build type
 IF(NOT CMAKE_BUILD_TYPE)
     SET(CMAKE_BUILD_TYPE "Debug" CACHE STRING
@@ -121,70 +119,16 @@ INCLUDE_DIRECTORIES(${FREI0R_INCLUDE_DIR})
 SET(CMAKE_PREFIX_PATH "/usr/local/opt/qt5")
 
 # search for Qt4
-if (NOT FORCE_QT4)
-    find_package(Qt5Core QUIET)
-    if (Qt5Core_FOUND)
-        message(STATUS "Using qt5")
-        # go on with other packages
-        if(WITH_GUI)
-            find_package(Qt5 COMPONENTS Widgets Gui Xml Network)
-        else()
-            find_packages(Qt5 COMPONENTS Xml Network)
-        endif()
-
-        macro(qt_use_modules)
-            qt5_use_modules(${ARGN})
-        endmacro()
-
-        macro(qt_wrap_ui)
-            qt5_wrap_ui(${ARGN})
-        endmacro()
-
-        macro(qt_add_resources)
-            qt5_add_resources(${ARGN})
-        endmacro()
-
-        find_package(Qt5LinguistTools REQUIRED)
-        macro(qt_add_translation)
-            qt5_add_translation(${ARGN})
-        endmacro()
-    endif()
-endif()
-if(NOT Qt5Core_FOUND)
-    if (NOT FORCE_QT4)
-        message(STATUS "Could not find Qt5, searching for Qt4 instead...")
+find_package(Qt5Core QUIET)
+if (Qt5Core_FOUND)
+    # go on with other packages
+    if(WITH_GUI)
+        find_package(Qt5 COMPONENTS Widgets Gui Xml Network)
+    else()
+        find_packages(Qt5 COMPONENTS Xml Network)
     endif()
 
-    set(NEEDED_QT4_COMPONENTS "QtCore" "QtXml" "QtNetwork")
-    if( WITH_GUI )
-        list(APPEND NEEDED_QT4_COMPONENTS "QtGui")
-    endif()
-
-    find_package(Qt4 REQUIRED COMPONENTS ${NEEDED_QT4_COMPONENTS})
-    message(STATUS "Found Qt4 & ${NEEDED_QT4_COMPONENTS} modules")
-    macro(qt_use_modules)
-
-    endmacro()
-
-    macro(qt_wrap_ui)
-        qt4_wrap_ui(${ARGN})
-    endmacro()
-
-    macro(qt_add_resources)
-        qt4_add_resources(${ARGN})
-    endmacro()
-
-    macro(qt_add_translation)
-        qt4_add_translation(${ARGN})
-    endmacro()
-
-    include(${QT_USE_FILE})
-    add_definitions(${QT_DEFINITIONS})
-
-    # On linux & using Qt4 we need to manually add -lX11
-    if (UNIX AND NOT APPLE)
-        list(APPEND VLMC_LIBS -lX11)
-    endif()
+    find_package(Qt5LinguistTools REQUIRED)
 endif()
 
 # layout of VLMC installation
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 889a807..3ec6c87 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -96,9 +96,9 @@ CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/cmake/config.h.cmake ${CMAKE_CURRENT_BINARY_D
 
 IF (NOT WITH_GUI)
     LIST (APPEND VLMC_SRCS Main/main.cpp Renderer/ConsoleRenderer.cpp )
-    QT_ADD_RESOURCES(VLMC_RCC_SRCS ${VLMC_RCC})
+    qt5_add_resources(VLMC_RCC_SRCS ${VLMC_RCC})
     ADD_EXECUTABLE(vlmc ${GUI_TYPE} ${VLMC_SRCS} ${VLMC_MOC_SRCS} ${VLMC_RCC_SRCS})
-    qt_use_modules(vlmc Core Xml Network)
+    qt5_use_modules(vlmc Core Xml Network)
     TARGET_LINK_LIBRARIES(vlmc ${VLMC_LIBS})
 
 #Add GUI stuff if required
@@ -215,8 +215,8 @@ ELSE(NOT WITH_GUI)
         LIST( APPEND VLMC_UIS Gui/widgets/ui/CrashHandler.ui )
     ENDIF(WITH_CRASHHANDLER_GUI)
 
-    QT_WRAP_UI(VLMC_UIS_H ${VLMC_UIS})
-    QT_ADD_RESOURCES(VLMC_RCC_SRCS ${VLMC_RCC})
+    qt5_wrap_ui(VLMC_UIS_H ${VLMC_UIS})
+    qt5_add_resources(VLMC_RCC_SRCS ${VLMC_RCC})
 
     IF( MINGW )
         # resource compilation for MinGW
@@ -249,7 +249,7 @@ message(${FOUNDATION_FRAMEWORK})
     ADD_EXECUTABLE( vlmc ${GUI_TYPE} ${VLMC_SRCS} ${VLMC_MOC_SRCS} ${VLMC_UIS_H} ${VLMC_RCC_SRCS} )
     TARGET_LINK_LIBRARIES( vlmc ${VLMC_LIBS} )
     if (NOT Qt4_FOUND)
-        qt_use_modules(vlmc Core Gui Widgets Xml Network)
+        qt5_use_modules(vlmc Core Gui Widgets Xml Network)
     else()
         # We need to know the target for this one, which is not the case when doing most of the QT4/5 specific stuff.
         # We could hide this command in qt_use_modules macro, but this would be some kind of black magic uglyness
@@ -272,10 +272,10 @@ ADD_CUSTOM_COMMAND(
 
 ADD_DEFINITIONS( -W -Wall -Wextra )
 
-if( !APPLE )
+if( NOT APPLE )
     # Ensure we can use some C++11 features
     target_compile_features(vlmc PUBLIC cxx_nullptr cxx_range_for)
-ENDIF( !APPLE )
+endif()
 
 IF(UNIX)
     IF (WITH_PROFILING)
diff --git a/ts/CMakeLists.txt b/ts/CMakeLists.txt
index dd5b458..11e2445 100644
--- a/ts/CMakeLists.txt
+++ b/ts/CMakeLists.txt
@@ -96,7 +96,7 @@ ENDFOREACH()
 
 IF(QT_LRELEASE_EXECUTABLE)
     ## Wraps the collected translations
-    QT4_ADD_TRANSLATIONS(vlmc_QMS ${vlmc_TS})
+    qt5_add_translation(vlmc_QMS ${vlmc_TS})
 
     ## Create a target that runs lrelease for all the .ts files
     ## "ALL" means that it will be run by default.



More information about the Vlmc-devel mailing list