1# Distributed under the OSI-approved BSD 3-Clause License. See accompanying 2# file Copyright.txt or https://cmake.org/licensing for details. 3 4#[=======================================================================[.rst: 5FindKDE3 6-------- 7 8Find the KDE3 include and library dirs, KDE preprocessors and define a some macros 9 10 11 12This module defines the following variables: 13 14``KDE3_DEFINITIONS`` 15 compiler definitions required for compiling KDE software 16``KDE3_INCLUDE_DIR`` 17 the KDE include directory 18``KDE3_INCLUDE_DIRS`` 19 the KDE and the Qt include directory, for use with include_directories() 20``KDE3_LIB_DIR`` 21 the directory where the KDE libraries are installed, for use with link_directories() 22``QT_AND_KDECORE_LIBS`` 23 this contains both the Qt and the kdecore library 24``KDE3_DCOPIDL_EXECUTABLE`` 25 the dcopidl executable 26``KDE3_DCOPIDL2CPP_EXECUTABLE`` 27 the dcopidl2cpp executable 28``KDE3_KCFGC_EXECUTABLE`` 29 the kconfig_compiler executable 30``KDE3_FOUND`` 31 set to TRUE if all of the above has been found 32 33The following user adjustable options are provided: 34 35``KDE3_BUILD_TESTS`` 36 enable this to build KDE testcases 37 38It also adds the following macros (from ``KDE3Macros.cmake``) ``SRCS_VAR`` is 39always the variable which contains the list of source files for your 40application or library. 41 42KDE3_AUTOMOC(file1 ... fileN) 43 44:: 45 46 Call this if you want to have automatic moc file handling. 47 This means if you include "foo.moc" in the source file foo.cpp 48 a moc file for the header foo.h will be created automatically. 49 You can set the property SKIP_AUTOMAKE using set_source_files_properties() 50 to exclude some files in the list from being processed. 51 52 53 54KDE3_ADD_MOC_FILES(SRCS_VAR file1 ... fileN ) 55 56:: 57 58 If you don't use the KDE3_AUTOMOC() macro, for the files 59 listed here moc files will be created (named "foo.moc.cpp") 60 61 62 63KDE3_ADD_DCOP_SKELS(SRCS_VAR header1.h ... headerN.h ) 64 65:: 66 67 Use this to generate DCOP skeletions from the listed headers. 68 69 70 71KDE3_ADD_DCOP_STUBS(SRCS_VAR header1.h ... headerN.h ) 72 73:: 74 75 Use this to generate DCOP stubs from the listed headers. 76 77 78 79KDE3_ADD_UI_FILES(SRCS_VAR file1.ui ... fileN.ui ) 80 81:: 82 83 Use this to add the Qt designer ui files to your application/library. 84 85 86 87KDE3_ADD_KCFG_FILES(SRCS_VAR file1.kcfgc ... fileN.kcfgc ) 88 89:: 90 91 Use this to add KDE kconfig compiler files to your application/library. 92 93 94 95KDE3_INSTALL_LIBTOOL_FILE(target) 96 97:: 98 99 This will create and install a simple libtool file for the given target. 100 101 102 103KDE3_ADD_EXECUTABLE(name file1 ... fileN ) 104 105:: 106 107 Currently identical to add_executable(), may provide some advanced 108 features in the future. 109 110 111 112KDE3_ADD_KPART(name [WITH_PREFIX] file1 ... fileN ) 113 114:: 115 116 Create a KDE plugin (KPart, kioslave, etc.) from the given source files. 117 If WITH_PREFIX is given, the resulting plugin will have the prefix "lib", 118 otherwise it won't. 119 It creates and installs an appropriate libtool la-file. 120 121 122 123KDE3_ADD_KDEINIT_EXECUTABLE(name file1 ... fileN ) 124 125:: 126 127 Create a KDE application in the form of a module loadable via kdeinit. 128 A library named kdeinit_<name> will be created and a small executable 129 which links to it. 130 131 132 133The option KDE3_ENABLE_FINAL to enable all-in-one compilation is no 134longer supported. 135 136 137 138Author: Alexander Neundorf <[email protected]> 139#]=======================================================================] 140 141if(NOT UNIX AND KDE3_FIND_REQUIRED) 142 message(FATAL_ERROR "Compiling KDE3 applications and libraries under Windows is not supported") 143endif() 144 145# If Qt4 has already been found, fail. 146if(QT4_FOUND) 147 if(KDE3_FIND_REQUIRED) 148 message( FATAL_ERROR "KDE3/Qt3 and Qt4 cannot be used together in one project.") 149 else() 150 if(NOT KDE3_FIND_QUIETLY) 151 message( STATUS "KDE3/Qt3 and Qt4 cannot be used together in one project.") 152 endif() 153 return() 154 endif() 155endif() 156 157 158set(QT_MT_REQUIRED TRUE) 159#set(QT_MIN_VERSION "3.0.0") 160 161#this line includes FindQt.cmake, which searches the Qt library and headers 162if(KDE3_FIND_REQUIRED) 163 set(_REQ_STRING_KDE3 "REQUIRED") 164endif() 165 166find_package(Qt3 ${_REQ_STRING_KDE3}) 167find_package(X11 ${_REQ_STRING_KDE3}) 168 169 170#now try to find some kde stuff 171find_program(KDECONFIG_EXECUTABLE NAMES kde-config 172 HINTS 173 $ENV{KDEDIR}/bin 174 PATHS 175 /opt/kde3/bin 176 /opt/kde/bin 177 ) 178 179set(KDE3PREFIX) 180if(KDECONFIG_EXECUTABLE) 181 execute_process(COMMAND ${KDECONFIG_EXECUTABLE} --version 182 OUTPUT_VARIABLE kde_config_version ) 183 184 string(REGEX MATCH "KDE: .\\." kde_version "${kde_config_version}") 185 if ("${kde_version}" MATCHES "KDE: 3\\.") 186 execute_process(COMMAND ${KDECONFIG_EXECUTABLE} --prefix 187 OUTPUT_VARIABLE kdedir ) 188 string(REPLACE "\n" "" KDE3PREFIX "${kdedir}") 189 190 endif () 191endif() 192 193 194 195# at first the KDE include directory 196# kpassdlg.h comes from kdeui and doesn't exist in KDE4 anymore 197find_path(KDE3_INCLUDE_DIR kpassdlg.h 198 HINTS 199 $ENV{KDEDIR}/include 200 ${KDE3PREFIX}/include 201 PATHS 202 /opt/kde3/include 203 /opt/kde/include 204 PATH_SUFFIXES include/kde 205 ) 206 207#now the KDE library directory 208find_library(KDE3_KDECORE_LIBRARY NAMES kdecore 209 HINTS 210 $ENV{KDEDIR}/lib 211 ${KDE3PREFIX}/lib 212 PATHS 213 /opt/kde3/lib 214 /opt/kde/lib 215) 216 217set(QT_AND_KDECORE_LIBS ${QT_LIBRARIES} ${KDE3_KDECORE_LIBRARY}) 218 219get_filename_component(KDE3_LIB_DIR ${KDE3_KDECORE_LIBRARY} PATH ) 220 221if(NOT KDE3_LIBTOOL_DIR) 222 if(KDE3_KDECORE_LIBRARY MATCHES lib64) 223 set(KDE3_LIBTOOL_DIR /lib64/kde3) 224 elseif(KDE3_KDECORE_LIBRARY MATCHES libx32) 225 set(KDE3_LIBTOOL_DIR /libx32/kde3) 226 else() 227 set(KDE3_LIBTOOL_DIR /lib/kde3) 228 endif() 229endif() 230 231#now search for the dcop utilities 232find_program(KDE3_DCOPIDL_EXECUTABLE NAMES dcopidl 233 HINTS 234 $ENV{KDEDIR}/bin 235 ${KDE3PREFIX}/bin 236 PATHS 237 /opt/kde3/bin 238 /opt/kde/bin 239 ) 240 241find_program(KDE3_DCOPIDL2CPP_EXECUTABLE NAMES dcopidl2cpp 242 HINTS 243 $ENV{KDEDIR}/bin 244 ${KDE3PREFIX}/bin 245 PATHS 246 /opt/kde3/bin 247 /opt/kde/bin 248 ) 249 250find_program(KDE3_KCFGC_EXECUTABLE NAMES kconfig_compiler 251 HINTS 252 $ENV{KDEDIR}/bin 253 ${KDE3PREFIX}/bin 254 PATHS 255 /opt/kde3/bin 256 /opt/kde/bin 257 ) 258 259 260#SET KDE3_FOUND 261if (KDE3_INCLUDE_DIR AND KDE3_LIB_DIR AND KDE3_DCOPIDL_EXECUTABLE AND KDE3_DCOPIDL2CPP_EXECUTABLE AND KDE3_KCFGC_EXECUTABLE) 262 set(KDE3_FOUND TRUE) 263else () 264 set(KDE3_FOUND FALSE) 265endif () 266 267# add some KDE specific stuff 268set(KDE3_DEFINITIONS -DQT_CLEAN_NAMESPACE -D_GNU_SOURCE) 269 270# set compiler flags only if KDE3 has actually been found 271if(KDE3_FOUND) 272 set(_KDE3_USE_FLAGS FALSE) 273 if(CMAKE_COMPILER_IS_GNUCXX) 274 set(_KDE3_USE_FLAGS TRUE) # use flags for gnu compiler 275 execute_process(COMMAND ${CMAKE_CXX_COMPILER} --version 276 OUTPUT_VARIABLE out) 277 # gnu gcc 2.96 does not work with flags 278 # I guess 2.95 also doesn't then 279 if("${out}" MATCHES "2.9[56]") 280 set(_KDE3_USE_FLAGS FALSE) 281 endif() 282 endif() 283 284 #only on linux, but NOT e.g. on FreeBSD: 285 if(CMAKE_SYSTEM_NAME MATCHES "Linux" AND _KDE3_USE_FLAGS) 286 set (KDE3_DEFINITIONS ${KDE3_DEFINITIONS} -D_XOPEN_SOURCE=500 -D_BSD_SOURCE) 287 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") 288 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") 289 endif() 290 291 # works on FreeBSD, NOT tested on NetBSD and OpenBSD 292 if (CMAKE_SYSTEM_NAME MATCHES BSD AND _KDE3_USE_FLAGS) 293 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") 294 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") 295 endif () 296 297 # if no special buildtype is selected, add -O2 as default optimization 298 if (NOT CMAKE_BUILD_TYPE AND _KDE3_USE_FLAGS) 299 set ( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O2") 300 set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O2") 301 endif () 302 303#set(CMAKE_SHARED_LINKER_FLAGS "-avoid-version -module -Wl,--no-undefined -Wl,--allow-shlib-undefined") 304#set(CMAKE_SHARED_LINKER_FLAGS "-Wl,--fatal-warnings -avoid-version -Wl,--no-undefined -lc") 305#set(CMAKE_MODULE_LINKER_FLAGS "-Wl,--fatal-warnings -avoid-version -Wl,--no-undefined -lc") 306endif() 307 308 309# KDE3Macros.cmake contains all the KDE specific macros 310include(${CMAKE_CURRENT_LIST_DIR}/KDE3Macros.cmake) 311 312 313macro (KDE3_PRINT_RESULTS) 314 if(KDE3_INCLUDE_DIR) 315 message(STATUS "Found KDE3 include dir: ${KDE3_INCLUDE_DIR}") 316 else() 317 message(STATUS "Didn't find KDE3 headers") 318 endif() 319 320 if(KDE3_LIB_DIR) 321 message(STATUS "Found KDE3 library dir: ${KDE3_LIB_DIR}") 322 else() 323 message(STATUS "Didn't find KDE3 core library") 324 endif() 325 326 if(KDE3_DCOPIDL_EXECUTABLE) 327 message(STATUS "Found KDE3 dcopidl preprocessor: ${KDE3_DCOPIDL_EXECUTABLE}") 328 else() 329 message(STATUS "Didn't find the KDE3 dcopidl preprocessor") 330 endif() 331 332 if(KDE3_DCOPIDL2CPP_EXECUTABLE) 333 message(STATUS "Found KDE3 dcopidl2cpp preprocessor: ${KDE3_DCOPIDL2CPP_EXECUTABLE}") 334 else() 335 message(STATUS "Didn't find the KDE3 dcopidl2cpp preprocessor") 336 endif() 337 338 if(KDE3_KCFGC_EXECUTABLE) 339 message(STATUS "Found KDE3 kconfig_compiler preprocessor: ${KDE3_KCFGC_EXECUTABLE}") 340 else() 341 message(STATUS "Didn't find the KDE3 kconfig_compiler preprocessor") 342 endif() 343 344endmacro () 345 346 347if (KDE3_FIND_REQUIRED AND NOT KDE3_FOUND) 348 #bail out if something wasn't found 349 KDE3_PRINT_RESULTS() 350 message(FATAL_ERROR "Could NOT find everything required for compiling KDE 3 programs") 351 352endif () 353 354 355if (NOT KDE3_FIND_QUIETLY) 356 KDE3_PRINT_RESULTS() 357endif () 358 359#add the found Qt and KDE include directories to the current include path 360set(KDE3_INCLUDE_DIRS ${QT_INCLUDE_DIR} ${KDE3_INCLUDE_DIR}) 361