QtConfiguration.cmake 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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})