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>
67 MESSAGE(FATAL_ERROR "Compiling KDE3 applications and libraries under Windows is not supported")
71 SET(QT_MT_REQUIRED TRUE)
72 #SET(QT_MIN_VERSION "3.0.0")
74 #this line includes FindQt.cmake, which searches the Qt library and headers
75 FIND_PACKAGE(Qt3 REQUIRED)
76 FIND_PACKAGE(X11 REQUIRED)
79 #add some KDE specific stuff
80 SET(KDE3_DEFINITIONS -DQT_CLEAN_NAMESPACE -D_GNU_SOURCE)
82 #only on linux, but NOT e.g. on FreeBSD:
83 IF(CMAKE_SYSTEM_NAME MATCHES "Linux")
84 SET (KDE3_DEFINITIONS ${KDE3_DEFINITIONS} -D_XOPEN_SOURCE=500 -D_BSD_SOURCE)
85 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")
86 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")
87 ENDIF(CMAKE_SYSTEM_NAME MATCHES "Linux")
89 # works on FreeBSD, NOT tested on NetBSD and OpenBSD
90 IF (CMAKE_SYSTEM_NAME MATCHES BSD)
91 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")
92 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")
93 ENDIF (CMAKE_SYSTEM_NAME MATCHES BSD)
95 # if no special buildtype is selected, add -O2 as default optimization
96 IF (NOT CMAKE_BUILD_TYPE)
97 SET ( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O2")
98 SET ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O2")
99 ENDIF (NOT CMAKE_BUILD_TYPE)
102 #SET(CMAKE_SHARED_LINKER_FLAGS "-avoid-version -module -Wl,--no-undefined -Wl,--allow-shlib-undefined")
103 #SET(CMAKE_SHARED_LINKER_FLAGS "-Wl,--fatal-warnings -avoid-version -Wl,--no-undefined -lc")
104 #SET(CMAKE_MODULE_LINKER_FLAGS "-Wl,--fatal-warnings -avoid-version -Wl,--no-undefined -lc")
106 # all calls to FIND_PROGRAM/PATH/LIBRARY() follow the same scheme:
107 # at first try some special paths with the argument "NO_DEFAULT_PATH"
108 # so only these paths are checked
109 # this is followed by a second call to FIND_PROGRAM/PATH/LIBRARY()
110 # but this time without any paths and without NO_DEFAULT_PATH
111 # this second call will do nothing if the first call already found
112 # what it was looking for, if not, it will search only in the default
113 # directories (/usr, /usr/local, etc.)
115 #now try to find some kde stuff
116 FIND_PROGRAM(KDECONFIG_EXECUTABLE NAMES kde-config PATHS
124 FIND_PROGRAM(KDECONFIG_EXECUTABLE kde-config)
128 IF(KDECONFIG_EXECUTABLE)
129 EXECUTE_PROCESS(COMMAND ${KDECONFIG_EXECUTABLE} --version
130 OUTPUT_VARIABLE kde_config_version )
132 STRING(REGEX MATCH "KDE: .\\." kde_version ${kde_config_version})
133 IF (${kde_version} MATCHES "KDE: 3\\.")
134 EXECUTE_PROCESS(COMMAND ${KDECONFIG_EXECUTABLE} --prefix
135 OUTPUT_VARIABLE kdedir )
136 STRING(REGEX REPLACE "\n" "" KDE3PREFIX "${kdedir}")
138 ENDIF (${kde_version} MATCHES "KDE: 3\\.")
139 ENDIF(KDECONFIG_EXECUTABLE)
143 # at first the KDE include direcory
144 # kpassdlg.h comes from kdeui and doesn't exist in KDE4 anymore
145 FIND_PATH(KDE3_INCLUDE_DIR kpassdlg.h
147 ${KDE3PREFIX}/include
151 /usr/local/include/kde
155 FIND_PATH(KDE3_INCLUDE_DIR kpassdlg.h)
157 #now the KDE library directory
158 FIND_LIBRARY(KDE3_KDECORE_LIBRARY NAMES kdecore
167 FIND_LIBRARY(KDE3_KDECORE_LIBRARY NAMES kdecore)
169 SET(QT_AND_KDECORE_LIBS ${QT_LIBRARIES} ${KDE3_KDECORE_LIBRARY})
171 GET_FILENAME_COMPONENT(KDE3_LIB_DIR ${KDE3_KDECORE_LIBRARY} PATH )
173 IF(NOT KDE3_LIBTOOL_DIR)
174 IF(KDE3_KDECORE_LIBRARY MATCHES lib64)
175 SET(KDE3_LIBTOOL_DIR /lib64/kde3)
176 ELSE(KDE3_KDECORE_LIBRARY MATCHES lib64)
177 SET(KDE3_LIBTOOL_DIR /lib/kde3)
178 ENDIF(KDE3_KDECORE_LIBRARY MATCHES lib64)
179 ENDIF(NOT KDE3_LIBTOOL_DIR)
181 #now search for the dcop utilities
182 FIND_PROGRAM(KDE3_DCOPIDL_EXECUTABLE NAMES dcopidl PATHS
190 FIND_PROGRAM(KDE3_DCOPIDL_EXECUTABLE NAMES dcopidl)
192 FIND_PROGRAM(KDE3_DCOPIDL2CPP_EXECUTABLE NAMES dcopidl2cpp PATHS
200 FIND_PROGRAM(KDE3_DCOPIDL2CPP_EXECUTABLE NAMES dcopidl2cpp)
202 FIND_PROGRAM(KDE3_KCFGC_EXECUTABLE NAMES kconfig_compiler PATHS
210 FIND_PROGRAM(KDE3_KCFGC_EXECUTABLE NAMES kconfig_compiler)
212 # KDE3Macros.cmake contains all the KDE specific macros
217 IF (KDE3_INCLUDE_DIR AND KDE3_LIB_DIR AND KDE3_DCOPIDL_EXECUTABLE AND KDE3_DCOPIDL2CPP_EXECUTABLE AND KDE3_KCFGC_EXECUTABLE)
219 ELSE (KDE3_INCLUDE_DIR AND KDE3_LIB_DIR AND KDE3_DCOPIDL_EXECUTABLE AND KDE3_DCOPIDL2CPP_EXECUTABLE AND KDE3_KCFGC_EXECUTABLE)
220 SET(KDE3_FOUND FALSE)
221 ENDIF (KDE3_INCLUDE_DIR AND KDE3_LIB_DIR AND KDE3_DCOPIDL_EXECUTABLE AND KDE3_DCOPIDL2CPP_EXECUTABLE AND KDE3_KCFGC_EXECUTABLE)
224 MACRO (KDE3_PRINT_RESULTS)
226 MESSAGE(STATUS "Found KDE3 include dir: ${KDE3_INCLUDE_DIR}")
227 ELSE(KDE3_INCLUDE_DIR)
228 MESSAGE(STATUS "Didn't find KDE3 headers")
229 ENDIF(KDE3_INCLUDE_DIR)
232 MESSAGE(STATUS "Found KDE3 library dir: ${KDE3_LIB_DIR}")
234 MESSAGE(STATUS "Didn't find KDE3 core library")
237 IF(KDE3_DCOPIDL_EXECUTABLE)
238 MESSAGE(STATUS "Found KDE3 dcopidl preprocessor: ${KDE3_DCOPIDL_EXECUTABLE}")
239 ELSE(KDE3_DCOPIDL_EXECUTABLE)
240 MESSAGE(STATUS "Didn't find the KDE3 dcopidl preprocessor")
241 ENDIF(KDE3_DCOPIDL_EXECUTABLE)
243 IF(KDE3_DCOPIDL2CPP_EXECUTABLE)
244 MESSAGE(STATUS "Found KDE3 dcopidl2cpp preprocessor: ${KDE3_DCOPIDL2CPP_EXECUTABLE}")
245 ELSE(KDE3_DCOPIDL2CPP_EXECUTABLE)
246 MESSAGE(STATUS "Didn't find the KDE3 dcopidl2cpp preprocessor")
247 ENDIF(KDE3_DCOPIDL2CPP_EXECUTABLE)
249 IF(KDE3_KCFGC_EXECUTABLE)
250 MESSAGE(STATUS "Found KDE3 kconfig_compiler preprocessor: ${KDE3_KCFGC_EXECUTABLE}")
251 ELSE(KDE3_KCFGC_EXECUTABLE)
252 MESSAGE(STATUS "Didn't find the KDE3 kconfig_compiler preprocessor")
253 ENDIF(KDE3_KCFGC_EXECUTABLE)
255 ENDMACRO (KDE3_PRINT_RESULTS)
258 IF (KDE3_FIND_REQUIRED AND NOT KDE3_FOUND)
259 #bail out if something wasn't found
261 MESSAGE(FATAL_ERROR "Could NOT find everything required for compiling KDE 3 programs")
263 ENDIF (KDE3_FIND_REQUIRED AND NOT KDE3_FOUND)
266 IF (NOT KDE3_FIND_QUIETLY)
268 ENDIF (NOT KDE3_FIND_QUIETLY)
270 #add the found Qt and KDE include directories to the current include path
271 SET(KDE3_INCLUDE_DIRS ${QT_INCLUDE_DIR} ${KDE3_INCLUDE_DIR})