Commit ac7326cc authored by Mathieu Malaterre's avatar Mathieu Malaterre
Browse files

ENH: Add a new option: VTK_USE_SYSTEM_FREETYPE. This allow fixing problem when...

ENH: Add a new option: VTK_USE_SYSTEM_FREETYPE. This allow fixing problem when building VTK and having include file being in the path, this also fix issue: http://bugs.debian.org/277602 when two different freetype libs where loaded
parent 9db17ff6
#
# Find the native FREETYPE includes and library
#
# This module defines
# FREETYPE_INCLUDE_DIR, where to find ft2build.h, ftheader.h, ...
# FREETYPE_LIBRARIES, the libraries to link against to use FREETYPE.
# FREETYPE_FOUND, If false, do not try to use FREETYPE.
# also defined, but not for general use are
# FREETYPE_LIBRARY, where to find the FREETYPE library.
FIND_PATH(FREETYPE_INCLUDE_DIR_FT2BUILD ft2build.h
/usr/include/
/usr/local/include/
)
FIND_PATH(FREETYPE_INCLUDE_DIR_FTHEADER freetype/config/ftheader.h
/usr/include/freetype2
/usr/local/include/freetype2
)
FIND_LIBRARY(FREETYPE_LIBRARY freetype
/usr/lib
/usr/local/lib
)
IF (FREETYPE_LIBRARY)
IF (FREETYPE_INCLUDE_DIR_FTHEADER AND FREETYPE_INCLUDE_DIR_FT2BUILD)
SET( FREETYPE_FOUND "YES" )
SET( FREETYPE_INCLUDE_DIR
${FREETYPE_INCLUDE_DIR_FT2BUILD}
${FREETYPE_INCLUDE_DIR_FTHEADER} )
SET( FREETYPE_LIBRARIES ${FREETYPE_LIBRARY} )
ENDIF (FREETYPE_INCLUDE_DIR_FTHEADER AND FREETYPE_INCLUDE_DIR_FT2BUILD)
ENDIF (FREETYPE_LIBRARY)
......@@ -667,6 +667,7 @@ VTK_THIRD_PARTY_OPTION(JPEG jpeg)
VTK_THIRD_PARTY_OPTION(PNG png)
VTK_THIRD_PARTY_OPTION(TIFF tiff)
VTK_THIRD_PARTY_OPTION(EXPAT expat)
VTK_THIRD_PARTY_OPTION(FREETYPE freetype)
#-----------------------------------------------------------------------------
# Configure OpenGL support.
......
......@@ -12,7 +12,7 @@ IF (JAVA_AWT_LIBRARY)
ENDIF (JAVA_AWT_LIBRARY)
SET(KIT_LIBS vtkGraphics vtkImaging vtkIO
vtkftgl
vtkfreetype
${VTK_FREETYPE_LIBRARIES}
)
SET( Kit_SRCS
......
......@@ -30,7 +30,7 @@ class vtkTextProperty;
// FreeType
#include "ft2build.h"
#include "vtk_freetype.h" //since ft2build.h could be in the path
#include FT_FREETYPE_H
#include FT_CACHE_H
#include FT_CACHE_IMAGE_H
......
......@@ -23,7 +23,6 @@
#include "vtkToolkits.h" // for VTK_USE_GL2PS
#include "vtkFreeTypeUtilities.h"
#include "vtkFreeTypeConfig.h"
#include "vtkftglConfig.h"
#include "vtkgluPickMatrix.h"
......@@ -91,7 +90,7 @@ vtkOpenGLFreeTypeTextMapper_GetGL2PSFontName(vtkTextProperty *tprop,
//----------------------------------------------------------------------------
#ifndef VTK_IMPLEMENT_MESA_CXX
vtkCxxRevisionMacro(vtkOpenGLFreeTypeTextMapper, "1.43");
vtkCxxRevisionMacro(vtkOpenGLFreeTypeTextMapper, "1.44");
vtkStandardNewMacro(vtkOpenGLFreeTypeTextMapper);
#endif
......
......@@ -5,6 +5,7 @@ VTK_THIRD_PARTY_SUBDIR(JPEG vtkjpeg)
VTK_THIRD_PARTY_SUBDIR(PNG vtkpng)
VTK_THIRD_PARTY_SUBDIR(TIFF vtktiff)
VTK_THIRD_PARTY_SUBDIR(EXPAT vtkexpat)
VTK_THIRD_PARTY_SUBDIR(FREETYPE vtkfreetype)
VTK_THIRD_PARTY_SUBDIR(DICOMParser DICOMParser)
SUBDIRS(Doxygen)
......@@ -13,7 +14,7 @@ IF(VTK_INCLUDE_NEED_TCL)
ENDIF(VTK_INCLUDE_NEED_TCL)
IF(VTK_USE_RENDERING)
SUBDIRS(freetype ftgl ParseOGLExt)
SUBDIRS(ftgl ParseOGLExt)
ENDIF(VTK_USE_RENDERING)
IF(NOT VTK_INSTALL_NO_DEVELOPMENT)
......@@ -21,7 +22,7 @@ IF(NOT VTK_INSTALL_NO_DEVELOPMENT)
# level.
INSTALL_FILES(${VTK_INSTALL_LIB_DIR} .cmake VTKConfig)
INSTALL_FILES(${VTK_INSTALL_INCLUDE_DIR} .h
vtk_expat vtk_jpeg vtk_png vtk_zlib vtk_tiff)
vtk_expat vtk_jpeg vtk_png vtk_zlib vtk_tiff vtk_freetype)
ENDIF(NOT VTK_INSTALL_NO_DEVELOPMENT)
#-----------------------------------------------------------------------------
......
# do not do coverage in this directory
......@@ -11,8 +11,6 @@ INCLUDE_REGULAR_EXPRESSION(".*")
INCLUDE_DIRECTORIES (
${VTKFTGL_SOURCE_DIR}/src
${VTKFTGL_BINARY_DIR}
${VTKFREETYPE_SOURCE_DIR}/include
${VTKFREETYPE_BINARY_DIR}
)
#
......@@ -129,7 +127,7 @@ ENDIF (APPLE)
# Use GL library provided by parent VTK if possible.
#
IF(NOT OPENGL_FOUND)
INCLUDE (${CMAKE_ROOT}/Modules/FindOpenGL.cmake)
FIND_PACKAGE(OpenGL)
IF (OPENGL_INCLUDE_PATH)
INCLUDE_DIRECTORIES (${OPENGL_INCLUDE_PATH})
ENDIF (OPENGL_INCLUDE_PATH)
......@@ -139,7 +137,7 @@ SET (VTKFTGL_LIBS "${VTKFTGL_LIBS};${OPENGL_gl_LIBRARY}")
#
# We obviously need FreeType
#
SET (VTKFTGL_LIBS "${VTKFTGL_LIBS};vtkfreetype")
SET (VTKFTGL_LIBS "${VTKFTGL_LIBS};${VTK_FREETYPE_LIBRARIES}")
#
# Define the library (and install it)
......@@ -176,8 +174,8 @@ IF (FTGL_BUILD_EXAMPLES)
#
# Need GLU and GLUT
#
INCLUDE (${CMAKE_ROOT}/Modules/FindGLU.cmake)
INCLUDE (${CMAKE_ROOT}/Modules/FindGLUT.cmake)
FIND_PACKAGE(GLU)
FIND_PACKAGE(GLUT)
IF (GLU_LIBRARY AND GLUT_LIBRARY)
......@@ -234,7 +232,7 @@ IF (FTGL_BUILD_EXAMPLES)
#
# Link examples to FTGL and Freetype
#
SET (VTKFTGL_EXAMPLES_LIBS "${VTKFTGL_EXAMPLES_LIBS};vtkftgl;vtkfreetype")
SET (VTKFTGL_EXAMPLES_LIBS "${VTKFTGL_EXAMPLES_LIBS};vtkftgl;${VTK_FREETYPE_LIBRARIES}")
#
# Example 1
......
......@@ -2,7 +2,6 @@
#define __FTGL__
#if defined(VTKFTGL)
#include "vtkFreeTypeConfig.h"
#include "vtkftglConfig.h"
#endif
......
/*=========================================================================
Program: Visualization Toolkit
Module: vtk_freetype.h
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
All rights reserved.
See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
#ifndef __vtk_freetype_h
#define __vtk_freetype_h
/* Use the freetype library configured for VTK. */
#include "vtkToolkits.h"
#ifdef VTK_USE_SYSTEM_FREETYPE
#ifndef FTC_Manager_LookupFace
#define FTC_Manager_LookupFace FTC_Manager_Lookup_Face
#endif //FTC_Manager_LookupFace
#ifndef FTC_Manager_LookupSize
#define FTC_Manager_LookupSize FTC_Manager_Lookup_Size
#endif //FTC_Manager_LookupSize
# include <ft2build.h>
#else
# include <vtkfreetype/include/ft2build.h>
# if defined(VTKFREETYPE)
# include "vtkFreeTypeConfig.h"
# endif
#endif
#endif
/***************************************************************************/
/* */
/* ftconfig.in */
/* */
/* UNIX-specific configuration file (specification only). */
/* */
/* Copyright 1996-2001, 2002, 2003, 2004 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
/* modified, and distributed under the terms of the FreeType project */
/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
/* this file you indicate that you have read the license and */
/* understand and accept it fully. */
/* */
/***************************************************************************/
/*************************************************************************/
/* */
/* This header file contains a number of macro definitions that are used */
/* by the rest of the engine. Most of the macros here are automatically */
/* determined at compile time, and you should not need to change it to */
/* port FreeType, except to compile the library with a non-ANSI */
/* compiler. */
/* */
/* Note however that if some specific modifications are needed, we */
/* advise you to place a modified copy in your build directory. */
/* */
/* The build directory is usually `freetype/builds/<system>', and */
/* contains system-specific files that are always included first when */
/* building the library. */
/* */
/*************************************************************************/
#ifndef __FTCONFIG_H__
#define __FTCONFIG_H__
#include <ft2build.h>
#include FT_CONFIG_OPTIONS_H
#include FT_CONFIG_STANDARD_LIBRARY_H
FT_BEGIN_HEADER
/*************************************************************************/
/* */
/* PLATFORM-SPECIFIC CONFIGURATION MACROS */
/* */
/* These macros can be toggled to suit a specific system. The current */
/* ones are defaults used to compile FreeType in an ANSI C environment */
/* (16bit compilers are also supported). Copy this file to your own */
/* `freetype/builds/<system>' directory, and edit it to port the engine. */
/* */
/*************************************************************************/
#cmakedefine HAVE_FCNTL_H ${HAVE_FCNTL_H}
#cmakedefine HAVE_UNISTD_H ${HAVE_UNISTD_H}
#undef SIZEOF_INT
#undef SIZEOF_LONG
#define FT_SIZEOF_INT ${CMAKE_SIZEOF_INT}
#define FT_SIZEOF_LONG ${CMAKE_SIZEOF_LONG}
#define FT_CHAR_BIT CHAR_BIT
/* Preferred alignment of data */
#define FT_ALIGNMENT 8
/* FT_UNUSED is a macro used to indicate that a given parameter is not */
/* used -- this is only used to get rid of unpleasant compiler warnings */
#ifndef FT_UNUSED
#define FT_UNUSED( arg ) ( (arg) = (arg) )
#endif
/*************************************************************************/
/* */
/* AUTOMATIC CONFIGURATION MACROS */
/* */
/* These macros are computed from the ones defined above. Don't touch */
/* their definition, unless you know precisely what you are doing. No */
/* porter should need to mess with them. */
/* */
/*************************************************************************/
/*************************************************************************/
/* */
/* Mac support */
/* */
/* This is the only necessary change, so it is defined here instead */
/* providing a new configuration file. */
/* */
#if ( defined( __APPLE__ ) && !defined( DARWIN_NO_CARBON ) ) || \
( defined( __MWERKS__ ) && defined( macintosh ) )
#define FT_MACINTOSH 1
#endif
/*************************************************************************/
/* */
/* IntN types */
/* */
/* Used to guarantee the size of some specific integers. */
/* */
typedef signed short FT_Int16;
typedef unsigned short FT_UInt16;
#if FT_SIZEOF_INT == 4
typedef signed int FT_Int32;
typedef unsigned int FT_UInt32;
#elif FT_SIZEOF_LONG == 4
typedef signed long FT_Int32;
typedef unsigned long FT_UInt32;
#else
#error "no 32bit type found -- please check your configuration files"
#endif
/* look up an integer type that is at least 32 bits */
#if FT_SIZEOF_INT >= 4
typedef int FT_Fast;
typedef unsigned int FT_UFast;
#elif FT_SIZEOF_LONG >= 4
typedef long FT_Fast;
typedef unsigned long FT_UFast;
#endif
/* determine whether we have a 64-bit int type for platforms without */
/* Autoconf */
#if FT_SIZEOF_LONG == 8
/* FT_LONG64 must be defined if a 64-bit type is available */
#define FT_LONG64
#define FT_INT64 long
#elif defined( _MSC_VER ) && _MSC_VER >= 900 /* Visual C++ (and Intel C++) */
/* this compiler provides the __int64 type */
#define FT_LONG64
#define FT_INT64 __int64
#elif defined( __BORLANDC__ ) /* Borland C++ */
/* XXXX: We should probably check the value of __BORLANDC__ in order */
/* to test the compiler version. */
/* this compiler provides the __int64 type */
#define FT_LONG64
#define FT_INT64 __int64
#elif defined( __WATCOMC__ ) /* Watcom C++ */
/* Watcom doesn't provide 64-bit data types */
#elif defined( __MWERKS__ ) /* Metrowerks CodeWarrior */
#define FT_LONG64
#define FT_INT64 long long int
#elif defined( __GNUC__ )
/* GCC provides the "long long" type */
#define FT_LONG64
#define FT_INT64 long long int
#endif /* FT_SIZEOF_LONG == 8 */
#define FT_BEGIN_STMNT do {
#define FT_END_STMNT } while ( 0 )
#define FT_DUMMY_STMNT FT_BEGIN_STMNT FT_END_STMNT
/*************************************************************************/
/* */
/* A 64-bit data type will create compilation problems if you compile */
/* in strict ANSI mode. To avoid them, we disable their use if */
/* __STDC__ is defined. You can however ignore this rule by */
/* defining the FT_CONFIG_OPTION_FORCE_INT64 configuration macro. */
/* */
#if defined( FT_LONG64 ) && !defined( FT_CONFIG_OPTION_FORCE_INT64 )
#ifdef __STDC__
/* Undefine the 64-bit macros in strict ANSI compilation mode. */
/* Since `#undef' doesn't survive in configuration header files */
/* we use the postprocessing facility of AC_CONFIG_HEADERS to */
/* replace the leading `/' with `#'. */
#undef FT_LONG64
#undef FT_INT64
#endif /* __STDC__ */
#endif /* FT_LONG64 && !FT_CONFIG_OPTION_FORCE_INT64 */
#ifdef FT_MAKE_OPTION_SINGLE_OBJECT
#define FT_LOCAL( x ) static x
#define FT_LOCAL_DEF( x ) static x
#else
#ifdef __cplusplus
#define FT_LOCAL( x ) extern "C" x
#define FT_LOCAL_DEF( x ) extern "C" x
#else
#define FT_LOCAL( x ) extern x
#define FT_LOCAL_DEF( x ) x
#endif
#endif /* FT_MAKE_OPTION_SINGLE_OBJECT */
#ifndef FT_BASE
#ifdef __cplusplus
#define FT_BASE( x ) extern "C" x
#else
#define FT_BASE( x ) extern x
#endif
#endif /* !FT_BASE */
#ifndef FT_BASE_DEF
#ifdef __cplusplus
#define FT_BASE_DEF( x ) extern "C" x
#else
#define FT_BASE_DEF( x ) extern x
#endif
#endif /* !FT_BASE_DEF */
#ifndef FT_EXPORT
#ifdef __cplusplus
#define FT_EXPORT( x ) extern "C" x
#else
#define FT_EXPORT( x ) extern x
#endif
#endif /* !FT_EXPORT */
#ifndef FT_EXPORT_DEF
#ifdef __cplusplus
#define FT_EXPORT_DEF( x ) extern "C" x
#else
#define FT_EXPORT_DEF( x ) extern x
#endif
#endif /* !FT_EXPORT_DEF */
#ifndef FT_EXPORT_VAR
#ifdef __cplusplus
#define FT_EXPORT_VAR( x ) extern "C" x
#else
#define FT_EXPORT_VAR( x ) extern x
#endif
#endif /* !FT_EXPORT_VAR */
/* The following macros are needed to compile the library with a */
/* C++ compiler and with 16bit compilers. */
/* */
/* This is special. Within C++, you must specify `extern "C"' for */
/* functions which are used via function pointers, and you also */
/* must do that for structures which contain function pointers to */
/* assure C linkage -- it's not possible to have (local) anonymous */
/* functions which are accessed by (global) function pointers. */
/* */
/* */
/* FT_CALLBACK_DEF is used to _define_ a callback function. */
/* */
/* FT_CALLBACK_TABLE is used to _declare_ a constant variable that */
/* contains pointers to callback functions. */
/* */
/* FT_CALLBACK_TABLE_DEF is used to _define_ a constant variable */
/* that contains pointers to callback functions. */
/* */
/* */
/* Some 16bit compilers have to redefine these macros to insert */
/* the infamous `_cdecl' or `__fastcall' declarations. */
/* */
#ifndef FT_CALLBACK_DEF
#ifdef __cplusplus
#define FT_CALLBACK_DEF( x ) extern "C" x
#else
#define FT_CALLBACK_DEF( x ) static x
#endif
#endif /* FT_CALLBACK_DEF */
#ifndef FT_CALLBACK_TABLE
#ifdef __cplusplus
#define FT_CALLBACK_TABLE extern "C"
#define FT_CALLBACK_TABLE_DEF extern "C"
#else
#define FT_CALLBACK_TABLE extern
#define FT_CALLBACK_TABLE_DEF /* nothing */
#endif
#endif /* FT_CALLBACK_TABLE */
FT_END_HEADER
#endif /* __FTCONFIG_H__ */
/* END */
/***************************************************************************/
/* */
/* ftsystem.c */
/* */
/* Unix-specific FreeType low-level system interface (body). */
/* */
/* Copyright 1996-2001, 2002, 2004 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
/* modified, and distributed under the terms of the FreeType project */
/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
/* this file you indicate that you have read the license and */
/* understand and accept it fully. */
/* */
/***************************************************************************/
#include <ft2build.h>
/* we use our special ftconfig.h file, not the standard one */
#include <ftconfig.h>
#include FT_INTERNAL_DEBUG_H
#include FT_SYSTEM_H
#include FT_ERRORS_H
#include FT_TYPES_H
#include FT_INTERNAL_OBJECTS_H
/* memory-mapping includes and definitions */
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#include <sys/mman.h>
#ifndef MAP_FILE
#define MAP_FILE 0x00
#endif
#ifdef MUNMAP_USES_VOIDP
#define MUNMAP_ARG_CAST void *
#else
#define MUNMAP_ARG_CAST char *
#endif
#ifdef NEED_MUNMAP_DECL
#ifdef __cplusplus
extern "C"
#else
extern
#endif
int
munmap( char* addr,
int len );
#define MUNMAP_ARG_CAST char *
#endif /* NEED_DECLARATION_MUNMAP */
#include <sys/types.h>
#include <sys/stat.h>
#ifdef HAVE_FCNTL_H
#include <fcntl.h>
#endif
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
/*************************************************************************/
/* */
/* MEMORY MANAGEMENT INTERFACE */
/* */
/*************************************************************************/
/*************************************************************************/
/* */
/* <Function> */
/* ft_alloc */
/* */
/* <Description> */