Commit 84b31ae5 authored by Hugo Beauzée-Luyssen's avatar Hugo Beauzée-Luyssen

cmake: Attempt to make our build system work for Qt4 & 5

parent 6e510b29
...@@ -13,6 +13,8 @@ SET(PROJECT_CONTACT "vlmc-devel@videolan.org") ...@@ -13,6 +13,8 @@ SET(PROJECT_CONTACT "vlmc-devel@videolan.org")
SET(PROJECT_VENDOR "VLMC Team") SET(PROJECT_VENDOR "VLMC Team")
SET(ORG_WEBSITE "videolan.org") SET(ORG_WEBSITE "videolan.org")
option(FORCE_QT4 "Forces VLMC to build using Qt4" OFF)
# Configuring build type # Configuring build type
IF(NOT CMAKE_BUILD_TYPE) IF(NOT CMAKE_BUILD_TYPE)
SET(CMAKE_BUILD_TYPE "Debug" CACHE STRING SET(CMAKE_BUILD_TYPE "Debug" CACHE STRING
...@@ -103,70 +105,67 @@ ELSE(NOT APPLE) ...@@ -103,70 +105,67 @@ ELSE(NOT APPLE)
#SET(CMAKE_INSTALL_PREFIX "${CMAKE_CURRENT_BINARY_DIR}") #SET(CMAKE_INSTALL_PREFIX "${CMAKE_CURRENT_BINARY_DIR}")
ENDIF(NOT APPLE) ENDIF(NOT APPLE)
FIND_PACKAGE(LIBVLC) FIND_PACKAGE(LIBVLC REQUIRED)
IF (NOT LIBVLC_FOUND) list(APPEND VLMC_LIBS ${LIBVLC_LIBRARY} ${LIBVLCCORE_LIBRARY})
MESSAGE (SEND_ERROR "LibVLC dependency was not found (please get libvlc)!")
ENDIF (NOT LIBVLC_FOUND)
INCLUDE_DIRECTORIES(${LIBVLC_INCLUDE_DIR}) INCLUDE_DIRECTORIES(${LIBVLC_INCLUDE_DIR})
FIND_PACKAGE(frei0r) FIND_PACKAGE(frei0r REQUIRED)
IF (NOT FREI0R_FOUND)
MESSAGE (SEND_ERROR "frei0r not found! It is required for effects engine to work.")
ENDIF (NOT FREI0R_FOUND)
INCLUDE_DIRECTORIES(${FREI0R_INCLUDE_DIR}) INCLUDE_DIRECTORIES(${FREI0R_INCLUDE_DIR})
# search for Qt4
IF (WITH_GUI)
IF(WIN32)
#FindQt4.cmake is so brain-dead when Xcompiling
SET(QT_LIBRARY_DIR ${CONTRIBS_PATH}/lib)
SET(QT_INCLUDE_DIR ${CONTRIBS_PATH}/include/qt4)
ADD_DEFINITIONS( -I${CONTRIBS_PATH}/include/qt4/QtCore)
ADD_DEFINITIONS( -I${CONTRIBS_PATH}/include/qt4/QtGui)
ADD_DEFINITIONS( -I${CONTRIBS_PATH}/include/qt4/QtXml)
ADD_DEFINITIONS( -I${CONTRIBS_PATH}/include/qt4/QtNetwork)
ADD_DEFINITIONS( -I${CONTRIBS_PATH}/include/qt4/)
FIND_PACKAGE(Qt4 4.5.1 COMPONENTS QtCore QtXml QtGui QtNetwork REQUIRED )
ELSE(WIN32)
FIND_PACKAGE(Qt4 4.5.1 COMPONENTS QtCore QtXml QtGui QtNetwork REQUIRED )
ENDIF(WIN32)
ELSE(WITH_GUI)
FIND_PACKAGE (Qt4 4.5.1 COMPONENTS QtCore QtNetwork QtXml REQUIRED)
ENDIF(WITH_GUI)
IF (NOT WIN32) # search for Qt4
#FindQt4.cmake is so brain-dead when Xcompiling if (NOT FORCE_QT4)
SET (VLMC_LIBS ${QT_QTCORE_LIBRARY} message(STATUS "using qt5")
${QT_QTGUI_LIBRARY} find_package(Qt5Core )
${QT_QTNETWORK_LIBRARY} if (Qt5Core_DIR)
${QT_QTSVG_LIBRARY} # go on with other packages
${QT_QTXML_LIBRARY} if(WITH_GUI)
${LIBVLC_LIBRARY} find_package(Qt5 COMPONENTS Widgets Gui XML Network)
${LIBVLCCORE_LIBRARY}) else()
find_packages(Qt5 COMPONENTS XML Network)
IF (APPLE) # Fails to link to Cocoa framework automatically endif()
SET (VLMC_LIBS ${VLMC_LIBS} message(STATUS "Found Qt5! Be aware that Qt5-support is still experimental and not officially supported!")
${CMAKE_OSX_SYSROOT}/System/Library/Frameworks/Cocoa.framework)
ELSE (APPLE) macro(qt_wrap_ui)
IF (WITH_GUI) qt5_wrap_ui(${ARGN})
SET (VLMC_LIBS ${VLMC_LIBS} -lX11) endmacro()
ENDIF (WITH_GUI)
ENDIF(APPLE) macro(qt_add_resources)
qt5_add_resources(${ARGN})
INCLUDE(${QT_USE_FILE}) endmacro()
ADD_DEFINITIONS(${QT_DEFINITIONS})
ELSE (NOT WIN32) find_package(Qt5LinguistTools REQUIRED)
SET (VLMC_LIBS -L${CONTRIBS_PATH}/lib macro(qt_add_translation)
${CONTRIBS_PATH}/lib/libQtNetwork.a qt5_add_translation(${ARGN})
${CONTRIBS_PATH}/lib/libQtXml.a endmacro()
${CONTRIBS_PATH}/lib/libQtGui.a endif()
${CONTRIBS_PATH}/lib/libQtCore.a else()
${CONTRIBS_PATH}/lib/libvlccore.dll.a message(STATUS "Could not find Qt5, searching for Qt4 instead...")
${CONTRIBS_PATH}/lib/libvlc.dll.a
ws2_32 winmm imm32 libeay32 ssleay32 crypt32 gdi32) set(NEEDED_QT4_COMPONENTS "QtCore" "QtXml" "QtNetwork")
ENDIF(NOT WIN32) 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")
macro(qt5_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()
endif()
# layout of VLMC installation # layout of VLMC installation
# (default values are platform-specific) # (default values are platform-specific)
...@@ -209,7 +208,7 @@ IF (UNIX) ...@@ -209,7 +208,7 @@ IF (UNIX)
SET (VLMC_MANUAL_DIR ${CMAKE_INSTALL_PREFIX}/${VLMC_MANUAL_SUBDIR}) SET (VLMC_MANUAL_DIR ${CMAKE_INSTALL_PREFIX}/${VLMC_MANUAL_SUBDIR})
ENDIF (UNIX) ENDIF (UNIX)
SUBDIRS(ts) #SUBDIRS(ts)
SUBDIRS(src) SUBDIRS(src)
SUBDIRS(nsis) SUBDIRS(nsis)
SUBDIRS(effects) SUBDIRS(effects)
...@@ -272,8 +271,6 @@ ELSE(WIN32 AND NOT UNIX) ...@@ -272,8 +271,6 @@ ELSE(WIN32 AND NOT UNIX)
#SET(CPACK_SOURCE_STRIP_FILES "") #SET(CPACK_SOURCE_STRIP_FILES "")
ENDIF(WIN32 AND NOT UNIX) ENDIF(WIN32 AND NOT UNIX)
SET(PACKAGE_REQUIRES "libvlc-dev ( >= 1.1.4 ), frei0r-plugins, libqt4-gui ( >= 4.6 ), libqt4-network ( >= 4.6 ), libqt4-svg ( >= 4.6 ), libqt4-xml ( >= 4.6 )")
# RPM packages # RPM packages
INCLUDE ( ${CMAKE_MODULE_PATH}/RpmBuild.cmake ) INCLUDE ( ${CMAKE_MODULE_PATH}/RpmBuild.cmake )
IF ( RPMBUILD_FOUND AND NOT WIN32 ) IF ( RPMBUILD_FOUND AND NOT WIN32 )
......
...@@ -103,8 +103,9 @@ CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/cmake/config.h.cmake ${CMAKE_CURRENT_BINARY_D ...@@ -103,8 +103,9 @@ CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/cmake/config.h.cmake ${CMAKE_CURRENT_BINARY_D
IF (NOT WITH_GUI) IF (NOT WITH_GUI)
LIST (APPEND VLMC_SRCS Main/main.cpp Renderer/ConsoleRenderer.cpp ) LIST (APPEND VLMC_SRCS Main/main.cpp Renderer/ConsoleRenderer.cpp )
QT4_ADD_RESOURCES(VLMC_RCC_SRCS ${VLMC_RCC}) QT_ADD_RESOURCES(VLMC_RCC_SRCS ${VLMC_RCC})
ADD_EXECUTABLE(vlmc ${GUI_TYPE} ${VLMC_SRCS} ${VLMC_MOC_SRCS} ${VLMC_RCC_SRCS}) ADD_EXECUTABLE(vlmc ${GUI_TYPE} ${VLMC_SRCS} ${VLMC_MOC_SRCS} ${VLMC_RCC_SRCS})
qt5_use_modules(vlmc Core Xml Network)
TARGET_LINK_LIBRARIES(vlmc ${VLMC_LIBS}) TARGET_LINK_LIBRARIES(vlmc ${VLMC_LIBS})
#Add GUI stuff if required #Add GUI stuff if required
...@@ -220,8 +221,8 @@ ELSE(NOT WITH_GUI) ...@@ -220,8 +221,8 @@ ELSE(NOT WITH_GUI)
LIST( APPEND VLMC_UIS Gui/widgets/ui/CrashHandler.ui ) LIST( APPEND VLMC_UIS Gui/widgets/ui/CrashHandler.ui )
ENDIF(WITH_CRASHHANDLER_GUI) ENDIF(WITH_CRASHHANDLER_GUI)
QT4_WRAP_UI(VLMC_UIS_H ${VLMC_UIS}) QT_WRAP_UI(VLMC_UIS_H ${VLMC_UIS})
QT4_ADD_RESOURCES(VLMC_RCC_SRCS ${VLMC_RCC}) QT_ADD_RESOURCES(VLMC_RCC_SRCS ${VLMC_RCC})
IF( MINGW ) IF( MINGW )
# resource compilation for MinGW # resource compilation for MinGW
...@@ -251,6 +252,7 @@ ELSE(NOT WITH_GUI) ...@@ -251,6 +252,7 @@ ELSE(NOT WITH_GUI)
ADD_EXECUTABLE( vlmc ${GUI_TYPE} ${VLMC_SRCS} ${VLMC_MOC_SRCS} ${VLMC_UIS_H} ${VLMC_RCC_SRCS} ) ADD_EXECUTABLE( vlmc ${GUI_TYPE} ${VLMC_SRCS} ${VLMC_MOC_SRCS} ${VLMC_UIS_H} ${VLMC_RCC_SRCS} )
TARGET_LINK_LIBRARIES( vlmc ${VLMC_LIBS} ) TARGET_LINK_LIBRARIES( vlmc ${VLMC_LIBS} )
qt5_use_modules(vlmc Core Gui Widgets Xml Network)
ENDIF( NOT WITH_GUI ) ENDIF( NOT WITH_GUI )
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment