Advertisement
Guest User

Untitled

a guest
Mar 25th, 2018
353
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
CMake 6.32 KB | None | 0 0
  1. # Distributed under the OSI-approved BSD 3-Clause License.  See accompanying
  2. # file Copyright.txt or https://cmake.org/licensing for details.
  3.  
  4. #.rst:
  5. # FindQt
  6. # ------
  7. #
  8. # Searches for all installed versions of Qt.
  9. #
  10. # This should only be used if your project can work with multiple
  11. # versions of Qt.  If not, you should just directly use FindQt4 or
  12. # FindQt3.  If multiple versions of Qt are found on the machine, then
  13. # The user must set the option DESIRED_QT_VERSION to the version they
  14. # want to use.  If only one version of qt is found on the machine, then
  15. # the DESIRED_QT_VERSION is set to that version and the matching FindQt3
  16. # or FindQt4 module is included.  Once the user sets DESIRED_QT_VERSION,
  17. # then the FindQt3 or FindQt4 module is included.
  18. #
  19. # This module can only detect and switch between Qt versions 3 and 4. It
  20. # cannot handle Qt5 or any later versions.
  21. #
  22. # ::
  23. #
  24. #   QT_REQUIRED if this is set to TRUE then if CMake can
  25. #               not find Qt4 or Qt3 an error is raised
  26. #               and a message is sent to the user.
  27. #
  28. #
  29. #
  30. # ::
  31. #
  32. #   DESIRED_QT_VERSION OPTION is created
  33. #   QT4_INSTALLED is set to TRUE if qt4 is found.
  34. #   QT3_INSTALLED is set to TRUE if qt3 is found.
  35.  
  36. # look for signs of qt3 installations
  37. file(GLOB GLOB_TEMP_VAR /usr/lib*/qt-3*/bin/qmake /usr/lib*/qt3*/bin/qmake)
  38. if(GLOB_TEMP_VAR)
  39.   set(QT3_INSTALLED TRUE)
  40. endif()
  41. set(GLOB_TEMP_VAR)
  42.  
  43. file(GLOB GLOB_TEMP_VAR /usr/local/qt-x11-commercial-3*/bin/qmake)
  44. if(GLOB_TEMP_VAR)
  45.   set(QT3_INSTALLED TRUE)
  46. endif()
  47. set(GLOB_TEMP_VAR)
  48.  
  49. file(GLOB GLOB_TEMP_VAR /usr/local/lib/qt3/bin/qmake)
  50. if(GLOB_TEMP_VAR)
  51.   set(QT3_INSTALLED TRUE)
  52. endif()
  53. set(GLOB_TEMP_VAR)
  54.  
  55. # look for qt4 installations
  56. file(GLOB GLOB_TEMP_VAR /usr/local/qt-x11-commercial-4*/bin/qmake)
  57. if(GLOB_TEMP_VAR)
  58.   set(QT4_INSTALLED TRUE)
  59. endif()
  60. set(GLOB_TEMP_VAR)
  61.  
  62. file(GLOB GLOB_TEMP_VAR /usr/local/Trolltech/Qt-4*/bin/qmake)
  63. if(GLOB_TEMP_VAR)
  64.   set(QT4_INSTALLED TRUE)
  65. endif()
  66. set(GLOB_TEMP_VAR)
  67.  
  68. file(GLOB GLOB_TEMP_VAR /usr/local/lib/qt4/bin/qmake)
  69. if(GLOB_TEMP_VAR)
  70.   set(QT4_INSTALLED TRUE)
  71. endif()
  72. set(GLOB_TEMP_VAR)
  73.  
  74. if (Qt_FIND_VERSION)
  75.   if (Qt_FIND_VERSION MATCHES "^([34])(\\.[0-9]+.*)?$")
  76.     set(DESIRED_QT_VERSION ${CMAKE_MATCH_1})
  77.   else ()
  78.     message(FATAL_ERROR "FindQt was called with invalid version '${Qt_FIND_VERSION}'. Only Qt major versions 3 or 4 are supported. If you do not need to support both Qt3 and Qt4 in your source consider calling find_package(Qt3) or find_package(Qt4) instead of find_package(Qt) instead.")
  79.   endif ()
  80. endif ()
  81.  
  82. # now find qmake
  83. find_program(QT_QMAKE_EXECUTABLE_FINDQT NAMES qmake PATHS "${QT_SEARCH_PATH}/bin" "$ENV{QTDIR}/bin")
  84. if(QT_QMAKE_EXECUTABLE_FINDQT)
  85.   exec_program(${QT_QMAKE_EXECUTABLE_FINDQT} ARGS "-query QT_VERSION"
  86.     OUTPUT_VARIABLE QTVERSION)
  87.   if(QTVERSION MATCHES "4")
  88.     set(QT_QMAKE_EXECUTABLE ${QT_QMAKE_EXECUTABLE_FINDQT} CACHE PATH "Qt4 qmake program.")
  89.     set(QT4_INSTALLED TRUE)
  90.   endif()
  91.   if(QTVERSION MATCHES "Unknown")
  92.     set(QT3_INSTALLED TRUE)
  93.   endif()
  94. endif()
  95.  
  96. if(QT_QMAKE_EXECUTABLE_FINDQT)
  97.   exec_program( ${QT_QMAKE_EXECUTABLE_FINDQT}
  98.     ARGS "-query QT_INSTALL_HEADERS"
  99.     OUTPUT_VARIABLE qt_headers )
  100. endif()
  101.  
  102. find_file( QT4_QGLOBAL_H_FILE qglobal.h
  103.   "${QT_SEARCH_PATH}/Qt/include"
  104.   "[HKEY_CURRENT_USER\\Software\\Trolltech\\Qt3Versions\\4.0.0;InstallDir]/include/Qt"
  105.   "[HKEY_CURRENT_USER\\Software\\Trolltech\\Versions\\4.0.0;InstallDir]/include/Qt"
  106.   ${qt_headers}/Qt
  107.   $ENV{QTDIR}/include/Qt
  108.   /usr/local/qt/include/Qt
  109.   /usr/local/include/Qt
  110.   /usr/lib/qt/include/Qt
  111.   /usr/include/Qt
  112.   /usr/share/qt4/include/Qt
  113.   /usr/local/include/X11/qt4/Qt
  114.   C:/Progra~1/qt/include/Qt )
  115.  
  116. if(QT4_QGLOBAL_H_FILE)
  117.   set(QT4_INSTALLED TRUE)
  118. endif()
  119.  
  120. find_file( QT3_QGLOBAL_H_FILE qglobal.h
  121.   "${QT_SEARCH_PATH}/Qt/include"
  122.  "[HKEY_CURRENT_USER\\Software\\Trolltech\\Qt3Versions\\3.2.1;InstallDir]/include/Qt"
  123.   "[HKEY_CURRENT_USER\\Software\\Trolltech\\Qt3Versions\\3.2.0;InstallDir]/include/Qt"
  124.   "[HKEY_CURRENT_USER\\Software\\Trolltech\\Qt3Versions\\3.1.0;InstallDir]/include/Qt"
  125.   C:/Qt/3.3.3Educational/include
  126.   $ENV{QTDIR}/include
  127.   /usr/include/qt3/Qt
  128.   /usr/local/qt/include
  129.   /usr/local/include
  130.   /usr/lib/qt/include
  131.   /usr/include
  132.   /usr/share/qt3/include
  133.   /usr/local/include/X11/qt3
  134.   C:/Progra~1/qt/include
  135.   /usr/include/qt3 )
  136.  
  137. if(QT3_QGLOBAL_H_FILE)
  138.   set(QT3_INSTALLED TRUE)
  139. endif()
  140.  
  141. if(QT3_INSTALLED AND QT4_INSTALLED AND NOT DESIRED_QT_VERSION)
  142.   # force user to pick if we have both
  143.   set(DESIRED_QT_VERSION 0 CACHE STRING "Pick a version of Qt to use: 3 or 4")
  144. else()
  145.   # if only one found then pick that one
  146.   if(QT3_INSTALLED AND NOT DESIRED_QT_VERSION EQUAL 4)
  147.     set(DESIRED_QT_VERSION 3 CACHE STRING "Pick a version of Qt to use: 3 or 4")
  148.   endif()
  149.   if(QT4_INSTALLED AND NOT DESIRED_QT_VERSION EQUAL 3)
  150.     set(DESIRED_QT_VERSION 4 CACHE STRING "Pick a version of Qt to use: 3 or 4")
  151.   endif()
  152. endif()
  153.  
  154. if(DESIRED_QT_VERSION EQUAL 3)
  155.   set(Qt3_FIND_REQUIRED ${Qt_FIND_REQUIRED})
  156.   set(Qt3_FIND_QUIETLY  ${Qt_FIND_QUIETLY})
  157.   include(${CMAKE_CURRENT_LIST_DIR}/FindQt3.cmake)
  158. endif()
  159. if(DESIRED_QT_VERSION EQUAL 4)
  160.   set(Qt4_FIND_REQUIRED ${Qt_FIND_REQUIRED})
  161.   set(Qt4_FIND_QUIETLY  ${Qt_FIND_QUIETLY})
  162.   include(${CMAKE_CURRENT_LIST_DIR}/FindQt4.cmake)
  163. endif()
  164.  
  165. if(NOT QT3_INSTALLED AND NOT QT4_INSTALLED)
  166.   if(QT_REQUIRED)
  167.     message(SEND_ERROR "CMake was unable to find any Qt versions, put qmake in your path, or set QT_QMAKE_EXECUTABLE.")
  168.   endif()
  169. else()
  170.   if(NOT QT_FOUND AND NOT DESIRED_QT_VERSION)
  171.     if(QT_REQUIRED)
  172.       message(SEND_ERROR "Multiple versions of Qt found please set DESIRED_QT_VERSION")
  173.     else()
  174.       message("Multiple versions of Qt found please set DESIRED_QT_VERSION")
  175.     endif()
  176.   endif()
  177.   if(NOT QT_FOUND AND DESIRED_QT_VERSION)
  178.     if(QT_REQUIRED)
  179.       message(FATAL_ERROR "CMake was unable to find Qt version: ${DESIRED_QT_VERSION}. Set advanced values QT_QMAKE_EXECUTABLE and QT${DESIRED_QT_VERSION}_QGLOBAL_H_FILE, if those are set then QT_QT_LIBRARY or QT_LIBRARY_DIR.")
  180.     else()
  181.       message( "CMake was unable to find desired Qt version: ${DESIRED_QT_VERSION}. Set advanced values QT_QMAKE_EXECUTABLE and QT${DESIRED_QT_VERSION}_QGLOBAL_H_FILE.")
  182.     endif()
  183.   endif()
  184. endif()
  185. mark_as_advanced(QT3_QGLOBAL_H_FILE QT4_QGLOBAL_H_FILE QT_QMAKE_EXECUTABLE_FINDQT)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement