QtConfiguration.cmake 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. include(FetchDependencies)
  2. if(WIN32)
  3. set(WINARCHSTR ARCHSTR windows-x86_64)
  4. endif(WIN32)
  5. if(NOT IS_DIRECTORY ${QTROOT})
  6. download_deps(
  7. "plexmediaplayer-qt"
  8. DIRECTORY dir
  9. DEPHASH_VAR QT_DEPS_HASH
  10. ARTIFACTNAME konvergo-qt
  11. DYLIB_SCRIPT_PATH ${PROJECT_SOURCE_DIR}/scripts/fix-install-names.py
  12. )
  13. set(QTROOT ${dir})
  14. # Write qt.conf in the Qt depends directory so that the Qt tools can find QML files
  15. set(QTCONFCONTENT "[Paths]
  16. Prefix=${QTROOT}
  17. ")
  18. file(WRITE ${QTROOT}/bin/qt.conf ${QTCONFCONTENT})
  19. endif()
  20. message(STATUS "Qt root directory: ${QTROOT}")
  21. list(APPEND CMAKE_FIND_ROOT_PATH ${QTROOT})
  22. list(APPEND CMAKE_PREFIX_PATH ${QTROOT})
  23. include_directories(${QTROOT}/include)
  24. set(REQUIRED_QT_VERSION "5.6.0")
  25. set(QTCONFIGROOT ${QTROOT}/lib/cmake/Qt5)
  26. set(components Core Network WebChannel Qml Quick Xml WebEngine Widgets)
  27. if(UNIX AND (NOT APPLE) AND ((NOT BUILD_TARGET STREQUAL "RPI")))
  28. add_definitions(-DUSE_X11EXTRAS)
  29. set(components ${components} X11Extras)
  30. endif()
  31. if(OPENELEC)
  32. set(components ${components} DBus)
  33. endif(OPENELEC)
  34. foreach(COMP ${components})
  35. set(mod Qt5${COMP})
  36. # look for the config files in the QtConfigRoot defined above
  37. set(${mod}_DIR ${QTCONFIGROOT}${COMP})
  38. # look for the actual package
  39. find_package(${mod} ${REQUIRED_QT_VERSION} REQUIRED)
  40. include_directories(${${mod}_INCLUDE_DIRS})
  41. if(OPENELEC)
  42. include_directories(${${mod}_PRIVATE_INCLUDE_DIRS})
  43. endif(OPENELEC)
  44. list(APPEND QT5_LIBRARIES ${${mod}_LIBRARIES})
  45. list(APPEND QT5_CFLAGS ${${mod}_EXECUTABLE_COMPILE_FLAGS})
  46. endforeach(COMP ${components})
  47. if(QT5_CFLAGS)
  48. list(REMOVE_DUPLICATES QT5_CFLAGS)
  49. if(WIN32)
  50. list(REMOVE_ITEM QT5_CFLAGS -fPIC)
  51. endif(WIN32)
  52. endif(QT5_CFLAGS)
  53. message(STATUS "Qt version: ${Qt5Core_VERSION_STRING}")
  54. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${QT5_CFLAGS}")
  55. set(CMAKE_REQUIRED_INCLUDES ${Qt5WebEngine_INCLUDE_DIRS};${Qt5WebEngine_PRIVATE_INCLUDE_DIRS})
  56. set(CMAKE_REQUIRED_LIBRARIES ${QT5_LIBRARIES})
  57. include(CheckCXXSourceCompiles)
  58. CHECK_CXX_SOURCE_COMPILES(
  59. "
  60. #include <QSurfaceFormat>
  61. int main(int argc, char** argv) {
  62. QSurfaceFormat::FormatOption o = QSurfaceFormat::UseOptimalOrientation;
  63. return 0;
  64. }
  65. " QT5_HAVE_OPTIMALORIENTATION)
  66. if(QT5_HAVE_OPTIMALORIENTATION)
  67. message(STATUS "QSurfaceFormat::UseOptimalOrientation found")
  68. add_definitions(-DHAVE_OPTIMALORIENTATION)
  69. endif()