summaryrefslogtreecommitdiff
path: root/cmake
diff options
context:
space:
mode:
Diffstat (limited to 'cmake')
-rw-r--r--cmake/Modules/AutoArgs.cmake39
-rwxr-xr-xcmake/Modules/FindGcryptConfig.cmake241
-rw-r--r--cmake/Modules/GeneratePackage.cmake75
-rwxr-xr-xcmake/Modules/LibFindMacros.cmake99
-rwxr-xr-xcmake/Modules/SourceDistribution.cmake218
-rw-r--r--cmake/Modules/UseRPMTools.cmake177
-rw-r--r--cmake/cmake_uninstall.cmake.in20
7 files changed, 869 insertions, 0 deletions
diff --git a/cmake/Modules/AutoArgs.cmake b/cmake/Modules/AutoArgs.cmake
new file mode 100644
index 0000000..6f2ce54
--- /dev/null
+++ b/cmake/Modules/AutoArgs.cmake
@@ -0,0 +1,39 @@
+macro (enable_arg _enable_name _enable_default)
+if (${ARGC} GREATER 2)
+ set(_auto_arg_help
+ ${_AUTO_ARG_HELP}
+ "-Denable-${_enable_name}=[true|false] -- ${ARGV2} (default: ${_enable_default})"
+ )
+endif()
+
+if(NOT DEFINED enable-${_enable_name} AND NOT DEFINED disable-${_enable_name})
+ set(enable_${_enable_name} ${_enable_default})
+elseif(DEFINED enable-${_enable_name})
+ if(enable-${_enable_name})
+ set(enable_${_enable_name} true)
+ else()
+ set(enable_${_enable_name} false)
+ endif()
+ unset(enable-${_enable_name})
+ unset(enable-${_enable_name} CACHE)
+elseif(DEFINED disable-${_enable_name})
+ if(disable-${_enable_name})
+ set(enable_${_enable_name} false)
+ else()
+ set(enable_${_enable_name} true)
+ endif()
+ unset(disable-${_enable_name})
+ unset(disable-${_enable_name} CACHE)
+endif()
+endmacro()
+
+macro(args_help)
+if(DEFINED help-args)
+ message("Control arguments:")
+ foreach(_args_help ${_AUTO_ARG_HELP})
+ message(${_args_help})
+ endforeach()
+ unset(help-args)
+ unset(help-args CACHE)
+endif()
+endmacro()
diff --git a/cmake/Modules/FindGcryptConfig.cmake b/cmake/Modules/FindGcryptConfig.cmake
new file mode 100755
index 0000000..1770241
--- /dev/null
+++ b/cmake/Modules/FindGcryptConfig.cmake
@@ -0,0 +1,241 @@
+# - a gcrypt-config module for CMake
+#
+# Usage:
+# gcrypt_check(<PREFIX> [REQUIRED] <MODULE>)
+# checks if gcrypt is avialable
+#
+# When the 'REQUIRED' argument was set, macros will fail with an error
+# when gcrypt could not be found.
+#
+# It sets the following variables:
+# GCRYPT_CONFIG_FOUND ... true if libgcrypt-config works on the system
+# GCRYPT_CONFIG_EXECUTABLE ... pathname of the libgcrypt-config program
+# <PREFIX>_FOUND ... set to 1 if libgcrypt exist
+# <PREFIX>_LIBRARIES ... the libraries
+# <PREFIX>_CFLAGS ... all required cflags
+# <PREFIX>_ALGORITHMS ... the algorithms that this libgcrypt supports
+# <PREFIX>_VERSION ... gcrypt's version
+#
+# Examples:
+# gcrypt_check (GCRYPT gcrypt)
+# Check if a version of gcrypt is available, issues a warning
+# if not.
+#
+# gcrypt_check (GCRYPT REQUIRED gcrypt)
+# Check if a version of gcrypt is available and fails
+# if not.
+#
+# gcrypt_check (GCRYPT gcrypt>=1.4)
+# requires at least version 1.4 of gcrypt and defines e.g.
+# GCRYPT_VERSION=1.4.4. Issues a warning if a lower version
+# is available only.
+#
+# gcrypt_check (GCRYPT REQUIRED gcrypt>=1.4.4)
+# requires at least version 1.4.4 of gcrypt and fails if
+# only gcrypt 1.4.3 or lower is available only.
+#
+
+# Copyright (C) 2010 Werner Dittmann <werner.dittmann@t-online.de>
+#
+# Redistribution and use, with or without modification, are permitted
+# provided that the following conditions are met:
+#
+# 1. Redistributions must retain the above copyright notice, this
+# list of conditions and the following disclaimer.
+# 2. The name of the author may not be used to endorse or promote
+# products derived from this software without specific prior
+# written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+# GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
+# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+# IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#
+# This is a much edited and simplified variant of the original UsePkgConfig.cmake
+# from Enrico Scholz
+# Copyright (C) 2006 Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
+#
+
+### Common stuff ####
+set(GCR_CONFIG_VERSION 1)
+set(GCR_CONFIG_FOUND 0)
+
+find_program(GCR_CONFIG_EXECUTABLE NAMES libgcrypt-config --version DOC "libgcrypt-config executable")
+mark_as_advanced(GCR_CONFIG_EXECUTABLE)
+
+if(GCR_CONFIG_EXECUTABLE)
+ set(GCR_CONFIG_FOUND 1)
+endif(GCR_CONFIG_EXECUTABLE)
+
+
+# Unsets the given variables
+macro(_gcrconfig_unset var)
+ set(${var} "" CACHE INTERNAL "")
+endmacro(_gcrconfig_unset)
+
+macro(_gcrconfig_set var value)
+ set(${var} ${value} CACHE INTERNAL "")
+endmacro(_gcrconfig_set)
+
+# Invokes libgcrypt-config, cleans up the result and sets variables
+macro(_gcrconfig_invoke _gcrlist _prefix _varname _regexp)
+ set(_gcrconfig_invoke_result)
+
+ execute_process(
+ COMMAND ${GCR_CONFIG_EXECUTABLE} ${ARGN}
+ OUTPUT_VARIABLE _gcrconfig_invoke_result
+ RESULT_VARIABLE _gcrconfig_failed)
+
+ if (_gcrconfig_failed)
+ set(_gcrconfig_${_varname} "")
+ _gcrconfig_unset(${_prefix}_${_varname})
+ else(_gcrconfig_failed)
+ string(REGEX REPLACE "[\r\n]" " " _gcrconfig_invoke_result "${_gcrconfig_invoke_result}")
+ string(REGEX REPLACE " +$" "" _gcrconfig_invoke_result "${_gcrconfig_invoke_result}")
+
+ if (NOT ${_regexp} STREQUAL "")
+ string(REGEX REPLACE "${_regexp}" " " _gcrconfig_invoke_result "${_gcrconfig_invoke_result}")
+ endif(NOT ${_regexp} STREQUAL "")
+
+ separate_arguments(_gcrconfig_invoke_result)
+
+ #message(STATUS " ${_varname} ... ${_gcrconfig_invoke_result}")
+ set(_gcrconfig_${_varname} ${_gcrconfig_invoke_result})
+ _gcrconfig_set(${_prefix}_${_varname} "${_gcrconfig_invoke_result}")
+ endif(_gcrconfig_failed)
+endmacro(_gcrconfig_invoke)
+
+macro(_gcrconfig_invoke_dyn _gcrlist _prefix _varname cleanup_regexp)
+ _gcrconfig_invoke("${_gcrlist}" ${_prefix} ${_varname} "${cleanup_regexp}" ${ARGN})
+endmacro(_gcrconfig_invoke_dyn)
+
+# Splits given arguments into options and a package list
+macro(_gcrconfig_parse_options _result _is_req)
+ set(${_is_req} 0)
+
+ foreach(_gcr ${ARGN})
+ if (_gcr STREQUAL "REQUIRED")
+ set(${_is_req} 1)
+ endif (_gcr STREQUAL "REQUIRED")
+ endforeach(_gcr ${ARGN})
+
+ set(${_result} ${ARGN})
+ list(REMOVE_ITEM ${_result} "REQUIRED")
+endmacro(_gcrconfig_parse_options)
+
+###
+macro(_gcr_check_modules_internal _is_required _is_silent _prefix)
+ _gcrconfig_unset(${_prefix}_FOUND)
+ _gcrconfig_unset(${_prefix}_VERSION)
+ _gcrconfig_unset(${_prefix}_PREFIX)
+ _gcrconfig_unset(${_prefix}_LIBDIR)
+ _gcrconfig_unset(${_prefix}_LIBRARIES)
+ _gcrconfig_unset(${_prefix}_CFLAGS)
+ _gcrconfig_unset(${_prefix}_ALGORITHMS)
+
+ # create a better addressable variable of the modules and calculate its size
+ set(_gcr_check_modules_list ${ARGN})
+ list(LENGTH _gcr_check_modules_list _gcr_check_modules_cnt)
+
+ if(GCR_CONFIG_EXECUTABLE)
+ # give out status message telling checked module
+ if (NOT ${_is_silent})
+ message(STATUS "checking for module '${_gcr_check_modules_list}'")
+ endif(NOT ${_is_silent})
+
+ # iterate through module list and check whether they exist and match the required version
+ foreach (_gcr_check_modules_gcr ${_gcr_check_modules_list})
+
+ # check whether version is given
+ if (_gcr_check_modules_gcr MATCHES ".*(>=|=|<=).*")
+ string(REGEX REPLACE "(.*[^><])(>=|=|<=)(.*)" "\\1" _gcr_check_modules_gcr_name "${_gcr_check_modules_gcr}")
+ string(REGEX REPLACE "(.*[^><])(>=|=|<=)(.*)" "\\2" _gcr_check_modules_gcr_op "${_gcr_check_modules_gcr}")
+ string(REGEX REPLACE "(.*[^><])(>=|=|<=)(.*)" "\\3" _gcr_check_modules_gcr_ver "${_gcr_check_modules_gcr}")
+ else(_gcr_check_modules_gcr MATCHES ".*(>=|=|<=).*")
+ set(_gcr_check_modules_gcr_name "${_gcr_check_modules_gcr}")
+ set(_gcr_check_modules_gcr_op)
+ set(_gcr_check_modules_gcr_ver)
+ endif(_gcr_check_modules_gcr MATCHES ".*(>=|=|<=).*")
+
+ set(_gcr_check_prefix "${_prefix}")
+
+ _gcrconfig_invoke(${_gcr_check_modules_gcr_name} "${_gcr_check_prefix}" VERSION "" --version )
+# _gcrconfig_invoke(${_gcr_check_modules_gcr_name} "${_gcr_check_prefix}" PREFIX "" --prefix )
+ _gcrconfig_invoke(${_gcr_check_modules_gcr_name} "${_gcr_check_prefix}" LIBRARIES "" --libs )
+ _gcrconfig_invoke(${_gcr_check_modules_gcr_name} "${_gcr_check_prefix}" CFLAGS "" --cflags )
+ _gcrconfig_invoke(${_gcr_check_modules_gcr_name} "${_gcr_check_prefix}" ALGORITHMS "" --algorithms )
+
+ message(STATUS " found ${_gcr_check_modules_gcr}, version ${_gcrconfig_VERSION}")
+ # handle the operands
+ set(_gcr_wrong_version 0)
+ if (_gcr_check_modules_gcr_op STREQUAL ">=")
+ if(_gcr_check_modules_gcr_ver VERSION_EQUAL _gcrconfig_VERSION)
+ message(STATUS " gcrypt wrong version: required: ${_gcr_check_modules_gcr_op}${_gcr_check_modules_gcr_ver}, found: ${_gcrconfig_VERSION}")
+ set(_gcr_wrong_version 1)
+ endif()
+
+ if(_gcrconfig_VERSION VERSION_LESS _gcr_check_modules_gcr_ver )
+ message(STATUS " gcrypt wrong version: required: ${_gcr_check_modules_gcr_op}${_gcr_check_modules_gcr_ver}, found: ${_gcrconfig_VERSION}")
+ set(_gcr_wrong_version 1)
+ endif()
+ endif(_gcr_check_modules_gcr_op STREQUAL ">=")
+
+ if (_gcr_check_modules_gcr_op STREQUAL "=")
+ if(_gcr_check_modules_gcr_ver VERSION_EQUAL _gcrconfig_VERSION)
+ message(STATUS " gcrypt wrong version: required: ${_gcr_check_modules_gcr_op}${_gcr_check_modules_gcr_ver}, found: ${_gcrconfig_VERSION}")
+ set(_gcr_wrong_version 1)
+ endif()
+ endif(_gcr_check_modules_gcr_op STREQUAL "=")
+
+ if (_gcr_check_modules_gcr_op STREQUAL "<=")
+ if(_gcr_check_modules_gcr_ver VERSION_EQUAL _gcrconfig_VERSION)
+ message(STATUS " gcrypt wrong version: required: ${_gcr_check_modules_gcr_op}${_gcr_check_modules_gcr_ver}, found: ${_gcrconfig_VERSION}")
+ set(_gcr_wrong_version 1)
+ endif()
+
+ if(_gcrconfig_VERSION VERSION_GREATER _gcr_check_modules_gcr_ver)
+ message(STATUS " gcrypt wrong version: required: ${_gcr_check_modules_gcr_op}${_gcr_check_modules_gcr_ver}, found: ${_gcrconfig_VERSION}")
+ set(_gcr_wrong_version 1)
+ endif()
+ endif(_gcr_check_modules_gcr_op STREQUAL "<=")
+ if (${_is_required} AND _gcr_wrong_version)
+ message(FATAL_ERROR "")
+ endif()
+
+ endforeach(_gcr_check_modules_gcr)
+ _gcrconfig_set(${_prefix}_FOUND 1)
+
+ else(GCR_CONFIG_EXECUTABLE)
+ if (${_is_required})
+ message(FATAL_ERROR "libgcrypt-config tool not found")
+ endif (${_is_required})
+ endif(GCR_CONFIG_EXECUTABLE)
+endmacro(_gcr_check_modules_internal)
+
+###
+### User visible macro starts here
+###
+
+###
+macro(gcr_check _prefix _module0)
+ # check cached value
+ if (NOT DEFINED __gcr_config_checked_${_prefix} OR __gcr_config_checked_${_prefix} LESS ${GCR_CONFIG_VERSION} OR NOT ${_prefix}_FOUND)
+ _gcrconfig_parse_options (_gcr_modules _gcr_is_required "${_module0}" ${ARGN})
+ _gcr_check_modules_internal("${_gcr_is_required}" 0 "${_prefix}" ${_gcr_modules})
+
+ _gcrconfig_set(__gcr_config_checked_${_prefix} ${GCR_CONFIG_VERSION})
+ endif(NOT DEFINED __gcr_config_checked_${_prefix} OR __gcr_config_checked_${_prefix} LESS ${GCR_CONFIG_VERSION} OR NOT ${_prefix}_FOUND)
+endmacro(gcr_check)
+
+###
+
+### Local Variables:
+### mode: cmake
+### End:
diff --git a/cmake/Modules/GeneratePackage.cmake b/cmake/Modules/GeneratePackage.cmake
new file mode 100644
index 0000000..43a3d11
--- /dev/null
+++ b/cmake/Modules/GeneratePackage.cmake
@@ -0,0 +1,75 @@
+
+MACRO(GENERATE_PACKAGING PACKAGE VERSION)
+
+ # The following components are regex's to match anywhere (unless anchored)
+ # in absolute path + filename to find files or directories to be excluded
+ # from source tarball.
+ SET (CPACK_SOURCE_IGNORE_FILES
+ #svn files
+ "\\\\.svn/"
+ "\\\\.cvsignore$"
+ # temporary files
+ "\\\\.swp$"
+ # backup files
+ "~$"
+ # eclipse files
+ "\\\\.cdtproject$"
+ "\\\\.cproject$"
+ "\\\\.project$"
+ "\\\\.settings/"
+ "\\\\.kdev4/"
+ "\\\\.kdev4$"
+ "\\\\.kdev4_include_paths$"
+ # others
+ "\\\\.#"
+ "/#"
+ "/build/"
+ "/autom4te\\\\.cache/"
+ "/_build/"
+ "/doc/html/"
+ "/\\\\.git/"
+ # used before
+ "/CVS/"
+ "/\\\\.libs/"
+ "/\\\\.deps/"
+ "\\\\.o$"
+ "\\\\.lo$"
+ "\\\\.la$"
+ "\\\\.sh$"
+ "Makefile\\\\.in$"
+ )
+
+ SET(CPACK_PACKAGE_VENDOR "Werner Dittmann")
+ #SET(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/ReadMe.txt")
+ #SET(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/Copyright.txt")
+ #SET(CPACK_PACKAGE_VERSION_MAJOR ${version_major})
+ #SET(CPACK_PACKAGE_VERSION_MINOR ${version_minor})
+ #SET(CPACK_PACKAGE_VERSION_PATCH ${version_patch})
+ SET( CPACK_GENERATOR "TBZ2")
+ SET( CPACK_SOURCE_GENERATOR "TBZ2")
+ SET( CPACK_SOURCE_PACKAGE_FILE_NAME "${PACKAGE}-${VERSION}" )
+ INCLUDE(CPack)
+
+# SPECFILE()
+
+ ADD_CUSTOM_TARGET( svncheck
+ COMMAND cd $(CMAKE_SOURCE_DIR) && LC_ALL=C git status | grep -q "nothing to commit .working directory clean."
+ )
+
+ SET( AUTOBUILD_COMMAND
+ COMMAND ${CMAKE_COMMAND} -E remove ${CMAKE_BINARY_DIR}/package/*.tar.bz2
+ COMMAND ${CMAKE_MAKE_PROGRAM} package_source
+ COMMAND ${CMAKE_COMMAND} -E copy ${CPACK_SOURCE_PACKAGE_FILE_NAME}.tar.bz2 ${CMAKE_BINARY_DIR}/package
+ COMMAND ${CMAKE_COMMAND} -E remove ${CPACK_SOURCE_PACKAGE_FILE_NAME}.tar.bz2
+# COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_SOURCE_DIR}/package/${PACKAGE}.changes" "${CMAKE_BINARY_DIR}/package/${PACKAGE}.changes"
+ )
+
+ ADD_CUSTOM_TARGET( srcpackage_local
+ ${AUTOBUILD_COMMAND}
+ )
+
+ ADD_CUSTOM_TARGET( srcpackage
+ COMMAND ${CMAKE_MAKE_PROGRAM} svncheck
+ ${AUTOBUILD_COMMAND}
+ )
+ENDMACRO(GENERATE_PACKAGING)
diff --git a/cmake/Modules/LibFindMacros.cmake b/cmake/Modules/LibFindMacros.cmake
new file mode 100755
index 0000000..69975c5
--- /dev/null
+++ b/cmake/Modules/LibFindMacros.cmake
@@ -0,0 +1,99 @@
+# Works the same as find_package, but forwards the "REQUIRED" and "QUIET" arguments
+# used for the current package. For this to work, the first parameter must be the
+# prefix of the current package, then the prefix of the new package etc, which are
+# passed to find_package.
+macro (libfind_package PREFIX)
+ set (LIBFIND_PACKAGE_ARGS ${ARGN})
+ if (${PREFIX}_FIND_QUIETLY)
+ set (LIBFIND_PACKAGE_ARGS ${LIBFIND_PACKAGE_ARGS} QUIET)
+ endif (${PREFIX}_FIND_QUIETLY)
+ if (${PREFIX}_FIND_REQUIRED)
+ set (LIBFIND_PACKAGE_ARGS ${LIBFIND_PACKAGE_ARGS} REQUIRED)
+ endif (${PREFIX}_FIND_REQUIRED)
+ find_package(${LIBFIND_PACKAGE_ARGS})
+endmacro (libfind_package)
+
+# CMake developers made the UsePkgConfig system deprecated in the same release (2.6)
+# where they added pkg_check_modules. Consequently I need to support both in my scripts
+# to avoid those deprecated warnings. Here's a helper that does just that.
+# Works identically to pkg_check_modules, except that no checks are needed prior to use.
+macro (libfind_pkg_check_modules PREFIX PKGNAME)
+ if (${CMAKE_MAJOR_VERSION} EQUAL 2 AND ${CMAKE_MINOR_VERSION} EQUAL 4)
+ include(UsePkgConfig)
+ pkgconfig(${PKGNAME} ${PREFIX}_INCLUDE_DIRS ${PREFIX}_LIBRARY_DIRS ${PREFIX}_LDFLAGS ${PREFIX}_CFLAGS)
+ else (${CMAKE_MAJOR_VERSION} EQUAL 2 AND ${CMAKE_MINOR_VERSION} EQUAL 4)
+ find_package(PkgConfig)
+ if (PKG_CONFIG_FOUND)
+ pkg_check_modules(${PREFIX} ${PKGNAME})
+ endif (PKG_CONFIG_FOUND)
+ endif (${CMAKE_MAJOR_VERSION} EQUAL 2 AND ${CMAKE_MINOR_VERSION} EQUAL 4)
+endmacro (libfind_pkg_check_modules)
+
+# Do the final processing once the paths have been detected.
+# If include dirs are needed, ${PREFIX}_PROCESS_INCLUDES should be set to contain
+# all the variables, each of which contain one include directory.
+# Ditto for ${PREFIX}_PROCESS_LIBS and library files.
+# Will set ${PREFIX}_FOUND, ${PREFIX}_INCLUDE_DIRS and ${PREFIX}_LIBRARIES.
+# Also handles errors in case library detection was required, etc.
+macro (libfind_process PREFIX)
+ # Skip processing if already processed during this run
+ if (NOT ${PREFIX}_FOUND)
+ # Start with the assumption that the library was found
+ set (${PREFIX}_FOUND TRUE)
+
+ # Process all includes and set _FOUND to false if any are missing
+ foreach (i ${${PREFIX}_PROCESS_INCLUDES})
+ if (${i})
+ set (${PREFIX}_INCLUDE_DIRS ${${PREFIX}_INCLUDE_DIRS} ${${i}})
+ mark_as_advanced(${i})
+ else (${i})
+ set (${PREFIX}_FOUND FALSE)
+ endif (${i})
+ endforeach (i)
+
+ # Process all libraries and set _FOUND to false if any are missing
+ foreach (i ${${PREFIX}_PROCESS_LIBS})
+ if (${i})
+ set (${PREFIX}_LIBRARIES ${${PREFIX}_LIBRARIES} ${${i}})
+ mark_as_advanced(${i})
+ else (${i})
+ set (${PREFIX}_FOUND FALSE)
+ endif (${i})
+ endforeach (i)
+
+ # Print message and/or exit on fatal error
+ if (${PREFIX}_FOUND)
+ if (NOT ${PREFIX}_FIND_QUIETLY)
+ message (STATUS "Found ${PREFIX} ${${PREFIX}_VERSION}")
+ endif (NOT ${PREFIX}_FIND_QUIETLY)
+ else (${PREFIX}_FOUND)
+ if (${PREFIX}_FIND_REQUIRED)
+ foreach (i ${${PREFIX}_PROCESS_INCLUDES} ${${PREFIX}_PROCESS_LIBS})
+ message("${i}=${${i}}")
+ endforeach (i)
+ message (FATAL_ERROR "Required library ${PREFIX} NOT FOUND.\nInstall the library (dev version) and try again. If the library is already installed, use ccmake to set the missing variables manually.")
+ endif (${PREFIX}_FIND_REQUIRED)
+ endif (${PREFIX}_FOUND)
+ endif (NOT ${PREFIX}_FOUND)
+endmacro (libfind_process)
+
+macro(libfind_library PREFIX basename)
+ set(TMP "")
+ if(MSVC80)
+ set(TMP -vc80)
+ endif(MSVC80)
+ if(MSVC90)
+ set(TMP -vc90)
+ endif(MSVC90)
+ set(${PREFIX}_LIBNAMES ${basename}${TMP})
+ if(${ARGC} GREATER 2)
+ set(${PREFIX}_LIBNAMES ${basename}${TMP}-${ARGV2})
+ string(REGEX REPLACE "\\." "_" TMP ${${PREFIX}_LIBNAMES})
+ set(${PREFIX}_LIBNAMES ${${PREFIX}_LIBNAMES} ${TMP})
+ endif(${ARGC} GREATER 2)
+ find_library(${PREFIX}_LIBRARY
+ NAMES ${${PREFIX}_LIBNAMES}
+ PATHS ${${PREFIX}_PKGCONF_LIBRARY_DIRS}
+ )
+endmacro(libfind_library)
+
diff --git a/cmake/Modules/SourceDistribution.cmake b/cmake/Modules/SourceDistribution.cmake
new file mode 100755
index 0000000..c4dae25
--- /dev/null
+++ b/cmake/Modules/SourceDistribution.cmake
@@ -0,0 +1,218 @@
+# - a CMake module that helps to create a source distribution
+#
+# This module provide some macros that setup a source distribution.
+# In contrast to standard CPack processing this is a very lightweight
+# module that works very fast. The source distribution module enables
+# the Cmake user to add indivdiual files and directories and thus
+# provides a more fine grained control than CPack.
+#
+# The module works similar to the standard CMake INSTALL command: the
+# macros of this module prepare CMake files (cmake_src_dist.cmake) that
+# contain all necessary commands to create the distribution directoy.
+# The make target 'src_dist' executes the commands and builds the
+# compressed tar file of the source distribution.
+#
+# Usage:
+# src_distribution_init([NOT_INCLUDE_DEFAULT] [<distribtuion name>])
+# Initializes the source distribution functions. Each CMakeList.txt
+# that distributes sources must call this macro before it can use
+# other source distrbution macros.
+# Only the first call from the top level CMakeLists.txt uses the
+# distribution name argument. All subsequent call silently ignore it.
+# The macro sets the distribution name to ${PROJECT_NAME}-{VERSION}
+# if no distribution name is provided.
+# The macro automatically includes some default files and directories
+# into the distribution: CMakeLists.txt and the cmake directory.
+# Set NOT_INCLUDE_DEFAULT to disable this function.
+# The macro creates a make target 'src_dist'. This target executes
+# all operations to create the distribution directory structure and
+# to create the compressed tar file <distrbution name>.tar.gz. The
+# source distribution directory can be deleted afterwards.
+#
+# add_src_dist_dirs(<DIRECTORY> [<DIRECTORY>]*)
+# Works imilar to the normal add_subdirectory command of CMake.
+# This call adds a subdirectory that contains sources or other
+# files that go into a source distribution. The subdirecty must
+# contain a CMakeLists.txt file that also uses the source distrbution
+# macros.
+#
+# add_src_dist_files(<FILENAME> [<FILENAME>]*)
+# Adds one or more files to the source distrbution.
+#
+# Eaxample:
+#
+# include(SourceDistrbution)
+#
+# The following call initializes the module and sets the distrbution's
+# name to 'mySourceDist'. The macro creates a directory with this name
+# in the current build directory and include the standard CMakeLists.txt
+# file and the 'cmake' directory (it it exists) into the distribution.
+#
+# src_distribution_init(mySourceDist)
+#
+# Now add some files (assumes ${src_files} was set previously):
+# add_src_dist_files(README LICENSE ${src_files})
+#
+# Now add a subdirectoy, in this case an include directory:
+# add_src_dist_dirs(include)
+#
+#
+# ---- internal macros ----
+#
+# This macro gets the current directory relative to CMAKE_SOURCE_DIR
+# and sets an internal variable to the current distribution directory.
+# Another variable holds the current path to the CMake command file.
+# Other macros use these variable to construct commands
+# to build the distribution structure.
+#
+MACRO (_set_src_dist_scope_vars)
+STRING(REPLACE "${CMAKE_SOURCE_DIR}" "" _src_dist_subdir "${CMAKE_CURRENT_SOURCE_DIR}")
+if (NOT _src_dist_subdir)
+ set(_src_dist_fulldir ${SRC_DIST_DIR})
+else()
+ set(_src_dist_fulldir ${SRC_DIST_DIR}${_src_dist_subdir})
+endif()
+set(_src_dist_cmd_file_path ${CMAKE_CURRENT_BINARY_DIR}/${_SRC_DIST_CMD_FILE_NAME})
+ENDMACRO()
+
+#
+# Check for the NOT_INCLUDE_DEFAULT option.
+#
+MACRO(_src_dist_parse_options _result _default _length)
+ set(${_default} TRUE)
+
+ foreach(_arg ${ARGN})
+ if (_arg STREQUAL "NOT_INCLUDE_DEFAULT")
+ set(${_default} FALSE)
+ endif()
+ endforeach()
+
+ set(${_result} ${ARGN})
+ list(LENGTH ${_result} ${_length})
+ if (${_length} GREATER 0)
+ list(REMOVE_ITEM ${_result} "NOT_INCLUDE_DEFAULT")
+ endif()
+ # recompute length of list
+ list(LENGTH ${_result} ${_length})
+
+ENDMACRO()
+
+
+#
+# This macro initializes the source distribution package.
+# Only the top-level initialization macro init_src_distribution()
+# calls this internal macro.
+#
+MACRO (_src_dist_internal_init)
+# internal variable for distribution cmake file
+set(_SRC_DIST_CMD_FILE_NAME "cmake_src_dist.cmake")
+
+if (${_src_dist_dirlist_length} EQUAL 0)
+ set(_src_dist_tardir ${PROJECT_NAME}-${VERSION})
+else()
+ list(GET _src_dist_dirlist 0 _src_dist_tardir)
+endif()
+set(SRC_DIST_DIR ${CMAKE_BINARY_DIR}/${_src_dist_tardir})
+
+message(STATUS "Source distribution direcrory set to: ${SRC_DIST_DIR}")
+
+_set_src_dist_scope_vars()
+file(REMOVE ${_src_dist_cmd_file_path})
+
+# fill in first commands into the distribution cmake file. Calling
+# 'make src_dist' executes the stored commands and prepares the source
+# distrubtion.
+#
+file(APPEND ${_src_dist_cmd_file_path} "
+# clear contents of an existing distribution directory
+file(REMOVE_RECURSE ${SRC_DIST_DIR})
+")
+
+add_custom_target(src_dist
+ COMMAND ${CMAKE_COMMAND} -P ${_src_dist_cmd_file_path}
+ COMMAND ${CMAKE_COMMAND} -E tar cfj ${SRC_DIST_DIR}.tar.bz2 ${_src_dist_tardir}
+ COMMAND ${CMAKE_COMMAND} -E remove_directory ${SRC_DIST_DIR}
+ )
+
+ENDMACRO()
+
+################# User visible macros ###################
+#
+MACRO(src_distribution_init)
+
+# clear old src distribution cmake command file
+_src_dist_parse_options(_src_dist_dirlist _src_dist_default _src_dist_dirlist_length ${ARGN})
+
+if (NOT DEFINED _SRC_DIST_INIT)
+ _src_dist_internal_init()
+ set(_SRC_DIST_INIT TRUE)
+else()
+ _set_src_dist_scope_vars()
+ file(REMOVE ${_src_dist_cmd_file_path})
+endif()
+
+if(_src_dist_default)
+ if(IS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
+ set(_src_dist_list_tmp)
+ # Get all files names in cmake subdir
+ # Unfortunately CMake also globs all directories and files that start
+ # with . - that is not the same as shell behaviour
+ file(GLOB_RECURSE _src_dist_names_tmp RELATIVE
+ ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/cmake/*)
+ #
+ # Remove all file names that contain a name that start with .
+ foreach(_nm ${_src_dist_names_tmp})
+ string(REGEX REPLACE .*/\\..* "" _nm ${_nm})
+ set(_src_dist_list_tmp ${_src_dist_list_tmp} ${_nm})
+ endforeach()
+ add_src_dist_files(${_src_dist_list_tmp})
+ endif()
+ if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt")
+ file(APPEND ${_src_dist_cmd_file_path} "
+FILE(INSTALL DESTINATION \"${_src_dist_fulldir}\" TYPE FILE FILES
+\"${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt\")
+")
+ endif()
+endif()
+
+ENDMACRO()
+
+# Add a subdirectory to the src distribution
+#
+MACRO(add_src_dist_dirs)
+
+foreach(_dir ${ARGN})
+ if (NOT EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${_dir}/CMakeLists.txt)
+ message(FATAL_ERROR
+ "Soure distribution subdirectory \"${CMAKE_CURRENT_SOURCE_DIR}/${_dir}\" does not contain a CMakeLists.txt")
+ endif()
+
+ # include subdirectory's distribution cmake command file
+ file(APPEND ${_src_dist_cmd_file_path} "
+include(\"${CMAKE_CURRENT_BINARY_DIR}/${_dir}/${_SRC_DIST_CMD_FILE_NAME}\")
+")
+endforeach()
+ENDMACRO()
+
+#
+# Add files to the src distribution. The handles and install files
+# that are in the same directory as the current source as well as files
+# in sub directories of the current source (with relative path).
+#
+MACRO(add_src_dist_files)
+
+foreach(_file ${ARGN})
+ get_filename_component(_src_dist_tmp_path ${_file} PATH)
+# string(REPLACE "${CMAKE_SOURCE_DIR}" "" _src_dist_tmp_path "${_src_dist_tmp_path}")
+ if(_src_dist_tmp_path)
+ set(_src_dist_tmp_path ${_src_dist_fulldir}/${_src_dist_tmp_path})
+ else ()
+ set(_src_dist_tmp_path ${_src_dist_fulldir})
+ endif()
+ file(APPEND ${_src_dist_cmd_file_path} "
+FILE(INSTALL DESTINATION \"${_src_dist_tmp_path}\" TYPE FILE FILES
+ \"${CMAKE_CURRENT_SOURCE_DIR}/${_file}\") ")
+
+endforeach()
+
+ENDMACRO()
diff --git a/cmake/Modules/UseRPMTools.cmake b/cmake/Modules/UseRPMTools.cmake
new file mode 100644
index 0000000..a612208
--- /dev/null
+++ b/cmake/Modules/UseRPMTools.cmake
@@ -0,0 +1,177 @@
+#
+# - Find tools needed for building RPM Packages
+# on Linux systems and defines macro that helps to
+# build source or binary RPM, the MACRO assumes
+# CMake 2.4.x which includes CPack support.
+# CPack is used to build tar.gz source tarball
+# which may be used by a custom user-made spec file.
+#
+# - Define RPMTools_ADD_RPM_TARGETS which defines
+# two (top-level) CUSTOM targets for building
+# source and binary RPMs
+#
+# Those CMake macros are provided by the TSP Developer Team
+# https://savannah.nongnu.org/projects/tsp
+#
+# Modified by Werner to use the SoureDistribution variables and
+# files instead of CPack stuff. Only minor changes.
+
+IF (WIN32)
+ MESSAGE(STATUS "RPM tools not available on Win32 systems")
+ENDIF(WIN32)
+
+IF (UNIX)
+ # Look for RPM builder executable
+ FIND_PROGRAM(RPMTools_RPMBUILD_EXECUTABLE
+ NAMES rpmbuild
+ PATHS "/usr/bin;/usr/lib/rpm"
+ PATH_SUFFIXES bin
+ DOC "The RPM builder tool")
+
+ IF (RPMTools_RPMBUILD_EXECUTABLE)
+ MESSAGE(STATUS "Looking for RPMTools... - found rpmuild is ${RPMTools_RPMBUILD_EXECUTABLE}")
+ SET(RPMTools_RPMBUILD_FOUND "YES")
+ GET_FILENAME_COMPONENT(RPMTools_BINARY_DIRS ${RPMTools_RPMBUILD_EXECUTABLE} PATH)
+ ELSE (RPMTools_RPMBUILD_EXECUTABLE)
+ SET(RPMTools_RPMBUILD_FOUND "NO")
+ MESSAGE(STATUS "Looking for RPMTools... - rpmbuild NOT FOUND")
+ ENDIF (RPMTools_RPMBUILD_EXECUTABLE)
+
+ # Detect if CourceDistribution was initialized or not
+ IF (NOT DEFINED "SRC_DIST_DIR")
+ MESSAGE(FATAL_ERROR "SourceDistribution was not initialized")
+ ENDIF (NOT DEFINED "SRC_DIST_DIR")
+
+ IF (RPMTools_RPMBUILD_FOUND)
+ SET(RPMTools_FOUND TRUE)
+ #
+ # - first arg (ARGV0) is RPM name
+ # - second arg (ARGV1) is the RPM spec file path [optional]
+ # - third arg (ARGV2) is the RPM ROOT DIRECTORY used to build RPMs [optional]
+ #
+ MACRO(RPMTools_ADD_RPM_TARGETS RPMNAME)
+
+ #
+ # If no spec file is provided create a minimal one
+ #
+ IF ("${ARGV1}" STREQUAL "")
+ SET(SPECFILE_PATH "${CMAKE_BINARY_DIR}/${RPMNAME}.spec")
+ ELSE ("${ARGV1}" STREQUAL "")
+ SET(SPECFILE_PATH "${ARGV1}")
+ ENDIF("${ARGV1}" STREQUAL "")
+
+ # Verify whether if RPM_ROOTDIR was provided or not
+ IF("${ARGV2}" STREQUAL "")
+ SET(RPM_ROOTDIR ${CMAKE_BINARY_DIR}/RPM)
+ ELSE ("${ARGV2}" STREQUAL "")
+ SET(RPM_ROOTDIR "${ARGV2}")
+ ENDIF("${ARGV2}" STREQUAL "")
+ MESSAGE(STATUS "RPMTools:: Using RPM_ROOTDIR=${RPM_ROOTDIR}")
+
+ # Prepare RPM build tree
+ FILE(MAKE_DIRECTORY ${RPM_ROOTDIR})
+ FILE(MAKE_DIRECTORY ${RPM_ROOTDIR}/tmp)
+ FILE(MAKE_DIRECTORY ${RPM_ROOTDIR}/BUILD)
+ FILE(MAKE_DIRECTORY ${RPM_ROOTDIR}/RPMS)
+ FILE(MAKE_DIRECTORY ${RPM_ROOTDIR}/SOURCES)
+ FILE(MAKE_DIRECTORY ${RPM_ROOTDIR}/SPECS)
+ FILE(MAKE_DIRECTORY ${RPM_ROOTDIR}/SRPMS)
+
+ #
+ # We check whether if the provided spec file is
+ # to be configure or not.
+ #
+ IF ("${ARGV1}" STREQUAL "")
+ SET(SPECFILE_PATH "${RPM_ROOTDIR}/SPECS/${RPMNAME}.spec")
+ SET(SPECFILE_NAME "${RPMNAME}.spec")
+ MESSAGE(STATUS "No Spec file given generate a minimal one --> ${RPM_ROOTDIR}/SPECS/${RPMNAME}.spec")
+ FILE(WRITE ${RPM_ROOTDIR}/SPECS/${RPMNAME}.spec
+ "# -*- rpm-spec -*-
+Summary: ${RPMNAME}
+Name: ${RPMNAME}
+Version: ${PACKAGE_VERSION}
+Release: 1
+License: Unknown
+Group: Unknown
+Source: ${SRC_DIST_DIR}.tar.gz
+BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root
+BuildRequires: cmake
+
+%define prefix /opt/${RPMNAME}-%{version}
+%define rpmprefix $RPM_BUILD_ROOT%{prefix}
+%define srcdirname %{name}-%{version}-Source
+
+%description
+${RPMNAME} : No description for now
+
+%prep
+%setup -q -n %{srcdirname}
+
+%build
+cd ..
+rm -rf build_tree
+mkdir build_tree
+cd build_tree
+cmake -DCMAKE_INSTALL_PREFIX=%{rpmprefix} ../%{srcdirname}
+make
+
+%install
+cd ../build_tree
+make install
+
+%clean
+rm -rf %{srcdirname}
+rm -rf build_tree
+
+%files
+%defattr(-,root,root,-)
+%dir %{prefix}
+%{prefix}/*
+
+%changelog
+* Wed Feb 28 2007 Erk <eric.noulard@gmail.com>
+ Generated by CMake UseRPMTools macros"
+ )
+
+ ELSE ("${ARGV1}" STREQUAL "")
+ SET(SPECFILE_PATH "${ARGV1}")
+
+ GET_FILENAME_COMPONENT(SPECFILE_EXT ${SPECFILE_PATH} EXT)
+ IF ("${SPECFILE_EXT}" STREQUAL ".spec")
+ # This is a 'ready-to-use' spec file which does not need to be CONFIGURED
+ GET_FILENAME_COMPONENT(SPECFILE_NAME ${SPECFILE_PATH} NAME)
+ MESSAGE(STATUS "Simple copy spec file <${SPECFILE_PATH}> --> <${RPM_ROOTDIR}/SPECS/${SPECFILE_NAME}>")
+ CONFIGURE_FILE(
+ ${SPECFILE_PATH}
+ ${RPM_ROOTDIR}/SPECS/${SPECFILE_NAME}
+ COPYONLY)
+ ELSE ("${SPECFILE_EXT}" STREQUAL ".spec")
+ # This is a to-be-configured spec file
+ GET_FILENAME_COMPONENT(SPECFILE_NAME ${SPECFILE_PATH} NAME_WE)
+ SET(SPECFILE_NAME "${SPECFILE_NAME}.spec")
+ MESSAGE(STATUS "Configuring spec file <${SPECFILE_PATH}> --> <${RPM_ROOTDIR}/SPECS/${SPECFILE_NAME}>")
+ CONFIGURE_FILE(
+ ${SPECFILE_PATH}
+ ${RPM_ROOTDIR}/SPECS/${SPECFILE_NAME}
+ @ONLY)
+ ENDIF ("${SPECFILE_EXT}" STREQUAL ".spec")
+ ENDIF("${ARGV1}" STREQUAL "")
+
+ ADD_CUSTOM_TARGET(${RPMNAME}_srpm
+ COMMAND ${CMAKE_BUILD_TOOL} src_dist
+ COMMAND ${CMAKE_COMMAND} -E copy ${SRC_DIST_DIR}.tar.gz ${RPM_ROOTDIR}/SOURCES
+ COMMAND ${RPMTools_RPMBUILD_EXECUTABLE} -bs --define=\"_topdir ${RPM_ROOTDIR}\" --buildroot=${RPM_ROOTDIR}/tmp ${RPM_ROOTDIR}/SPECS/${SPECFILE_NAME}
+ )
+
+ ADD_CUSTOM_TARGET(${RPMNAME}_rpm
+ COMMAND ${CMAKE_BUILD_TOOL} src_dist
+ COMMAND ${CMAKE_COMMAND} -E copy ${SRC_DIST_DIR}.tar.gz ${RPM_ROOTDIR}/SOURCES
+ COMMAND ${RPMTools_RPMBUILD_EXECUTABLE} -bb --define=\"_topdir ${RPM_ROOTDIR}\" --buildroot=${RPM_ROOTDIR}/tmp ${RPM_ROOTDIR}/SPECS/${SPECFILE_NAME}
+ )
+ ENDMACRO(RPMTools_ADD_RPM_TARGETS)
+
+ ELSE (RPMTools_RPMBUILD_FOUND)
+ SET(RPMTools FALSE)
+ ENDIF (RPMTools_RPMBUILD_FOUND)
+
+ENDIF (UNIX)
diff --git a/cmake/cmake_uninstall.cmake.in b/cmake/cmake_uninstall.cmake.in
new file mode 100644
index 0000000..691ab38
--- /dev/null
+++ b/cmake/cmake_uninstall.cmake.in
@@ -0,0 +1,20 @@
+IF(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt")
+ MESSAGE(FATAL_ERROR "Cannot find install manifest: @CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt")
+ENDIF(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt")
+
+FILE(READ "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt" files)
+STRING(REGEX REPLACE "\n" ";" files "${files}")
+FOREACH(file ${files})
+ MESSAGE(STATUS "Uninstalling ${file}")
+ IF(EXISTS "${file}")
+ EXEC_PROGRAM(@CMAKE_COMMAND@ -E remove "${file}"
+ OUTPUT_VARIABLE rm_out
+ RETURN_VALUE rm_retval
+ )
+ IF(NOT "${rm_retval}" STREQUAL 0)
+ MESSAGE(FATAL_ERROR "Problem when removing ${file}")
+ ENDIF(NOT "${rm_retval}" STREQUAL 0)
+ ELSE(EXISTS "$ENV{DESTDIR}${file}")
+ MESSAGE(STATUS "File ${file} does not exist.")
+ ENDIF(EXISTS "${file}")
+ENDFOREACH(file)