FindKDE4.cmake 3.5 KB

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