FindKDE4.cmake 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. # Distributed under the OSI-approved BSD 3-Clause License. See accompanying
  2. # file Copyright.txt or https://cmake.org/licensing for details.
  3. #[=======================================================================[.rst:
  4. FindKDE4
  5. --------
  6. Find KDE4 and provide all necessary variables and macros to compile
  7. software for it. It looks for KDE 4 in the following directories in
  8. the given order:
  9. ::
  10. CMAKE_INSTALL_PREFIX
  11. KDEDIRS
  12. /opt/kde4
  13. Please look in ``FindKDE4Internal.cmake`` and ``KDE4Macros.cmake`` for more
  14. information. They are installed with the KDE 4 libraries in
  15. $KDEDIRS/share/apps/cmake/modules/.
  16. Author: Alexander Neundorf <neundorf@kde.org>
  17. #]=======================================================================]
  18. # If Qt3 has already been found, fail.
  19. if(QT_QT_LIBRARY)
  20. if(KDE4_FIND_REQUIRED)
  21. message( FATAL_ERROR "KDE4/Qt4 and Qt3 cannot be used together in one project.")
  22. else()
  23. if(NOT KDE4_FIND_QUIETLY)
  24. message( STATUS "KDE4/Qt4 and Qt3 cannot be used together in one project.")
  25. endif()
  26. return()
  27. endif()
  28. endif()
  29. file(TO_CMAKE_PATH "$ENV{KDEDIRS}" _KDEDIRS)
  30. # when cross compiling, searching kde4-config in order to run it later on
  31. # doesn't make a lot of sense. We'll have to do something about this.
  32. # Searching always in the target environment ? Then we get at least the correct one,
  33. # still it can't be used to run it. Alex
  34. # For KDE4 kde-config has been renamed to kde4-config
  35. find_program(KDE4_KDECONFIG_EXECUTABLE NAMES kde4-config
  36. # the suffix must be used since KDEDIRS can be a list of directories which don't have bin/ appended
  37. PATH_SUFFIXES bin
  38. HINTS
  39. ${CMAKE_INSTALL_PREFIX}
  40. ${_KDEDIRS}
  41. /opt/kde4
  42. ONLY_CMAKE_FIND_ROOT_PATH
  43. )
  44. if (NOT KDE4_KDECONFIG_EXECUTABLE)
  45. if (KDE4_FIND_REQUIRED)
  46. message(FATAL_ERROR "ERROR: Could not find KDE4 kde4-config")
  47. endif ()
  48. endif ()
  49. # when cross compiling, KDE4_DATA_DIR may be already preset
  50. if(NOT KDE4_DATA_DIR)
  51. if(CMAKE_CROSSCOMPILING)
  52. # when cross compiling, don't run kde4-config but use its location as install dir
  53. get_filename_component(KDE4_DATA_DIR "${KDE4_KDECONFIG_EXECUTABLE}" PATH)
  54. get_filename_component(KDE4_DATA_DIR "${KDE4_DATA_DIR}" PATH)
  55. else()
  56. # then ask kde4-config for the kde data dirs
  57. if(KDE4_KDECONFIG_EXECUTABLE)
  58. execute_process(COMMAND "${KDE4_KDECONFIG_EXECUTABLE}" --path data OUTPUT_VARIABLE _data_DIR ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE)
  59. file(TO_CMAKE_PATH "${_data_DIR}" _data_DIR)
  60. # then check the data dirs for FindKDE4Internal.cmake
  61. find_path(KDE4_DATA_DIR cmake/modules/FindKDE4Internal.cmake HINTS ${_data_DIR})
  62. endif()
  63. endif()
  64. endif()
  65. # if it has been found...
  66. if (KDE4_DATA_DIR)
  67. set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${KDE4_DATA_DIR}/cmake/modules)
  68. if (KDE4_FIND_QUIETLY)
  69. set(_quiet QUIET)
  70. endif ()
  71. if (KDE4_FIND_REQUIRED)
  72. set(_req REQUIRED)
  73. endif ()
  74. # use FindKDE4Internal.cmake to do the rest
  75. find_package(KDE4Internal ${_req} ${_quiet} NO_POLICY_SCOPE)
  76. else ()
  77. if (KDE4_FIND_REQUIRED)
  78. message(FATAL_ERROR "ERROR: cmake/modules/FindKDE4Internal.cmake not found in ${_data_DIR}")
  79. endif ()
  80. endif ()