[PATCH 4/9] Migrate to Qt5Transitional.cmake in order to support both Qt4 and Qt5.

Jon Severinsson jon at severinsson.net
Sat Oct 6 19:15:46 BST 2012


---
 cmake/FindPhononInternal.cmake      |   27 +++++----------------------
 demos/metadatareader/CMakeLists.txt |    9 +++++----
 demos/phota/CMakeLists.txt          |    9 +++++----
 demos/simplecapture/CMakeLists.txt  |    9 +++++----
 demos/simpleplayer/CMakeLists.txt   |    9 +++++----
 5 filer ändrade, 25 tillägg(+), 38 borttagningar(-)

diff --git a/cmake/FindPhononInternal.cmake b/cmake/FindPhononInternal.cmake
index 413da3c..91e318f 100644
--- a/cmake/FindPhononInternal.cmake
+++ b/cmake/FindPhononInternal.cmake
@@ -43,29 +43,15 @@ include(${phonon_cmake_module_dir}/MacroEnsureVersion.cmake)
 
 # Check Requirements
 
-# - Qt
+# - extra-cmake-modules
 
-# Store CMAKE_MODULE_PATH and then append the current dir to it, so we are sure
-# we get the FindQt4.cmake located next to us and not a different one.
-# The original CMAKE_MODULE_PATH is restored later on.
-set(_phonon_cmake_module_path_back ${CMAKE_MODULE_PATH})
-set(CMAKE_MODULE_PATH ${phonon_cmake_module_dir} ${CMAKE_MODULE_PATH} )
+find_package(ECM 0.0.5 REQUIRED NO_MODULE)
 
-# if the minimum Qt requirement is changed, change all occurrence in the
-# following lines
-if (NOT QT_MIN_VERSION)
-  set(QT_MIN_VERSION "4.6.0")
-endif (NOT QT_MIN_VERSION)
-if (${QT_MIN_VERSION} VERSION_LESS "4.6.0")
-  set(QT_MIN_VERSION "4.6.0")
-endif (${QT_MIN_VERSION} VERSION_LESS "4.6.0")
+set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH})
 
-# # Tell FindQt4.cmake to point the QT_QTFOO_LIBRARY targets at the imported targets
-# # for the Qt libraries, so we get full handling of release and debug versions of the
-# # Qt libs and are flexible regarding the install location of Qt under Windows:
-# set(QT_USE_IMPORTED_TARGETS TRUE)
+# - Qt
 
-find_package(Qt4 ${_REQ_STRING_KDE4})
+find_package(Qt5Transitional REQUIRED Core Gui Widgets)
 
 # - Automoc
 
@@ -79,9 +65,6 @@ macro(AUTOMOC4_ADD_LIBRARY _target_NAME _add_executable_param)
     add_library(${_target_NAME} ${_add_executable_param} ${ARGN})
 endmacro(AUTOMOC4_ADD_LIBRARY)
 
-# restore the original CMAKE_MODULE_PATH
-set(CMAKE_MODULE_PATH ${_phonon_cmake_module_path_back})
-
 # Set Installation Directories
 
 set(LIB_SUFFIX "" CACHE STRING "Define suffix of directory name (32/64)" )
diff --git a/demos/metadatareader/CMakeLists.txt b/demos/metadatareader/CMakeLists.txt
index 397c1d6..45ba2f9 100644
--- a/demos/metadatareader/CMakeLists.txt
+++ b/demos/metadatareader/CMakeLists.txt
@@ -1,8 +1,10 @@
 project(metadatareader)
 cmake_minimum_required(VERSION 2.8.6 FATAL_ERROR)
 
-find_package(Qt4 COMPONENTS QtCore REQUIRED)
-include(${QT_USE_FILE})
+find_package(ECM 0.0.5 REQUIRED NO_MODULE)
+set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH})
+find_package(Qt5Transitional REQUIRED Core)
+set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${Qt5Widgets_EXECUTABLE_COMPILE_FLAGS}")
 
 find_package(Phonon REQUIRED)
 
@@ -15,5 +17,4 @@ set(metadatareader_SRCS
 )
 
 phonon_add_executable(metadatareader ${metadatareader_SRCS})
