1 # - Find the KDE3 include and library dirs, KDE preprocessors and define a some macros
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
14 # The following user adjustable options are provided:
16 # KDE3_BUILD_TESTS - enable this to build KDE testcases
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.
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.
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")
33 # KDE3_ADD_DCOP_SKELS(SRCS_VAR header1.h ... headerN.h )
34 # Use this to generate DCOP skeletions from the listed headers.
36 # KDE3_ADD_DCOP_STUBS(SRCS_VAR header1.h ... headerN.h )
37 # Use this to generate DCOP stubs from the listed headers.
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.
42 # KDE3_ADD_KCFG_FILES(SRCS_VAR file1.kcfgc ... fileN.kcfgc )
43 # Use this to add KDE kconfig compiler files to your application/library.
45 # KDE3_INSTALL_LIBTOOL_FILE(target)
46 # This will create and install a simple libtool file for the given target.
48 # KDE3_ADD_EXECUTABLE(name file1 ... fileN )
49 # Currently identical to ADD_EXECUTABLE(), may provide some advanced features in the future.
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.
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.
60 # The option KDE3_ENABLE_FINAL to enable all-in-one compilation is
61 # no longer supported.
64 # Author: Alexander Neundorf <neundorf@kde.org>
66 IF(NOT UNIX AND KDE3_FIND_REQUIRED)
67 MESSAGE(FATAL_ERROR "Compiling KDE3 applications and libraries under Windows is not supported")
68 ENDIF(NOT UNIX AND KDE3_FIND_REQUIRED)
70 # If Qt4 has already been found, fail.
72 IF(KDE3_FIND_REQUIRED)
73 MESSAGE( FATAL_ERROR "KDE3/Qt3 and Qt4 cannot be used together in one project.")
74 ELSE(KDE3_FIND_REQUIRED)
75 IF(NOT KDE3_FIND_QUIETLY)
76 MESSAGE( STATUS "KDE3/Qt3 and Qt4 cannot be used together in one project.")
77 ENDIF(NOT KDE3_FIND_QUIETLY)
79 ENDIF(KDE3_FIND_REQUIRED)
83 SET(QT_MT_REQUIRED TRUE)
84 #SET(QT_MIN_VERSION "3.0.0")
86 #this line includes FindQt.cmake, which searches the Qt library and headers
87 IF(KDE3_FIND_REQUIRED)
88 SET(_REQ_STRING_KDE3 "REQUIRED")
89 ENDIF(KDE3_FIND_REQUIRED)
91 FIND_PACKAGE(Qt3 ${_REQ_STRING_KDE3})
92 FIND_PACKAGE(X11 ${_REQ_STRING_KDE3})
95 #now try to find some kde stuff
96 FIND_PROGRAM(KDECONFIG_EXECUTABLE NAMES kde-config
105 IF(KDECONFIG_EXECUTABLE)
106 EXECUTE_PROCESS(COMMAND ${KDECONFIG_EXECUTABLE} --version
107 OUTPUT_VARIABLE kde_config_version )
109 STRING(REGEX MATCH "KDE: .\\." kde_version ${kde_config_version})
110 IF (${kde_version} MATCHES "KDE: 3\\.")
111 EXECUTE_PROCESS(COMMAND ${KDECONFIG_EXECUTABLE} --prefix
112 OUTPUT_VARIABLE kdedir )
113 STRING(REGEX REPLACE "\n" "" KDE3PREFIX "${kdedir}")
115 ENDIF (${kde_version} MATCHES "KDE: 3\\.")
116 ENDIF(KDECONFIG_EXECUTABLE)
120 # at first the KDE include direcory
121 # kpassdlg.h comes from kdeui and doesn't exist in KDE4 anymore
122 FIND_PATH(KDE3_INCLUDE_DIR kpassdlg.h
125 ${KDE3PREFIX}/include
130 /usr/local/include/kde
133 #now the KDE library directory
134 FIND_LIBRARY(KDE3_KDECORE_LIBRARY NAMES kdecore
143 SET(QT_AND_KDECORE_LIBS ${QT_LIBRARIES} ${KDE3_KDECORE_LIBRARY})
145 GET_FILENAME_COMPONENT(KDE3_LIB_DIR ${KDE3_KDECORE_LIBRARY} PATH )
147 IF(NOT KDE3_LIBTOOL_DIR)
148 IF(KDE3_KDECORE_LIBRARY MATCHES lib64)
149 SET(KDE3_LIBTOOL_DIR /lib64/kde3)
150 ELSE(KDE3_KDECORE_LIBRARY MATCHES lib64)
151 SET(KDE3_LIBTOOL_DIR /lib/kde3)
152 ENDIF(KDE3_KDECORE_LIBRARY MATCHES lib64)
153 ENDIF(NOT KDE3_LIBTOOL_DIR)
155 #now search for the dcop utilities
156 FIND_PROGRAM(KDE3_DCOPIDL_EXECUTABLE NAMES dcopidl
165 FIND_PROGRAM(KDE3_DCOPIDL2CPP_EXECUTABLE NAMES dcopidl2cpp
174 FIND_PROGRAM(KDE3_KCFGC_EXECUTABLE NAMES kconfig_compiler
185 IF (KDE3_INCLUDE_DIR AND KDE3_LIB_DIR AND KDE3_DCOPIDL_EXECUTABLE AND KDE3_DCOPIDL2CPP_EXECUTABLE AND KDE3_KCFGC_EXECUTABLE)
187 ELSE (KDE3_INCLUDE_DIR AND KDE3_LIB_DIR AND KDE3_DCOPIDL_EXECUTABLE AND KDE3_DCOPIDL2CPP_EXECUTABLE AND KDE3_KCFGC_EXECUTABLE)
188 SET(KDE3_FOUND FALSE)
189 ENDIF (KDE3_INCLUDE_DIR AND KDE3_LIB_DIR AND KDE3_DCOPIDL_EXECUTABLE AND KDE3_DCOPIDL2CPP_EXECUTABLE AND KDE3_KCFGC_EXECUTABLE)
191 # add some KDE specific stuff
192 SET(KDE3_DEFINITIONS -DQT_CLEAN_NAMESPACE -D_GNU_SOURCE)
194 # set compiler flags only if KDE3 has actually been found
196 SET(_KDE3_USE_FLAGS FALSE)
197 IF(CMAKE_COMPILER_IS_GNUCXX)
198 SET(_KDE3_USE_FLAGS TRUE) # use flags for gnu compiler
199 EXECUTE_PROCESS(COMMAND ${CMAKE_CXX_COMPILER} --version
201 # gnu gcc 2.96 does not work with flags
202 # I guess 2.95 also doesn't then
203 IF("${out}" MATCHES "2.9[56]")
204 SET(_KDE3_USE_FLAGS FALSE)
205 ENDIF("${out}" MATCHES "2.9[56]")
206 ENDIF(CMAKE_COMPILER_IS_GNUCXX)
208 #only on linux, but NOT e.g. on FreeBSD:
209 IF(CMAKE_SYSTEM_NAME MATCHES "Linux" AND _KDE3_USE_FLAGS)
210 SET (KDE3_DEFINITIONS ${KDE3_DEFINITIONS} -D_XOPEN_SOURCE=500 -D_BSD_SOURCE)
211 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")
212 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")
213 ENDIF(CMAKE_SYSTEM_NAME MATCHES "Linux" AND _KDE3_USE_FLAGS)
215 # works on FreeBSD, NOT tested on NetBSD and OpenBSD
216 IF (CMAKE_SYSTEM_NAME MATCHES BSD AND _KDE3_USE_FLAGS)
217 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")
218 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")
219 ENDIF (CMAKE_SYSTEM_NAME MATCHES BSD AND _KDE3_USE_FLAGS)
221 # if no special buildtype is selected, add -O2 as default optimization
222 IF (NOT CMAKE_BUILD_TYPE AND _KDE3_USE_FLAGS)
223 SET ( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O2")
224 SET ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O2")
225 ENDIF (NOT CMAKE_BUILD_TYPE AND _KDE3_USE_FLAGS)
227 #SET(CMAKE_SHARED_LINKER_FLAGS "-avoid-version -module -Wl,--no-undefined -Wl,--allow-shlib-undefined")
228 #SET(CMAKE_SHARED_LINKER_FLAGS "-Wl,--fatal-warnings -avoid-version -Wl,--no-undefined -lc")
229 #SET(CMAKE_MODULE_LINKER_FLAGS "-Wl,--fatal-warnings -avoid-version -Wl,--no-undefined -lc")
233 # KDE3Macros.cmake contains all the KDE specific macros
237 MACRO (KDE3_PRINT_RESULTS)
239 MESSAGE(STATUS "Found KDE3 include dir: ${KDE3_INCLUDE_DIR}")
240 ELSE(KDE3_INCLUDE_DIR)
241 MESSAGE(STATUS "Didn't find KDE3 headers")
242 ENDIF(KDE3_INCLUDE_DIR)
245 MESSAGE(STATUS "Found KDE3 library dir: ${KDE3_LIB_DIR}")
247 MESSAGE(STATUS "Didn't find KDE3 core library")
250 IF(KDE3_DCOPIDL_EXECUTABLE)
251 MESSAGE(STATUS "Found KDE3 dcopidl preprocessor: ${KDE3_DCOPIDL_EXECUTABLE}")
252 ELSE(KDE3_DCOPIDL_EXECUTABLE)
253 MESSAGE(STATUS "Didn't find the KDE3 dcopidl preprocessor")
254 ENDIF(KDE3_DCOPIDL_EXECUTABLE)
256 IF(KDE3_DCOPIDL2CPP_EXECUTABLE)
257 MESSAGE(STATUS "Found KDE3 dcopidl2cpp preprocessor: ${KDE3_DCOPIDL2CPP_EXECUTABLE}")
258 ELSE(KDE3_DCOPIDL2CPP_EXECUTABLE)
259 MESSAGE(STATUS "Didn't find the KDE3 dcopidl2cpp preprocessor")
260 ENDIF(KDE3_DCOPIDL2CPP_EXECUTABLE)
262 IF(KDE3_KCFGC_EXECUTABLE)
263 MESSAGE(STATUS "Found KDE3 kconfig_compiler preprocessor: ${KDE3_KCFGC_EXECUTABLE}")
264 ELSE(KDE3_KCFGC_EXECUTABLE)
265 MESSAGE(STATUS "Didn't find the KDE3 kconfig_compiler preprocessor")
266 ENDIF(KDE3_KCFGC_EXECUTABLE)
268 ENDMACRO (KDE3_PRINT_RESULTS)
271 IF (KDE3_FIND_REQUIRED AND NOT KDE3_FOUND)
272 #bail out if something wasn't found
274 MESSAGE(FATAL_ERROR "Could NOT find everything required for compiling KDE 3 programs")
276 ENDIF (KDE3_FIND_REQUIRED AND NOT KDE3_FOUND)
279 IF (NOT KDE3_FIND_QUIETLY)
281 ENDIF (NOT KDE3_FIND_QUIETLY)
283 #add the found Qt and KDE include directories to the current include path
284 SET(KDE3_INCLUDE_DIRS ${QT_INCLUDE_DIR} ${KDE3_INCLUDE_DIR})