3 # See FindKDE3.cmake for documentation.
5 # this file contains the following macros:
12 # KDE3_INSTALL_LIBTOOL_FILE
13 # KDE3_CREATE_FINAL_FILE
15 # KDE3_ADD_KDEINIT_EXECUTABLE
21 INCLUDE(AddFileDependencies)
23 #create the kidl and skeletion file for dcop stuff
24 #usage: KDE_ADD_COP_SKELS(foo_SRCS ${dcop_headers})
25 MACRO(KDE3_ADD_DCOP_SKELS _sources)
26 FOREACH (_current_FILE ${ARGN})
28 GET_FILENAME_COMPONENT(_tmp_FILE ${_current_FILE} ABSOLUTE)
29 GET_FILENAME_COMPONENT(_basename ${_tmp_FILE} NAME_WE)
31 SET(_skel ${CMAKE_CURRENT_BINARY_DIR}/${_basename}_skel.cpp)
32 SET(_kidl ${CMAKE_CURRENT_BINARY_DIR}/${_basename}.kidl)
34 IF (NOT HAVE_${_basename}_KIDL_RULE)
35 SET(HAVE_${_basename}_KIDL_RULE ON)
37 ADD_CUSTOM_COMMAND(OUTPUT ${_kidl}
38 COMMAND ${KDE3_DCOPIDL_EXECUTABLE}
39 ARGS ${_tmp_FILE} > ${_kidl}
43 ENDIF (NOT HAVE_${_basename}_KIDL_RULE)
45 IF (NOT HAVE_${_basename}_SKEL_RULE)
46 SET(HAVE_${_basename}_SKEL_RULE ON)
48 ADD_CUSTOM_COMMAND(OUTPUT ${_skel}
49 COMMAND ${KDE3_DCOPIDL2CPP_EXECUTABLE}
50 ARGS --c++-suffix cpp --no-signals --no-stub ${_kidl}
54 ENDIF (NOT HAVE_${_basename}_SKEL_RULE)
56 SET(${_sources} ${${_sources}} ${_skel})
58 ENDFOREACH (_current_FILE)
60 ENDMACRO(KDE3_ADD_DCOP_SKELS)
63 MACRO(KDE3_ADD_DCOP_STUBS _sources)
64 FOREACH (_current_FILE ${ARGN})
66 GET_FILENAME_COMPONENT(_tmp_FILE ${_current_FILE} ABSOLUTE)
68 GET_FILENAME_COMPONENT(_basename ${_tmp_FILE} NAME_WE)
70 SET(_stub_CPP ${CMAKE_CURRENT_BINARY_DIR}/${_basename}_stub.cpp)
71 SET(_kidl ${CMAKE_CURRENT_BINARY_DIR}/${_basename}.kidl)
73 IF (NOT HAVE_${_basename}_KIDL_RULE)
74 SET(HAVE_${_basename}_KIDL_RULE ON)
77 ADD_CUSTOM_COMMAND(OUTPUT ${_kidl}
78 COMMAND ${KDE3_DCOPIDL_EXECUTABLE}
79 ARGS ${_tmp_FILE} > ${_kidl}
83 ENDIF (NOT HAVE_${_basename}_KIDL_RULE)
86 IF (NOT HAVE_${_basename}_STUB_RULE)
87 SET(HAVE_${_basename}_STUB_RULE ON)
89 ADD_CUSTOM_COMMAND(OUTPUT ${_stub_CPP}
90 COMMAND ${KDE3_DCOPIDL2CPP_EXECUTABLE}
91 ARGS --c++-suffix cpp --no-signals --no-skel ${_kidl}
95 ENDIF (NOT HAVE_${_basename}_STUB_RULE)
97 SET(${_sources} ${${_sources}} ${_stub_CPP})
99 ENDFOREACH (_current_FILE)
101 ENDMACRO(KDE3_ADD_DCOP_STUBS)
104 MACRO(KDE3_ADD_KCFG_FILES _sources)
105 FOREACH (_current_FILE ${ARGN})
107 GET_FILENAME_COMPONENT(_tmp_FILE ${_current_FILE} ABSOLUTE)
109 GET_FILENAME_COMPONENT(_basename ${_tmp_FILE} NAME_WE)
111 FILE(READ ${_tmp_FILE} _contents)
112 STRING(REGEX REPLACE "^(.*\n)?File=([^\n]+)\n.*$" "\\2" _kcfg_FILE "${_contents}")
114 SET(_src_FILE ${CMAKE_CURRENT_BINARY_DIR}/${_basename}.cpp)
115 SET(_header_FILE ${CMAKE_CURRENT_BINARY_DIR}/${_basename}.h)
117 ADD_CUSTOM_COMMAND(OUTPUT ${_src_FILE}
118 COMMAND ${KDE3_KCFGC_EXECUTABLE}
119 ARGS ${CMAKE_CURRENT_SOURCE_DIR}/${_kcfg_FILE} ${_tmp_FILE}
120 DEPENDS ${_tmp_FILE} ${CMAKE_CURRENT_SOURCE_DIR}/${_kcfg_FILE} )
122 SET(${_sources} ${${_sources}} ${_src_FILE})
124 ENDFOREACH (_current_FILE)
126 ENDMACRO(KDE3_ADD_KCFG_FILES)
129 #create the moc files and add them to the list of sources
130 #usage: KDE_ADD_MOC_FILES(foo_SRCS ${moc_headers})
131 MACRO(KDE3_ADD_MOC_FILES _sources)
132 FOREACH (_current_FILE ${ARGN})
134 GET_FILENAME_COMPONENT(_tmp_FILE ${_current_FILE} ABSOLUTE)
136 GET_FILENAME_COMPONENT(_basename ${_tmp_FILE} NAME_WE)
137 SET(_moc ${CMAKE_CURRENT_BINARY_DIR}/${_basename}.moc.cpp)
139 ADD_CUSTOM_COMMAND(OUTPUT ${_moc}
140 COMMAND ${QT_MOC_EXECUTABLE}
141 ARGS ${_tmp_FILE} -o ${_moc}
145 SET(${_sources} ${${_sources}} ${_moc})
147 ENDFOREACH (_current_FILE)
148 ENDMACRO(KDE3_ADD_MOC_FILES)
151 GET_FILENAME_COMPONENT( KDE3_MODULE_DIR ${CMAKE_CURRENT_LIST_FILE} PATH)
153 #create the implementation files from the ui files and add them to the list of sources
154 #usage: KDE_ADD_UI_FILES(foo_SRCS ${ui_files})
155 MACRO(KDE3_ADD_UI_FILES _sources )
156 FOREACH (_current_FILE ${ARGN})
158 GET_FILENAME_COMPONENT(_tmp_FILE ${_current_FILE} ABSOLUTE)
160 GET_FILENAME_COMPONENT(_basename ${_tmp_FILE} NAME_WE)
161 SET(_header ${CMAKE_CURRENT_BINARY_DIR}/${_basename}.h)
162 SET(_src ${CMAKE_CURRENT_BINARY_DIR}/${_basename}.cpp)
163 SET(_moc ${CMAKE_CURRENT_BINARY_DIR}/${_basename}.moc.cpp)
165 ADD_CUSTOM_COMMAND(OUTPUT ${_header}
166 COMMAND ${QT_UIC_EXECUTABLE}
167 ARGS -L ${KDE3_LIB_DIR}/kde3/plugins/designer -nounload -o ${_header} ${CMAKE_CURRENT_SOURCE_DIR}/${_current_FILE}
171 ADD_CUSTOM_COMMAND(OUTPUT ${_src}
172 COMMAND ${CMAKE_COMMAND}
174 -DKDE_UIC_PLUGIN_DIR:FILEPATH=${KDE3_LIB_DIR}/kde3/plugins/designer
175 -DKDE_UIC_EXECUTABLE:FILEPATH=${QT_UIC_EXECUTABLE}
176 -DKDE_UIC_FILE:FILEPATH=${_tmp_FILE}
177 -DKDE_UIC_CPP_FILE:FILEPATH=${_src}
178 -DKDE_UIC_H_FILE:FILEPATH=${_header}
179 -P ${KDE3_MODULE_DIR}/kde3uic.cmake
183 ADD_CUSTOM_COMMAND(OUTPUT ${_moc}
184 COMMAND ${QT_MOC_EXECUTABLE}
185 ARGS ${_header} -o ${_moc}
189 SET(${_sources} ${${_sources}} ${_src} ${_moc} )
191 ENDFOREACH (_current_FILE)
192 ENDMACRO(KDE3_ADD_UI_FILES)
196 SET(_matching_FILES )
197 FOREACH (_current_FILE ${ARGN})
199 GET_FILENAME_COMPONENT(_abs_FILE ${_current_FILE} ABSOLUTE)
201 # if "SKIP_AUTOMOC" is set to true, we will not handle this file here.
202 # here. this is required to make bouic work correctly:
203 # we need to add generated .cpp files to the sources (to compile them),
204 # but we cannot let automoc handle them, as the .cpp files don't exist yet when
205 # cmake is run for the very first time on them -> however the .cpp files might
206 # exist at a later run. at that time we need to skip them, so that we don't add two
207 # different rules for the same moc file
208 GET_SOURCE_FILE_PROPERTY(_skip ${_abs_FILE} SKIP_AUTOMOC)
210 IF (EXISTS ${_abs_FILE} AND NOT _skip)
212 FILE(READ ${_abs_FILE} _contents)
214 GET_FILENAME_COMPONENT(_abs_PATH ${_abs_FILE} PATH)
216 STRING(REGEX MATCHALL "#include +[^ ]+\\.moc[\">]" _match "${_contents}")
218 FOREACH (_current_MOC_INC ${_match})
219 STRING(REGEX MATCH "[^ <\"]+\\.moc" _current_MOC "${_current_MOC_INC}")
221 GET_FILENAME_COMPONENT(_basename ${_current_MOC} NAME_WE)
222 # SET(_header ${CMAKE_CURRENT_SOURCE_DIR}/${_basename}.h)
223 SET(_header ${_abs_PATH}/${_basename}.h)
224 SET(_moc ${CMAKE_CURRENT_BINARY_DIR}/${_current_MOC})
226 ADD_CUSTOM_COMMAND(OUTPUT ${_moc}
227 COMMAND ${QT_MOC_EXECUTABLE}
228 ARGS ${_header} -o ${_moc}
232 ADD_FILE_DEPENDENCIES(${_abs_FILE} ${_moc})
234 ENDFOREACH (_current_MOC_INC)
237 ENDIF (EXISTS ${_abs_FILE} AND NOT _skip)
238 ENDFOREACH (_current_FILE)
239 ENDMACRO(KDE3_AUTOMOC)
241 # only used internally by KDE3_INSTALL_ICONS
242 MACRO (_KDE3_ADD_ICON_INSTALL_RULE _install_SCRIPT _install_PATH _group _orig_NAME _install_NAME)
244 # if the string doesn't match the pattern, the result is the full string, so all three have the same content
245 IF (NOT ${_group} STREQUAL ${_install_NAME} )
246 SET(_icon_GROUP "actions")
248 IF (${_group} STREQUAL "mime")
249 SET(_icon_GROUP "mimetypes")
250 ENDIF (${_group} STREQUAL "mime")
252 IF (${_group} STREQUAL "filesys")
253 SET(_icon_GROUP "filesystems")
254 ENDIF (${_group} STREQUAL "filesys")
256 IF (${_group} STREQUAL "device")
257 SET(_icon_GROUP "devices")
258 ENDIF (${_group} STREQUAL "device")
260 IF (${_group} STREQUAL "app")
261 SET(_icon_GROUP "apps")
262 ENDIF (${_group} STREQUAL "app")
264 IF (${_group} STREQUAL "action")
265 SET(_icon_GROUP "actions")
266 ENDIF (${_group} STREQUAL "action")
268 # message(STATUS "icon: ${_current_ICON} size: ${_size} group: ${_group} name: ${_name}" )
269 INSTALL(FILES ${_orig_NAME} DESTINATION ${_install_PATH}/${_icon_GROUP}/ RENAME ${_install_NAME} )
270 ENDIF (NOT ${_group} STREQUAL ${_install_NAME} )
272 ENDMACRO (_KDE3_ADD_ICON_INSTALL_RULE)
275 MACRO (KDE3_INSTALL_ICONS _theme )
276 SET(_defaultpath "${CMAKE_INSTALL_PREFIX}/share/icons")
277 # first the png icons
278 FILE(GLOB _icons *.png)
279 FOREACH (_current_ICON ${_icons} )
280 STRING(REGEX REPLACE "^.*/[a-zA-Z]+([0-9]+)\\-([a-z]+)\\-(.+\\.png)$" "\\1" _size "${_current_ICON}")
281 STRING(REGEX REPLACE "^.*/[a-zA-Z]+([0-9]+)\\-([a-z]+)\\-(.+\\.png)$" "\\2" _group "${_current_ICON}")
282 STRING(REGEX REPLACE "^.*/[a-zA-Z]+([0-9]+)\\-([a-z]+)\\-(.+\\.png)$" "\\3" _name "${_current_ICON}")
283 _KDE3_ADD_ICON_INSTALL_RULE(${CMAKE_CURRENT_BINARY_DIR}/install_icons.cmake
284 ${_defaultpath}/${_theme}/${_size}x${_size}
285 ${_group} ${_current_ICON} ${_name})
286 ENDFOREACH (_current_ICON)
288 # and now the svg icons
289 FILE(GLOB _icons *.svgz)
290 FOREACH (_current_ICON ${_icons} )
291 STRING(REGEX REPLACE "^.*/crsc\\-([a-z]+)\\-(.+\\.svgz)$" "\\1" _group "${_current_ICON}")
292 STRING(REGEX REPLACE "^.*/crsc\\-([a-z]+)\\-(.+\\.svgz)$" "\\2" _name "${_current_ICON}")
293 _KDE3_ADD_ICON_INSTALL_RULE(${CMAKE_CURRENT_BINARY_DIR}/install_icons.cmake
294 ${_defaultpath}/${_theme}/scalable
295 ${_group} ${_current_ICON} ${_name})
296 ENDFOREACH (_current_ICON)
298 ENDMACRO (KDE3_INSTALL_ICONS)
300 MACRO(KDE3_INSTALL_LIBTOOL_FILE _target)
301 GET_TARGET_PROPERTY(_target_location ${_target} LOCATION)
303 GET_FILENAME_COMPONENT(_laname ${_target_location} NAME_WE)
304 GET_FILENAME_COMPONENT(_soname ${_target_location} NAME)
305 SET(_laname ${CMAKE_CURRENT_BINARY_DIR}/${_laname}.la)
307 FILE(WRITE ${_laname} "# ${_laname} - a libtool library file, generated by cmake \n")
308 FILE(APPEND ${_laname} "# The name that we can dlopen(3).\n")
309 FILE(APPEND ${_laname} "dlname='${_soname}'\n")
310 FILE(APPEND ${_laname} "# Names of this library\n")
311 FILE(APPEND ${_laname} "library_names='${_soname} ${_soname} ${_soname}'\n")
312 FILE(APPEND ${_laname} "# The name of the static archive\n")
313 FILE(APPEND ${_laname} "old_library=''\n")
314 FILE(APPEND ${_laname} "# Libraries that this one depends upon.\n")
315 FILE(APPEND ${_laname} "dependency_libs=''\n")
316 # FILE(APPEND ${_laname} "dependency_libs='${${_target}_LIB_DEPENDS}'\n")
317 FILE(APPEND ${_laname} "# Version information.\ncurrent=0\nage=0\nrevision=0\n")
318 FILE(APPEND ${_laname} "# Is this an already installed library?\ninstalled=yes\n")
319 FILE(APPEND ${_laname} "# Should we warn about portability when linking against -modules?\nshouldnotlink=yes\n")
320 FILE(APPEND ${_laname} "# Files to dlopen/dlpreopen\ndlopen=''\ndlpreopen=''\n")
321 FILE(APPEND ${_laname} "# Directory that this library needs to be installed in:\n")
322 FILE(APPEND ${_laname} "libdir='${CMAKE_INSTALL_PREFIX}/lib/kde3'\n")
324 INSTALL_FILES(${KDE3_LIBTOOL_DIR} FILES ${_laname})
325 ENDMACRO(KDE3_INSTALL_LIBTOOL_FILE)
328 MACRO(KDE3_CREATE_FINAL_FILE _filename)
329 FILE(WRITE ${_filename} "//autogenerated file\n")
330 FOREACH (_current_FILE ${ARGN})
331 FILE(APPEND ${_filename} "#include \"${_current_FILE}\"\n")
332 ENDFOREACH (_current_FILE)
334 ENDMACRO(KDE3_CREATE_FINAL_FILE)
337 # OPTION(KDE3_ENABLE_FINAL "Enable final all-in-one compilation")
338 OPTION(KDE3_BUILD_TESTS "Build the tests")
341 MACRO(KDE3_ADD_KPART _target_NAME _with_PREFIX)
342 #is the first argument is "WITH_PREFIX" then keep the standard "lib" prefix, otherwise SET the prefix empty
343 IF (${_with_PREFIX} STREQUAL "WITH_PREFIX")
345 ELSE (${_with_PREFIX} STREQUAL "WITH_PREFIX")
346 SET(_first_SRC ${_with_PREFIX})
347 ENDIF (${_with_PREFIX} STREQUAL "WITH_PREFIX")
349 # IF (KDE3_ENABLE_FINAL)
350 # KDE3_CREATE_FINAL_FILE(${_target_NAME}_final.cpp ${_first_SRC} ${ARGN})
351 # ADD_LIBRARY(${_target_NAME} MODULE ${_target_NAME}_final.cpp)
352 # ELSE (KDE3_ENABLE_FINAL)
353 ADD_LIBRARY(${_target_NAME} MODULE ${_first_SRC} ${ARGN})
354 # ENDIF (KDE3_ENABLE_FINAL)
357 SET_TARGET_PROPERTIES(${_target_NAME} PROPERTIES PREFIX "")
360 KDE3_INSTALL_LIBTOOL_FILE(${_target_NAME})
362 ENDMACRO(KDE3_ADD_KPART)
365 MACRO(KDE3_ADD_KDEINIT_EXECUTABLE _target_NAME )
367 # IF (KDE3_ENABLE_FINAL)
368 # KDE3_CREATE_FINAL_FILE(${_target_NAME}_final.cpp ${ARGN})
369 # ADD_LIBRARY(kdeinit_${_target_NAME} SHARED ${_target_NAME}_final.cpp)
370 # ELSE (KDE3_ENABLE_FINAL)
371 ADD_LIBRARY(kdeinit_${_target_NAME} SHARED ${ARGN} )
372 # ENDIF (KDE3_ENABLE_FINAL)
374 CONFIGURE_FILE(${KDE3_MODULE_DIR}/kde3init_dummy.cpp.in ${CMAKE_CURRENT_BINARY_DIR}/${_target_NAME}_dummy.cpp)
376 ADD_EXECUTABLE( ${_target_NAME} ${CMAKE_CURRENT_BINARY_DIR}/${_target_NAME}_dummy.cpp )
377 TARGET_LINK_LIBRARIES( ${_target_NAME} kdeinit_${_target_NAME} )
379 ENDMACRO(KDE3_ADD_KDEINIT_EXECUTABLE)
382 MACRO(KDE3_ADD_EXECUTABLE _target_NAME )
384 # IF (KDE3_ENABLE_FINAL)
385 # KDE3_CREATE_FINAL_FILE(${_target_NAME}_final.cpp ${ARGN})
386 # ADD_EXECUTABLE(${_target_NAME} ${_target_NAME}_final.cpp)
387 # ELSE (KDE3_ENABLE_FINAL)
388 ADD_EXECUTABLE(${_target_NAME} ${ARGN} )
389 # ENDIF (KDE3_ENABLE_FINAL)
391 ENDMACRO(KDE3_ADD_EXECUTABLE)