Commit 22e89701 authored by Maciej Zawadzki's avatar Maciej Zawadzki

init version for public use

parents
PROJECT(Tokenizer)
cmake_minimum_required(VERSION 2.6.0)
# use some of our own Find* scripts
set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/CMakeScripts)
IF(NOT CMAKE_BUILD_TYPE)
SET(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING
"Choose the type of build, options are: None Debug Release
RelWithDebInfo MinSizeRel."
FORCE)
ENDIF(NOT CMAKE_BUILD_TYPE)
if(CMAKE_COMPILER_IS_GNUCXX)
# Set our own default flags at first run.
if(NOT CONFIGURED)
if(ENABLE_STRICT_COMPILATION)
set(STRICT_FLAGS "-Werror -Wno-unused-parameter")
else(ENABLE_STRICT_COMPILATION)
set(STRICT_FLAGS "")
endif(ENABLE_STRICT_COMPILATION)
set(CMAKE_C_FLAGS "-W -Wall -ansi $ENV{CFLAGS}"
CACHE STRING "Flags used by the C compiler during normal builds."
FORCE)
set(CMAKE_C_FLAGS_DEBUG "-O0 -DDEBUG -ggdb3 -W -Wall -ansi $ENV{CFLAGS}"
CACHE STRING "Flags used by the C compiler during debug builds."
FORCE)
set(CMAKE_CXX_FLAGS "-W -Wall -ansi ${STRICT_FLAGS} $ENV{CXXFLAGS}"
CACHE STRING "Flags used by the CXX compiler during normal builds."
FORCE)
set(CMAKE_CXX_FLAGS_DEBUG "-O0 -DDEBUG -ggdb3 -W -Wall -ansi ${STRICT_FLAGS} $ENV{CXXFLAGS}"
CACHE STRING "Flags used by the CXX compiler during debug builds."
FORCE)
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O2 -g -fno-omit-frame-pointer"
CACHE STRING "Flags used by the CXX compiler during relwithdebiginfo builds" FORCE)
endif(NOT CONFIGURED)
endif(CMAKE_COMPILER_IS_GNUCXX)
find_package(Boost 1.41 REQUIRED COMPONENTS program_options filesystem system regex)
add_subdirectory(libtoki)
if(UNIX)
add_subdirectory(tests)
endif(UNIX)
add_subdirectory(toki-app)
FIND_PATH(Corpus2_INCLUDE_DIR token.h /usr/include/libcorpus2 /usr/local/include/libcorpus2 )
FIND_LIBRARY(Corpus2_LIBRARY NAMES corpus2 PATH /usr/lib /usr/local/lib)
MARK_AS_ADVANCED(Corpus2_LIBRARY)
MARK_AS_ADVANCED(Corpus2_INCLUDE_DIR)
IF (Corpus2_INCLUDE_DIR AND Corpus2_LIBRARY)
SET(Corpus2_FOUND TRUE)
ENDIF (Corpus2_INCLUDE_DIR AND Corpus2_LIBRARY)
IF (Corpus2_FOUND)
set(Corpus2_VERSION 0.0.0)
FIND_FILE(_Corpus2_VERSION_FILE version.h ${Corpus2_INCLUDE_DIR})
MARK_AS_ADVANCED(_Corpus2_VERSION_FILE)
IF (_Corpus2_VERSION_FILE)
FILE(READ ${_Corpus2_VERSION_FILE} _Corpus2_VERSION_CONENTS)
STRING(REGEX REPLACE ".*#define LIBCORPUS2_VERSION \\\"([0-9.]+)\\\".*" "\\1" Corpus2_VERSION "${_Corpus2_VERSION_CONENTS}")
ENDIF (_Corpus2_VERSION_FILE)
IF (Corpus2_FIND_VERSION)
IF (Corpus2_VERSION VERSION_LESS Corpus2_FIND_VERSION)
IF (Corpus2_FIND_REQUIRED)
MESSAGE(FATAL_ERROR "Corpus2 version too old: ${Corpus2_VERSION}, requested >= ${Corpus2_FIND_VERSION}")
ELSE (Corpus2_FIND_REQUIRED)
IF (NOT Corpus2_FIND_QUIETLY)
MESSAGE(STATUS "Corpus2 version too old: ${Corpus2_VERSION}, requested >= ${Corpus2_FIND_VERSION}")
ENDIF (NOT Corpus2_FIND_QUIETLY)
ENDIF (Corpus2_FIND_REQUIRED)
set(Corpus2_FOUND False)
ENDIF (Corpus2_VERSION VERSION_LESS Corpus2_FIND_VERSION)
ENDIF (Corpus2_FIND_VERSION)
IF (NOT Corpus2_FIND_QUIETLY)
MESSAGE(STATUS "Found libcorpus2 ${Corpus2_VERSION}: ${Corpus2_LIBRARY}")
ENDIF (NOT Corpus2_FIND_QUIETLY)
ELSE (Corpus2_FOUND)
IF (Corpus2_FIND_REQUIRED)
MESSAGE(FATAL_ERROR "Could not find libcorpus2")
ELSE (Corpus2_FIND_REQUIRED)
MESSAGE(STATUS "libcorpus2 not found")
ENDIF (Corpus2_FIND_REQUIRED)
ENDIF (Corpus2_FOUND)
# - Try to find Glib-2.0 (with gobject)
# Once done, this will define
#
# Glib_FOUND - system has Glib
# Glib_INCLUDE_DIRS - the Glib include directories
# Glib_LIBRARIES - link these to use Glib
include(LibFindMacros)
# Use pkg-config to get hints about paths
libfind_pkg_check_modules(Glib_PKGCONF glib-2.0)
# Main include dir
find_path(Glib_INCLUDE_DIR
NAMES glib.h
PATHS ${Glib_PKGCONF_INCLUDE_DIRS}
PATH_SUFFIXES glib-2.0
)
# Glib-related libraries also use a separate config header, which is in lib dir
find_path(GlibConfig_INCLUDE_DIR
NAMES glibconfig.h
PATHS ${Glib_PKGCONF_INCLUDE_DIRS} /usr
PATH_SUFFIXES lib/glib-2.0/include
)
# Finally the library itself
find_library(Glib_LIBRARY
NAMES glib-2.0
PATHS ${Glib_PKGCONF_LIBRARY_DIRS}
)
# Set the include dir variables and the libraries and let libfind_process do the rest.
# NOTE: Singular variables for this library, plural for libraries this this lib depends on.
set(Glib_PROCESS_INCLUDES Glib_INCLUDE_DIR GlibConfig_INCLUDE_DIR)
set(Glib_PROCESS_LIBS Glib_LIBRARY)
libfind_process(Glib)
# - Try to find Glibmm-2.4
# Once done, this will define
#
# Glibmm_FOUND - system has Glibmm
# Glibmm_INCLUDE_DIRS - the Glibmm include directories
# Glibmm_LIBRARIES - link these to use Glibmm
include(LibFindMacros)
# Dependencies
libfind_package(Glibmm Glib)
libfind_package(Glibmm SigC++)
# Use pkg-config to get hints about paths
libfind_pkg_check_modules(Glibmm_PKGCONF glibmm-2.4)
# Main include dir
find_path(Glibmm_INCLUDE_DIR
NAMES glibmm/main.h
PATHS ${Glibmm_PKGCONF_INCLUDE_DIRS}
PATH_SUFFIXES glibmm-2.4
)
# Glib-related libraries also use a separate config header, which is in lib dir
find_path(GlibmmConfig_INCLUDE_DIR
NAMES glibmmconfig.h
PATHS ${Glibmm_PKGCONF_INCLUDE_DIRS} /usr
PATH_SUFFIXES lib/glibmm-2.4/include
)
libfind_library(Glibmm glibmm 2.4)
# Set the include dir variables and the libraries and let libfind_process do the rest.
# NOTE: Singular variables for this library, plural for libraries this this lib depends on.
set(Glibmm_PROCESS_INCLUDES Glibmm_INCLUDE_DIR GlibmmConfig_INCLUDE_DIR Glib_INCLUDE_DIRS SigC++_INCLUDE_DIRS)
set(Glibmm_PROCESS_LIBS Glibmm_LIBRARY Glib_LIBRARIES SigC++_LIBRARIES)
libfind_process(Glibmm)
# Finds the International Components for Unicode (ICU) Library
#
# ICU_FOUND - True if ICU found.
# ICU_I18N_FOUND - True if ICU's internationalization library found.
# ICU_INCLUDE_DIRS - Directory to include to get ICU headers
# Note: always include ICU headers as, e.g.,
# unicode/utypes.h
# ICU_LIBRARIES - Libraries to link against for the common ICU
# ICU_I18N_LIBRARIES - Libraries to link against for ICU internationaliation
# (note: in addition to ICU_LIBRARIES)
MARK_AS_ADVANCED(ICU_DIR)
# Look for the header file.
find_path(
ICU_INCLUDE_DIR
NAMES unicode/utypes.h
DOC "Include directory for the ICU library")
mark_as_advanced(ICU_INCLUDE_DIR)
# Look for the library.
find_library(
ICU_LIBRARY
NAMES icuuc cygicuuc cygicuuc32
DOC "Libraries to link against for the common parts of ICU")
mark_as_advanced(ICU_LIBRARY)
# Copy the results to the output variables.
if(ICU_INCLUDE_DIR AND ICU_LIBRARY)
set(ICU_FOUND 1)
set(ICU_LIBRARIES ${ICU_LIBRARY})
set(ICU_INCLUDE_DIRS ${ICU_INCLUDE_DIR})
set(ICU_VERSION 0)
set(ICU_MAJOR_VERSION 0)
set(ICU_MINOR_VERSION 0)
FILE(READ "${ICU_INCLUDE_DIR}/unicode/uversion.h" _ICU_VERSION_CONENTS)
STRING(REGEX REPLACE ".*#define U_ICU_VERSION_MAJOR_NUM ([0-9]+).*" "\\1" ICU_MAJOR_VERSION "${_ICU_VERSION_CONENTS}")
STRING(REGEX REPLACE ".*#define U_ICU_VERSION_MINOR_NUM ([0-9]+).*" "\\1" ICU_MINOR_VERSION "${_ICU_VERSION_CONENTS}")
set(ICU_VERSION "${ICU_MAJOR_VERSION}.${ICU_MINOR_VERSION}")
# Look for the ICU internationalization libraries
find_library(
ICU_I18N_LIBRARY
NAMES icuin icui18n cygicuin cygicuin32
DOC "Libraries to link against for ICU internationalization")
mark_as_advanced(ICU_I18N_LIBRARY)
if (ICU_I18N_LIBRARY)
set(ICU_I18N_FOUND 1)
set(ICU_I18N_LIBRARIES ${ICU_I18N_LIBRARY})
else (ICU_I18N_LIBRARY)
set(ICU_I18N_FOUND 0)
set(ICU_I18N_LIBRARIES)
endif (ICU_I18N_LIBRARY)
else(ICU_INCLUDE_DIR AND ICU_LIBRARY)
set(ICU_FOUND 0)
set(ICU_I18N_FOUND 0)
set(ICU_LIBRARIES)
set(ICU_I18N_LIBRARIES)
set(ICU_INCLUDE_DIRS)
set(ICU_VERSION)
set(ICU_MAJOR_VERSION)
set(ICU_MINOR_VERSION)
endif(ICU_INCLUDE_DIR AND ICU_LIBRARY)
IF(ICU_FOUND)
IF( NOT ICU_FIND_QUIETLY )
MESSAGE( STATUS "Found ICU header files in ${ICU_INCLUDE_DIRS}")
MESSAGE( STATUS "Found ICU libraries: ${ICU_LIBRARIES}")
ENDIF( NOT ICU_FIND_QUIETLY )
ELSE(ICU_FOUND)
IF(ICU_FIND_REQUIRED)
MESSAGE( FATAL_ERROR "Could not find ICU" )
ELSE(ICU_FIND_REQUIRED)
MESSAGE( STATUS "Optional package ICU was not found" )
ENDIF(ICU_FIND_REQUIRED)
ENDIF(ICU_FOUND)
# - Try to find LibXML++ 2.6
# Once done, this will define
#
# LibXML++_FOUND - system has LibXML++
# LibXML++_INCLUDE_DIRS - the LibXML++ include directories
# LibXML++_LIBRARIES - link these to use LibXML++
include(LibFindMacros)
# Dependencies
libfind_package(LibXML++ LibXML2)
libfind_package(LibXML++ Glibmm)
# Use pkg-config to get hints about paths
libfind_pkg_check_modules(LibXML++_PKGCONF libxml++-2.6)
# Main include dir
find_path(LibXML++_INCLUDE_DIR
NAMES libxml++/libxml++.h
PATHS ${LibXML++_PKGCONF_INCLUDE_DIRS}
PATH_SUFFIXES libxml++-2.6
)
# Glib-related libraries also use a separate config header, which is in lib dir
find_path(LibXML++Config_INCLUDE_DIR
NAMES libxml++config.h
PATHS ${LibXML++_PKGCONF_INCLUDE_DIRS} /usr
PATH_SUFFIXES lib/libxml++-2.6/include
)
# Finally the library itself
find_library(LibXML++_LIBRARY
NAMES xml++-2.6
PATHS ${LibXML++_PKGCONF_LIBRARY_DIRS}
)
# Set the include dir variables and the libraries and let libfind_process do the rest.
# NOTE: Singular variables for this library, plural for libraries this this lib depends on.
set(LibXML++_PROCESS_INCLUDES LibXML++_INCLUDE_DIR LibXML++Config_INCLUDE_DIR LibXML2_INCLUDE_DIRS Glibmm_INCLUDE_DIRS)
set(LibXML++_PROCESS_LIBS LibXML++_LIBRARY LibXML2_LIBRARIES Glibmm_LIBRARIES)
libfind_process(LibXML++)
# - Try to find libxml2
# Once done this will define
#
# LibXML2_FOUND - system has xml2
# LibXML2_INCLUDE_DIRS - the xml2 include directory
# LibXML2_LIBRARIES - Link these to use xml2
# LibXML2_DEFINITIONS - Compiler switches required for using xml2
#
# Copyright (c) 2008 Andreas Schneider <mail@cynapses.org>
# Modified for other libraries by Lasse Kärkkäinen <tronic>
#
# Redistribution and use is allowed according to the terms of the New
# BSD license.
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
#
if (LibXML2_LIBRARIES AND LibXML2_INCLUDE_DIRS)
# in cache already
set(LibXML2_FOUND TRUE)
else (LibXML2_LIBRARIES AND LibXML2_INCLUDE_DIRS)
# use pkg-config to get the directories and then use these values
# in the FIND_PATH() and FIND_LIBRARY() calls
if (${CMAKE_MAJOR_VERSION} EQUAL 2 AND ${CMAKE_MINOR_VERSION} EQUAL 4)
include(UsePkgConfig)
pkgconfig(libxml-2.0 _LibXML2_INCLUDEDIR _LibXML2_LIBDIR _LibXML2_LDFLAGS _LibXML2_CFLAGS)
else (${CMAKE_MAJOR_VERSION} EQUAL 2 AND ${CMAKE_MINOR_VERSION} EQUAL 4)
find_package(PkgConfig)
if (PKG_CONFIG_FOUND)
pkg_check_modules(_LIBXML2 libxml-2.0)
endif (PKG_CONFIG_FOUND)
endif (${CMAKE_MAJOR_VERSION} EQUAL 2 AND ${CMAKE_MINOR_VERSION} EQUAL 4)
find_path(LibXML2_INCLUDE_DIR
NAMES
libxml/xpath.h
PATHS
${_LibXML2_INCLUDEDIR}
/usr/include
/usr/local/include
/opt/local/include
/sw/include
PATH_SUFFIXES
libxml2
)
find_library(LibXML2_LIBRARY
NAMES
xml2
PATHS
${_LibXML2_LIBDIR}
/usr/lib
/usr/local/lib
/opt/local/lib
/sw/lib
)
if (LibXML2_LIBRARY)
set(LibXML2_FOUND TRUE)
endif (LibXML2_LIBRARY)
set(LibXML2_INCLUDE_DIRS
${LibXML2_INCLUDE_DIR}
)
if (LibXML2_FOUND)
set(LibXML2_LIBRARIES
${LibXML2_LIBRARIES}
${LibXML2_LIBRARY}
)
endif (LibXML2_FOUND)
if (LibXML2_INCLUDE_DIRS AND LibXML2_LIBRARIES)
set(LibXML2_FOUND TRUE)
endif (LibXML2_INCLUDE_DIRS AND LibXML2_LIBRARIES)
if (LibXML2_FOUND)
if (NOT LibXML2_FIND_QUIETLY)
message(STATUS "Found libxml2: ${LibXML2_LIBRARY}")
endif (NOT LibXML2_FIND_QUIETLY)
else (LibXML2_FOUND)
if (LibXML2_FIND_REQUIRED)
message(FATAL_ERROR "Could not find libxml2")
endif (LibXML2_FIND_REQUIRED)
endif (LibXML2_FOUND)
# show the LibXML2_INCLUDE_DIRS and LibXML2_LIBRARIES variables only in the advanced view
mark_as_advanced(LibXML2_INCLUDE_DIRS LibXML2_LIBRARIES)
endif (LibXML2_LIBRARIES AND LibXML2_INCLUDE_DIRS)
FIND_PATH(LOKI_INCLUDE_DIR loki/LokiExport.h /usr/include /usr/local/include)
FIND_LIBRARY(LOKI_LIBRARY NAMES loki PATHS /usr/lib /usr/local/lib)
MARK_AS_ADVANCED(LOKI_LIBRARY)
MARK_AS_ADVANCED(LOKI_INCLUDE_DIR)
IF (LOKI_INCLUDE_DIR AND LOKI_LIBRARY)
SET(LOKI_FOUND TRUE)
ENDIF (LOKI_INCLUDE_DIR AND LOKI_LIBRARY)
IF (LOKI_FOUND)
IF (NOT LOKI_FIND_QUIETLY)
MESSAGE(STATUS "Found LOKI: ${LOKI_LIBRARY}")
ENDIF (NOT LOKI_FIND_QUIETLY)
ELSE (LOKI_FOUND)
IF (Loki_FIND_REQUIRED)
MESSAGE(FATAL_ERROR "Could not find Loki-lib")
ELSE (Loki_FIND_REQUIRED)
MESSAGE(STATUS "Loki not found")
ENDIF (Loki_FIND_REQUIRED)
ENDIF (LOKI_FOUND)
#FIND_PATH(MORFEUSZ_INCLUDE_DIR morfeusz.h /usr/include /usr/local/include)
#MARK_AS_ADVANCED(MORFEUSZ_INCLUDE_DIR)
FIND_LIBRARY(MORFEUSZ_LIBRARY NAMES morfeusz PATH /usr/lib /usr/local/lib)
MARK_AS_ADVANCED(MORFEUSZ_LIBRARY)
#IF (MORFEUSZ_INCLUDE_DIR AND MORFEUSZ_LIBRARY)
IF (MORFEUSZ_LIBRARY)
SET(MORFEUSZ_FOUND TRUE)
ENDIF (MORFEUSZ_LIBRARY)
IF (MORFEUSZ_FOUND)
IF (NOT Morfeusz_FIND_QUIETLY)
MESSAGE(STATUS "Found Morfeusz: ${MORFEUSZ_LIBRARY}")
ENDIF (NOT Morfeusz_FIND_QUIETLY)
ELSE (MORFEUSZ_FOUND)
IF (Morfeusz_FIND_REQUIRED)
MESSAGE(FATAL_ERROR "Could not find Morfeusz")
ENDIF (Morfeusz_FIND_REQUIRED)
ENDIF (MORFEUSZ_FOUND)
FIND_PATH(PwrUtils_INCLUDE_DIR libpwrutils/version.h /usr/include /usr/local/include )
FIND_LIBRARY(PwrUtils_LIBRARY NAMES pwrutils PATH /usr/lib /usr/local/lib)
MARK_AS_ADVANCED(PwrUtils_LIBRARY)
MARK_AS_ADVANCED(PwrUtils_INCLUDE_DIR)
IF (PwrUtils_INCLUDE_DIR AND PwrUtils_LIBRARY)
SET(PwrUtils_FOUND TRUE)
ENDIF (PwrUtils_INCLUDE_DIR AND PwrUtils_LIBRARY)
IF (PwrUtils_FOUND)
set(PwrUtils_VERSION 0.0.0)
FIND_FILE(_PwrUtils_VERSION_FILE libpwrutils/version.h ${PwrUtils_INCLUDE_DIR})
MARK_AS_ADVANCED(_PwrUtils_VERSION_FILE)
IF (_PwrUtils_VERSION_FILE)
FILE(READ ${_PwrUtils_VERSION_FILE} _PwrUtils_VERSION_CONENTS)
STRING(REGEX REPLACE ".*#define LIBPWRUTILS_VERSION \\\"([0-9.]+)\\\".*" "\\1" PwrUtils_VERSION "${_PwrUtils_VERSION_CONENTS}")
ENDIF (_PwrUtils_VERSION_FILE)
IF (PwrUtils_FIND_VERSION)
IF (PwrUtils_VERSION VERSION_LESS PwrUtils_FIND_VERSION)
IF (PwrUtils_FIND_REQUIRED)
MESSAGE(FATAL_ERROR "PwrUtils version too old: ${PwrUtils_VERSION}, requested >= ${PwrUtils_FIND_VERSION}")
ELSE (PwrUtils_FIND_REQUIRED)
IF (NOT PwrUtils_FIND_QUIETLY)
MESSAGE(STATUS "PwrUtils version too old: ${PwrUtils_VERSION}, requested >= ${PwrUtils_FIND_VERSION}")
ENDIF (NOT PwrUtils_FIND_QUIETLY)
ENDIF (PwrUtils_FIND_REQUIRED)
set(PwrUtils_FOUND False)
ENDIF (PwrUtils_VERSION VERSION_LESS PwrUtils_FIND_VERSION)
ENDIF (PwrUtils_FIND_VERSION)
IF (NOT PwrUtils_FIND_QUIETLY)
MESSAGE(STATUS "Found libpwrutils ${PwrUtils_VERSION}: ${PwrUtils_LIBRARY}")
ENDIF (NOT PwrUtils_FIND_QUIETLY)
ELSE (PwrUtils_FOUND)
IF (PwrUtils_FIND_REQUIRED)
MESSAGE(FATAL_ERROR "Could not find libpwrutils")
ELSE (PwrUtils_FIND_REQUIRED)
MESSAGE(STATUS "libpwrutils not found")
ENDIF (PwrUtils_FIND_REQUIRED)
ENDIF (PwrUtils_FOUND)
# - Try to find SigC++-2.0
# Once done, this will define
#
# SigC++_FOUND - system has SigC++
# SigC++_INCLUDE_DIRS - the SigC++ include directories
# SigC++_LIBRARIES - link these to use SigC++
include(LibFindMacros)
# Use pkg-config to get hints about paths
libfind_pkg_check_modules(SigC++_PKGCONF sigc++-2.0)
# Main include dir
find_path(SigC++_INCLUDE_DIR
NAMES sigc++/sigc++.h
PATHS ${SigC++_PKGCONF_INCLUDE_DIRS}
PATH_SUFFIXES sigc++-2.0
)
# Glib-related libraries also use a separate config header, which is in lib dir
find_path(SigC++Config_INCLUDE_DIR
NAMES sigc++config.h
PATHS ${SigC++_PKGCONF_INCLUDE_DIRS} /usr
PATH_SUFFIXES lib/sigc++-2.0/include
)
libfind_library(SigC++ sigc 2.0)
# Set the include dir variables and the libraries and let libfind_process do the rest.
# NOTE: Singular variables for this library, plural for libraries this this lib depends on.
set(SigC++_PROCESS_INCLUDES SigC++_INCLUDE_DIR SigC++Config_INCLUDE_DIR)
set(SigC++_PROCESS_LIBS SigC++_LIBRARY)
libfind_process(SigC++)
# 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 "")