diff options
Diffstat (limited to 'modules/KDE4Macros.cmake')
-rw-r--r-- | modules/KDE4Macros.cmake | 133 |
1 files changed, 106 insertions, 27 deletions
diff --git a/modules/KDE4Macros.cmake b/modules/KDE4Macros.cmake index cf33ad35..4aa4236a 100644 --- a/modules/KDE4Macros.cmake +++ b/modules/KDE4Macros.cmake @@ -22,6 +22,8 @@ # KDE4_ADD_APP_ICON # KDE4_CREATE_MANPAGE # KDE4_CREATE_BASIC_CMAKE_VERSION_FILE (function) +# 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> @@ -53,16 +55,37 @@ endif(NOT COMMAND _AUTOMOC4_KDE4_PRE_TARGET_HANDLING) macro (KDE4_ADD_KCFG_FILES _sources ) - if( ${ARGV1} STREQUAL "GENERATE_MOC" ) - set(_kcfg_generatemoc TRUE) - endif( ${ARGV1} STREQUAL "GENERATE_MOC" ) + foreach (_current_ARG ${ARGN}) + if( ${_current_ARG} STREQUAL "GENERATE_MOC" ) + set(_kcfg_generatemoc TRUE) + endif( ${_current_ARG} STREQUAL "GENERATE_MOC" ) + + 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") + if(NOT ${_current_FILE} STREQUAL "GENERATE_MOC" AND NOT ${_current_FILE} STREQUAL "USE_RELATIVE_PATH") get_filename_component(_tmp_FILE ${_current_FILE} ABSOLUTE) get_filename_component(_abs_PATH ${_tmp_FILE} PATH) + + if (_kcfg_relativepath) # Process relative path only if the option was set + # Get relative path + get_filename_component(_rel_PATH ${_current_FILE} PATH) + + 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}") @@ -78,10 +101,15 @@ macro (KDE4_ADD_KCFG_FILES _sources ) 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}") + # the command for creating the source file from the kcfg file add_custom_command(OUTPUT ${_header_FILE} ${_src_FILE} COMMAND ${KDE4_KCFGC_EXECUTABLE} - ARGS ${_kcfg_FILE} ${_tmp_FILE} -d ${CMAKE_CURRENT_BINARY_DIR} + ARGS ${_kcfg_FILE} ${_tmp_FILE} -d ${CMAKE_CURRENT_BINARY_DIR}/${_rel_PATH} MAIN_DEPENDENCY ${_tmp_FILE} DEPENDS ${_kcfg_FILE} ${_KDE4_KCONFIG_COMPILER_DEP} ) @@ -92,7 +120,7 @@ macro (KDE4_ADD_KCFG_FILES _sources ) endif(_kcfg_generatemoc) list(APPEND ${_sources} ${_src_FILE} ${_header_FILE}) - endif(NOT ${_current_FILE} STREQUAL "GENERATE_MOC") + endif(NOT ${_current_FILE} STREQUAL "GENERATE_MOC" AND NOT ${_current_FILE} STREQUAL "USE_RELATIVE_PATH") endforeach (_current_FILE) endmacro (KDE4_ADD_KCFG_FILES) @@ -496,10 +524,12 @@ endmacro (KDE4_CREATE_FINAL_FILES) # If RPATH is not disabled, these scripts are also used but only for consistency, because # they don't really influence anything then, because the compiled-in RPATH overrides # the LD_LIBRARY_PATH env. variable. -macro (KDE4_HANDLE_RPATH_FOR_EXECUTABLE _target_NAME _type) +macro (KDE4_HANDLE_RPATH_FOR_EXECUTABLE _target_NAME) if (UNIX) if (APPLE) set(_library_path_variable "DYLD_LIBRARY_PATH") + elseif (CYGWIN) + set(_library_path_variable "PATH") else (APPLE) set(_library_path_variable "LD_LIBRARY_PATH") endif (APPLE) @@ -590,15 +620,14 @@ endmacro (KDE4_ADD_PLUGIN _target_NAME _with_PREFIX) # if "NOGUI" is in the list of files, the _nogui argument is set to # "NOGUI" (which evaluates to TRUE in cmake), otherwise it is set empty # (which evaluates to FALSE in cmake) -# if "RUN_UNINSTALLED" is in the list of files, the _uninst argument is set to -# "RUN_UNINSTALLED" (which evaluates to TRUE in cmake), otherwise it is set empty -# (which evaluates to FALSE in cmake) +# "RUN_UNINSTALLED" in the list of files is ignored, it is not necessary anymore +# since KDE 4.2 (with cmake 2.6.2), since then all executables are always built +# with RPATH pointing into the build dir. # if "TEST" is in the list of files, the _test argument is set to # "TEST" (which evaluates to TRUE in cmake), otherwise it is set empty # (which evaluates to FALSE in cmake) -macro(KDE4_CHECK_EXECUTABLE_PARAMS _output_LIST _nogui _uninst _test) +macro(KDE4_CHECK_EXECUTABLE_PARAMS _output_LIST _nogui _test) set(${_nogui}) - set(${_uninst}) set(${_test}) set(${_output_LIST} ${ARGN}) list(LENGTH ${_output_LIST} count) @@ -618,7 +647,6 @@ macro(KDE4_CHECK_EXECUTABLE_PARAMS _output_LIST _nogui _uninst _test) endif (${first_PARAM} STREQUAL "NOGUI") if (${first_PARAM} STREQUAL "RUN_UNINSTALLED") - set(${_uninst} "RUN_UNINSTALLED") set(remove 0) endif (${first_PARAM} STREQUAL "RUN_UNINSTALLED") @@ -633,7 +661,6 @@ macro(KDE4_CHECK_EXECUTABLE_PARAMS _output_LIST _nogui _uninst _test) endif (${second_PARAM} STREQUAL "NOGUI") if (${second_PARAM} STREQUAL "RUN_UNINSTALLED") - set(${_uninst} "RUN_UNINSTALLED") set(remove 0;1) endif (${second_PARAM} STREQUAL "RUN_UNINSTALLED") @@ -643,7 +670,6 @@ macro(KDE4_CHECK_EXECUTABLE_PARAMS _output_LIST _nogui _uninst _test) endif (${second_PARAM} STREQUAL "TEST") - if (NOT "${remove}" STREQUAL "NOTFOUND") list(REMOVE_AT ${_output_LIST} ${remove}) endif (NOT "${remove}" STREQUAL "NOTFOUND") @@ -653,7 +679,7 @@ endmacro(KDE4_CHECK_EXECUTABLE_PARAMS) macro (KDE4_ADD_KDEINIT_EXECUTABLE _target_NAME ) - kde4_check_executable_params(_SRCS _nogui _uninst _test ${ARGN}) + kde4_check_executable_params(_SRCS _nogui _test ${ARGN}) configure_file(${KDE4_MODULE_DIR}/kde4init_dummy.cpp.in ${CMAKE_CURRENT_BINARY_DIR}/${_target_NAME}_dummy.cpp) set_source_files_properties(${CMAKE_CURRENT_BINARY_DIR}/${_target_NAME}_dummy.cpp PROPERTIES SKIP_AUTOMOC TRUE) @@ -679,10 +705,10 @@ macro (KDE4_ADD_KDEINIT_EXECUTABLE _target_NAME ) if (KDE4_ENABLE_FINAL) kde4_create_final_files(${CMAKE_CURRENT_BINARY_DIR}/${_target_NAME}_final_cpp.cpp _separate_files ${_SRCS}) - kde4_add_executable(${_target_NAME} "${_nogui}" "${_uninst}" ${CMAKE_CURRENT_BINARY_DIR}/kdeinit_${_target_NAME}_final_cpp.cpp ${_separate_files} ${CMAKE_CURRENT_BINARY_DIR}/${_target_NAME}_dummy.cpp ${_resourcefile}) + kde4_add_executable(${_target_NAME} "${_nogui}" ${CMAKE_CURRENT_BINARY_DIR}/kdeinit_${_target_NAME}_final_cpp.cpp ${_separate_files} ${CMAKE_CURRENT_BINARY_DIR}/${_target_NAME}_dummy.cpp ${_resourcefile}) else (KDE4_ENABLE_FINAL) - kde4_add_executable(${_target_NAME} "${_nogui}" "${_uninst}" ${_SRCS} ${CMAKE_CURRENT_BINARY_DIR}/${_target_NAME}_dummy.cpp ${_resourcefile}) + kde4_add_executable(${_target_NAME} "${_nogui}" ${_SRCS} ${CMAKE_CURRENT_BINARY_DIR}/${_target_NAME}_dummy.cpp ${_resourcefile}) endif (KDE4_ENABLE_FINAL) set_target_properties(kdeinit_${_target_NAME} PROPERTIES OUTPUT_NAME kdeinit4_${_target_NAME}) @@ -703,7 +729,7 @@ macro (KDE4_ADD_KDEINIT_EXECUTABLE _target_NAME ) set_target_properties(kdeinit_${_target_NAME} PROPERTIES OUTPUT_NAME kdeinit4_${_target_NAME}) - kde4_add_executable(${_target_NAME} "${_nogui}" "${_uninst}" ${CMAKE_CURRENT_BINARY_DIR}/${_target_NAME}_dummy.cpp) + kde4_add_executable(${_target_NAME} "${_nogui}" ${CMAKE_CURRENT_BINARY_DIR}/${_target_NAME}_dummy.cpp) target_link_libraries(${_target_NAME} kdeinit_${_target_NAME}) endif(WIN32) @@ -847,10 +873,9 @@ endmacro(_KDE4_ADD_MANIFEST) macro (KDE4_ADD_EXECUTABLE _target_NAME) - kde4_check_executable_params( _SRCS _nogui _uninst _test ${ARGN}) + kde4_check_executable_params( _SRCS _nogui _test ${ARGN}) set(_add_executable_param) - set(_type "GUI") # determine additional parameters for add_executable() # for GUI apps, create a bundle on OSX @@ -864,14 +889,9 @@ macro (KDE4_ADD_EXECUTABLE _target_NAME) endif (WIN32) if (_nogui) - set(_type "NOGUI") set(_add_executable_param) endif (_nogui) - if (_uninst OR _test) - set(_type "RUN_UNINSTALLED ${_type}") - endif (_uninst OR _test) - if (_test AND NOT KDE4_BUILD_TESTS) set(_add_executable_param ${_add_executable_param} EXCLUDE_FROM_ALL) endif (_test AND NOT KDE4_BUILD_TESTS) @@ -895,7 +915,7 @@ macro (KDE4_ADD_EXECUTABLE _target_NAME) set_target_properties(${_target_NAME} PROPERTIES COMPILE_FLAGS -DKDESRCDIR="\\"${CMAKE_CURRENT_SOURCE_DIR}/\\"") endif (_test) - kde4_handle_rpath_for_executable(${_target_NAME} ${_type}) + kde4_handle_rpath_for_executable(${_target_NAME}) if (WIN32) target_link_libraries(${_target_NAME} ${QT_QTMAIN_LIBRARY}) @@ -1189,6 +1209,65 @@ macro (KDE4_HANDLE_RPATH_FOR_LIBRARY _target_NAME) endif (NOT CMAKE_SKIP_RPATH) endmacro (KDE4_HANDLE_RPATH_FOR_LIBRARY) +# 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) + + if (_kdeBootStrapping) + set(_stubFilesDir ${CMAKE_SOURCE_DIR}/kdecore/auth/backends/dbus/ ) + else (_kdeBootStrapping) + set(_stubFilesDir ${KDE4_DATA_INSTALL_DIR}/kauth/ ) + endif (_kdeBootStrapping) + + configure_file(${_stubFilesDir}/dbus_policy.stub + ${CMAKE_CURRENT_BINARY_DIR}/${HELPER_ID}.conf) + install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${HELPER_ID}.conf + DESTINATION ${SYSCONF_INSTALL_DIR}/dbus-1/system.d/) + + configure_file(${_stubFilesDir}/dbus_service.stub + ${CMAKE_CURRENT_BINARY_DIR}/${HELPER_ID}.service) + install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${HELPER_ID}.service + DESTINATION ${DBUS_SYSTEM_SERVICES_INSTALL_DIR}) +endfunction(KDE4_INSTALL_AUTH_HELPER_FILES) + +# This macro generates an action file, depending on the backend used, for applications using KAuth. +# It accepts the helper id (the DBUS name) and a file containing the actions (check kdelibs/kdecore/auth/example +# for file format). The macro will take care of generating the file according to the backend specified, +# and to install it in the right location. This (at the moment) means that on Linux (PolicyKit) a .policy +# file will be generated and installed into the policykit action directory (usually /usr/share/PolicyKit/policy/), +# and on Mac (Authorization Services) will be added to the system action registry using the native MacOS API during +# the install phase +function(KDE4_INSTALL_AUTH_ACTIONS HELPER_ID ACTIONS_FILE) + + if(APPLE) + install(CODE "execute_process(COMMAND ${KDE4_KAUTH_POLICY_GEN_EXECUTABLE} ${ACTIONS_FILE} WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})") + elseif(UNIX) + set(_output ${CMAKE_CURRENT_BINARY_DIR}/${HELPER_ID}.policy) + get_filename_component(_input ${ACTIONS_FILE} ABSOLUTE) + + add_custom_command(OUTPUT ${_output} + COMMAND ${KDE4_KAUTH_POLICY_GEN_EXECUTABLE} ${_input} > ${_output} + MAIN_DEPENDENCY ${_input} + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} + COMMENT "Generating ${HELPER_ID}.policy" + DEPENDS ${_KDE4_KAUTH_POLICY_GEN_EXECUTABLE_DEP}) + add_custom_target("actions for ${HELPER_ID}" ALL DEPENDS ${_output}) + + if (NOT POLKITQT_FOUND) + macro_optional_find_package(PolkitQt) + endif (NOT POLKITQT_FOUND) + + if (POLKITQT_FOUND) + install(FILES ${_output} DESTINATION ${POLKITQT_POLICY_FILES_INSTALL_DIR}) + endif (POLKITQT_FOUND) + endif() + +endfunction(KDE4_INSTALL_AUTH_ACTIONS) + macro(_KDE4_EXPORT_LIBRARY_DEPENDENCIES _append_or_write _filename) message(FATAL_ERROR "_KDE4_EXPORT_LIBRARY_DEPENDENCIES() was an internal macro and has been removed again. Just remove the code which calls it, there is no substitute.") |