1 # Locate KDE include paths and libraries
9 #the macro ADD_DCOP_SOURCES(src_headers dest_srcs)
12 #SET(MY_APP_SOURCES main.cpp kfoo.cpp)
13 #SET(MY_DCOP_SOURCES kfooiface.h)
14 #ADD_DCOP_SOURCES(MY_DCOP_SOURCES MY_APP_SOURCES)
15 #and then it should work :-)
19 CMAKE_MINIMUM_REQUIRED(VERSION 2.0.0)
21 FIND_PATH(KDE_INCLUDE_DIR kurl.h
28 /usr/local/include/kde
32 MESSAGE(STATUS "Found KDE header files in ${KDE_INCLUDE_DIR}")
34 MESSAGE(FATAL_ERROR "Didn't find KDE headers")
35 ENDIF(KDE_INCLUDE_DIR)
37 FIND_PROGRAM(KDE_CONFIG NAME kde-config PATHS
43 MESSAGE(FATAL_ERROR "Didn't find the kde-config utility")
46 FIND_PATH(KDE_LIB_DIR libkdecore.so
53 MESSAGE(STATUS "Found KDE libraries in ${KDE_LIB_DIR}")
55 MESSAGE(FATAL_ERROR "Didn't find KDE core library")
59 #extract the version from kdeversion.h
61 FILE(READ ${KDE_INCLUDE_DIR}/kdeversion.h KDE_VERSION_H)
63 STRING(REGEX REPLACE ".*#define[\\t\\ ]+KDE_VERSION_STRING[\\t\\ ]+\"([0-9]+\\.[0-9]+\\.[0-9]+)\".*" "\\1" KDE_VERSION "${KDE_VERSION_H}")
64 STRING(REGEX REPLACE ".*#define[\\t\\ ]+KDE_VERSION_MAJOR[\\t\\ ]+([0-9]+).*" "\\1" kde_major_vers "${KDE_VERSION_H}")
65 STRING(REGEX REPLACE ".*#define[\\t\\ ]+KDE_VERSION_MINOR[\\t\\ ]+([0-9]+).*" "\\1" kde_minor_vers "${KDE_VERSION_H}")
66 STRING(REGEX REPLACE ".*#define[\\t\\ ]+KDE_VERSION_RELEASE[\\t\\ ]+([0-9]+).*" "\\1" kde_vers_release "${KDE_VERSION_H}")
68 #now parse the parts of the user given version string into variables
69 STRING(REGEX MATCH "^[0-9]+\\.[0-9]+\\.[0-9]+$" req_kde_major_vers "${KDE_MIN_VERSION}")
70 IF (NOT req_kde_major_vers)
71 MESSAGE( FATAL_ERROR "Invalid KDE version string given: \"${KDE_MIN_VERSION}\", expected e.g. \"3.1.5\"")
72 ENDIF (NOT req_kde_major_vers)
74 STRING(REGEX REPLACE "([0-9]+)\\.[0-9]+\\.[0-9]+" "\\1" req_kde_major_vers "${KDE_MIN_VERSION}")
75 STRING(REGEX REPLACE "[0-9]+\\.([0-9])+\\.[0-9]+" "\\1" req_kde_minor_vers "${KDE_MIN_VERSION}")
76 STRING(REGEX REPLACE "[0-9]+\\.[0-9]+\\.([0-9]+)" "\\1" req_kde_patch_vers "${KDE_MIN_VERSION}")
78 # req = "6.5.4", qt = "3.2.1"
80 IF (req_kde_major_vers GREATER kde_major_vers) # (6 > 3) ?
81 MESSAGE( FATAL_ERROR "KDE major version not matched (required: ${KDE_MIN_VERSION}, found: ${KDE_VERSION})") # yes
82 ELSE (req_kde_major_vers GREATER kde_major_vers) # no
83 IF (req_kde_major_vers LESS kde_major_vers) # (6 < 3) ?
84 SET( QT_VERSION_BIG_ENOUGH "YES" ) # yes
85 ELSE (req_kde_major_vers LESS kde_major_vers) # ( 6==3) ?
86 IF (req_kde_minor_vers GREATER kde_minor_vers) # (5>2) ?
87 MESSAGE( FATAL_ERROR "KDE minor version not matched (required: ${KDE_MIN_VERSION}, found: ${KDE_VERSION})") # yes
88 ELSE (req_kde_minor_vers GREATER kde_minor_vers) # no
89 IF (req_kde_minor_vers LESS kde_minor_vers) # (5<2) ?
90 SET( QT_VERSION_BIG_ENOUGH "YES" ) # yes
91 ELSE (req_kde_minor_vers LESS kde_minor_vers) # (5==2)
92 IF (req_kde_patch_vers GREATER kde_vers_release) # (4>1) ?
93 MESSAGE( FATAL_ERROR "KDE release version not matched (required: ${KDE_MIN_VERSION}, found: ${KDE_VERSION})") # yes
94 ELSE (req_kde_patch_vers GREATER kde_patch_vers) # (4>1) ?
95 SET( QT_VERSION_BIG_ENOUGH "YES" ) # yes
96 ENDIF (req_kde_patch_vers GREATER kde_vers_release) # (4>1) ?
97 ENDIF (req_kde_minor_vers LESS kde_minor_vers)
98 ENDIF (req_kde_minor_vers GREATER kde_minor_vers)
99 ENDIF (req_kde_major_vers LESS kde_major_vers)
100 ENDIF (req_kde_major_vers GREATER kde_major_vers)
101 MESSAGE(STATUS "KDE version ok (required: ${KDE_MIN_VERSION}, found: ${KDE_VERSION})")
102 ENDIF (KDE_MIN_VERSION)
104 #now search for the dcop utilities
105 FIND_PROGRAM(KDE_DCOPIDL NAME dcopidl PATHS
111 MESSAGE(FATAL_ERROR "Didn't find the dcopidl preprocessor")
112 ENDIF(NOT KDE_DCOPIDL)
114 FIND_PROGRAM(KDE_DCOPIDL2CPP NAME dcopidl2cpp PATHS
119 IF(NOT KDE_DCOPIDL2CPP)
120 MESSAGE(FATAL_ERROR "Didn't find the dcopidl2cpp preprocessor")
121 ENDIF(NOT KDE_DCOPIDL2CPP)
123 MACRO(DCOP_WRAP SKEL_SOURCES)
124 FOREACH(dcop_source ${ARGN})
126 GET_FILENAME_COMPONENT(dcop_source_basename ${dcop_source} NAME_WE)
128 SET(idl_file ${CMAKE_BINARY_DIR}/${dcop_source_basename}.kidl)
129 SET(skel_file ${CMAKE_BINARY_DIR}/${dcop_source_basename}_skel.cpp)
133 COMMAND ${KDE_DCOPIDL}
134 ARGS ${CMAKE_SOURCE_DIR}/${dcop_source} > ${idl_file}
135 DEPENDS ${CMAKE_SOURCE_DIR}/${dcop_source})
139 COMMAND ${KDE_DCOPIDL2CPP}
140 ARGS --c++-suffix cpp --no-signals --no-stub ${idl_file}
143 SET( SKEL_SOURCES ${${SKEL_SOURCES}}
145 ENDFOREACH(dcop_source)