FindKDE3.cmake 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212
  1. # - Find the KDE3 include and library dirs, KDE preprocessors and define a some macros
  2. #
  3. # This module defines the following variables:
  4. # KDE3_DEFINITIONS - compiler definitions required for compiling KDE software
  5. # KDE3_INCLUDE_DIR - the KDE include directory
  6. # KDE3_INCLUDE_DIRS - the KDE and the Qt include directory, for use with INCLUDE_DIRECTORIES()
  7. # KDE3_LIB_DIR - the directory where the KDE libraries are installed, for use with LINK_DIRECTORIES()
  8. # QT_AND_KDECORE_LIBRARIES - this contains both the Qt and the kdecore library
  9. # KDE3_DCOPIDL_EXECUTABLE - the dcopidl executable
  10. # KDE3_DCOPIDL2CPP_EXECUTABLE - the dcopidl2cpp executable
  11. # KDE3_KCFGC_EXECUTABLE - the kconfig_compiler executable
  12. # KDE3_FOUND - set to TRUE if all of the above has been found
  13. #
  14. # The following user adjustable options are provided:
  15. #
  16. # KDE3_ENABLE_FINAL - enable this for KDE-style enable-final all-in-one compilation
  17. # KDE3_BUILD_TESTS - enable this to build KDE testcases
  18. #
  19. #
  20. # It also adds the following macros (from KDE3Macros.cmake)
  21. # SRCS_VAR is always the variable which contains the list of source files for your application or library.
  22. #
  23. # KDE3_AUTOMOC(file1 ... fileN)
  24. # Call this if you want to have automatic moc file handling.
  25. # This means if you include "foo.moc" in the source file foo.cpp
  26. # a moc file for the header foo.h will be created automatically.
  27. # You can set the property SKIP_AUTOMAKE using SET_SOURCE_FILES_PROPERTIES()
  28. # to exclude some files in the list from being processed.
  29. #
  30. # KDE3_ADD_MOC_FILES(SRCS_VAR file1 ... fileN )
  31. # If you don't use the KDE3_AUTOMOC() macro, for the files
  32. # listed here moc files will be created (named "foo.moc.cpp")
  33. #
  34. # KDE3_ADD_DCOP_SKELS(SRCS_VAR header1.h ... headerN.h )
  35. # Use this to generate DCOP skeletions from the listed headers.
  36. #
  37. # KDE3_ADD_DCOP_STUBS(SRCS_VAR header1.h ... headerN.h )
  38. # Use this to generate DCOP stubs from the listed headers.
  39. #
  40. # KDE3_ADD_UI_FILES(SRCS_VAR file1.ui ... fileN.ui )
  41. # Use this to add the Qt designer ui files to your application/library.
  42. #
  43. # KDE3_ADD_KCFG_FILES(SRCS_VAR file1.kcfgc ... fileN.kcfgc )
  44. # Use this to add KDE kconfig compiler files to your application/library.
  45. #
  46. # KDE3_INSTALL_LIBTOOL_FILE(target)
  47. # This will create and install a simple libtool file for the given target.
  48. #
  49. # KDE3_ADD_EXECUTABLE(name file1 ... fileN )
  50. # Equivalent to ADD_EXECUTABLE(), but additionally supports KDE3_ENABLE_FINAL
  51. #
  52. # KDE3_ADD_KPART(name [WITH_PREFIX] file1 ... fileN )
  53. # Create a KDE plugin (KPart, kioslave, etc.) from the given source files.
  54. # It supports KDE3_ENABLE_FINAL
  55. # If WITH_PREFIX is given, the resulting plugin will have the prefix "lib", otherwise it won't.
  56. # It creates and installs an appropriate libtool la-file.
  57. #
  58. # KDE3_ADD_KDEINIT_EXECUTABLE(name file1 ... fileN )
  59. # Create a KDE application in the form of a module loadable via kdeinit.
  60. # A library named kdeinit_<name> will be created and a small executable which links to it.
  61. # It supports KDE3_ENABLE_FINAL
  62. #
  63. # Author: Alexander Neundorf <[email protected]>
  64. IF(NOT UNIX)
  65. MESSAGE(FATAL_ERROR "Compiling KDE3 applications and libraries under Windows is not supported")
  66. ENDIF(NOT UNIX)
  67. SET(QT_MT_REQUIRED TRUE)
  68. #SET(QT_MIN_VERSION "3.0.0")
  69. #this line includes FindQt.cmake, which searches the Qt library and headers
  70. FIND_PACKAGE(Qt3 REQUIRED)
  71. FIND_PACKAGE(X11 REQUIRED)
  72. SET(QT_AND_KDECORE_LIBS ${QT_LIBRARIES} kdecore)
  73. #add some KDE specific stuff
  74. SET(KDE3_DEFINITIONS -DQT_CLEAN_NAMESPACE -D_GNU_SOURCE)
  75. #only on linux, but NOT e.g. on FreeBSD:
  76. IF(CMAKE_SYSTEM_NAME MATCHES "Linux")
  77. SET (KDE3_DEFINITIONS ${KDE3_DEFINITIONS} -D_XOPEN_SOURCE=500 -D_BSD_SOURCE)
  78. SET ( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-long-long -ansi -Wundef -Wcast-align -Wconversion -Wchar-subscripts -Wall -W -Wpointer-arith -Wwrite-strings -O2 -Wformat-security -Wmissing-format-attribute -fno-common")
  79. SET ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wnon-virtual-dtor -Wno-long-long -ansi -Wundef -Wcast-align -Wconversion -Wchar-subscripts -Wall -W -Wpointer-arith -Wwrite-strings -O2 -Wformat-security -fno-exceptions -fno-check-new -fno-common")
  80. ENDIF(CMAKE_SYSTEM_NAME MATCHES "Linux")
  81. # works on FreeBSD, NOT tested on NetBSD and OpenBSD
  82. IF (CMAKE_SYSTEM_NAME MATCHES BSD)
  83. SET ( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-long-long -ansi -Wundef -Wcast-align -Wconversion -Wchar-subscripts -Wall -W -Wpointer-arith -Wwrite-strings -O2 -Wformat-security -Wmissing-format-attribute -fno-common")
  84. SET ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wnon-virtual-dtor -Wno-long-long -Wundef -Wcast-align -Wconversion -Wchar-subscripts -Wall -W -Wpointer-arith -Wwrite-strings -O2 -Wformat-security -Wmissing-format-attribute -fno-exceptions -fno-check-new -fno-common")
  85. ENDIF (CMAKE_SYSTEM_NAME MATCHES BSD)
  86. #SET(CMAKE_SHARED_LINKER_FLAGS "-avoid-version -module -Wl,--no-undefined -Wl,--allow-shlib-undefined")
  87. #SET(CMAKE_SHARED_LINKER_FLAGS "-Wl,--fatal-warnings -avoid-version -Wl,--no-undefined -lc")
  88. #SET(CMAKE_MODULE_LINKER_FLAGS "-Wl,--fatal-warnings -avoid-version -Wl,--no-undefined -lc")
  89. #now try to find some kde stuff
  90. #at first the KDE include direcory
  91. # kpassdlg.h comes from kdeui and doesn't exist in KDE4 anymore
  92. FIND_PATH(KDE3_INCLUDE_DIR kpassdlg.h
  93. $ENV{KDEDIR}/include
  94. /opt/kde/include
  95. /opt/kde3/include
  96. /usr/local/include
  97. /usr/include/
  98. /usr/include/kde
  99. /usr/local/include/kde
  100. )
  101. #now the KDE library directory
  102. FIND_LIBRARY(KDE3_KDECORE_LIBRARY NAMES kdecore
  103. PATHS
  104. $ENV{KDEDIR}/lib
  105. /opt/kde/lib
  106. /opt/kde3/lib
  107. /usr/lib
  108. /usr/local/lib
  109. )
  110. GET_FILENAME_COMPONENT(KDE3_LIB_DIR ${KDE3_KDECORE_LIBRARY} PATH )
  111. #now the KDE service types directory
  112. #FIND_PATH(KDE3_SERVICETYPES_DIR ktexteditor.desktop
  113. # $ENV{KDEDIR}/share/servicetypes/
  114. # /opt/kde/share/servicetypes/
  115. # /opt/kde3/share/servicetypes/
  116. #)
  117. #now search for the dcop utilities
  118. FIND_PROGRAM(KDE3_DCOPIDL_EXECUTABLE NAME dcopidl PATHS
  119. $ENV{KDEDIR}/bin
  120. /opt/kde/bin
  121. /opt/kde3/bin
  122. )
  123. FIND_PROGRAM(KDE3_DCOPIDL2CPP_EXECUTABLE NAME dcopidl2cpp PATHS
  124. $ENV{KDEDIR}/bin
  125. /opt/kde/bin
  126. /opt/kde3/bin)
  127. FIND_PROGRAM(KDE3_KCFGC_EXECUTABLE NAME kconfig_compiler PATHS
  128. $ENV{KDEDIR}/bin
  129. /opt/kde/bin
  130. /opt/kde3/bin)
  131. # KDE3Macros.cmake contains all the KDE specific macros
  132. INCLUDE(KDE3Macros)
  133. #SET KDE3_FOUND
  134. IF (KDE3_INCLUDE_DIR AND KDE3_LIB_DIR AND KDE3_DCOPIDL_EXECUTABLE AND KDE3_DCOPIDL2CPP_EXECUTABLE AND KDE3_KCFGC_EXECUTABLE)
  135. SET(KDE3_FOUND TRUE)
  136. ELSE (KDE3_INCLUDE_DIR AND KDE3_LIB_DIR AND KDE3_DCOPIDL_EXECUTABLE AND KDE3_DCOPIDL2CPP_EXECUTABLE AND KDE3_KCFGC_EXECUTABLE)
  137. SET(KDE3_FOUND FALSE)
  138. ENDIF (KDE3_INCLUDE_DIR AND KDE3_LIB_DIR AND KDE3_DCOPIDL_EXECUTABLE AND KDE3_DCOPIDL2CPP_EXECUTABLE AND KDE3_KCFGC_EXECUTABLE)
  139. MACRO (KDE3_PRINT_RESULTS)
  140. IF(KDE3_INCLUDE_DIR)
  141. MESSAGE(STATUS "Found KDE3 include dir: ${KDE3_INCLUDE_DIR}")
  142. ELSE(KDE3_INCLUDE_DIR)
  143. MESSAGE(STATUS "Didn't find KDE3 headers")
  144. ENDIF(KDE3_INCLUDE_DIR)
  145. IF(KDE3_LIB_DIR)
  146. MESSAGE(STATUS "Found KDE3 library dir: ${KDE3_LIB_DIR}")
  147. ELSE(KDE3_LIB_DIR)
  148. MESSAGE(STATUS "Didn't find KDE3 core library")
  149. ENDIF(KDE3_LIB_DIR)
  150. IF(KDE3_DCOPIDL_EXECUTABLE)
  151. MESSAGE(STATUS "Found KDE3 dcopidl preprocessor: ${KDE3_DCOPIDL_EXECUTABLE}")
  152. ELSE(KDE3_DCOPIDL_EXECUTABLE)
  153. MESSAGE(STATUS "Didn't find the KDE3 dcopidl preprocessor")
  154. ENDIF(KDE3_DCOPIDL_EXECUTABLE)
  155. IF(KDE3_DCOPIDL2CPP_EXECUTABLE)
  156. MESSAGE(STATUS "Found KDE3 dcopidl2cpp preprocessor: ${KDE3_DCOPIDL2CPP_EXECUTABLE}")
  157. ELSE(KDE3_DCOPIDL2CPP_EXECUTABLE)
  158. MESSAGE(STATUS "Didn't find the KDE3 dcopidl2cpp preprocessor")
  159. ENDIF(KDE3_DCOPIDL2CPP_EXECUTABLE)
  160. IF(KDE3_KCFGC_EXECUTABLE)
  161. MESSAGE(STATUS "Found KDE3 kconfig_compiler preprocessor: ${KDE3_KCFGC_EXECUTABLE}")
  162. ELSE(KDE3_KCFGC_EXECUTABLE)
  163. MESSAGE(STATUS "Didn't find the KDE3 kconfig_compiler preprocessor")
  164. ENDIF(KDE3_KCFGC_EXECUTABLE)
  165. ENDMACRO (KDE3_PRINT_RESULTS)
  166. IF (KDE3_FIND_REQUIRED AND NOT KDE3_FOUND)
  167. #bail out if something wasn't found
  168. KDE3_PRINT_RESULTS()
  169. MESSAGE(FATAL_ERROR "Could NOT find everything required for compiling KDE 3 programs")
  170. ENDIF (KDE3_FIND_REQUIRED AND NOT KDE3_FOUND)
  171. IF (NOT KDE3_FIND_QUIETLY)
  172. KDE3_PRINT_RESULTS()
  173. ENDIF (NOT KDE3_FIND_QUIETLY)
  174. #add the found Qt and KDE include directories to the current include path
  175. SET(KDE3_INCLUDE_DIRS ${QT_INCLUDE_DIR} ${KDE3_INCLUDE_DIR})