FindKDE4.cmake 3.0 KB

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