Use FindPkgConfig to find libcloudproviders and related libs

Instead of using custom find modules.

This allows using imported targets which make the code much nicer.

Signed-off-by: Nicolas Fella <nicolas.fella@gmx.de>
This commit is contained in:
Nicolas Fella 2021-04-01 19:46:56 +02:00 коммит произвёл Felix Weilbach (Rebase PR Action)
Родитель e74746c4e7
Коммит b34a901838
7 изменённых файлов: 23 добавлений и 141 удалений

Просмотреть файл

@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.2)
cmake_minimum_required(VERSION 3.6)
set(CMAKE_CXX_STANDARD 14)
project(client)
@ -197,9 +197,16 @@ if(BUILD_CLIENT)
find_package(OpenSSL 1.1 REQUIRED )
find_package(ZLIB REQUIRED)
find_package(GLib2)
find_package(Gio)
find_package(Libcloudproviders)
if(NOT WIN32 AND NOT APPLE)
find_package(PkgConfig REQUIRED)
pkg_check_modules(CLOUDPROVIDERS cloudproviders IMPORTED_TARGET)
if(CLOUDPROVIDERS_FOUND)
pkg_check_modules(GIO REQUIRED gio-2.0 IMPORTED_TARGET)
pkg_check_modules(GLIB2 REQUIRED glib-2.0 IMPORTED_TARGET)
endif()
endif()
endif()
if (NOT DEFINED APPLICATION_ICON_NAME)

Просмотреть файл

@ -1,35 +0,0 @@
# FindGLib2.cmake
# GLib2_FOUND - System has GLib2
# GLib2_INCLUDES - The GLib2 include directories
# GLib2_LIBRARIES - The libraries needed to use GLib2
# GLib2_DEFINITIONS - Compiler switches required for using GLib2
find_package(PkgConfig)
pkg_check_modules(GLib2 QUIET glib-2.0)
set(GLib2_DEFINITIONS ${GLib2_CFLAGS_OTHER})
find_path(GLib2_INCLUDE_DIR
NAMES glib.h glib-object.h
HINTS ${GLib2_INCLUDEDIR} ${GLib2_INCLUDE_DIRS}
PATH_SUFFIXES glib-2.0)
find_path(GLIBCONFIG_INCLUDE_DIR
NAMES glibconfig.h
HINTS ${LIBDIR} ${LIBRARY_DIRS} ${_GLib2_LIBRARY_DIR}
${GLib2_INCLUDEDIR} ${GLib2_INCLUDE_DIRS}
${CMAKE_EXTRA_INCLUDES} ${CMAKE_EXTRA_LIBRARIES}
PATH_SUFFIXES glib-2.0 glib-2.0/include)
list(APPEND GLib2_INCLUDE_DIR ${GLIBCONFIG_INCLUDE_DIR})
find_library(GLib2_LIBRARY
NAMES glib-2.0 libglib-2.0
HINTS ${GLib2_LIBDIR} ${GLib2_LIBRARY_DIRS})
set(GLib2_LIBRARIES ${GLib2_LIBRARY})
set(GLib2_INCLUDE_DIRS ${GLib2_INCLUDE_DIR})
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(GLib2 DEFAULT_MSG
GLib2_LIBRARY GLib2_INCLUDE_DIR)
mark_as_advanced(GLib2_INCLUDE_DIR GLib2_LIBRARY)

Просмотреть файл

@ -1,61 +0,0 @@
# - Try to find Gio
# Once done this will define
#
# GIO_FOUND - system has Gio
# GIO_INCLUDE_DIR - the Gio include directory
# GIO_LIBRARIES - the libraries needed to use Gio
# GIO_DEFINITIONS - Compiler switches required for using Gio
IF (GIO_INCLUDE_DIR AND GIO_LIBRARIES)
# in cache already
SET(Gio_FIND_QUIETLY TRUE)
ELSE (GIO_INCLUDE_DIR AND GIO_LIBRARIES)
SET(Gio_FIND_QUIETLY FALSE)
ENDIF (GIO_INCLUDE_DIR AND GIO_LIBRARIES)
IF (NOT WIN32)
# use pkg-config to get the directories and then use these values
# in the FIND_PATH() and FIND_LIBRARY() calls
FIND_PACKAGE(PkgConfig)
PKG_CHECK_MODULES(GIO gio-2.0)
#MESSAGE(STATUS "DEBUG: Gio include directory = ${GIO_INCLUDE_DIRS}")
#MESSAGE(STATUS "DEBUG: Gio link directory = ${GIO_LIBRARY_DIRS}")
#MESSAGE(STATUS "DEBUG: Gio CFlags = ${GIO_CFLAGS}")
SET(GIO_DEFINITIONS ${GIO_CFLAGS_OTHER})
ENDIF (NOT WIN32)
FIND_PATH(GIO_INCLUDE_DIR gio.h
PATHS
${GIO_INCLUDEDIR}
${GIO_INCLUDE_DIRS}
PATH_SUFFIXES glib-2.0/gio/
)
FIND_LIBRARY(_GioLibs NAMES gio-2.0 libgio-2.0
PATHS
${GIO_LIBDIR}
${GIO_LIBRARY_DIRS}
)
SET( GIO_LIBRARIES ${_GioLibs} )
SET( GIO_INCLUDE_DIRS ${GIO_INCLUDE_DIR} )
IF (GIO_INCLUDE_DIR AND GIO_LIBRARIES)
SET(GIO_FOUND TRUE)
ELSE (GIO_INCLUDE_DIR AND GIO_LIBRARIES)
SET(GIO_FOUND FALSE)
ENDIF (GIO_INCLUDE_DIR AND GIO_LIBRARIES)
IF (GIO_FOUND)
IF (NOT Gio_FIND_QUIETLY)
MESSAGE(STATUS "Found Gio libraries: ${GIO_LIBRARIES}")
MESSAGE(STATUS "Found Gio includes : ${GIO_INCLUDE_DIR}")
ENDIF (NOT Gio_FIND_QUIETLY)
ELSE (GIO_FOUND)
IF (Gio_FIND_REQUIRED)
MESSAGE(STATUS "Could NOT find Gio")
ENDIF(Gio_FIND_REQUIRED)
ENDIF (GIO_FOUND)
MARK_AS_ADVANCED(GIO_INCLUDE_DIR _GioLibs)

