2014-11-13 01:04:59 +02:00
# for documentation look at FindKDE4Internal.cmake
# this file contains the following macros (or functions):
# KDE4_ADD_KCFG_FILES
# KDE4_ADD_PLUGIN
2015-09-01 01:05:33 +03:00
# KDE4_ADD_TEST
2014-11-13 01:04:59 +02:00
# KDE4_ADD_WIDGET_FILES
# KDE4_INSTALL_ICONS
# KDE4_CREATE_MANPAGE
# KDE4_INSTALL_AUTH_HELPER_FILES
# KDE4_AUTH_INSTALL_ACTIONS
# Copyright (c) 2006-2009 Alexander Neundorf, <neundorf@kde.org>
# Copyright (c) 2006, 2007, Laurent Montel, <montel@kde.org>
# Copyright (c) 2007 Matthias Kretz <kretz@kde.org>
#
# Redistribution and use is allowed according to the terms of the BSD license.
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
macro ( KDE4_ADD_KCFG_FILES _sources )
foreach ( _current_ARG ${ ARGN } )
2015-07-08 04:24:17 +03:00
if ( ${ _current_ARG } STREQUAL "GENERATE_MOC" )
set ( _kcfg_generatemoc TRUE )
endif ( ${ _current_ARG } STREQUAL "GENERATE_MOC" )
2014-11-13 01:04:59 +02:00
if ( ${ _current_ARG } STREQUAL "USE_RELATIVE_PATH" )
set ( _kcfg_relativepath TRUE )
endif ( ${ _current_ARG } STREQUAL "USE_RELATIVE_PATH" )
endforeach ( _current_ARG ${ ARGN } )
foreach ( _current_FILE ${ ARGN } )
if ( NOT ${ _current_FILE } STREQUAL "GENERATE_MOC" AND NOT ${ _current_FILE } STREQUAL "USE_RELATIVE_PATH" )
get_filename_component ( _tmp_FILE ${ _current_FILE } ABSOLUTE )
2015-09-01 01:05:33 +03:00
get_filename_component ( _abs_PATH ${ _tmp_FILE } DIRECTORY )
2014-11-13 01:04:59 +02:00
if ( _kcfg_relativepath ) # Process relative path only if the option was set
# Get relative path
2015-09-01 01:05:33 +03:00
get_filename_component ( _rel_PATH ${ _current_FILE } DIRECTORY )
2014-11-13 01:04:59 +02:00
if ( IS_ABSOLUTE ${ _rel_PATH } )
# We got an absolute path
set ( _rel_PATH "" )
endif ( IS_ABSOLUTE ${ _rel_PATH } )
endif ( _kcfg_relativepath )
get_filename_component ( _basename ${ _tmp_FILE } NAME_WE )
# If we had a relative path and we're asked to use it, then change the basename accordingly
if ( NOT ${ _rel_PATH } STREQUAL "" )
set ( _basename ${ _rel_PATH } / ${ _basename } )
endif ( NOT ${ _rel_PATH } STREQUAL "" )
file ( READ ${ _tmp_FILE } _contents )
string ( REGEX REPLACE "^(.*\n)?File=([^\n]+kcfg).*\n.*$" "\\2" _kcfg_FILENAME "${_contents}" )
set ( _src_FILE ${ CMAKE_CURRENT_BINARY_DIR } / ${ _basename } .cpp )
set ( _header_FILE ${ CMAKE_CURRENT_BINARY_DIR } / ${ _basename } .h )
set ( _moc_FILE ${ CMAKE_CURRENT_BINARY_DIR } / ${ _basename } .moc )
set ( _kcfg_FILE ${ _abs_PATH } / ${ _kcfg_FILENAME } )
# Maybe the .kcfg is a generated file?
if ( NOT EXISTS "${_kcfg_FILE}" )
set ( _kcfg_FILE ${ CMAKE_CURRENT_BINARY_DIR } / ${ _kcfg_FILENAME } )
endif ( NOT EXISTS "${_kcfg_FILE}" )
if ( NOT EXISTS "${_kcfg_FILE}" )
message ( ERROR "${_kcfg_FILENAME} not found; tried in ${_abs_PATH} and ${CMAKE_CURRENT_BINARY_DIR}" )
endif ( NOT EXISTS "${_kcfg_FILE}" )
# make sure the directory exist in the build directory
if ( NOT EXISTS "${CMAKE_CURRENT_BINARY_DIR}/${_rel_PATH}" )
file ( MAKE_DIRECTORY ${ CMAKE_CURRENT_BINARY_DIR } / ${ _rel_PATH } )
endif ( NOT EXISTS "${CMAKE_CURRENT_BINARY_DIR}/${_rel_PATH}" )
# if (CMAKE_CROSSCOMPILING)
# set(IMPORT_KCONFIG_COMPILER_EXECUTABLE "${KDE_HOST_TOOLS_PATH}/ImportKConfigCompilerExecutable.cmake" CACHE FILEPATH "Point it to the export file of kconfig_compiler from a native build")
# include(${IMPORT_KCONFIG_COMPILER_EXECUTABLE})
# set(KDE4_KCFGC_EXECUTABLE kconfig_compiler)
# endif (CMAKE_CROSSCOMPILING)
# the command for creating the source file from the kcfg file
add_custom_command ( OUTPUT ${ _header_FILE } ${ _src_FILE }
C O M M A N D $ { K D E 4 _ K C F G C _ E X E C U T A B L E }
A R G S $ { _ k c f g _ F I L E } $ { _ t m p _ F I L E } - d $ { C M A K E _ C U R R E N T _ B I N A R Y _ D I R } / $ { _ r e l _ P A T H }
M A I N _ D E P E N D E N C Y $ { _ t m p _ F I L E }
2015-09-01 01:05:33 +03:00
D E P E N D S $ { _ k c f g _ F I L E }
)
2014-11-13 01:04:59 +02:00
2015-07-08 04:24:17 +03:00
if ( _kcfg_generatemoc )
qt4_generate_moc ( ${ _header_FILE } ${ _moc_FILE } )
set_source_files_properties ( ${ _src_FILE } PROPERTIES SKIP_AUTOMOC TRUE ) # don't run automoc on this file
list ( APPEND ${ _sources } ${ _moc_FILE } )
endif ( _kcfg_generatemoc )
2014-11-13 01:04:59 +02:00
list ( APPEND ${ _sources } ${ _src_FILE } ${ _header_FILE } )
endif ( NOT ${ _current_FILE } STREQUAL "GENERATE_MOC" AND NOT ${ _current_FILE } STREQUAL "USE_RELATIVE_PATH" )
endforeach ( _current_FILE )
endmacro ( KDE4_ADD_KCFG_FILES )
2015-09-01 01:05:33 +03:00
get_filename_component ( KDE4_MODULE_DIR ${ CMAKE_CURRENT_LIST_FILE } DIRECTORY )
2014-11-13 01:04:59 +02:00
macro ( KDE4_CREATE_MANPAGE _docbook _section )
get_filename_component ( _input ${ _docbook } ABSOLUTE )
get_filename_component ( _base ${ _input } NAME )
string ( REGEX REPLACE "\\.${_section}\\.docbook$" "" _base ${ _base } )
set ( _doc ${ CMAKE_CURRENT_BINARY_DIR } / ${ _base } . ${ _section } )
# sometimes we have "man-" prepended
string ( REGEX REPLACE "/man-" "/" _outdoc ${ _doc } )
add_custom_command ( OUTPUT ${ _outdoc }
2014-12-31 01:25:08 +00:00
C O M M A N D x s l t p r o c $ { _ i n p u t }
D E P E N D S $ { _ i n p u t } x s l t p r o c
2014-11-13 01:04:59 +02:00
)
get_filename_component ( _targ ${ CMAKE_CURRENT_SOURCE_DIR } NAME )
set ( _targ "${_targ}-manpage-${_base}" )
add_custom_target ( ${ _targ } ALL DEPENDS "${_outdoc}" )
set ( _args ${ ARGN } )
set ( _installDest )
if ( _args )
list ( GET _args 0 _tmp )
if ( "${_tmp}" STREQUAL "INSTALL_DESTINATION" )
list ( GET _args 1 _installDest )
list ( REMOVE_AT _args 0 1 )
endif ( "${_tmp}" STREQUAL "INSTALL_DESTINATION" )
endif ( _args )
get_filename_component ( dirname ${ CMAKE_CURRENT_SOURCE_DIR } NAME_WE )
if ( _args )
list ( GET _args 0 _tmp )
if ( "${_tmp}" STREQUAL "SUBDIR" )
list ( GET _args 1 dirname )
list ( REMOVE_AT _args 0 1 )
endif ( "${_tmp}" STREQUAL "SUBDIR" )
endif ( _args )
if ( _installDest )
install ( FILES ${ _outdoc } DESTINATION ${ _installDest } /man ${ _section } )
endif ( _installDest )
endmacro ( KDE4_CREATE_MANPAGE )
# a "map" of short type names to the directories
# unknown names should give empty results
# KDE 3 compatibility
set ( _KDE4_ICON_GROUP_mime "mimetypes" )
set ( _KDE4_ICON_GROUP_filesys "places" )
set ( _KDE4_ICON_GROUP_device "devices" )
set ( _KDE4_ICON_GROUP_app "apps" )
set ( _KDE4_ICON_GROUP_action "actions" )
# KDE 4 / icon naming specification compatibility
set ( _KDE4_ICON_GROUP_mimetypes "mimetypes" )
set ( _KDE4_ICON_GROUP_places "places" )
set ( _KDE4_ICON_GROUP_devices "devices" )
set ( _KDE4_ICON_GROUP_apps "apps" )
set ( _KDE4_ICON_GROUP_actions "actions" )
set ( _KDE4_ICON_GROUP_categories "categories" )
set ( _KDE4_ICON_GROUP_status "status" )
set ( _KDE4_ICON_GROUP_emblems "emblems" )
set ( _KDE4_ICON_GROUP_emotes "emotes" )
set ( _KDE4_ICON_GROUP_animations "animations" )
set ( _KDE4_ICON_GROUP_intl "intl" )
# a "map" of short theme names to the theme directory
2014-11-30 23:10:20 +00:00
set ( _KDE4_ICON_THEME_ox "ariya" )
2014-11-13 01:04:59 +02:00
set ( _KDE4_ICON_THEME_lo "locolor" )
set ( _KDE4_ICON_THEME_hi "hicolor" )
# only used internally by KDE4_INSTALL_ICONS
2015-09-01 01:05:33 +03:00
macro ( _KDE4_ADD_ICON_INSTALL_RULE _install_SCRIPT _install_PATH _group _orig_NAME _install_NAME _l10n_SUBDIR )
# if the string doesn't match the pattern, the result is the full string, so all three have the same content
if ( NOT ${ _group } STREQUAL ${ _install_NAME } )
set ( _icon_GROUP ${ _KDE4_ICON_GROUP_${_group } } )
if ( NOT _icon_GROUP )
set ( _icon_GROUP "actions" )
endif ( )
# message(STATUS "icon: ${_current_ICON} size: ${_size} group: ${_group} name: ${_name} l10n: ${_l10n_SUBDIR}")
install ( FILES ${ _orig_NAME } DESTINATION ${ _install_PATH } / ${ _icon_GROUP } / ${ _l10n_SUBDIR } / RENAME ${ _install_NAME } )
endif ( )
endmacro ( _KDE4_ADD_ICON_INSTALL_RULE )
macro ( KDE4_INSTALL_ICONS _defaultpath )
# the l10n-subdir if language given as second argument (localized icon)
set ( _lang ${ ARGV1 } )
if ( _lang )
set ( _l10n_SUBDIR l10n/ ${ _lang } )
else ( _lang )
set ( _l10n_SUBDIR "." )
endif ( _lang )
# first the png icons
file ( GLOB _icons *.png )
foreach ( _current_ICON ${ _icons } )
# since CMake 2.6 regex matches are stored in special variables CMAKE_MATCH_x, if it didn't match, they are empty
string ( REGEX MATCH "^.*/([a-zA-Z]+)([0-9]+)\\-([a-z]+)\\-(.+\\.png)$" _dummy "${_current_ICON}" )
set ( _type "${CMAKE_MATCH_1}" )
set ( _size "${CMAKE_MATCH_2}" )
set ( _group "${CMAKE_MATCH_3}" )
set ( _name "${CMAKE_MATCH_4}" )
set ( _theme_GROUP ${ _KDE4_ICON_THEME_${_type } } )
if ( _theme_GROUP )
_KDE4_ADD_ICON_INSTALL_RULE (
$ { C M A K E _ C U R R E N T _ B I N A R Y _ D I R } / i n s t a l l _ i c o n s . c m a k e
$ { _ d e f a u l t p a t h } / $ { _ t h e m e _ G R O U P } / $ { _ s i z e } x $ { _ s i z e }
$ { _ g r o u p } $ { _ c u r r e n t _ I C O N } $ { _ n a m e } $ { _ l 1 0 n _ S U B D I R }
)
endif ( _theme_GROUP )
endforeach ( _current_ICON )
# mng icons
file ( GLOB _icons *.mng )
foreach ( _current_ICON ${ _icons } )
# since CMake 2.6 regex matches are stored in special variables CMAKE_MATCH_x, if it didn't match, they are empty
string ( REGEX MATCH "^.*/([a-zA-Z]+)([0-9]+)\\-([a-z]+)\\-(.+\\.mng)$" _dummy "${_current_ICON}" )
set ( _type "${CMAKE_MATCH_1}" )
set ( _size "${CMAKE_MATCH_2}" )
set ( _group "${CMAKE_MATCH_3}" )
set ( _name "${CMAKE_MATCH_4}" )
set ( _theme_GROUP ${ _KDE4_ICON_THEME_${_type } } )
if ( _theme_GROUP )
_KDE4_ADD_ICON_INSTALL_RULE (
$ { C M A K E _ C U R R E N T _ B I N A R Y _ D I R } / i n s t a l l _ i c o n s . c m a k e
2014-11-13 01:04:59 +02:00
$ { _ d e f a u l t p a t h } / $ { _ t h e m e _ G R O U P } / $ { _ s i z e } x $ { _ s i z e }
2015-09-01 01:05:33 +03:00
$ { _ g r o u p } $ { _ c u r r e n t _ I C O N } $ { _ n a m e } $ { _ l 1 0 n _ S U B D I R }
2014-11-13 01:04:59 +02:00
)
2015-09-01 01:05:33 +03:00
endif ( )
endforeach ( )
# and now the svg icons
file ( GLOB _icons *.svgz )
foreach ( _current_ICON ${ _icons } )
# since CMake 2.6 regex matches are stored in special variables CMAKE_MATCH_x, if it didn't match, they are empty
string ( REGEX MATCH "^.*/([a-zA-Z]+)sc\\-([a-z]+)\\-(.+\\.svgz)$" _dummy "${_current_ICON}" )
set ( _type "${CMAKE_MATCH_1}" )
set ( _group "${CMAKE_MATCH_2}" )
set ( _name "${CMAKE_MATCH_3}" )
set ( _theme_GROUP ${ _KDE4_ICON_THEME_${_type } } )
if ( _theme_GROUP )
_KDE4_ADD_ICON_INSTALL_RULE (
$ { C M A K E _ C U R R E N T _ B I N A R Y _ D I R } / i n s t a l l _ i c o n s . c m a k e
$ { _ d e f a u l t p a t h } / $ { _ t h e m e _ G R O U P } / s c a l a b l e
$ { _ g r o u p } $ { _ c u r r e n t _ I C O N } $ { _ n a m e } $ { _ l 1 0 n _ S U B D I R }
2014-11-13 01:04:59 +02:00
)
2015-09-01 01:05:33 +03:00
endif ( )
endforeach ( )
endmacro ( KDE4_INSTALL_ICONS )
# If "WITH_PREFIX" is in the arugments then the standard "lib" prefix will be
# preserved
macro ( KDE4_ADD_PLUGIN _target_NAME )
set ( _plugin_type MODULE )
set ( _plugin_prefix )
set ( _plugin_srcs )
2015-09-01 04:56:26 +03:00
foreach ( arg ${ ARGN } )
2015-09-01 01:05:33 +03:00
if ( arg STREQUAL "STATIC" )
set ( _plugin_type STATIC )
elseif ( arg STREQUAL "SHARED" )
set ( _plugin_type SHARED )
elseif ( arg STREQUAL "WITH_PREFIX" )
set ( _plugin_prefix TRUE )
else ( )
list ( APPEND _plugin_srcs ${ arg } )
endif ( )
2015-09-01 04:56:26 +03:00
endforeach ( )
2015-09-01 01:05:33 +03:00
add_library ( ${ _target_NAME } ${ _plugin_type } ${ _plugin_srcs } )
if ( "${_plugin_type}" STREQUAL STATIC )
target_compile_definitions ( ${ _target_NAME } PRIVATE -DQT_STATICPLUGIN )
endif ( )
if ( NOT "${_plugin_prefix}" )
set_target_properties ( ${ _target_NAME } PROPERTIES PREFIX "" )
endif ( )
endmacro ( KDE4_ADD_PLUGIN )
# Add a unit test, which is executed when running make test. The targets are
# always created and built unless ENABLE_TESTING is set to negative value.
macro ( KDE4_ADD_TEST _targetName )
2014-11-13 01:04:59 +02:00
set ( _srcList ${ ARGN } )
2015-09-01 01:05:33 +03:00
add_executable ( ${ _targetName } ${ _srcList } )
2014-11-13 01:04:59 +02:00
2015-09-01 01:05:33 +03:00
string ( REPLACE "test" "" _testName ${ _targetName } )
add_test ( NAME ${ _testName } COMMAND ${ _targetName } )
2014-11-13 01:04:59 +02:00
2015-09-01 01:05:33 +03:00
target_compile_definitions ( ${ _targetName } PRIVATE -DKDESRCDIR= "${CMAKE_CURRENT_SOURCE_DIR}/" )
endmacro ( KDE4_ADD_TEST )
2014-11-13 01:04:59 +02:00
2015-09-01 01:05:33 +03:00
macro ( KDE4_ADD_WIDGET_FILES _sources )
foreach ( _current_FILE ${ _sources } )
get_filename_component ( _input ${ _current_FILE } ABSOLUTE )
get_filename_component ( _basename ${ _input } NAME_WE )
get_filename_component ( _extension ${ _input } EXT )
2014-11-13 01:04:59 +02:00
2015-09-01 01:05:33 +03:00
set ( _source ${ CMAKE_CURRENT_BINARY_DIR } / ${ _basename } widgets.cpp )
set ( _moc ${ CMAKE_CURRENT_BINARY_DIR } / ${ _basename } widgets.moc )
2014-11-13 01:04:59 +02:00
2015-09-01 01:05:33 +03:00
# create source file from the .widgets file
add_custom_command ( OUTPUT ${ _source }
C O M M A N D $ { K D E 4 _ M A K E K D E W I D G E T S _ E X E C U T A B L E } - o $ { _ s o u r c e } $ { _ i n p u t }
M A I N _ D E P E N D E N C Y $ { _ i n p u t }
)
2014-11-13 01:04:59 +02:00
2015-09-01 01:05:33 +03:00
qt4_generate_moc ( ${ _source } ${ _moc } )
add_library ( ${ _basename } _autowidgets OBJECT ${ _source } ${ _moc } )
endforeach ( _current_FILE )
endmacro ( KDE4_ADD_WIDGET_FILES )
2014-11-13 01:04:59 +02:00
# This macro adds the needed files for an helper executable meant to be used by applications using KAuth.
# It accepts the helper target, the helper ID (the DBUS name) and the user under which the helper will run on.
# This macro takes care of generate the needed files, and install them in the right location. This boils down
# to a DBus policy to let the helper register on the system bus, and a service file for letting the helper
# being automatically activated by the system bus.
# *WARNING* You have to install the helper in ${LIBEXEC_INSTALL_DIR} to make sure everything will work.
function ( KDE4_INSTALL_AUTH_HELPER_FILES HELPER_TARGET HELPER_ID HELPER_USER )
2014-11-24 15:01:31 +00:00
if ( _kdeBootStrapping )
2015-09-01 01:05:33 +03:00
set ( _stubFilesDir ${ CMAKE_SOURCE_DIR } /kdecore/auth/backends/dbus/ )
2014-11-24 15:01:31 +00:00
else ( _kdeBootStrapping )
2015-09-01 01:05:33 +03:00
set ( _stubFilesDir ${ KDE4_DATA_INSTALL_DIR } /kauth/ )
2014-11-24 15:01:31 +00:00
endif ( _kdeBootStrapping )
configure_file ( ${ _stubFilesDir } /dbus_policy.stub
$ { C M A K E _ C U R R E N T _ B I N A R Y _ D I R } / $ { H E L P E R _ I D } . c o n f )
install ( FILES ${ CMAKE_CURRENT_BINARY_DIR } / ${ HELPER_ID } .conf
D E S T I N A T I O N $ { S Y S C O N F _ I N S T A L L _ D I R } / d b u s - 1 / s y s t e m . d / )
configure_file ( ${ _stubFilesDir } /dbus_service.stub
$ { C M A K E _ C U R R E N T _ B I N A R Y _ D I R } / $ { H E L P E R _ I D } . s e r v i c e )
install ( FILES ${ CMAKE_CURRENT_BINARY_DIR } / ${ HELPER_ID } .service
D E S T I N A T I O N $ { D B U S _ S Y S T E M _ S E R V I C E S _ I N S T A L L _ D I R } )
2014-11-13 01:04:59 +02:00
endfunction ( KDE4_INSTALL_AUTH_HELPER_FILES )