-
-target_link_libraries(metadatareader ${QT_LIBRARIES} phonon)
+target_link_libraries(metadatareader ${QT_QTCORE_LIBRARY} ${PHONON_LIBRARY})
diff --git a/demos/phota/CMakeLists.txt b/demos/phota/CMakeLists.txt
index 09594d7..cd451e7 100644
--- a/demos/phota/CMakeLists.txt
+++ b/demos/phota/CMakeLists.txt
@@ -1,8 +1,10 @@
 project(phota)
 cmake_minimum_required(VERSION 2.8.6 FATAL_ERROR)
 
-find_package(Qt4 REQUIRED)
-include(${QT_USE_FILE})
+find_package(ECM 0.0.5 REQUIRED NO_MODULE)
+set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH})
+find_package(Qt5Transitional REQUIRED Core Gui)
+set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${Qt5Widgets_EXECUTABLE_COMPILE_FLAGS}")
 
 find_package(Phonon REQUIRED)
 
@@ -19,5 +21,4 @@ set(phota_SRCS
 qt4_wrap_ui(phota_SRCS videoeffects.ui)
 
 phonon_add_executable(phota ${phota_SRCS})
-
-target_link_libraries(phota ${QT_LIBRARIES} phonon)
+target_link_libraries(phota ${QT_QTCORE_LIBRARY} ${QT_QTGUI_LIBRARY} ${PHONON_LIBRARY})
diff --git a/demos/simplecapture/CMakeLists.txt b/demos/simplecapture/CMakeLists.txt
index 28b9564..9546697 100644
--- a/demos/simplecapture/CMakeLists.txt
+++ b/demos/simplecapture/CMakeLists.txt
@@ -1,8 +1,10 @@
 project(simplecapture)
 cmake_minimum_required(VERSION 2.8.6 FATAL_ERROR)
 
-find_package(Qt4 REQUIRED)
-include(${QT_USE_FILE})
+find_package(ECM 0.0.5 REQUIRED NO_MODULE)
+set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH})
+find_package(Qt5Transitional REQUIRED Core Gui)
+set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${Qt5Widgets_EXECUTABLE_COMPILE_FLAGS}")
 
 find_package(Phonon REQUIRED)
 
@@ -15,5 +17,4 @@ set(simplecapture_SRCS
 )
 
 phonon_add_executable(simplecapture ${simplecapture_SRCS})
-
-target_link_libraries(simplecapture ${QT_LIBRARIES} phonon)
+target_link_libraries(simplecapture ${QT_QTCORE_LIBRARY} ${QT_QTGUI_LIBRARY} ${PHONON_LIBRARY})
diff --git a/demos/simpleplayer/CMakeLists.txt b/demos/simpleplayer/CMakeLists.txt
index c60ddc9..1109133 100644
--- a/demos/simpleplayer/CMakeLists.txt
+++ b/demos/simpleplayer/CMakeLists.txt
@@ -1,8 +1,10 @@
 project(simpleplayer)
 cmake_minimum_required(VERSION 2.8.6 FATAL_ERROR)
 
-find_package(Qt4 REQUIRED)
-include(${QT_USE_FILE})
+find_package(ECM 0.0.5 REQUIRED NO_MODULE)
+set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH})
+find_package(Qt5Transitional REQUIRED Core Gui)
+set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${Qt5Widgets_EXECUTABLE_COMPILE_FLAGS}")
 
 find_package(Phonon REQUIRED)
 
@@ -15,5 +17,4 @@ set(simpleplayer_SRCS
 )
 
 phonon_add_executable(simpleplayer ${simpleplayer_SRCS})
-
-target_link_libraries(simpleplayer ${QT_LIBRARIES} phonon)
+target_link_libraries(simpleplayer ${QT_QTCORE_LIBRARY} ${QT_QTGUI_LIBRARY} ${PHONON_LIBRARY})
-- 
1.7.10.4

_______________________________________________
Kde-frameworks-devel mailing list
Kde-frameworks-devel at kde.org
https://mail.kde.org/mailman/listinfo/kde-frameworks-devel


More information about the kde-multimedia mailing list