Просмотреть файл

@ -1,22 +0,0 @@
# FindLibcloudproviders.cmake
find_path(LIBCLOUDPROVIDERS_INCLUDE_DIR
NAMES cloudprovidersproviderexporter.h cloudprovidersaccountexporter.h
PATH_SUFFIXES cloudproviders
)
find_library(LIBCLOUDPROVIDERS_LIBRARY
NAMES
libcloudproviders
cloudproviders
HINTS
/usr/lib
/usr/lib/${CMAKE_ARCH_TRIPLET}
/usr/local/lib
/opt/local/lib
${CMAKE_LIBRARY_PATH}
${CMAKE_INSTALL_PREFIX}/lib
)
message("================> ${LIBCLOUDPROVIDERS_LIBRARY}")
find_package_handle_standard_args(LIBCLOUDPROVIDERS DEFAULT_MSG LIBCLOUDPROVIDERS_INCLUDE_DIR LIBCLOUDPROVIDERS_LIBRARY)

Просмотреть файл

@ -192,17 +192,6 @@ else()
list(APPEND 3rdparty_SRC ../3rdparty/qtlockedfile/qtlockedfile_win.cpp )
endif()
IF( NOT WIN32 AND NOT APPLE AND LIBCLOUDPROVIDERS_FOUND)
message("Building with libcloudproviderssupport")
add_definitions(-DWITH_LIBCLOUDPROVIDERS)
set(client_SRCS ${client_SRCS} cloudproviders/cloudprovidermanager.cpp)
set(client_SRCS ${client_SRCS} cloudproviders/cloudproviderwrapper.cpp)
include_directories(${GLib2_INCLUDE_DIRS})
include_directories(${GIO_INCLUDE_DIRS})
include_directories(${LIBCLOUDPROVIDERS_INCLUDE_DIR})
ENDIF()
find_package(Qt5LinguistTools)
if(Qt5LinguistTools_FOUND)
qt5_add_translation(client_I18N ${TRANSLATIONS})
@ -355,7 +344,10 @@ endif()
target_link_libraries(nextcloudCore PUBLIC ${OS_SPECIFIC_LINK_LIBRARIES})
IF( LIBCLOUDPROVIDERS_FOUND )
if(TARGET PkgConfig::CLOUDPROVIDERS)
message("Building with libcloudproviderssupport")
target_sources(nextcloudCore PRIVATE cloudproviders/cloudprovidermanager.cpp cloudproviders/cloudproviderwrapper.cpp)
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}")
@ -366,13 +358,14 @@ IF( LIBCLOUDPROVIDERS_FOUND )
set(LIBCLOUDPROVIDERS_DBUS_OBJECT_PATH "/${DBUS_PREFIX}/${DBUS_VENDOR}/${DBUS_APPLICATION_NAME}")
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/cloudproviders/cloudproviderconfig.h.in ${CMAKE_CURRENT_BINARY_DIR}/cloudproviderconfig.h)
target_compile_definitions(nextcloudCore PUBLIC -DWITH_LIBCLOUDPROVIDERS)
target_link_libraries(nextcloudCore
PUBLIC
${GLib2_LDFLAGS}
${GIO_LDFLAGS}
${LIBCLOUDPROVIDERS_LIBRARY}
PRIVATE
PkgConfig::CLOUDPROVIDERS
PkgConfig::GLIB2
PkgConfig::GIO
)
ENDIF()
endif()
## handle DBUS for Fdo notifications
if( UNIX AND NOT APPLE )

Просмотреть файл

@ -13,7 +13,7 @@
*/
#include <glib.h>
#include <gio.h>
#include <gio/gio.h>
#include <cloudprovidersproviderexporter.h>
#include "cloudproviderwrapper.h"

Просмотреть файл

@ -14,7 +14,7 @@
*/
#include <glib.h>
#include <gio.h>
#include <gio/gio.h>
#include <cloudprovidersaccountexporter.h>
#include <cloudprovidersproviderexporter.h>