QtConfiguration.cmake 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. include(FetchDependencies)
  2. if(NOT IS_DIRECTORY ${QTROOT})
  3. download_deps("plexmediaplayer-qt" dir QT_DEPS_HASH)
  4. set(QTROOT ${dir})
  5. endif()
  6. list(APPEND CMAKE_FIND_ROOT_PATH ${QTROOT})
  7. list(APPEND CMAKE_PREFIX_PATH ${QTROOT})
  8. include_directories(${QTROOT}/include)
  9. # Write qt.conf in the Qt depends directory so that the Qt tools can find QML files
  10. set(QTCONFCONTENT "[Paths]
  11. Prefix=${QTROOT}
  12. ")
  13. file(WRITE ${QTROOT}/bin/qt.conf ${QTCONFCONTENT})
  14. set(REQUIRED_QT_VERSION "5.6.0")
  15. message(STATUS ${QTROOT})
  16. set(QTCONFIGROOT ${QTROOT}/lib/cmake/Qt5)
  17. set(components Core Network WebChannel Qml Quick Xml WebEngine)
  18. if(OPENELEC)
  19. set(components ${components} DBus)
  20. endif(OPENELEC)
  21. foreach(COMP ${components})
  22. set(mod Qt5${COMP})
  23. # look for the config files in the QtConfigRoot defined above
  24. set(${mod}_DIR ${QTCONFIGROOT}${COMP})
  25. # look for the actual package
  26. find_package(${mod} ${REQUIRED_QT_VERSION} REQUIRED)
  27. include_directories(${${mod}_INCLUDE_DIRS})
  28. if(OPENELEC)
  29. include_directories(${${mod}_PRIVATE_INCLUDE_DIRS})
  30. endif(OPENELEC)
  31. list(APPEND QT5_LIBRARIES ${${mod}_LIBRARIES})
  32. list(APPEND QT5_CFLAGS ${${mod}_EXECUTABLE_COMPILE_FLAGS})
  33. endforeach(COMP ${components})
  34. list(REMOVE_DUPLICATES QT5_CFLAGS)
  35. if(WIN32)
  36. list(REMOVE_ITEM QT5_CFLAGS -fPIC)
  37. endif(WIN32)
  38. message(STATUS "Qt version: ${Qt5Core_VERSION_STRING}")
  39. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${QT5_CFLAGS}")
  40. set(CMAKE_REQUIRED_INCLUDES ${Qt5WebEngine_INCLUDE_DIRS};${Qt5WebEngine_PRIVATE_INCLUDE_DIRS})
  41. set(CMAKE_REQUIRED_LIBRARIES ${QT5_LIBRARIES})
  42. OPTION(SKIP_QT_TEST "Skip tests for required Qt features" OFF)
  43. if(NOT SKIP_QT_TEST)
  44. include(CheckCXXSourceCompiles)
  45. check_cxx_source_compiles("
  46. #include <private/qquickwebengineview_p.h>
  47. #include <QColor>
  48. int main()
  49. {
  50. QQuickWebEngineView* view = new QQuickWebEngineView(NULL);
  51. view->setBackgroundColor(QColor(\"transparent\"));
  52. }
  53. " WebEngineBackgroundProperty)
  54. if(NOT WebEngineBackgroundProperty)
  55. message(FATAL_ERROR "QQuickWebEngineView doesn't have the background property."
  56. "This will break video playback. As of Qt 5.5 you need to manually patch and build Qt to get this property."
  57. "With the release of Qt5.6 it will no longer be required. See qt-patches/README for more details.")
  58. endif(NOT WebEngineBackgroundProperty)
  59. endif(NOT SKIP_QT_TEST)