FindKDE4.cmake 3.8 KB

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