diff options
author | Ralf Habacker <ralf.habacker@freenet.de> | 2013-02-28 23:39:42 +0100 |
---|---|---|
committer | Ralf Habacker <ralf.habacker@freenet.de> | 2013-03-01 00:10:59 +0100 |
commit | e93b0decbeb06f897621d3f816365033dfa16a94 (patch) | |
tree | 21f783eaf0dcf83c608a0dde78728e7719f4df50 /cmake | |
parent | c57c4d281369589b636aee928238b7cf6e42e00f (diff) |
FindDBus.cmake and FindGLib2.cmake has been taken from the KDE project,
MacrosAutotools.cmake has been taken from dbus source.
pkgconfig file install is still missing
Diffstat (limited to 'cmake')
-rw-r--r-- | cmake/FindDBus.cmake | 72 | ||||
-rw-r--r-- | cmake/FindGLIB2.cmake | 52 | ||||
-rw-r--r-- | cmake/MacrosAutotools.cmake | 47 |
3 files changed, 171 insertions, 0 deletions
diff --git a/cmake/FindDBus.cmake b/cmake/FindDBus.cmake new file mode 100644 index 0000000..f227cc2 --- /dev/null +++ b/cmake/FindDBus.cmake @@ -0,0 +1,72 @@ +# - Try to find the low-level D-Bus library +# Once done this will define +# +# DBUS_FOUND - system has D-Bus +# DBUS_INCLUDE_DIR - the D-Bus include directory +# DBUS_ARCH_INCLUDE_DIR - the D-Bus architecture-specific include directory +# DBUS_LIBRARIES - the libraries needed to use D-Bus + +# Copyright (c) 2008, Kevin Kofler, <kevin.kofler@chello.at> +# modeled after FindLibArt.cmake: +# Copyright (c) 2006, Alexander Neundorf, <neundorf@kde.org> +# +# Redistribution and use is allowed according to the terms of the BSD license. +# For details see the accompanying COPYING-CMAKE-SCRIPTS file. + +if (DBUS_INCLUDE_DIR AND DBUS_ARCH_INCLUDE_DIR AND DBUS_LIBRARIES) + + # in cache already + SET(DBUS_FOUND TRUE) + +else (DBUS_INCLUDE_DIR AND DBUS_ARCH_INCLUDE_DIR AND DBUS_LIBRARIES) + + IF (NOT WIN32) + FIND_PACKAGE(PkgConfig) + IF (PKG_CONFIG_FOUND) + # use pkg-config to get the directories and then use these values + # in the FIND_PATH() and FIND_LIBRARY() calls + pkg_check_modules(_DBUS_PC QUIET dbus-1) + ENDIF (PKG_CONFIG_FOUND) + ENDIF (NOT WIN32) + + FIND_PATH(DBUS_INCLUDE_DIR dbus/dbus.h + ${_DBUS_PC_INCLUDE_DIRS} + /usr/include + /usr/include/dbus-1.0 + /usr/local/include + ) + + FIND_PATH(DBUS_ARCH_INCLUDE_DIR dbus/dbus-arch-deps.h + ${_DBUS_PC_INCLUDE_DIRS} + /usr/lib${LIB_SUFFIX}/include + /usr/lib${LIB_SUFFIX}/dbus-1.0/include + /usr/lib64/include + /usr/lib64/dbus-1.0/include + /usr/lib/include + /usr/lib/dbus-1.0/include + ) + + FIND_LIBRARY(DBUS_LIBRARIES NAMES dbus-1 dbus + PATHS + ${_DBUS_PC_LIBDIR} + ) + + + if (DBUS_INCLUDE_DIR AND DBUS_ARCH_INCLUDE_DIR AND DBUS_LIBRARIES) + set(DBUS_FOUND TRUE) + endif (DBUS_INCLUDE_DIR AND DBUS_ARCH_INCLUDE_DIR AND DBUS_LIBRARIES) + + + if (DBUS_FOUND) + if (NOT DBus_FIND_QUIETLY) + message(STATUS "Found D-Bus: ${DBUS_LIBRARIES}") + endif (NOT DBus_FIND_QUIETLY) + else (DBUS_FOUND) + if (DBus_FIND_REQUIRED) + message(FATAL_ERROR "Could NOT find D-Bus") + endif (DBus_FIND_REQUIRED) + endif (DBUS_FOUND) + + MARK_AS_ADVANCED(DBUS_INCLUDE_DIR DBUS_ARCH_INCLUDE_DIR DBUS_LIBRARIES) + +endif (DBUS_INCLUDE_DIR AND DBUS_ARCH_INCLUDE_DIR AND DBUS_LIBRARIES) diff --git a/cmake/FindGLIB2.cmake b/cmake/FindGLIB2.cmake new file mode 100644 index 0000000..09fd98d --- /dev/null +++ b/cmake/FindGLIB2.cmake @@ -0,0 +1,52 @@ +# - Try to find the GLIB2 libraries +# Once done this will define +# +# GLIB2_FOUND - system has glib2 +# GLIB2_INCLUDE_DIR - the glib2 include directory +# GLIB2_LIBRARIES - glib2 library + +# Copyright (c) 2008 Laurent Montel, <montel@kde.org> +# +# Redistribution and use is allowed according to the terms of the BSD license. +# For details see the accompanying COPYING-CMAKE-SCRIPTS file. + + +if(GLIB2_INCLUDE_DIR AND GLIB2_LIBRARIES) + # Already in cache, be silent + set(GLIB2_FIND_QUIETLY TRUE) +endif(GLIB2_INCLUDE_DIR AND GLIB2_LIBRARIES) + +find_package(PkgConfig) +pkg_check_modules(PC_LibGLIB2 QUIET glib-2.0) + +find_path(GLIB2_MAIN_INCLUDE_DIR + NAMES glib.h + HINTS ${PC_LibGLIB2_INCLUDEDIR} + PATH_SUFFIXES glib-2.0) + +find_library(GLIB2_LIBRARY + NAMES glib-2.0 + HINTS ${PC_LibGLIB2_LIBDIR} +) + +set(GLIB2_LIBRARIES ${GLIB2_LIBRARY}) + +# search the glibconfig.h include dir under the same root where the library is found +get_filename_component(glib2LibDir "${GLIB2_LIBRARIES}" PATH) + +find_path(GLIB2_INTERNAL_INCLUDE_DIR glibconfig.h + PATH_SUFFIXES glib-2.0/include + HINTS ${PC_LibGLIB2_INCLUDEDIR} "${glib2LibDir}" ${CMAKE_SYSTEM_LIBRARY_PATH}) + +set(GLIB2_INCLUDE_DIR "${GLIB2_MAIN_INCLUDE_DIR}") + +# not sure if this include dir is optional or required +# for now it is optional +if(GLIB2_INTERNAL_INCLUDE_DIR) + set(GLIB2_INCLUDE_DIR ${GLIB2_INCLUDE_DIR} "${GLIB2_INTERNAL_INCLUDE_DIR}") +endif(GLIB2_INTERNAL_INCLUDE_DIR) + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(GLIB2 DEFAULT_MSG GLIB2_LIBRARIES GLIB2_MAIN_INCLUDE_DIR) + +mark_as_advanced(GLIB2_INCLUDE_DIR GLIB2_LIBRARIES) diff --git a/cmake/MacrosAutotools.cmake b/cmake/MacrosAutotools.cmake new file mode 100644 index 0000000..08c95d1 --- /dev/null +++ b/cmake/MacrosAutotools.cmake @@ -0,0 +1,47 @@ +# +# @Author Ralf Habacker +# +# extracts version information from autoconf config file +# and set related cmake variables +# +# returns +# ${prefix}_VERSION +# ${prefix}_VERSION_STRING +# ${prefix}_MAJOR_VERSION +# ${prefix}_MINOR_VERSION +# ${prefix}_MICRO_VERSION +# +macro(autoversion config prefix) + file (READ ${config} _configure_ac) + string(TOUPPER ${prefix} prefix_upper) + string (REGEX REPLACE ".*${prefix}_major_version[]]*,[ ]*([0-9]+).*" "\\1" ${prefix_upper}_MAJOR_VERSION ${_configure_ac}) + string (REGEX REPLACE ".*${prefix}_minor_version[]]*,[ ]*([0-9]+).*" "\\1" ${prefix_upper}_MINOR_VERSION ${_configure_ac}) + string (REGEX REPLACE ".*${prefix}_micro_version[]]*,[ ]*([0-9]+).*" "\\1" ${prefix_upper}_MICRO_VERSION ${_configure_ac}) + set (${prefix_upper}_VERSION ${${prefix_upper}_MAJOR_VERSION}.${${prefix_upper}_MINOR_VERSION}.${${prefix_upper}_MICRO_VERSION}) + set (${prefix_upper}_VERSION_STRING "${${prefix_upper}_VERSION}") + +endmacro() + +# +# parses config.h template and create cmake equivalent +# not implemented yet +# +macro(autoconfig template output) + file(READ ${template} contents) + # Convert file contents into a CMake list (where each element in the list + # is one line of the file) + STRING(REGEX REPLACE ";" "\\\\;" contents "${contents}") + STRING(REGEX REPLACE "\n" ";" contents "${contents}") + #message(STATUS ${contents}) + foreach(line ${contents}) + if(line MATCHES "#undef HAVE") + STRING(REGEX REPLACE "#undef (.*)$" "#cmakedefine \\1 @\\1@" line "${line}") + elseif(line MATCHES "#undef") + STRING(REGEX REPLACE "#undef (.*)$" "#cmakedefine \\1 \"@\\1@\"" line "${line}") + endif() + #message(STATUS ${line}) + # append to config.h #define <variable-name> <variable-content> + set(outlines "${outlines}\n${line}") + endforeach() + file(WRITE ${output} ${outlines}) +endmacro() |