Commit 37d20551 authored by Pino Toscano's avatar Pino Toscano

Introduce the CMake-based build system.

Mostly works nicely as the autotools, and it mimics (almost) all the autotools behaviours.
Copied some scripts from the KDE cmake scripts (BSD-licensed).
TODO: gtk-doc.
parent 1ea831d3
This diff is collapsed.
# Copyright 2008 Pino Toscano, <pino@kde.org>
#
# Redistribution and use is allowed according to the terms of the BSD license.
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
include(CheckIncludeFile)
include(CheckIncludeFiles)
include(CheckSymbolExists)
include(CheckFunctionExists)
include(CheckLibraryExists)
include(CheckTypeSize)
include(CheckCSourceCompiles)
check_include_files(dlfcn.h HAVE_DLFCN_H)
check_include_files(inttypes.h HAVE_INTTYPES_H)
check_include_files(memory.h HAVE_MEMORY_H)
check_include_files(stdint.h HAVE_STDINT_H)
check_include_files(stdlib.h HAVE_STDLIB_H)
check_include_files(strings.h HAVE_STRINGS_H)
check_include_files(string.h HAVE_STRING_H)
check_include_files(sys/stat.h HAVE_SYS_STAT_H)
check_include_files(sys/types.h HAVE_SYS_TYPES_H)
check_include_files(unistd.h HAVE_UNISTD_H)
check_function_exists(fseek64 HAVE_FSEEK64)
check_function_exists(fseeko HAVE_FSEEKO)
check_function_exists(ftell64 HAVE_FTELL64)
check_function_exists(gettimeofday HAVE_GETTIMEOFDAY)
check_function_exists(popen HAVE_POPEN)
check_function_exists(mkstemp HAVE_MKSTEMP)
check_function_exists(mkstemps HAVE_MKSTEMPS)
macro(CHECK_FOR_DIR include var)
check_c_source_compiles(
"#include <${include}>
int main(int argc, char *argv[])
{
DIR* d = 0;
return 0;
}
" ${var})
endmacro(CHECK_FOR_DIR)
check_for_dir("dirent.h" HAVE_DIRENT_H)
check_for_dir("ndir.h" HAVE_NDIR_H)
check_for_dir("sys/dir.h" HAVE_SYS_DIR_H)
check_for_dir("sys/ndir.h" HAVE_SYS_NDIR_H)
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. 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.
# - try to find Cairo
# Once done this will define
#
# CAIRO_FOUND - system has Cairo
# CAIRO_CFLAGS - the Cairo CFlags
# CAIRO_LIBRARIES - Link these to use Cairo
#
# Copyright (c) 2007, Pino Toscano, <pino@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 (NOT WIN32)
include(UsePkgConfig)
pkgconfig(cairo _LibCairoIncDir _LibCairoLinkDir _CairoLinkFlags _CairoCflags)
set (CAIRO_FOUND FALSE)
if (_LibCairoIncDir)
if (CAIRO_VERSION)
exec_program(${PKGCONFIG_EXECUTABLE} ARGS --atleast-version=${CAIRO_VERSION} cairo RETURN_VALUE _return_VALUE OUTPUT_VARIABLE _pkgconfigDevNull)
if(_return_VALUE STREQUAL "0")
set (CAIRO_CFLAGS ${_CairoCflags})
set (CAIRO_LIBRARIES ${_CairoLinkFlags})
endif(_return_VALUE STREQUAL "0")
else (CAIRO_VERSION)
set (CAIRO_CFLAGS ${_CairoCflags})
set (CAIRO_LIBRARIES ${_CairoLinkFlags})
endif (CAIRO_VERSION)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Cairo DEFAULT_MSG CAIRO_LIBRARIES CAIRO_CFLAGS)
endif (_LibCairoIncDir)
endif(NOT WIN32)
mark_as_advanced(
CAIRO_CFLAGS
CAIRO_LIBRARIES
)
# - Try to find the Fontconfig
# Once done this will define
#
# FONTCONFIG_FOUND - system has Fontconfig
# FONTCONFIG_LIBRARIES - Link these to use FONTCONFIG
# FONTCONFIG_DEFINITIONS - Compiler switches required for using FONTCONFIG
# Copyright (c) 2006,2007 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 (FONTCONFIG_LIBRARIES AND FONTCONFIG_INCLUDE_DIR)
# in cache already
set(FONTCONFIG_FOUND TRUE)
else (FONTCONFIG_LIBRARIES AND FONTCONFIG_INCLUDE_DIR)
if (NOT WIN32)
# use pkg-config to get the directories and then use these values
# in the FIND_PATH() and FIND_LIBRARY() calls
include(UsePkgConfig)
pkgconfig(fontconfig _FONTCONFIGIncDir _FONTCONFIGLinkDir _FONTCONFIGLinkFlags _FONTCONFIGCflags)
set(FONTCONFIG_DEFINITIONS ${_FONTCONFIGCflags} CACHE INTERNAL "The compilation flags for fontconfig")
endif (NOT WIN32)
find_path(FONTCONFIG_INCLUDE_DIR fontconfig/fontconfig.h
PATHS
${_FONTCONFIGIncDir}
/usr/X11/include
)
find_library(FONTCONFIG_LIBRARIES NAMES fontconfig
PATHS
${_FONTCONFIGLinkDir}
)
include(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(Fontconfig DEFAULT_MSG FONTCONFIG_LIBRARIES FONTCONFIG_INCLUDE_DIR )
mark_as_advanced(FONTCONFIG_LIBRARIES FONTCONFIG_INCLUDE_DIR)
endif (FONTCONFIG_LIBRARIES AND FONTCONFIG_INCLUDE_DIR)
# - Try to find the freetype library
# Once done this will define
#
# FREETYPE_FOUND - system has Freetype
# FREETYPE_INCLUDE_DIRS - the FREETYPE include directories
# FREETYPE_LIBRARIES - Link these to use FREETYPE
# FREETYPE_INCLUDE_DIR is internal and deprecated for use
# Copyright (c) 2006, 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 (FREETYPE_LIBRARIES AND FREETYPE_INCLUDE_DIR)
# in cache already
set(FREETYPE_FOUND TRUE)
else (FREETYPE_LIBRARIES AND FREETYPE_INCLUDE_DIR)
FIND_PROGRAM(FREETYPECONFIG_EXECUTABLE NAMES freetype-config PATHS
/opt/local/bin
)
#reset vars
set(FREETYPE_LIBRARIES)
set(FREETYPE_INCLUDE_DIR)
# if freetype-config has been found
if(FREETYPECONFIG_EXECUTABLE)
EXEC_PROGRAM(${FREETYPECONFIG_EXECUTABLE} ARGS --libs RETURN_VALUE _return_VALUE OUTPUT_VARIABLE FREETYPE_LIBRARIES)
EXEC_PROGRAM(${FREETYPECONFIG_EXECUTABLE} ARGS --cflags RETURN_VALUE _return_VALUE OUTPUT_VARIABLE _freetype_pkgconfig_output)
if(FREETYPE_LIBRARIES AND _freetype_pkgconfig_output)
set(FREETYPE_FOUND TRUE)
# freetype-config can print out more than one -I, so we need to chop it up
# into a list and process each entry separately
SEPARATE_ARGUMENTS(_freetype_pkgconfig_output)
FOREACH(value ${_freetype_pkgconfig_output})
STRING(REGEX REPLACE "-I(.+)" "\\1" value "${value}")
set(FREETYPE_INCLUDE_DIR ${FREETYPE_INCLUDE_DIR} ${value})
ENDFOREACH(value)
endif(FREETYPE_LIBRARIES AND _freetype_pkgconfig_output)
MARK_AS_ADVANCED(FREETYPE_LIBRARIES FREETYPE_INCLUDE_DIR)
set( FREETYPE_LIBRARIES ${FREETYPE_LIBRARIES} CACHE INTERNAL "The libraries for freetype" )
else(FREETYPECONFIG_EXECUTABLE)
find_path (FREETYPE_INCLUDE_DIR freetype2/freetype/freetype.h)
set (FREETYPE_INCLUDE_DIR ${FREETYPE_INCLUDE_DIR}/freetype2)
find_library(FREETYPE_LIBRARIES freetype)
if(FREETYPE_INCLUDE_DIR AND FREETYPE_LIBRARIES)
set(FREETYPE_FOUND TRUE)
endif(FREETYPE_INCLUDE_DIR AND FREETYPE_LIBRARIES)
endif(FREETYPECONFIG_EXECUTABLE)
IF (FREETYPE_FOUND)
IF (NOT Freetype_FIND_QUIETLY)
MESSAGE(STATUS "Found Freetype: ${FREETYPE_LIBRARIES}")
ENDIF (NOT Freetype_FIND_QUIETLY)
ELSE (FREETYPE_FOUND)
IF (Freetype_FIND_REQUIRED)
MESSAGE(FATAL_ERROR "Could not find FreeType library")
ENDIF (Freetype_FIND_REQUIRED)
ENDIF (FREETYPE_FOUND)
endif (FREETYPE_LIBRARIES AND FREETYPE_INCLUDE_DIR)
set(FREETYPE_INCLUDE_DIRS ${FREETYPE_INCLUDE_DIR})
# - try to find GTK (and glib)
# Once done this will define
#
# GLIB_FOUND - system has GLib
# GLIB_CFLAGS - the GLib CFlags
# GLIB_LIBRARIES - Link these to use GLib
#
# Copyright 2008 Pino Toscano, <pino@kde.org>
#
# Redistribution and use is allowed according to the terms of the BSD license.
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
include(FindPackageHandleStandardArgs)
if (NOT WIN32)
include(UsePkgConfig)
pkgconfig(glib-2.0 _LibGLIB2IncDir _LibGLIB2LinkDir GLIB2LinkFlags GLIB2Cflags)
pkgconfig(gdk-2.0 _LibGDK2IncDir _LibGDK2LinkDir GDK2LinkFlags GDK2Cflags)
set (GLIB_FOUND FALSE)
if (_LibGLIB2IncDir AND _LibGDK2IncDir)
exec_program(${PKGCONFIG_EXECUTABLE} ARGS --atleast-version=2.6 glib-2.0 RETURN_VALUE _return_VALUE OUTPUT_VARIABLE _pkgconfigDevNull)
if(_return_VALUE STREQUAL "0")
set(_glib_FOUND TRUE)
endif(_return_VALUE STREQUAL "0")
exec_program(${PKGCONFIG_EXECUTABLE} ARGS --atleast-version=2.4.0 gdk-2.0 RETURN_VALUE _return_VALUE OUTPUT_VARIABLE _pkgconfigDevNull)
if(_return_VALUE STREQUAL "0")
set(_gdk_FOUND TRUE)
endif(_return_VALUE STREQUAL "0")
if (_glib_FOUND AND _gdk_FOUND)
set (GLIB2_CFLAGS ${GLIB2Cflags} ${GDK2Cflags})
set (GLIB2_LIBRARIES ${GLIB2LinkFlags} ${GDK2LinkFlags})
endif (_glib_FOUND AND _gdk_FOUND)
find_package_handle_standard_args(GLib DEFAULT_MSG GLIB2_LIBRARIES GLIB2_CFLAGS)
endif (_LibGLIB2IncDir AND _LibGDK2IncDir)
pkgconfig(gtk+-2.0 _LibGTK2IncDir _LibGTK2LinkDir GTK2LinkFlags GTK2Cflags)
pkgconfig(gdk-pixbuf-2.0 _LibGDK2PixbufIncDir _LibGDK2PixbufLinkDir GDK2PixbufLinkFlags GDK2PixbufCflags)
pkgconfig(libglade-2.0 _LibGLADE2IncDir _LibGLADE2LinkDir GLADE2LinkFlags GLADE2Cflags)
if (_LibGTK2IncDir AND _LibGDK2PixbufIncDir AND _LibGLADE2IncDir)
exec_program(${PKGCONFIG_EXECUTABLE} ARGS --atleast-version=2.8.0 gtk+-2.0 RETURN_VALUE _return_VALUE OUTPUT_VARIABLE _pkgconfigDevNull)
if(_return_VALUE STREQUAL "0")
set(_gtk_FOUND TRUE)
endif(_return_VALUE STREQUAL "0")
if (_gtk_FOUND)
set (GTK2_CFLAGS ${GTK2Cflags} ${GDK2PixbufCflags} ${GLADE2Cflags})
set (GTK2_LIBRARIES ${GTK2LinkFlags} ${GDK2PixbufLinkFlags} ${GLADE2LinkFlags})
endif (_gtk_FOUND)
find_package_handle_standard_args(GTK DEFAULT_MSG GTK2_LIBRARIES GTK2_CFLAGS)
endif (_LibGTK2IncDir AND _LibGDK2PixbufIncDir AND _LibGLADE2IncDir)
endif(NOT WIN32)
mark_as_advanced(
GLIB2_CFLAGS
GLIB2_LIBRARIES
GTK2_CFLAGS
GTK2_LIBRARIES
)
# FIND_PACKAGE_HANDLE_STANDARD_ARGS(NAME (DEFAULT_MSG|"Custom failure message") VAR1 ... )
# This macro is intended to be used in FindXXX.cmake modules files.
# It handles the REQUIRED and QUIET argument to FIND_PACKAGE() and
# it also sets the <UPPERCASED_NAME>_FOUND variable.
# The package is found if all variables listed are TRUE.
# Example:
#
# FIND_PACKAGE_HANDLE_STANDARD_ARGS(LibXml2 DEFAULT_MSG LIBXML2_LIBRARIES LIBXML2_INCLUDE_DIR)
#
# LibXml2 is considered to be found, if both LIBXML2_LIBRARIES and
# LIBXML2_INCLUDE_DIR are valid. Then also LIBXML2_FOUND is set to TRUE.
# If it is not found and REQUIRED was used, it fails with FATAL_ERROR,
# independent whether QUIET was used or not.
# If it is found, the location is reported using the VAR1 argument, so
# here a message "Found LibXml2: /usr/lib/libxml2.so" will be printed out.
# If the second argument is DEFAULT_MSG, the message in the failure case will
# be "Could NOT find LibXml2", if you don't like this message you can specify
# your own custom failure message there.
MACRO(FIND_PACKAGE_HANDLE_STANDARD_ARGS _NAME _FAIL_MSG _VAR1 )
IF("${_FAIL_MSG}" STREQUAL "DEFAULT_MSG")
IF (${_NAME}_FIND_REQUIRED)
SET(_FAIL_MESSAGE "Could not find REQUIRED package ${_NAME}")
ELSE (${_NAME}_FIND_REQUIRED)
SET(_FAIL_MESSAGE "Could not find OPTIONAL package ${_NAME}")
ENDIF (${_NAME}_FIND_REQUIRED)
ELSE("${_FAIL_MSG}" STREQUAL "DEFAULT_MSG")
SET(_FAIL_MESSAGE "${_FAIL_MSG}")
ENDIF("${_FAIL_MSG}" STREQUAL "DEFAULT_MSG")
STRING(TOUPPER ${_NAME} _NAME_UPPER)
SET(${_NAME_UPPER}_FOUND TRUE)
IF(NOT ${_VAR1})
SET(${_NAME_UPPER}_FOUND FALSE)
ENDIF(NOT ${_VAR1})
FOREACH(_CURRENT_VAR ${ARGN})
IF(NOT ${_CURRENT_VAR})
SET(${_NAME_UPPER}_FOUND FALSE)
ENDIF(NOT ${_CURRENT_VAR})
ENDFOREACH(_CURRENT_VAR)
IF (${_NAME_UPPER}_FOUND)
IF (NOT ${_NAME}_FIND_QUIETLY)
MESSAGE(STATUS "Found ${_NAME}: ${${_VAR1}}")
ENDIF (NOT ${_NAME}_FIND_QUIETLY)
ELSE (${_NAME_UPPER}_FOUND)
IF (${_NAME}_FIND_REQUIRED)
MESSAGE(FATAL_ERROR "${_FAIL_MESSAGE}")
ELSE (${_NAME}_FIND_REQUIRED)
IF (NOT ${_NAME}_FIND_QUIETLY)
MESSAGE(STATUS "${_FAIL_MESSAGE}")
ENDIF (NOT ${_NAME}_FIND_QUIETLY)
ENDIF (${_NAME}_FIND_REQUIRED)
ENDIF (${_NAME_UPPER}_FOUND)
ENDMACRO(FIND_PACKAGE_HANDLE_STANDARD_ARGS)
This diff is collapsed.
This diff is collapsed.
# MACRO_BOOL_TO_01( VAR RESULT0 ... RESULTN )
# This macro evaluates its first argument
# and sets all the given vaiables either to 0 or 1
# depending on the value of the first one
# 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.
MACRO(MACRO_BOOL_TO_01 FOUND_VAR )
FOREACH (_current_VAR ${ARGN})
IF(${FOUND_VAR})
SET(${_current_VAR} 1)
ELSE(${FOUND_VAR})
SET(${_current_VAR} 0)
ENDIF(${FOUND_VAR})
ENDFOREACH(_current_VAR)
ENDMACRO(MACRO_BOOL_TO_01)
# This file defines the following macros for developers to use in ensuring
# that installed software is of the right version:
#
# MACRO_ENSURE_VERSION - test that a version number is greater than
# or equal to some minimum
# MACRO_ENSURE_VERSION_RANGE - test that a version number is greater than
# or equal to some minimum and less than some
# maximum
# MACRO_ENSURE_VERSION2 - deprecated, do not use in new code
#
# MACRO_ENSURE_VERSION
# This macro compares version numbers of the form "x.y.z" or "x.y"
# MACRO_ENSURE_VERSION( FOO_MIN_VERSION FOO_VERSION_FOUND FOO_VERSION_OK)
# will set FOO_VERSION_OK to true if FOO_VERSION_FOUND >= FOO_MIN_VERSION
# Leading and trailing text is ok, e.g.
# MACRO_ENSURE_VERSION( "2.5.31" "flex 2.5.4a" VERSION_OK)
# which means 2.5.31 is required and "flex 2.5.4a" is what was found on the system
# Copyright (c) 2006, David Faure, <faure@kde.org>
# Copyright (c) 2007, Will Stephenson <wstephenson@kde.org>
#
# Redistribution and use is allowed according to the terms of the BSD license.
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
# MACRO_ENSURE_VERSION_RANGE
# This macro ensures that a version number of the form
# "x.y.z" or "x.y" falls within a range defined by
# min_version <= found_version < max_version.
# If this expression holds, FOO_VERSION_OK will be set TRUE
#
# Example: MACRO_ENSURE_VERSION_RANGE3( "0.1.0" ${FOOCODE_VERSION} "0.7.0" FOO_VERSION_OK )
#
# This macro will break silently if any of x,y,z are greater than 100.
#
# Copyright (c) 2007, Will Stephenson <wstephenson@kde.org>
#
# Redistribution and use is allowed according to the terms of the BSD license.
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
# NORMALIZE_VERSION
# Helper macro to convert version numbers of the form "x.y.z"
# to an integer equal to 10^4 * x + 10^2 * y + z
#
# This macro will break silently if any of x,y,z are greater than 100.
#
# Copyright (c) 2006, David Faure, <faure@kde.org>
# Copyright (c) 2007, Will Stephenson <wstephenson@kde.org>
#
# Redistribution and use is allowed according to the terms of the BSD license.
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
# CHECK_RANGE_INCLUSIVE_LOWER
# Helper macro to check whether x <= y < z
#
# Copyright (c) 2007, Will Stephenson <wstephenson@kde.org>
#
# Redistribution and use is allowed according to the terms of the BSD license.
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
MACRO(NORMALIZE_VERSION _requested_version _normalized_version)
STRING(REGEX MATCH "[^0-9]*[0-9]+\\.[0-9]+\\.[0-9]+.*" _threePartMatch "${_requested_version}")
if (_threePartMatch)
# parse the parts of the version string
STRING(REGEX REPLACE "[^0-9]*([0-9]+)\\.[0-9]+\\.[0-9]+.*" "\\1" _major_vers "${_requested_version}")
STRING(REGEX REPLACE "[^0-9]*[0-9]+\\.([0-9]+)\\.[0-9]+.*" "\\1" _minor_vers "${_requested_version}")
STRING(REGEX REPLACE "[^0-9]*[0-9]+\\.[0-9]+\\.([0-9]+).*" "\\1" _patch_vers "${_requested_version}")
else (_threePartMatch)
STRING(REGEX REPLACE "([0-9]+)\\.[0-9]+" "\\1" _major_vers "${_requested_version}")
STRING(REGEX REPLACE "[0-9]+\\.([0-9]+)" "\\1" _minor_vers "${_requested_version}")
set(_patch_vers "0")
endif (_threePartMatch)
# compute an overall version number which can be compared at once
MATH(EXPR ${_normalized_version} "${_major_vers}*10000 + ${_minor_vers}*100 + ${_patch_vers}")
ENDMACRO(NORMALIZE_VERSION)
MACRO(MACRO_CHECK_RANGE_INCLUSIVE_LOWER _lower_limit _value _upper_limit _ok)
if (${_value} LESS ${_lower_limit})
set( ${_ok} FALSE )
elseif (${_value} EQUAL ${_lower_limit})
set( ${_ok} TRUE )
elseif (${_value} EQUAL ${_upper_limit})
set( ${_ok} FALSE )
elseif (${_value} GREATER ${_upper_limit})
set( ${_ok} FALSE )
else (${_value} LESS ${_lower_limit})
set( ${_ok} TRUE )
endif (${_value} LESS ${_lower_limit})
ENDMACRO(MACRO_CHECK_RANGE_INCLUSIVE_LOWER)
MACRO(MACRO_ENSURE_VERSION requested_version found_version var_too_old)
NORMALIZE_VERSION( ${requested_version} req_vers_num )
NORMALIZE_VERSION( ${found_version} found_vers_num )
if (found_vers_num LESS req_vers_num)
set( ${var_too_old} FALSE )
else (found_vers_num LESS req_vers_num)
set( ${var_too_old} TRUE )
endif (found_vers_num LESS req_vers_num)
ENDMACRO(MACRO_ENSURE_VERSION)
MACRO(MACRO_ENSURE_VERSION2 requested_version2 found_version2 var_too_old2)
MACRO_ENSURE_VERSION( ${requested_version2} ${found_version2} ${var_too_old2})
ENDMACRO(MACRO_ENSURE_VERSION2)
MACRO(MACRO_ENSURE_VERSION_RANGE min_version found_version max_version var_ok)
NORMALIZE_VERSION( ${min_version} req_vers_num )
NORMALIZE_VERSION( ${found_version} found_vers_num )
NORMALIZE_VERSION( ${max_version} max_vers_num )
MACRO_CHECK_RANGE_INCLUSIVE_LOWER( ${req_vers_num} ${found_vers_num} ${max_vers_num} ${var_ok})
ENDMACRO(MACRO_ENSURE_VERSION_RANGE)
# - MACRO_OPTIONAL_FIND_PACKAGE() combines FIND_PACKAGE() with an OPTION()
# MACRO_OPTIONAL_FIND_PACKAGE( <name> [QUIT] )
# This macro is a combination of OPTION() and FIND_PACKAGE(), it
# works like FIND_PACKAGE(), but additionally it automatically creates
# an option name WITH_<name>, which can be disabled via the cmake GUI.
# or via -DWITH_<name>=OFF
# The standard <name>_FOUND variables can be used in the same way
# as when using the normal FIND_PACKAGE()
# 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.
MACRO (MACRO_OPTIONAL_FIND_PACKAGE _name )
OPTION(WITH_${_name} "Search for ${_name} package" ON)
if (WITH_${_name})
FIND_PACKAGE(${_name} ${ARGN})
else (WITH_${_name})
set(${_name}_FOUND)
set(${_name}_INCLUDE_DIR)
set(${_name}_INCLUDES)
set(${_name}_LIBRARY)
set(${_name}_LIBRARIES)
endif (WITH_${_name})
ENDMACRO (MACRO_OPTIONAL_FIND_PACKAGE)
# this module defines two macros:
# MACRO_PUSH_REQUIRED_VARS()
# and
# MACRO_POP_REQUIRED_VARS()
# use these if you call cmake macros which use
# any of the CMAKE_REQUIRED_XXX variables
#
# Usage:
# MACRO_PUSH_REQUIRED_VARS()
# SET(CMAKE_REQUIRED_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS} -DSOME_MORE_DEF)
# CHECK_FUNCTION_EXISTS(...)
# MACRO_POP_REQUIRED_VARS()
# 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.
MACRO(MACRO_PUSH_REQUIRED_VARS)
IF(NOT DEFINED _PUSH_REQUIRED_VARS_COUNTER)
SET(_PUSH_REQUIRED_VARS_COUNTER 0)
ENDIF(NOT DEFINED _PUSH_REQUIRED_VARS_COUNTER)
MATH(EXPR _PUSH_REQUIRED_VARS_COUNTER "${_PUSH_REQUIRED_VARS_COUNTER}+1")
SET(_CMAKE_REQUIRED_INCLUDES_SAVE_${_PUSH_REQUIRED_VARS_COUNTER} ${CMAKE_REQUIRED_INCLUDES})
SET(_CMAKE_REQUIRED_DEFINITIONS_SAVE_${_PUSH_REQUIRED_VARS_COUNTER} ${CMAKE_REQUIRED_DEFINITIONS})
SET(_CMAKE_REQUIRED_LIBRARIES_SAVE_${_PUSH_REQUIRED_VARS_COUNTER} ${CMAKE_REQUIRED_LIBRARIES})
SET(_CMAKE_REQUIRED_FLAGS_SAVE_${_PUSH_REQUIRED_VARS_COUNTER} ${CMAKE_REQUIRED_FLAGS})
ENDMACRO(MACRO_PUSH_REQUIRED_VARS)
MACRO(MACRO_POP_REQUIRED_VARS)
# don't pop more than we pushed
IF("${_PUSH_REQUIRED_VARS_COUNTER}" GREATER "0")
SET(CMAKE_REQUIRED_INCLUDES ${_CMAKE_REQUIRED_INCLUDES_SAVE_${_PUSH_REQUIRED_VARS_COUNTER}})
SET(CMAKE_REQUIRED_DEFINITIONS ${_CMAKE_REQUIRED_DEFINITIONS_SAVE_${_PUSH_REQUIRED_VARS_COUNTER}})
SET(CMAKE_REQUIRED_LIBRARIES ${_CMAKE_REQUIRED_LIBRARIES_SAVE_${_PUSH_REQUIRED_VARS_COUNTER}})
SET(CMAKE_REQUIRED_FLAGS ${_CMAKE_REQUIRED_FLAGS_SAVE_${_PUSH_REQUIRED_VARS_COUNTER}})
MATH(EXPR _PUSH_REQUIRED_VARS_COUNTER "${_PUSH_REQUIRED_VARS_COUNTER}-1")
ENDIF("${_PUSH_REQUIRED_VARS_COUNTER}" GREATER "0")
ENDMACRO(MACRO_POP_REQUIRED_VARS)
# enable the testing facilities
enable_testing()
# put the include directories of the sources before other include paths
# (eg, system includes)
set(CMAKE_INCLUDE_DIRECTORIES_PROJECT_BEFORE ON)
# colored output
set(CMAKE_COLOR_MAKEFILE ON)
# Copyright 2008 Pino Toscano, <pino@kde.org>
#
# Redistribution and use is allowed according to the terms of the BSD license.
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
macro(POPPLER_ADD_TEST exe build_flag)
set(build_test ${${build_flag}})
if(NOT build_test)
set(_add_executable_param ${_add_executable_param} EXCLUDE_FROM_ALL)
endif(NOT build_test)
add_executable(${exe} ${_add_executable_param} ${ARGN})
# if the tests are EXCLUDE_FROM_ALL, add a target "buildtests" to build all tests
if(NOT build_test)
get_directory_property(_buildtestsAdded BUILDTESTS_ADDED)
if(NOT _buildtestsAdded)
add_custom_target(buildtests)
set_directory_properties(PROPERTIES BUILDTESTS_ADDED TRUE)
endif(NOT _buildtestsAdded)
add_dependencies(buildtests ${exe})
endif(NOT build_test)
endmacro(POPPLER_ADD_TEST)
macro(POPPLER_ADD_UNITTEST exe build_flag)
set(build_test ${${build_flag}})
if(NOT build_test)
set(_add_executable_param ${_add_executable_param} EXCLUDE_FROM_ALL)
endif(NOT build_test)
add_executable(${exe} ${_add_executable_param} ${ARGN})
add_test(${exe} ${EXECUTABLE_OUTPUT_PATH}/${exe})
# if the tests are EXCLUDE_FROM_ALL, add a target "buildtests" to build all tests
if(NOT build_test)
get_directory_property(_buildtestsAdded BUILDTESTS_ADDED)
if(NOT _buildtestsAdded)
add_custom_target(buildtests)
set_directory_properties(PROPERTIES BUILDTESTS_ADDED TRUE)
endif(NOT _buildtestsAdded)
add_dependencies(buildtests ${exe})
endif(NOT build_test)
endmacro(POPPLER_ADD_UNITTEST)
macro(POPPLER_CREATE_INSTALL_PKGCONFIG generated_file install_location)
if(NOT WIN32)
configure_file(${generated_file}.cmake ${CMAKE_CURRENT_BINARY_DIR}/${generated_file} @ONLY)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${generated_file} DESTINATION ${install_location})
endif(NOT WIN32)
endmacro(POPPLER_CREATE_INSTALL_PKGCONFIG)
macro(SHOW_END_MESSAGE what enabled)
string(LENGTH ${what} length_what)
math(EXPR left_char "20 - ${length_what}")
set(blanks)
foreach(_i RANGE 1 ${left_char})
set(blanks "${blanks} ")
endforeach(_i)
if(${enabled})
set(enabled_string "yes")
else(${enabled})
set(enabled_string "no")
endif(${enabled})
message(" ${what}:${blanks} ${enabled_string}")
endmacro(SHOW_END_MESSAGE)
set(CMAKE_SYSTEM_INCLUDE_PATH ${CMAKE_SYSTEM_INCLUDE_PATH}
"${CMAKE_INSTALL_PREFIX}/include" )
set(CMAKE_SYSTEM_PROGRAM_PATH ${CMAKE_SYSTEM_PROGRAM_PATH}
"${CMAKE_INSTALL_PREFIX}/bin" )
set(CMAKE_SYSTEM_LIBRARY_PATH ${CMAKE_SYSTEM_LIBRARY_PATH}
"${CMAKE_INSTALL_PREFIX}/lib" )
# under Windows dlls may be also installed in bin/
if(WIN32)
set(CMAKE_SYSTEM_LIBRARY_PATH ${CMAKE_SYSTEM_LIBRARY_PATH}
"${CMAKE_INSTALL_PREFIX}/bin" )
endif(WIN32)
/* config.h. Generated from config.h.cmake by cmake. */
/* Use libjpeg instead of builtin jpeg decoder. */
#cmakedefine ENABLE_LIBJPEG 1
/* Use zlib instead of builtin zlib decoder. */
#cmakedefine ENABLE_ZLIB 1
/* Use cairo for rendering. */
#cmakedefine HAVE_CAIRO 1
/* Define to 1 if you have the <dirent.h> header file, and it defines `DIR'. */
#cmakedefine HAVE_DIRENT_H 1
/* Define to 1 if you have the <dlfcn.h> header file. */
#cmakedefine HAVE_DLFCN_H 1
/* Have FreeType2 include files */
#cmakedefine HAVE_FREETYPE_H 1
/* Define to 1 if you have the `fseek64' function. */
#cmakedefine HAVE_FSEEK64 1
/* Define to 1 if fseeko (and presumably ftello) exists and is declared. */
#cmakedefine HAVE_FSEEKO 1
/* Define to 1 if you have the `ftell64' function. */
#cmakedefine HAVE_FTELL64 1
/* Defines if gettimeofday is available on your system */
#cmakedefine HAVE_GETTIMEOFDAY 1
/* Define to 1 if you have the <inttypes.h> header file. */
#cmakedefine HAVE_INTTYPES_H 1
/* Define to 1 if you have the `z' library (-lz). */
#cmakedefine HAVE_LIBZ 1
/* Define to 1 if you have the <memory.h> header file. */
#cmakedefine HAVE_MEMORY_H 1