Permalink
Browse files

cmake: fixes #208

  • Loading branch information...
1 parent ee373b4 commit ec337927fc4375ee0e22f6751965bb31be41ec0b @karolherbst committed May 13, 2012
View
@@ -79,6 +79,7 @@ endif()
if(NOT WIN32)
find_package(Boost COMPONENTS date_time filesystem thread system REQUIRED)
+ find_package(Notify)
endif()
find_package(BZip2)
@@ -0,0 +1,220 @@
+# http://opensource.bolloretelecom.eu/projects/boc-wimax/browser/cmake/modules/FindGLIB2.cmake?rev=8f5b254534bd304923d4cc7bc7e9d6552c119ea2
+
+# - Try to find GLib2
+# Once done this will define
+#
+# GLIB2_FOUND - system has GLib2
+# GLIB2_INCLUDE_DIRS - the GLib2 include directory
+# GLIB2_LIBRARIES - Link these to use GLib2
+#
+# HAVE_GLIB_GREGEX_H glib has gregex.h header and
+# supports g_regex_match_simple
+#
+# Copyright (c) 2006 Andreas Schneider <mail@cynapses.org>
+# Copyright (c) 2006 Philippe Bernery <philippe.bernery@gmail.com>
+# Copyright (c) 2007 Daniel Gollub <dgollub@suse.de>
+# Copyright (c) 2007 Alban Browaeys <prahal@yahoo.com>
+# Copyright (c) 2008 Michael Bell <michael.bell@web.de>
+# Copyright (c) 2008 Bjoern Ricks <bjoern.ricks@googlemail.com>
+#
+# Redistribution and use is allowed according to the terms of the New
+# BSD license.
+# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
+#
+
+
+IF (GLIB2_LIBRARIES AND GLIB2_INCLUDE_DIRS )
+ # in cache already
+ SET(GLIB2_FOUND TRUE)
+ELSE (GLIB2_LIBRARIES AND GLIB2_INCLUDE_DIRS )
+
+ INCLUDE(FindPkgConfig)
+
+ ## Glib
+ IF ( GLIB2_FIND_REQUIRED )
+ SET( _pkgconfig_REQUIRED "REQUIRED" )
+ ELSE ( GLIB2_FIND_REQUIRED )
+ SET( _pkgconfig_REQUIRED "" )
+ ENDIF ( GLIB2_FIND_REQUIRED )
+
+ IF ( GLIB2_MIN_VERSION )
+ PKG_SEARCH_MODULE( GLIB2 ${_pkgconfig_REQUIRED} glib-2.0>=${GLIB2_MIN_VERSION} )
+ ELSE ( GLIB2_MIN_VERSION )
+ PKG_SEARCH_MODULE( GLIB2 ${_pkgconfig_REQUIRED} glib-2.0 )
+ ENDIF ( GLIB2_MIN_VERSION )
+ IF ( PKG_CONFIG_FOUND )
+ IF ( GLIB2_FOUND )
+ SET ( GLIB2_CORE_FOUND TRUE )
+ ELSE ( GLIB2_FOUND )
+ SET ( GLIB2_CORE_FOUND FALSE )
+ ENDIF ( GLIB2_FOUND )
+ ENDIF ( PKG_CONFIG_FOUND )
+
+ # Look for glib2 include dir and libraries w/o pkgconfig
+ IF ( NOT GLIB2_FOUND AND NOT PKG_CONFIG_FOUND )
+ FIND_PATH(
+ _glibconfig_include_DIR
+ NAMES
+ glibconfig.h
+ PATHS
+ /opt/gnome/lib64
+ /opt/gnome/lib
+ /opt/lib/
+ /opt/local/lib
+ /sw/lib/
+ /usr/lib64
+ /usr/lib
+ /usr/local/include
+ ${CMAKE_LIBRARY_PATH}
+ PATH_SUFFIXES
+ glib-2.0/include
+ )
+
+ FIND_PATH(
+ _glib2_include_DIR
+ NAMES
+ glib.h
+ PATHS
+ /opt/gnome/include
+ /opt/local/include
+ /sw/include
+ /usr/include
+ /usr/local/include
+ PATH_SUFFIXES
+ glib-2.0
+ )
+
+ #MESSAGE(STATUS "Glib headers: ${_glib2_include_DIR}")
+
+ FIND_LIBRARY(
+ _glib2_link_DIR
+ NAMES
+ glib-2.0
+ glib
+ PATHS
+ /opt/gnome/lib
+ /opt/local/lib
+ /sw/lib
+ /usr/lib
+ /usr/local/lib
+ )
+ IF ( _glib2_include_DIR AND _glib2_link_DIR )
+ SET ( _glib2_FOUND TRUE )
+ ENDIF ( _glib2_include_DIR AND _glib2_link_DIR )
+
+
+ IF ( _glib2_FOUND )
+ SET ( GLIB2_INCLUDE_DIRS ${_glib2_include_DIR} ${_glibconfig_include_DIR} )
+ SET ( GLIB2_LIBRARIES ${_glib2_link_DIR} )
+ SET ( GLIB2_CORE_FOUND TRUE )
+ ELSE ( _glib2_FOUND )
+ SET ( GLIB2_CORE_FOUND FALSE )
+ ENDIF ( _glib2_FOUND )
+
+ # Handle dependencies
+ # libintl
+ IF ( NOT LIBINTL_FOUND )
+ FIND_PATH(LIBINTL_INCLUDE_DIR
+ NAMES
+ libintl.h
+ PATHS
+ /opt/gnome/include
+ /opt/local/include
+ /sw/include
+ /usr/include
+ /usr/local/include
+ )
+
+ FIND_LIBRARY(LIBINTL_LIBRARY
+ NAMES
+ intl
+ PATHS
+ /opt/gnome/lib
+ /opt/local/lib
+ /sw/lib
+ /usr/local/lib
+ /usr/lib
+ )
+
+ IF (LIBINTL_LIBRARY AND LIBINTL_INCLUDE_DIR)
+ SET (LIBINTL_FOUND TRUE)
+ ENDIF (LIBINTL_LIBRARY AND LIBINTL_INCLUDE_DIR)
+ ENDIF ( NOT LIBINTL_FOUND )
+
+ # libiconv
+ IF ( NOT LIBICONV_FOUND )
+ FIND_PATH(LIBICONV_INCLUDE_DIR
+ NAMES
+ iconv.h
+ PATHS
+ /opt/gnome/include
+ /opt/local/include
+ /opt/local/include
+ /sw/include
+ /sw/include
+ /usr/local/include
+ /usr/include
+ PATH_SUFFIXES
+ glib-2.0
+ )
+
+ FIND_LIBRARY(LIBICONV_LIBRARY
+ NAMES
+ iconv
+ PATHS
+ /opt/gnome/lib
+ /opt/local/lib
+ /sw/lib
+ /usr/lib
+ /usr/local/lib
+ )
+
+ IF (LIBICONV_LIBRARY AND LIBICONV_INCLUDE_DIR)
+ SET (LIBICONV_FOUND TRUE)
+ ENDIF (LIBICONV_LIBRARY AND LIBICONV_INCLUDE_DIR)
+ ENDIF ( NOT LIBICONV_FOUND )
+
+ IF (LIBINTL_FOUND)
+ SET (GLIB2_LIBRARIES ${GLIB2_LIBRARIES} ${LIBINTL_LIBRARY})
+ SET (GLIB2_INCLUDE_DIRS ${GLIB2_INCLUDE_DIRS} ${LIBINTL_INCLUDE_DIR})
+ ENDIF (LIBINTL_FOUND)
+
+ IF (LIBICONV_FOUND)
+ SET (GLIB2_LIBRARIES ${GLIB2_LIBRARIES} ${LIBICONV_LIBRARY})
+ SET (GLIB2_INCLUDE_DIRS ${GLIB2_INCLUDE_DIRS} ${LIBICONV_INCLUDE_DIR})
+ ENDIF (LIBICONV_FOUND)
+
+ ENDIF ( NOT GLIB2_FOUND AND NOT PKG_CONFIG_FOUND )
+ ##
+
+ IF (GLIB2_CORE_FOUND AND GLIB2_INCLUDE_DIRS AND GLIB2_LIBRARIES)
+ SET (GLIB2_FOUND TRUE)
+ ENDIF (GLIB2_CORE_FOUND AND GLIB2_INCLUDE_DIRS AND GLIB2_LIBRARIES)
+
+ IF (GLIB2_FOUND)
+ IF (NOT GLIB2_FIND_QUIETLY)
+ MESSAGE (STATUS "Found GLib2: ${GLIB2_LIBRARIES} ${GLIB2_INCLUDE_DIRS}")
+ ENDIF (NOT GLIB2_FIND_QUIETLY)
+ ELSE (GLIB2_FOUND)
+ IF (GLIB2_FIND_REQUIRED)
+ MESSAGE (SEND_ERROR "Could not find GLib2")
+ ENDIF (GLIB2_FIND_REQUIRED)
+ ENDIF (GLIB2_FOUND)
+
+ # show the GLIB2_INCLUDE_DIRS and GLIB2_LIBRARIES variables only in the advanced view
+ MARK_AS_ADVANCED(GLIB2_INCLUDE_DIRS GLIB2_LIBRARIES)
+ MARK_AS_ADVANCED(LIBICONV_INCLUDE_DIR LIBICONV_LIBRARY)
+ MARK_AS_ADVANCED(LIBINTL_INCLUDE_DIR LIBINTL_LIBRARY)
+
+ENDIF (GLIB2_LIBRARIES AND GLIB2_INCLUDE_DIRS)
+
+IF ( GLIB2_FOUND )
+ # Check if system has a newer version of glib
+ # which supports g_regex_match_simple
+ INCLUDE( CheckIncludeFiles )
+ SET( CMAKE_REQUIRED_INCLUDES ${GLIB2_INCLUDE_DIRS} )
+ CHECK_INCLUDE_FILES ( glib/gregex.h HAVE_GLIB_GREGEX_H )
+ # Reset CMAKE_REQUIRED_INCLUDES
+ SET( CMAKE_REQUIRED_INCLUDES "" )
+ENDIF( GLIB2_FOUND )
+
@@ -0,0 +1,139 @@
+# https://gist.github.com/2025610
+
+# Find the Libnotify libraries
+
+# This module will find the libnotify library, and do some
+# sanity checking (making sure things compile, version checking,
+# dependancy checking, etc). Libnotify requires the GTK Library (GTK2 or GTK3) and glib Library (GLIB2)
+
+# This requires cmake => 2.8 to work correctly
+
+# @Author: Jacob "HACKhalo2" Litewski
+# @Version: 1.0
+# @Email: hackhalo2@precipicegames.com
+
+## DEFINE LIBNOTIFY_INCLUDE_DIR Where to find the libnotify headers
+## DEFINE LIBNOTIFY_LIBRARIES The libraries that are needed to use libnotify
+## DEFINE LIBNOTIFY_FOUND The Boolean for checking to see if libnotify was found on the system
+## DEFINE LIBNOTIFY_LIBRARY Where to find the libnotify libraries
+
+# Firstly, check to make sure that libnotify (or it's dependants) isn't already in CMake's cache
+
+## Check for GTK2 or GTK3
+if((GTK2_INCLUDE_DIR AND GTK2_LIBRARIES) OR (GTK3_INCLUDE_DIR AND GTK3_LIBRARIES))
+ set(GTK_IN_CACHE TRUE) # GTK in cache
+endif((GTK2_INCLUDE_DIR AND GTK2_LIBRARIES) OR (GTK3_INCLUDE_DIR AND GTK3_LIBRARIES))
+
+## Check for GLIB2
+if(GLIB2_INCLUDE_DIR AND GLIB2_LIBRARIES)
+ set(GLIB_IN_CACHE TRUE) # GLIB in cache
+endif(GLIB2_INCLUDE_DIR AND GLIB2_LIBRARIES)
+
+## Check for Libnotify
+if(LIBNOTIFY_INCLUDE_DIR AND LIBNOTIFY_LIBRARIES)
+ set(LIBNOTIFY_IN_CACHE TRUE) # Libnotify in cache
+endif(LIBNOTIFY_INCLUDE_DIR AND LIBNOTIFY_LIBRARIES)
+
+## Set up the paths
+find_path(LIBNOTIFY_INCLUDE_DIR notify.h
+ PATHS
+ HINTS ${PKG_LIBNOTIFY_INCLUDE_DIRS}
+ PATH_SUFFIXES libnotify
+)
+
+find_library(LIBNOTIFY_LIBRARIES notify
+ NAMES ${LIBNOTIFY_NAMES}
+)
+
+## Is Libnotify found?
+if(LIBNOTIFY_INCLUDE_DIR AND LIBNOTIFY_LIBRARIES)
+ set(LIBNOTIFY_LIBRARIES ${LIBNOTIFY_LIBRARY})
+ set(LIBNOTIFY_FOUND TRUE)
+else(LIBNOTIFY_INCLUDE_DIR AND LIBNOTIFY_LIBRARIES)
+ set(LIBNOTIFY_FOUND FALSE)
+endif(LIBNOTIFY_INCLUDE_DIR AND LIBNOTIFY_LIBRARIES)
+
+## If found, run some sanity checks, else fail out
+if(LIBNOTIFY_FOUND)
+ include(CheckCSourceCompiles)
+ if(NOT GLIB_IN_CACHE)
+ find_package(GLIB2 REQUIRED)
+ endif(NOT GLIB_IN_CACHE)
+ if(NOT GTK_IN_CACHE)
+ find_package(GTK3 QUIET)
+ if(NOT GTK3_FOUND)
+ find_package(GTK2 REQUIRED) #Require at least GTK2
+ endif(NOT GTK3_FOUND)
+ endif(NOT GTK_IN_CACHE)
+
+ #Correctly set up GTK dependancies
+ if(GTK3_FOUND)
+ set(CMAKE_REQUIRED_INCLUDES
+ ${LIBNOTIFY_INCLUDE_DIR}
+ ${GLIB2_INCLUDE_DIR}
+ ${GTK3_INCLUDE_DIRS}
+ )
+ set(CMAKE_REQUIRED_LIBRARIES
+ ${LIBNOTIFY_LIBRARIES}
+ ${GLIB2_LIBRARIES}
+ ${GTK3_LIBRARIES}
+ )
+ else(GTK3_FOUND)
+ set(CMAKE_REQUIRED_INCLUDES
+ ${LIBNOTIFY_INCLUDE_DIR}
+ ${GLIB2_INCLUDE_DIR}
+ ${GTK2_INCLUDE_DIRS}
+ )
+ set(CMAKE_REQUIRED_LIBRARIES
+ ${LIBNOTIFY_LIBRARIES}
+ ${GLIB2_LIBRARIES}
+ ${GTK2_LIBRARIES}
+ )
+ endif(GTK3_FOUND)
+
+ check_c_source_compiles("
+ #include <libnotify/notify.h>
+
+ int main() {
+ notify_notification_new('nothing', 'nothing', 'nothing', 'nothing');
+ }
+ " LIBNOTIFY_VERSION_04)
+
+ check_c_source_compiles("
+ #include <libnotify/notify.h>
+
+ int main() {
+ notify_notification_new('nothing', 'nothing', 'nothing');
+ }
+ " LIBNOTIFY_VERSION_07)
+
+ # Sanity check the above commands
+ if(NOT LIBNOTIFY_VERSION_07 AND NOT LIBNOTIFY_VERSION_04)
+ message(FATAL_ERROR "Version checking failed! Aborting")
+ endif(NOT LIBNOTIFY_VERSION_07 AND NOT LIBNOTIFY_VERSION_04)
+
+ # Reset these
+ set(CMAKE_REQUIRED_INCLUDES)
+ set(CMAKE_REQUIRED_LIBRARIES)
+
+ if(NOT LIBNOTIFY_FIND_QUIETLY)
+ if(LIBNOTIFY_VERSION_07)
+ message(STATUS "Found libnotify: '${LIBNOTIFY_LIBRARIES}' and header in '${LIBNOTIFY_INCLUDE_DIR}' version => 0.7")
+ endif(LIBNOTIFY_VERSION_07)
+ if(LIBNOTIFY_VERSION_04)
+ message(STATUS "Found libnotify: '${LIBNOTIFY_LIBRARIES}' and header in '${LIBNOTIFY_INCLUDE_DIR}' version => 0.4")
+ endif(LIBNOTIFY_VERSION_04)
+ endif(NOT LIBNOTIFY_FIND_QUIETLY)
+else(LIBNOTIFY_FOUND) # Libnotify was not found
+ if(LIBNOTIFY_FOUND_REQUIRED) # Check to see if it's required
+ MESSAGE(FATAL_ERROR "Could not find libnotify library")
+ endif(LIBNOTIFY_FOUND_REQUIRED)
+endif(LIBNOTIFY_FOUND)
+
+## Finally, set the caches (Idea taken from quassel2go)
+set(LIBNOTIFY_INCLUDE_DIR ${LIBNOTIFY_INCLUDE_DIR} CACHE INTERNAL "The libnotify include directory")
+set(LIBNOTIFY_LIBRARIES ${LIBNOTIFY_LIBRARIES} CACHE INTERNAL "The libnotify libraries")
+set(HAVE_LIBNOTIFY_0_4 ${HAVE_LIBNOTIFY_0_4} CACHE INTERNAL "Whether the version of libnotify is >= 0.4")
+set(HAVE_LIBNOTIFY_0_7 ${HAVE_LIBNOTIFY_0_7} CACHE INTERNAL "Whether the version of libnotify is >= 0.7")
+
+mark_as_advanced(LIBNOTIFY_INCLUDE_DIR LIBNOTIFY_LIBRARIES)
@@ -5,10 +5,6 @@ include_directories(
file(GLOB Sources code/*.cpp )
-if(UNIX)
- set(LINUX_LIBRARIES notify)
-endif()
-
add_executable(desura ${Sources})
target_link_libraries(desura
dl
@@ -22,7 +18,7 @@ target_link_libraries(desura
${BREAKPAD_EXCEPTION_HANDLER_LIBRARIES}
${SQLITE_LIBRARIES}
${wxWidgets_LIBRARIES}
- ${LINUX_LIBRARIES}
+ ${LIBNOTIFY_LIBRARIES}
)
install(TARGETS desura
Oops, something went wrong.

0 comments on commit ec33792

Please sign in to comment.