FindKDE3.cmake 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272
  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_LIBS - 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_BUILD_TESTS - enable this to build KDE testcases
  17. #
  18. #
  19. # It also adds the following macros (from KDE3Macros.cmake)
  20. # SRCS_VAR is always the variable which contains the list of source files for your application or library.
  21. #
  22. # KDE3_AUTOMOC(file1 ... fileN)
  23. # Call this if you want to have automatic moc file handling.
  24. # This means if you include "foo.moc" in the source file foo.cpp
  25. # a moc file for the header foo.h will be created automatically.
  26. # You can set the property SKIP_AUTOMAKE using SET_SOURCE_FILES_PROPERTIES()
  27. # to exclude some files in the list from being processed.
  28. #
  29. # KDE3_ADD_MOC_FILES(SRCS_VAR file1 ... fileN )
  30. # If you don't use the KDE3_AUTOMOC() macro, for the files
  31. # listed here moc files will be created (named "foo.moc.cpp")
  32. #
  33. # KDE3_ADD_DCOP_SKELS(SRCS_VAR header1.h ... headerN.h )
  34. # Use this to generate DCOP skeletions from the listed headers.
  35. #
  36. # KDE3_ADD_DCOP_STUBS(SRCS_VAR header1.h ... headerN.h )
  37. # Use this to generate DCOP stubs from the listed headers.
  38. #
  39. # KDE3_ADD_UI_FILES(SRCS_VAR file1.ui ... fileN.ui )
  40. # Use this to add the Qt designer ui files to your application/library.
  41. #
  42. # KDE3_ADD_KCFG_FILES(SRCS_VAR file1.kcfgc ... fileN.kcfgc )
  43. # Use this to add KDE kconfig compiler files to your application/library.
  44. #
  45. # KDE3_INSTALL_LIBTOOL_FILE(target)
  46. # This will create and install a simple libtool file for the given target.
  47. #
  48. # KDE3_ADD_EXECUTABLE(name file1 ... fileN )
  49. # Currently identical to ADD_EXECUTABLE(), may provide some advanced features in the future.
  50. #
  51. # KDE3_ADD_KPART(name [WITH_PREFIX] file1 ... fileN )
  52. # Create a KDE plugin (KPart, kioslave, etc.) from the given source files.
  53. # If WITH_PREFIX is given, the resulting plugin will have the prefix "lib", otherwise it won't.
  54. # It creates and installs an appropriate libtool la-file.
  55. #
  56. # KDE3_ADD_KDEINIT_EXECUTABLE(name file1 ... fileN )
  57. # Create a KDE application in the form of a module loadable via kdeinit.
  58. # A library named kdeinit_<name> will be created and a small executable which links to it.
  59. #
  60. # The option KDE3_ENABLE_FINAL to enable all-in-one compilation is
  61. # no longer supported.
  62. #
  63. #
  64. # Author: Alexander Neundorf <[email protected]>
  65. IF(NOT UNIX)
  66. MESSAGE(FATAL_ERROR "Compiling KDE3 applications and libraries under Windows is not supported")
  67. ENDIF(NOT UNIX)
  68. SET(QT_MT_REQUIRED TRUE)
  69. #SET(QT_MIN_VERSION "3.0.0")
  70. #this line includes FindQt.cmake, which searches the Qt library and headers
  71. FIND_PACKAGE(Qt3 REQUIRED)
  72. FIND_PACKAGE(X11 REQUIRED)
  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 -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 -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 -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 -Wformat-security -Wmissing-format-attribute -fno-exceptions -fno-check-new -fno-common")
  85. ENDIF (CMAKE_SYSTEM_NAME MATCHES BSD)
  86. # if no special buildtype is selected, add -O2 as default optimization
  87. IF (NOT CMAKE_BUILD_TYPE)
  88. SET ( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O2")
  89. SET ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O2")
  90. ENDIF (NOT CMAKE_BUILD_TYPE)
  91. #SET(CMAKE_SHARED_LINKER_FLAGS "-avoid-version -module -Wl,--no-undefined -Wl,--allow-shlib-undefined")
  92. #SET(CMAKE_SHARED_LINKER_FLAGS "-Wl,--fatal-warnings -avoid-version -Wl,--no-undefined -lc")
  93. #SET(CMAKE_MODULE_LINKER_FLAGS "-Wl,--fatal-warnings -avoid-version -Wl,--no-undefined -lc")
  94. # all calls to FIND_PROGRAM/PATH/LIBRARY() follow the same scheme:
  95. # at first try some special paths with the argument "NO_DEFAULT_PATH"
  96. # so only these paths are checked
  97. # this is followed by a second call to FIND_PROGRAM/PATH/LIBRARY()
  98. # but this time without any paths and without NO_DEFAULT_PATH
  99. # this second call will do nothing if the first call already found
  100. # what it was looking for, if not, it will search only in the default
  101. # directories (/usr, /usr/local, etc.)
  102. #now try to find some kde stuff
  103. FIND_PROGRAM(KDECONFIG_EXECUTABLE NAMES kde-config PATHS
  104. $ENV{KDEDIR}/bin
  105. /opt/kde3/bin
  106. /opt/kde/bin
  107. NO_DEFAULT_PATH
  108. )
  109. FIND_PROGRAM(KDECONFIG_EXECUTABLE kde-config)
  110. SET(KDE3PREFIX)
  111. IF(KDECONFIG_EXECUTABLE)
  112. EXECUTE_PROCESS(COMMAND ${KDECONFIG_EXECUTABLE} --version
  113. OUTPUT_VARIABLE kde_config_version )
  114. STRING(REGEX MATCH "KDE: .\\." kde_version ${kde_config_version})
  115. IF (${kde_version} MATCHES "KDE: 3\\.")
  116. EXECUTE_PROCESS(COMMAND ${KDECONFIG_EXECUTABLE} --prefix
  117. OUTPUT_VARIABLE kdedir )
  118. STRING(REGEX REPLACE "\n" "" KDE3PREFIX "${kdedir}")
  119. ENDIF (${kde_version} MATCHES "KDE: 3\\.")
  120. ENDIF(KDECONFIG_EXECUTABLE)
  121. # at first the KDE include direcory
  122. # kpassdlg.h comes from kdeui and doesn't exist in KDE4 anymore
  123. FIND_PATH(KDE3_INCLUDE_DIR kpassdlg.h
  124. $ENV{KDEDIR}/include
  125. ${KDE3PREFIX}/include
  126. /opt/kde3/include
  127. /opt/kde/include
  128. /usr/include/kde
  129. /usr/local/include/kde
  130. NO_DEFAULT_PATH
  131. )
  132. FIND_PATH(KDE3_INCLUDE_DIR kpassdlg.h)
  133. #now the KDE library directory
  134. FIND_LIBRARY(KDE3_KDECORE_LIBRARY NAMES kdecore
  135. PATHS
  136. $ENV{KDEDIR}/lib
  137. ${KDE3PREFIX}/lib
  138. /opt/kde3/lib
  139. /opt/kde/lib
  140. NO_DEFAULT_PATH
  141. )
  142. FIND_LIBRARY(KDE3_KDECORE_LIBRARY NAMES kdecore)
  143. SET(QT_AND_KDECORE_LIBS ${QT_LIBRARIES} ${KDE3_KDECORE_LIBRARY})
  144. GET_FILENAME_COMPONENT(KDE3_LIB_DIR ${KDE3_KDECORE_LIBRARY} PATH )
  145. IF(NOT KDE3_LIBTOOL_DIR)
  146. IF(KDE3_KDECORE_LIBRARY MATCHES lib64)
  147. SET(KDE3_LIBTOOL_DIR /lib64/kde3)
  148. ELSE(KDE3_KDECORE_LIBRARY MATCHES lib64)
  149. SET(KDE3_LIBTOOL_DIR /lib/kde3)
  150. ENDIF(KDE3_KDECORE_LIBRARY MATCHES lib64)
  151. ENDIF(NOT KDE3_LIBTOOL_DIR)
  152. #now search for the dcop utilities
  153. FIND_PROGRAM(KDE3_DCOPIDL_EXECUTABLE NAMES dcopidl PATHS
  154. $ENV{KDEDIR}/bin
  155. ${KDE3PREFIX}/bin
  156. /opt/kde3/bin
  157. /opt/kde/bin
  158. NO_DEFAULT_PATH
  159. )
  160. FIND_PROGRAM(KDE3_DCOPIDL_EXECUTABLE NAMES dcopidl)
  161. FIND_PROGRAM(KDE3_DCOPIDL2CPP_EXECUTABLE NAMES dcopidl2cpp PATHS
  162. $ENV{KDEDIR}/bin
  163. ${KDE3PREFIX}/bin
  164. /opt/kde3/bin
  165. /opt/kde/bin
  166. NO_DEFAULT_PATH
  167. )
  168. FIND_PROGRAM(KDE3_DCOPIDL2CPP_EXECUTABLE NAMES dcopidl2cpp)
  169. FIND_PROGRAM(KDE3_KCFGC_EXECUTABLE NAMES kconfig_compiler PATHS
  170. $ENV{KDEDIR}/bin
  171. ${KDE3PREFIX}/bin
  172. /opt/kde3/bin
  173. /opt/kde/bin
  174. NO_DEFAULT_PATH
  175. )
  176. FIND_PROGRAM(KDE3_KCFGC_EXECUTABLE NAMES kconfig_compiler)
  177. # KDE3Macros.cmake contains all the KDE specific macros
  178. INCLUDE(KDE3Macros)
  179. #SET KDE3_FOUND
  180. IF (KDE3_INCLUDE_DIR AND KDE3_LIB_DIR AND KDE3_DCOPIDL_EXECUTABLE AND KDE3_DCOPIDL2CPP_EXECUTABLE AND KDE3_KCFGC_EXECUTABLE)
  181. SET(KDE3_FOUND TRUE)
  182. ELSE (KDE3_INCLUDE_DIR AND KDE3_LIB_DIR AND KDE3_DCOPIDL_EXECUTABLE AND KDE3_DCOPIDL2CPP_EXECUTABLE AND KDE3_KCFGC_EXECUTABLE)
  183. SET(KDE3_FOUND FALSE)
  184. ENDIF (KDE3_INCLUDE_DIR AND KDE3_LIB_DIR AND KDE3_DCOPIDL_EXECUTABLE AND KDE3_DCOPIDL2CPP_EXECUTABLE AND KDE3_KCFGC_EXECUTABLE)
  185. MACRO (KDE3_PRINT_RESULTS)
  186. IF(KDE3_INCLUDE_DIR)
  187. MESSAGE(STATUS "Found KDE3 include dir: ${KDE3_INCLUDE_DIR}")
  188. ELSE(KDE3_INCLUDE_DIR)
  189. MESSAGE(STATUS "Didn't find KDE3 headers")
  190. ENDIF(KDE3_INCLUDE_DIR)
  191. IF(KDE3_LIB_DIR)
  192. MESSAGE(STATUS "Found KDE3 library dir: ${KDE3_LIB_DIR}")
  193. ELSE(KDE3_LIB_DIR)
  194. MESSAGE(STATUS "Didn't find KDE3 core library")
  195. ENDIF(KDE3_LIB_DIR)
  196. IF(KDE3_DCOPIDL_EXECUTABLE)
  197. MESSAGE(STATUS "Found KDE3 dcopidl preprocessor: ${KDE3_DCOPIDL_EXECUTABLE}")
  198. ELSE(KDE3_DCOPIDL_EXECUTABLE)
  199. MESSAGE(STATUS "Didn't find the KDE3 dcopidl preprocessor")
  200. ENDIF(KDE3_DCOPIDL_EXECUTABLE)
  201. IF(KDE3_DCOPIDL2CPP_EXECUTABLE)
  202. MESSAGE(STATUS "Found KDE3 dcopidl2cpp preprocessor: ${KDE3_DCOPIDL2CPP_EXECUTABLE}")
  203. ELSE(KDE3_DCOPIDL2CPP_EXECUTABLE)
  204. MESSAGE(STATUS "Didn't find the KDE3 dcopidl2cpp preprocessor")
  205. ENDIF(KDE3_DCOPIDL2CPP_EXECUTABLE)
  206. IF(KDE3_KCFGC_EXECUTABLE)
  207. MESSAGE(STATUS "Found KDE3 kconfig_compiler preprocessor: ${KDE3_KCFGC_EXECUTABLE}")
  208. ELSE(KDE3_KCFGC_EXECUTABLE)
  209. MESSAGE(STATUS "Didn't find the KDE3 kconfig_compiler preprocessor")
  210. ENDIF(KDE3_KCFGC_EXECUTABLE)
  211. ENDMACRO (KDE3_PRINT_RESULTS)
  212. IF (KDE3_FIND_REQUIRED AND NOT KDE3_FOUND)
  213. #bail out if something wasn't found
  214. KDE3_PRINT_RESULTS()
  215. MESSAGE(FATAL_ERROR "Could NOT find everything required for compiling KDE 3 programs")
  216. ENDIF (KDE3_FIND_REQUIRED AND NOT KDE3_FOUND)
  217. IF (NOT KDE3_FIND_QUIETLY)
  218. KDE3_PRINT_RESULTS()
  219. ENDIF (NOT KDE3_FIND_QUIETLY)
  220. #add the found Qt and KDE include directories to the current include path
  221. SET(KDE3_INCLUDE_DIRS ${QT_INCLUDE_DIR} ${KDE3_INCLUDE_DIR})