nextcloud-desktop/shell_integration/libcloudproviders/CMakeLists.txt
Julius Härtl 1cedb1919f
Integrate libcloudproviders support
This commit integrates support for libcloudproviders
desktop integration API. If build with the library it
will check on startup if the DBus interface is available
and then use it instead of the legacy status icon.

Signed-off-by: Julius Härtl <jus@bitgrid.net>
2017-12-14 11:19:25 +01:00

57 lines
2.5 KiB
CMake

include(UsePkgConfig)
MACRO(PKGCONFIG_GETVAR _package _var _output_variable)
SET(${_output_variable})
# if pkg-config has been found
IF (PKGCONFIG_EXECUTABLE)
EXEC_PROGRAM(${PKGCONFIG_EXECUTABLE} ARGS ${_package} --exists RETURN_VALUE _return_VALUE OUTPUT_VARIABLE _pkgconfigDevNull)
# and if the package of interest also exists for pkg-config, then get the information
IF (NOT _return_VALUE)
EXEC_PROGRAM(${PKGCONFIG_EXECUTABLE} ARGS ${_package} --variable ${_var} OUTPUT_VARIABLE ${_output_variable})
ENDIF (NOT _return_VALUE)
ENDIF (PKGCONFIG_EXECUTABLE)
ENDMACRO(PKGCONFIG_GETVAR _package _var _output_variable)
macro(dbus_add_activation_service _sources)
PKGCONFIG_GETVAR(dbus-1 session_bus_services_dir _install_dir)
foreach (_i ${_sources})
get_filename_component(_service_file ${_i} ABSOLUTE)
string(REGEX REPLACE "\\.service.*$" ".service" _output_file ${_i})
set(_target ${CMAKE_CURRENT_BINARY_DIR}/${_output_file})
configure_file(${_service_file} ${_target})
install(FILES ${_target} DESTINATION ${_install_dir} RENAME "${LIBCLOUDPROVIDERS_DBUS_BUS_NAME}.service")
endforeach (_i ${ARGN})
endmacro(dbus_add_activation_service _sources)
macro(libcloudproviders_add_config _sources)
set(_install_dir "${CMAKE_INSTALL_PREFIX}/share/cloud-providers")
foreach (_i ${_sources})
get_filename_component(_service_file ${_i} ABSOLUTE)
string(REGEX REPLACE "\\.ini.*$" ".ini" _output_file ${_i})
set(_target ${CMAKE_CURRENT_BINARY_DIR}/${_output_file})
configure_file(${_service_file} ${_target})
install(FILES ${_target} DESTINATION ${_install_dir} RENAME "${LIBCLOUDPROVIDERS_DBUS_BUS_NAME}.ini")
endforeach (_i ${ARGN})
endmacro(libcloudproviders_add_config _sources)
IF (UNIX AND WITH_DBUS AND LIBCLOUDPROVIDERS_FOUND)
STRING(TOLOWER "${APPLICATION_VENDOR}" DBUS_VENDOR)
STRING(REGEX REPLACE "[^A-z0-9]" "" DBUS_VENDOR "${DBUS_VENDOR}")
STRING(REGEX REPLACE "[^A-z0-9]" "" DBUS_APPLICATION_NAME "${APPLICATION_SHORTNAME}")
if (NOT DBUS_PREFIX)
set(DBUS_PREFIX "com")
endif ()
set(LIBCLOUDPROVIDERS_DBUS_BUS_NAME "${DBUS_PREFIX}.${DBUS_VENDOR}.${DBUS_APPLICATION_NAME}")
set(LIBCLOUDPROVIDERS_DBUS_OBJECT_PATH "/${DBUS_PREFIX}/${DBUS_VENDOR}/${DBUS_APPLICATION_NAME}")
dbus_add_activation_service(org.freedesktop.CloudProviders.service.in)
libcloudproviders_add_config(org.freedesktop.CloudProviders.ini.in)
ENDIF ()