[vlmc-devel] cmake: Fix build using Qt4
Hugo Beauzée-Luyssen
git at videolan.org
Wed Feb 5 00:24:32 CET 2014
vlmc | branch: master | Hugo Beauzée-Luyssen <hugo at beauzee.fr> | Wed Feb 5 01:00:04 2014 +0200| [5e4f446194ec6d7285f794a3aabb3e7fcd7ff045] | committer: Hugo Beauzée-Luyssen
cmake: Fix build using Qt4
> http://git.videolan.org/gitweb.cgi/vlmc.git/?a=commit;h=5e4f446194ec6d7285f794a3aabb3e7fcd7ff045
---
CMakeLists.txt | 15 +++++++++++----
src/CMakeLists.txt | 8 +++++++-
2 files changed, 18 insertions(+), 5 deletions(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 347f838..5f2c041 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -113,7 +113,6 @@ FIND_PACKAGE(frei0r REQUIRED)
INCLUDE_DIRECTORIES(${FREI0R_INCLUDE_DIR})
-
# search for Qt4
if (NOT FORCE_QT4)
message(STATUS "using qt5")
@@ -147,15 +146,15 @@ if (NOT FORCE_QT4)
else()
message(STATUS "Could not find Qt5, searching for Qt4 instead...")
- set(NEEDED_QT4_COMPONENTS "QtCore" "QtXml" "QtNetwork")
+ set(NEEDED_QT4_COMPONENTS "QtCore" "QtXml" "QtNetwork")
if( WITH_GUI )
list(APPEND NEEDED_QT4_COMPONENTS "QtGui")
endif()
- macro_optional_find_package(Qt4 4.7.0 COMPONENTS ${NEEDED_QT4_COMPONENTS} )
- macro_log_feature(QT4_FOUND "Qt" "A cross-platform application and UI framework" "http://qt.nokia.com" TRUE "" "If you see this, although libqt4-devel is installed, check whether the \n qtwebkit-devel package and whatever contains QtUiTools is installed too")
+ find_package(Qt4 REQUIRED COMPONENTS ${NEEDED_QT4_COMPONENTS})
macro(qt_use_modules)
+
endmacro()
macro(qt_wrap_ui)
@@ -169,6 +168,14 @@ else()
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()
endif()
# layout of VLMC installation
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 115b508..4b6b9b4 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -252,7 +252,13 @@ ELSE(NOT WITH_GUI)
ADD_EXECUTABLE( vlmc ${GUI_TYPE} ${VLMC_SRCS} ${VLMC_MOC_SRCS} ${VLMC_UIS_H} ${VLMC_RCC_SRCS} )
TARGET_LINK_LIBRARIES( vlmc ${VLMC_LIBS} )
- qt_use_modules(vlmc Core Gui Widgets Xml Network)
+ if (NOT Qt4_FOUND)
+ qt_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
+ TARGET_LINK_LIBRARIES(vlmc ${QT_LIBRARIES})
+ endif()
ENDIF( NOT WITH_GUI )
More information about the Vlmc-devel
mailing list