QtConfiguration.cmake 2.4 KB

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