From 13f203672155cd52278655f03da7ff8dcff75c29 Mon Sep 17 00:00:00 2001 From: Andrey Gankov Date: Sat, 10 Mar 2012 02:55:32 +0400 Subject: [PATCH] Fix Issue #9: linker error --- cmake/FindGLIB2.cmake | 120 ++++++++++++++++++++++++++++++++++++++++++++++++ cmake/FindGTK2.cmake | 21 ++------- cmake/FindGTK3.cmake | 24 +++------- remmina/CMakeLists.txt | 9 ++++ 4 files changed, 140 insertions(+), 34 deletions(-) create mode 100644 cmake/FindGLIB2.cmake diff --git a/cmake/FindGLIB2.cmake b/cmake/FindGLIB2.cmake new file mode 100644 index 0000000..8208ded --- /dev/null +++ b/cmake/FindGLIB2.cmake @@ -0,0 +1,120 @@ +# Remmina - The GTK+ Remote Desktop Client +# +# Copyright (C) 2012 Andrey Gankov +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, +# Boston, MA 02111-1307, USA. + +set(_GLIB_found_all true) + +# Glib + +pkg_check_modules(PC_GLIB2 glib-2.0) + +if(NOT PC_GLIB2_FOUND) + set(_GLIB_found_all false) +endif() + +find_path(GLIB2_INCLUDE_DIR_PART1 NAMES glib.h + HINTS ${PC_GLIB2_INCLUDEDIR} ${PC_GLIB2_INCLUDE_DIRS} + PATH_SUFFIXES glib-2.0) + +find_path(GLIB2_INCLUDE_DIR_PART2 NAMES glibconfig.h + HINTS ${PC_GLIB2_INCLUDEDIR} ${PC_GLIB2_INCLUDE_DIRS} + PATH_SUFFIXES glib-2.0/include) + +set(GLIB2_INCLUDE_DIR ${GLIB2_INCLUDE_DIR_PART1} ${GLIB2_INCLUDE_DIR_PART2}) + +find_library(GLIB2_LIBRARY NAMES glib-2.0) + +# GIO + +pkg_check_modules(PC_GIO gio-2.0) + +if(NOT PC_GIO_FOUND) + set(_GLIB_found_all false) +endif() + +find_path(GIO_INCLUDE_DIR gio/gio.h + HINTS ${PC_GIO_INCLUDEDIR} ${PC_GIO_INCLUDE_DIRS} + PATH_SUFFIXES gio-2.0) + +find_library(GIO_LIBRARY NAMES gio-2.0 + HINTS ${PC_GIO_LIBDIR} ${PC_GIO_LIBRARY_DIRS}) + +# gobject + +pkg_check_modules(PC_GOBJECT gobject-2.0) + +if(NOT PC_GOBJECT_FOUND) + set(_GLIB_found_all false) +endif() + +find_path(GOBJECT_INCLUDE_DIR gobject/gobject.h + HINTS ${PC_GOBJECT_INCLUDEDIR} ${PC_GOBJECT_INCLUDE_DIRS} + PATH_SUFFIXES gobject-2.0) + +find_library(GOBJECT_LIBRARY NAMES gobject-2.0 + HINTS ${PC_GOBJECT_LIBDIR} ${PC_GOBJECT_LIBRARY_DIRS}) + +# gmodule + +pkg_check_modules(PC_GMODULE gmodule-2.0) + +if(NOT PC_GMODULE_FOUND) + set(_GLIB_found_all false) +endif() + +find_path(GMODULE_INCLUDE_DIR gmodule.h + HINTS ${PC_GMODULE_INCLUDEDIR} ${PC_GMODULE_INCLUDE_DIRS} + PATH_SUFFIXES gmodule-2.0) + +find_library(GMODULE_LIBRARY NAMES gmodule-2.0 + HINTS ${PC_GMODULE_LIBDIR} ${PC_GMODULE_LIBRARY_DIRS}) + +# gthread + +pkg_check_modules(PC_GTHREAD gthread-2.0) + +if(NOT PC_GTHREAD_FOUND) + set(_GLIB_found_all false) +endif() + +find_path(GTHREAD_INCLUDE_DIR glib/gthread.h + HINTS ${PC_GTHREAD_INCLUDEDIR} ${PC_GTHREAD_INCLUDE_DIRS} + PATH_SUFFIXES gthread-2.0) + +find_library(GTHREAD_LIBRARY NAMES gthread-2.0 + HINTS ${PC_GTHREAD_LIBDIR} ${PC_GTHREAD_LIBRARY_DIRS}) + +# Finalize + +if(_GLIB_found_all) + include(FindPackageHandleStandardArgs) + + find_package_handle_standard_args(GLIB2 DEFAULT_MSG GLIB2_LIBRARY GLIB2_INCLUDE_DIR) + + set(GLIB2_LIBRARIES ${GLIB2_LIBRARY} ${GIO_LIBRARY} ${GOBJECT_LIBRARY} ${GMODULE_LIBRARY} ${GTHREAD_LIBRARY}) + set(GLIB2_INCLUDE_DIRS ${GLIB2_INCLUDE_DIR} ${GIO_INCLUDE_DIR} ${GOBJECT_INCLUDE_DIR} ${GMODULE_INCLUDE_DIR} ${GTHREAD_INCLUDE_DIR}) + + mark_as_advanced(GLIB2_INCLUDE_DIR GLIB2_LIBRARY) + + set(GLIB_FOUND true) +else() + unset(GLIB2_LIBRARY) + unset(GLIB2_INCLUDE_DIR) + + set(GLIB_FOUND false) +endif() diff --git a/cmake/FindGTK2.cmake b/cmake/FindGTK2.cmake index b33966e..caf0295 100644 --- a/cmake/FindGTK2.cmake +++ b/cmake/FindGTK2.cmake @@ -63,24 +63,11 @@ find_library(GDKPIXBUF_LIBRARY NAMES gdk_pixbuf-2.0 # Glib -pkg_check_modules(PC_GLIB2 glib-2.0) - -if(NOT PC_GLIB2_FOUND) +find_required_package(GLIB2) +if(NOT GLIB2_FOUND) set(_GTK2_found_all false) endif() -find_path(GLIB2_INCLUDE_DIR_PART1 NAMES glib.h - HINTS ${PC_GLIB2_INCLUDEDIR} ${PC_GLIB2_INCLUDE_DIRS} - PATH_SUFFIXES glib-2.0) - -find_path(GLIB2_INCLUDE_DIR_PART2 NAMES glibconfig.h - HINTS ${PC_GLIB2_INCLUDEDIR} ${PC_GLIB2_INCLUDE_DIRS} - PATH_SUFFIXES glib-2.0/include) - -set(GLIB2_INCLUDE_DIR ${GLIB2_INCLUDE_DIR_PART1} ${GLIB2_INCLUDE_DIR_PART2}) - -find_library(GLIB2_LIBRARY NAMES glib-2.0) - # Pango pkg_check_modules(PC_PANGO pango) @@ -129,8 +116,8 @@ if(_GTK2_found_all) find_package_handle_standard_args(GTK2 DEFAULT_MSG GTK2_LIBRARY GTK2_INCLUDE_DIR) - set(GTK2_LIBRARIES ${GTK2_LIBRARY} ${GDK2_LIBRARY} ${GLIB2_LIBRARY} ${PANGO_LIBRARY} ${CAIRO_LIBRARY} ${GDKPIXBUF_LIBRARY} ${ATK_LIBRARY}) - set(GTK2_INCLUDE_DIRS ${GTK2_INCLUDE_DIR} ${GDK2_INCLUDE_DIR} ${GLIB2_INCLUDE_DIR} ${PANGO_INCLUDE_DIR} ${CAIRO_INCLUDE_DIR} ${GDKPIXBUF_INCLUDE_DIR} ${ATK_INCLUDE_DIR}) + set(GTK2_LIBRARIES ${GTK2_LIBRARY} ${GDK2_LIBRARY} ${GLIB2_LIBRARIES} ${PANGO_LIBRARY} ${CAIRO_LIBRARY} ${GDKPIXBUF_LIBRARY} ${ATK_LIBRARY}) + set(GTK2_INCLUDE_DIRS ${GTK2_INCLUDE_DIR} ${GDK2_INCLUDE_DIR} ${GLIB2_INCLUDE_DIRS} ${PANGO_INCLUDE_DIR} ${CAIRO_INCLUDE_DIR} ${GDKPIXBUF_INCLUDE_DIR} ${ATK_INCLUDE_DIR}) mark_as_advanced(GTK2_INCLUDE_DIR GTK2_LIBRARY) diff --git a/cmake/FindGTK3.cmake b/cmake/FindGTK3.cmake index f73b64d..decb00a 100644 --- a/cmake/FindGTK3.cmake +++ b/cmake/FindGTK3.cmake @@ -53,24 +53,11 @@ find_library(GDKPIXBUF_LIBRARY NAMES gdk_pixbuf-2.0 # Glib -pkg_check_modules(PC_GLIB2 glib-2.0) - -if(NOT PC_GLIB2_FOUND) +find_required_package(GLIB2) +if(NOT GLIB2_FOUND) set(_GTK3_found_all false) endif() -find_path(GLIB2_INCLUDE_DIR_PART1 NAMES glib.h - HINTS ${PC_GLIB2_INCLUDEDIR} ${PC_GLIB2_INCLUDE_DIRS} - PATH_SUFFIXES glib-2.0) - -find_path(GLIB2_INCLUDE_DIR_PART2 NAMES glibconfig.h - HINTS ${PC_GLIB2_INCLUDEDIR} ${PC_GLIB2_INCLUDE_DIRS} - PATH_SUFFIXES glib-2.0/include) - -set(GLIB2_INCLUDE_DIR ${GLIB2_INCLUDE_DIR_PART1} ${GLIB2_INCLUDE_DIR_PART2}) - -find_library(GLIB2_LIBRARY NAMES glib-2.0) - # Pango pkg_check_modules(PC_PANGO pango) @@ -119,14 +106,17 @@ if(_GTK3_found_all) find_package_handle_standard_args(GTK3 DEFAULT_MSG GTK3_LIBRARY GTK3_INCLUDE_DIR) - set(GTK3_LIBRARIES ${GTK3_LIBRARY} ${GDK3_LIBRARY} ${GLIB2_LIBRARY} ${PANGO_LIBRARY} ${CAIRO_LIBRARY} ${GDKPIXBUF_LIBRARY} ${ATK_LIBRARY}) - set(GTK3_INCLUDE_DIRS ${GTK3_INCLUDE_DIR} ${GLIB2_INCLUDE_DIR} ${PANGO_INCLUDE_DIR} ${CAIRO_INCLUDE_DIR} ${GDKPIXBUF_INCLUDE_DIR} ${ATK_INCLUDE_DIR}) + set(GTK3_LIBRARIES ${GTK3_LIBRARY} ${GDK3_LIBRARY} ${GLIB2_LIBRARIES} ${PANGO_LIBRARY} ${CAIRO_LIBRARY} ${GDKPIXBUF_LIBRARY} ${ATK_LIBRARY}) + set(GTK3_INCLUDE_DIRS ${GTK3_INCLUDE_DIR} ${GLIB2_INCLUDE_DIRS} ${PANGO_INCLUDE_DIR} ${CAIRO_INCLUDE_DIR} ${GDKPIXBUF_INCLUDE_DIR} ${ATK_INCLUDE_DIR}) mark_as_advanced(GTK3_INCLUDE_DIR GTK3_LIBRARY) set(GTK3_FOUND true) else() unset(GTK3_LIBRARY) + unset(GTK3_INCLUDE_DIR) + + unset(GDK3_LIBRARY) unset(GDK3_INCLUDE_DIR) set(GTK3_FOUND false) diff --git a/remmina/CMakeLists.txt b/remmina/CMakeLists.txt index 0fe7bbf..9e7c982 100644 --- a/remmina/CMakeLists.txt +++ b/remmina/CMakeLists.txt @@ -93,6 +93,10 @@ add_executable(remmina ${REMMINA_SRCS}) include_directories(${GTK_INCLUDE_DIRS}) target_link_libraries(remmina ${GTK_LIBRARIES}) +find_package(X11) +include_directories(${X11_INCLUDE_DIR}) +target_link_libraries(remmina ${X11_LIBRARIES}) + find_suggested_package(LIBSSH) if(LIBSSH_FOUND) add_definitions(-DHAVE_LIBSSH) @@ -100,6 +104,11 @@ if(LIBSSH_FOUND) target_link_libraries(remmina ${LIBSSH_LIBRARIES}) endif() +if(PTHREAD_FOUND) + include_directories(${PTHREAD_INCLUDE_DIRS}) + target_link_libraries(remmina ${PTHREAD_LIBRARIES}) +endif() + if(GCRYPT_FOUND) include_directories(${GCRYPT_INCLUDE_DIRS}) target_link_libraries(remmina ${GCRYPT_LIBRARIES}) -- 1.7.5.4