QtVersionAbstraction.cmake 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. # (c) 2014 Copyright ownCloud GmbH
  2. # Redistribution and use is allowed according to the terms of the BSD license.
  3. # For details see the accompanying COPYING* file.
  4. include (MacroOptionalFindPackage)
  5. include (MacroLogFeature)
  6. find_package(Qt5Core REQUIRED)
  7. find_package(Qt5Network REQUIRED)
  8. find_package(Qt5Xml REQUIRED)
  9. find_package(Qt5Concurrent REQUIRED)
  10. if(UNIT_TESTING)
  11. find_package(Qt5Test REQUIRED)
  12. endif()
  13. if(NOT TOKEN_AUTH_ONLY)
  14. find_package(Qt5Widgets REQUIRED)
  15. if(APPLE)
  16. find_package(Qt5MacExtras REQUIRED)
  17. endif(APPLE)
  18. if(NOT NO_SHIBBOLETH)
  19. find_package(Qt5WebKitWidgets)
  20. find_package(Qt5WebKit)
  21. if(NOT Qt5WebKitWidgets_FOUND)
  22. message(FATAL_ERROR "Qt5WebKit required for Shibboleth. Use -DNO_SHIBBOLETH=1 to disable it.")
  23. endif()
  24. endif()
  25. endif()
  26. # We need this to find the paths to qdbusxml2cpp and co
  27. if (WITH_DBUS)
  28. find_package(Qt5DBus REQUIRED)
  29. include_directories(${Qt5DBus_INCLUDES})
  30. add_definitions(${Qt5DBus_DEFINITIONS})
  31. endif (WITH_DBUS)
  32. include_directories(${Qt5Core_INCLUDES})
  33. add_definitions(${Qt5Core_DEFINITIONS})
  34. if (NOT WIN32) #implied on Win32
  35. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC")
  36. endif(NOT WIN32)
  37. # set(CMAKE_CXX_FLAGS "${Qt5Widgets_EXECUTABLE_COMPILE_FLAGS}")
  38. if(APPLE AND NOT TOKEN_AUTH_ONLY)
  39. include_directories(${Qt5MacExtras_INCLUDE_DIRS})
  40. add_definitions(${Qt5MacExtras_DEFINITIONS})
  41. set (QT_LIBRARIES ${QT_LIBRARIES} ${Qt5MacExtras_LIBRARIES})
  42. endif()
  43. if(NOT BUILD_LIBRARIES_ONLY)
  44. macro(qt_wrap_ui)
  45. qt5_wrap_ui(${ARGN})
  46. endmacro()
  47. else()
  48. # hack
  49. SET(QT_UIC_EXECUTABLE "")
  50. endif()
  51. macro(qt_add_resources)
  52. qt5_add_resources(${ARGN})
  53. endmacro()
  54. if(NOT TOKEN_AUTH_ONLY)
  55. find_package(Qt5LinguistTools)
  56. if(Qt5LinguistTools_FOUND)
  57. macro(qt_add_translation)
  58. qt5_add_translation(${ARGN})
  59. endmacro()
  60. else()
  61. macro(qt_add_translation)
  62. endmacro()
  63. endif()
  64. else()
  65. macro(qt_add_translation)
  66. endmacro()
  67. endif()
  68. macro(qt_add_dbus_interface)
  69. qt5_add_dbus_interface(${ARGN})
  70. endmacro()
  71. macro(qt_add_dbus_adaptor)
  72. qt5_add_dbus_adaptor(${ARGN})
  73. endmacro()
  74. macro(qt_wrap_cpp)
  75. qt5_wrap_cpp(${ARGN})
  76. endmacro()
  77. macro(install_qt_executable)
  78. install_qt5_executable(${ARGN})
  79. endmacro()
  80. macro(setup_qt)
  81. endmacro()
  82. set(QT_RCC_EXECUTABLE "${Qt5Core_RCC_EXECUTABLE}")
  83. #Enable deprecated symbols
  84. add_definitions("-DQT_DISABLE_DEPRECATED_BEFORE=0")
  85. add_definitions("-DQT_USE_QSTRINGBUILDER") #optimize string concatenation
  86. add_definitions("-DQT_MESSAGELOGCONTEXT") #enable function name and line number in debug output