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
project(poppler)
cmake_minimum_required(VERSION 2.4.0 FATAL_ERROR)
set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/modules)
include(PopplerDefaults)
include(PopplerMacros)
include(MacroOptionalFindPackage)
find_package(PkgConfig)
include(MacroEnsureVersion)
include(MacroBoolTo01)
set(POPPLER_VERSION "0.6.80")
# command line switches
option(ENABLE_XPDF_HEADERS "Install unsupported xpdf headers." OFF)
option(BUILD_GTK_TESTS "Whether compile the GTK+ test programs." ON)
option(BUILD_QT3_TESTS "Whether compile the Qt3 test programs." ON)
option(BUILD_QT4_TESTS "Whether compile the Qt4 test programs." ON)
option(ENABLE_SPLASH "Build the Splash graphics backend." ON)
option(ENABLE_UTILS "Compile poppler command line utils." ON)
option(ENABLE_ABIWORD "Build the Abiword backend." ON)
option(ENABLE_ZLIB "TODO" OFF)
option(USE_EXCEPTIONS "Throw exceptions to deal with not enough memory and similar problems." OFF)
option(USE_FIXEDPOINT "Use fixed point arithmetic" OFF)
# Enable these unconditionally.
set(MULTITHREAD ON)
set(OPI_SUPPORT ON)
set(TEXTOUT_WORD_LIST ON)
# setting the minimum required versions for some components
set(QT3_MIN_VERSION "3.3.0")
set(QT4_MIN_VERSION "4.1.0")
set(CAIRO_VERSION "1.4")
# set the default compile warnings
if(CMAKE_COMPILER_IS_GNUCXX)
set(DEFAULT_COMPILE_WARNINGS_NO)
set(DEFAULT_COMPILE_WARNINGS_YES "-Wall -Wno-write-strings")
set(DEFAULT_COMPILE_WARNINGS_KDE "-Wnon-virtual-dtor -Wno-long-long -Wundef -ansi -D_XOPEN_SOURCE=500 -D_BSD_SOURCE -Wcast-align -Wconversion -Wchar-subscripts -Wall -W -Wpointer-arith -Wwrite-strings -O2 -Wformat-security -Wmissing-format-attribute -fno-exceptions -fno-check-new -fno-common")
endif(CMAKE_COMPILER_IS_GNUCXX)
macro_bool_to_01(ENABLE_SPLASH HAVE_SPLASH)
find_package(Freetype REQUIRED)
find_package(Fontconfig REQUIRED)
macro_optional_find_package(JPEG)
if(JPEG_FOUND)
set(ENABLE_LIBJPEG JPEG_FOUND)
endif(JPEG_FOUND)
macro_optional_find_package(Qt3)
macro_optional_find_package(Qt4)
macro_optional_find_package(GTK)
if(GLIB_FOUND)
macro_optional_find_package(Cairo)
set(HAVE_CAIRO CAIRO_FOUND)
if(CAIRO_FOUND)
set(CAIRO_REQ "cairo")
endif(CAIRO_FOUND)
endif(GLIB_FOUND)
if(ENABLE_ZLIB)
find_package(ZLIB)
if(ZLIB_FOUND)
set(HAVE_LIBZ ZLIB_FOUND)
endif(ZLIB_FOUND)
set(ENABLE_ZLIB ${ZLIB_FOUND})
endif(ENABLE_ZLIB)
if(ENABLE_ABIWORD)
find_package(LibXml2)
set(ENABLE_ABIWORD ${LIBXML2_FOUND})
endif(ENABLE_ABIWORD)
add_definitions(-DHAVE_CONFIG_H=1 ${FONTCONFIG_DEFINITIONS})
include_directories(
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/fofi
${CMAKE_CURRENT_SOURCE_DIR}/goo
${CMAKE_CURRENT_SOURCE_DIR}/poppler
${CMAKE_CURRENT_BINARY_DIR}
${CMAKE_CURRENT_BINARY_DIR}/poppler
${FREETYPE_INCLUDE_DIR}
)
set(HAVE_FREETYPE_H ON)
if(ENABLE_ZLIB)
include_directories(${ZLIB_INCLUDE_DIR})
endif(ENABLE_ZLIB)
if(JPEG_FOUND)
include_directories(${JPEG_INCLUDE_DIR})
set(ENABLE_LIBJPEG ON)
endif(JPEG_FOUND)
if(ENABLE_ABIWORD)
include_directories(${LIBXML2_INCLUDE_DIR})
add_definitions(${LIBXML2_DEFINITIONS})
endif(ENABLE_ABIWORD)
if(DEFINED COMPILE_WARNINGS)
else(DEFINED COMPILE_WARNINGS)
set(COMPILE_WARNINGS "yes")
endif(DEFINED COMPILE_WARNINGS)
string(TOLOWER "${COMPILE_WARNINGS}" _comp_warnings)
if(_comp_warnings STREQUAL "no")
add_definitions(${DEFAULT_COMPILE_WARNINGS_NO})
endif(_comp_warnings STREQUAL "no")
if(_comp_warnings STREQUAL "yes")
add_definitions(${DEFAULT_COMPILE_WARNINGS_YES})
endif(_comp_warnings STREQUAL "yes")
if(_comp_warnings STREQUAL "kde")
set(CMAKE_CXX_FLAGS "${DEFAULT_COMPILE_WARNINGS_KDE} ${CMAKE_CXX_FLAGS}")
endif(_comp_warnings STREQUAL "kde")
include(ConfigureChecks.cmake)
configure_file(config.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config.h)
configure_file(poppler-config.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/poppler/poppler-config.h)
set(poppler_SRCS
goo/gfile.cc
goo/gmempp.cc
goo/GooHash.cc
goo/GooList.cc
goo/GooTimer.cc
goo/GooString.cc
goo/gmem.cc
goo/FixedPoint.cc
fofi/FoFiBase.cc
fofi/FoFiEncodings.cc
fofi/FoFiTrueType.cc
fofi/FoFiType1.cc
fofi/FoFiType1C.cc
poppler/Annot.cc
poppler/Array.cc
poppler/BuiltinFont.cc
poppler/BuiltinFontTables.cc
poppler/Catalog.cc
poppler/CharCodeToUnicode.cc
poppler/CMap.cc
poppler/Decrypt.cc
poppler/Dict.cc
poppler/Error.cc
poppler/FontEncodingTables.cc
poppler/Form.cc
poppler/FontInfo.cc
poppler/Function.cc
poppler/Gfx.cc
poppler/GfxFont.cc
poppler/GfxState.cc
poppler/GlobalParams.cc
poppler/JArithmeticDecoder.cc
poppler/JBIG2Stream.cc
poppler/JPXStream.cc
poppler/Lexer.cc
poppler/Link.cc
poppler/NameToCharCode.cc
poppler/Object.cc
poppler/Outline.cc
poppler/OutputDev.cc
poppler/Page.cc
poppler/PageTransition.cc
poppler/Parser.cc
poppler/PDFDoc.cc
poppler/PDFDocEncoding.cc
poppler/ProfileData.cc
poppler/PreScanOutputDev.cc
poppler/PSTokenizer.cc
poppler/Stream.cc
poppler/UnicodeMap.cc
poppler/UnicodeTypeTable.cc
poppler/XRef.cc
poppler/PSOutputDev.cc
poppler/TextOutputDev.cc
poppler/PageLabelInfo.cc
poppler/SecurityHandler.cc
poppler/Sound.cc
poppler/XpdfPluginAPI.cc
)
set(poppler_LIBS ${FREETYPE_LIBRARIES} ${FONTCONFIG_LIBRARIES})
if(ENABLE_SPLASH)
set(poppler_SRCS ${poppler_SRCS}
poppler/SplashOutputDev.cc
splash/Splash.cc
splash/SplashBitmap.cc
splash/SplashClip.cc
splash/SplashFTFont.cc
splash/SplashFTFontEngine.cc
splash/SplashFTFontFile.cc
splash/SplashFont.cc
splash/SplashFontEngine.cc
splash/SplashFontFile.cc
splash/SplashFontFileID.cc
splash/SplashPath.cc
splash/SplashPattern.cc
splash/SplashScreen.cc
splash/SplashState.cc
splash/SplashT1Font.cc
splash/SplashT1FontEngine.cc
splash/SplashT1FontFile.cc
splash/SplashXPath.cc
splash/SplashXPathScanner.cc
)
endif(ENABLE_SPLASH)
if(JPEG_FOUND)
set(poppler_SRCS ${poppler_SRCS}
poppler/DCTStream.cc
)
set(poppler_LIBS ${poppler_LIBS} ${JPEG_LIBRARIES})
endif(JPEG_FOUND)
if(ENABLE_ZLIB)
set(poppler_SRCS ${poppler_SRCS}
poppler/FlateStream.cc
)
set(poppler_LIBS ${poppler_LIBS} ${ZLIB_LIBRARIES})
endif(ENABLE_ZLIB)
if(ENABLE_ABIWORD)
set(poppler_SRCS ${poppler_SRCS}
poppler/ABWOutputDev.cc
)
set(poppler_LIBS ${poppler_LIBS} ${LIBXML2_LIBRARIES})
endif(ENABLE_ABIWORD)
if(WIN32)
# gdi32 is needed under win32
set(poppler_LIBS ${poppler_LIBS} gdi32)
endif(WIN32)
add_library(poppler SHARED ${poppler_SRCS})
set_target_properties(poppler PROPERTIES VERSION 2.0.0 SOVERSION 2)
target_link_libraries(poppler ${poppler_LIBS})
install(TARGETS poppler RUNTIME DESTINATION bin LIBRARY DESTINATION lib ARCHIVE DESTINATION lib)
if(ENABLE_XPDF_HEADERS)
install(FILES
goo/GooHash.h
goo/GooList.h
goo/GooTimer.h
goo/GooMutex.h
goo/GooString.h
goo/GooVector.h
goo/gtypes.h
goo/gmem.h
goo/gfile.h
goo/FixedPoint.h
poppler/Annot.h
poppler/Array.h
poppler/BaseFile.h
poppler/BuiltinFont.h
poppler/BuiltinFontTables.h
poppler/Catalog.h
poppler/CharCodeToUnicode.h
poppler/CMap.h
poppler/Decrypt.h
poppler/Dict.h
poppler/Error.h
poppler/FontEncodingTables.h
poppler/FontInfo.h
poppler/Form.h
poppler/Function.cc
poppler/Function.h
poppler/Gfx.h
poppler/GfxFont.h
poppler/GfxState.h
poppler/GlobalParams.h
poppler/JArithmeticDecoder.h
poppler/JBIG2Stream.h
poppler/JPXStream.h
poppler/Lexer.h
poppler/Link.h
poppler/NameToCharCode.h
poppler/Object.h
poppler/Outline.h
poppler/OutputDev.h
poppler/Page.h
poppler/PageTransition.h
poppler/Parser.h
poppler/PDFDoc.h
poppler/PDFDocEncoding.h
poppler/ProfileData.h
poppler/PreScanOutputDev.h
poppler/PSTokenizer.h
poppler/Stream-CCITT.h
poppler/Stream.h
poppler/UnicodeMap.h
poppler/UnicodeMapTables.h
poppler/UnicodeTypeTable.h
poppler/UnicodeCClassTables.h
poppler/UnicodeCompTables.h
poppler/UnicodeDecompTables.h
poppler/XRef.h
poppler/CharTypes.h
poppler/CompactFontTables.h
poppler/ErrorCodes.h
poppler/NameToUnicodeTable.h
poppler/PSOutputDev.h
poppler/TextOutputDev.h
poppler/SecurityHandler.h
poppler/UTF8.h
poppler/XpdfPluginAPI.h
poppler/Sound.h
${CMAKE_CURRENT_BINARY_DIR}/poppler/poppler-config.h
DESTINATION include/poppler)
if(ENABLE_SPLASH)
install(FILES
poppler/SplashOutputDev.h
DESTINATION include/poppler)
install(FILES
splash/Splash.h
splash/SplashBitmap.h
splash/SplashClip.h
splash/SplashErrorCodes.h
splash/SplashFTFont.h
splash/SplashFTFontEngine.h
splash/SplashFTFontFile.h
splash/SplashFont.h
splash/SplashFontEngine.h
splash/SplashFontFile.h
splash/SplashFontFileID.h
splash/SplashGlyphBitmap.h
splash/SplashMath.h
splash/SplashPath.h
splash/SplashPattern.h
splash/SplashScreen.h
splash/SplashState.h
splash/SplashT1Font.h
splash/SplashT1FontEngine.h
splash/SplashT1FontFile.h
splash/SplashTypes.h
splash/SplashXPath.h
splash/SplashXPathScanner.h
DESTINATION include/poppler/splash)
endif(ENABLE_SPLASH)
endif(ENABLE_XPDF_HEADERS)
if(ENABLE_UTILS)
add_subdirectory(utils)
endif(ENABLE_UTILS)
if(GLIB_FOUND)
add_subdirectory(glib)
endif(GLIB_FOUND)
if(QT3_FOUND)
add_subdirectory(qt)
endif(QT3_FOUND)
add_subdirectory(test)
if(QT4_FOUND)
add_subdirectory(qt4)
endif(QT4_FOUND)
set(PKG_CONFIG_VERSION_0_18 TRUE)
if(PKGCONFIG_EXECUTABLE)
exec_program(${PKGCONFIG_EXECUTABLE} ARGS --version RETURN_VALUE _return_VALUE OUTPUT_VARIABLE _output_VAR)
macro_ensure_version("0.18" "${_output_VAR}" PKG_CONFIG_VERSION_0_18)
endif(PKGCONFIG_EXECUTABLE)
if(PKG_CONFIG_VERSION_0_18)
set(PC_REQUIRES "")
set(PC_REQUIRES_PRIVATE "Requires.private: poppler = ${POPPLER_VERSION}")
else(PKG_CONFIG_VERSION_0_18)
set(PC_REQUIRES "poppler = ${POPPLER_VERSION}")
set(PC_REQUIRES_PRIVATE "")
endif(PKG_CONFIG_VERSION_0_18)
poppler_create_install_pkgconfig(poppler.pc lib/pkgconfig)
if(ENABLE_SPLASH)
poppler_create_install_pkgconfig(poppler-splash.pc lib/pkgconfig)
endif(ENABLE_SPLASH)
if(QT3_FOUND)
poppler_create_install_pkgconfig(poppler-qt.pc lib/pkgconfig)
endif(QT3_FOUND)
if(QT4_FOUND)
poppler_create_install_pkgconfig(poppler-qt4.pc lib/pkgconfig)
endif(QT4_FOUND)
if(GLIB_FOUND)
poppler_create_install_pkgconfig(poppler-glib.pc lib/pkgconfig)
endif(GLIB_FOUND)
if(CAIRO_FOUND)
poppler_create_install_pkgconfig(poppler-cairo.pc lib/pkgconfig)
endif(CAIRO_FOUND)
message("Building Poppler with support for:")
show_end_message("splash output" ENABLE_SPLASH)
show_end_message("cairo output" CAIRO_FOUND)
show_end_message("abiword output" ENABLE_ABIWORD)
show_end_message("qt wrapper" QT3_FOUND)
show_end_message("qt4 wrapper" QT4_FOUND)
show_end_message("glib wrapper" GLIB_FOUND)
# message(" use gtk-doc: $enable_gtk_doc") # TODO
show_end_message("use libjpeg" ENABLE_LIBJPEG)
show_end_message("use zlib" ENABLE_ZLIB)
show_end_message("command line utils" ENABLE_UTILS)
# 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}}")