ctkMacroSetupQt.cmake 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. ###########################################################################
  2. #
  3. # Library: CTK
  4. #
  5. # Copyright (c) Kitware Inc.
  6. #
  7. # Licensed under the Apache License, Version 2.0 (the "License");
  8. # you may not use this file except in compliance with the License.
  9. # You may obtain a copy of the License at
  10. #
  11. # http://www.apache.org/licenses/LICENSE-2.0.txt
  12. #
  13. # Unless required by applicable law or agreed to in writing, software
  14. # distributed under the License is distributed on an "AS IS" BASIS,
  15. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  16. # See the License for the specific language governing permissions and
  17. # limitations under the License.
  18. #
  19. ###########################################################################
  20. #! \ingroup CMakeUtilities
  21. macro(ctkMacroSetupQt)
  22. if(CTK_USE_QT5)
  23. cmake_minimum_required(VERSION 2.8.9)
  24. set(QT5_INSTALL_PREFIX "" CACHE PATH "The install location of Qt5")
  25. if(NOT QT5_INSTALL_PREFIX OR NOT EXISTS ${QT5_INSTALL_PREFIX}/bin/qmake)
  26. message(FATAL_ERROR "You must specify the install location of Qt5")
  27. endif()
  28. set(CMAKE_PREFIX_PATH ${QT5_INSTALL_PREFIX})
  29. else()
  30. set(minimum_required_qt_version "4.6")
  31. find_package(Qt4)
  32. if(QT4_FOUND)
  33. if("${QT_VERSION_MAJOR}.${QT_VERSION_MINOR}" VERSION_LESS "${minimum_required_qt_version}")
  34. message(FATAL_ERROR "error: CTK requires Qt >= ${minimum_required_qt_version} -- you cannot use Qt ${QT_VERSION_MAJOR}.${QT_VERSION_MINOR}.${QT_VERSION_PATCH}.")
  35. endif()
  36. set(QT_USE_QTNETWORK ON)
  37. set(QT_USE_QTSQL ON)
  38. set(QT_USE_QTOPENGL ON)
  39. set(QT_USE_QTXML ON)
  40. set(QT_USE_QTXMLPATTERNS ON)
  41. set(QT_USE_QTTEST ${BUILD_TESTING})
  42. include(${QT_USE_FILE})
  43. # Set variable QT_INSTALLED_LIBRARY_DIR that will contains
  44. # Qt shared library
  45. set(QT_INSTALLED_LIBRARY_DIR ${QT_LIBRARY_DIR})
  46. if(WIN32)
  47. get_filename_component(QT_INSTALLED_LIBRARY_DIR ${QT_QMAKE_EXECUTABLE} PATH)
  48. endif()
  49. else()
  50. message(FATAL_ERROR "error: Qt4 was not found on your system. You probably need to set the QT_QMAKE_EXECUTABLE variable")
  51. endif()
  52. endif()
  53. endmacro()