Merge pull request #942 from kpp/find_freetype

Find freetype
pull/1/head
scrawl 9 years ago
commit c60688a5e3

@ -8,62 +8,93 @@
#-------------------------------------------------------------------
# - Try to find FreeType
#
# This module accepts the following env variable
# FREETYPE_SDK - Can be set to custom install path
#
# Once done, this will define
#
# FREETYPE_FOUND - system has FreeType
# FREETYPE_INCLUDE_DIRS - the FreeType include directories
# FREETYPE_LIBRARIES - link these to use FreeType
include(FindPkgMacros)
findpkg_begin(FREETYPE)
# Freetype_FOUND - system has FreeType
# Freetype_INCLUDE_DIRS - the FreeType include directories
# Freetype_LIBRARIES - link these to use FreeType
# Freetype_VERSION - version of FreeType
#
# libfreetype internals:
#
# ======================================
# new versions (2.5.2)
#
# file structure:
# <prefix>/include/freetype2/ft2build.h
# <prefix>/include/freetype2/freetype.h
# used as:
# #include <ft2build.h>
# #include <freetype.h>
# requires:
# -I <prefix>/include/freetype2/
#
# ======================================
# old versions (2.4.8, 2.3.5)
#
# file structure:
# <prefix>/include/ft2build.h
# <prefix>/include/freetype2/freetype/freetype.h
# used as:
# #include <ft2build.h>
# #include <freetype/freetype.h>
# requires:
# -I <prefix>/include/ -I <prefix>/include/freetype2/
#
# ======================================
# Get path, convert backslashes as ${ENV_${var}}
getenv_path(FREETYPE_HOME)
include(LibFindMacros)
include(PreprocessorUtils)
# construct search paths
set(FREETYPE_PREFIX_PATH ${FREETYPE_HOME} ${ENV_FREETYPE_HOME})
create_search_paths(FREETYPE)
# redo search if prefix path changed
clear_if_changed(FREETYPE_PREFIX_PATH
FREETYPE_LIBRARY_FWK
FREETYPE_LIBRARY_REL
FREETYPE_LIBRARY_DBG
FREETYPE_INCLUDE_DIR
set(_REGULAR_INSTALL_PATHS
/usr/X11R6
/usr/local/X11R6
/usr/local/X11
/usr/freeware
ENV GTKMM_BASEPATH
[HKEY_CURRENT_USER\\SOFTWARE\\gtkmm\\2.4;Path]
[HKEY_LOCAL_MACHINE\\SOFTWARE\\gtkmm\\2.4;Path]
)
set(FREETYPE_LIBRARY_NAMES freetype2311 freetype239 freetype238 freetype235 freetype219 freetype)
get_debug_names(FREETYPE_LIBRARY_NAMES)
use_pkgconfig(FREETYPE_PKGC freetype2)
# prefer static library over framework
set(CMAKE_FIND_FRAMEWORK "LAST")
message(STATUS "CMAKE_PREFIX_PATH: ${CMAKE_PREFIX_PATH}")
findpkg_framework(FREETYPE)
message(STATUS "CMAKE_PREFIX_PATH: ${CMAKE_PREFIX_PATH}")
find_path(FREETYPE_INCLUDE_DIR NAMES freetype/freetype.h HINTS ${FREETYPE_INC_SEARCH_PATH} ${FREETYPE_PKGC_INCLUDE_DIRS} PATH_SUFFIXES freetype2)
find_path(FREETYPE_FT2BUILD_INCLUDE_DIR NAMES ft2build.h HINTS ${FREETYPE_INC_SEARCH_PATH} ${FREETYPE_PKGC_INCLUDE_DIRS})
libfind_pkg_detect(Freetype freetype2
FIND_PATH ft2build.h
HINTS $ENV{FREETYPE_SDK}
PATHS ${_REGULAR_INSTALL_PATHS}
PATH_SUFFIXES include freetype2
FIND_LIBRARY freetype freetype2311 freetype239 freetype238 freetype235 freetype219
HINTS $ENV{FREETYPE_SDK}
PATHS ${_REGULAR_INSTALL_PATHS}
PATH_SUFFIXES lib
)
find_path(Freetype_OLD_INCLUDE_DIR
# in new versions of freetype old_include_dir equals to include_dir
# see explanation above
NAMES freetype/freetype.h freetype.h
PATHS ${Freetype_INCLUDE_DIR}
PATH_SUFFIXES freetype2
NO_DEFAULT_PATH
)
if (SYMBIAN)
set(ORIGINAL_CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH})
set(CMAKE_PREFIX_PATH ${CMAKE_SYSYEM_OUT_DIR})
message(STATUS "Lib will be searched in Symbian out dir: ${CMAKE_SYSYEM_OUT_DIR}")
endif (SYMBIAN)
find_library(FREETYPE_LIBRARY_REL NAMES ${FREETYPE_LIBRARY_NAMES} HINTS ${FREETYPE_LIB_SEARCH_PATH} ${FREETYPE_PKGC_LIBRARY_DIRS} PATH_SUFFIXES "" release relwithdebinfo minsizerel)
find_library(FREETYPE_LIBRARY_DBG NAMES ${FREETYPE_LIBRARY_NAMES_DBG} HINTS ${FREETYPE_LIB_SEARCH_PATH} ${FREETYPE_PKGC_LIBRARY_DIRS} PATH_SUFFIXES "" debug)
if (SYMBIAN)
set(CMAKE_PREFIX_PATH ${ORIGINAL_CMAKE_PREFIX_PATH})
endif (SYMBIAN)
# get version from freetype.h
find_file(Freetype_HEADER
NAMES freetype.h
PATH_SUFFIXES freetype
PATHS ${Freetype_OLD_INCLUDE_DIR}
)
if (Freetype_HEADER)
get_version_from_n_defines(Freetype_VERSION
${Freetype_HEADER}
FREETYPE_MAJOR FREETYPE_MINOR FREETYPE_PATCH
)
endif()
make_library_set(FREETYPE_LIBRARY)
set(Freetype_PROCESS_INCLUDES Freetype_INCLUDE_DIR Freetype_OLD_INCLUDE_DIR)
libfind_process(Freetype)
findpkg_finish(FREETYPE)
mark_as_advanced(FREETYPE_FT2BUILD_INCLUDE_DIR)
if (NOT FREETYPE_FT2BUILD_INCLUDE_DIR STREQUAL FREETYPE_INCLUDE_DIR)
set(FREETYPE_INCLUDE_DIRS ${FREETYPE_INCLUDE_DIRS} ${FREETYPE_FT2BUILD_INCLUDE_DIR})
if (Freetype_INCLUDE_DIRS)
list(REMOVE_DUPLICATES Freetype_INCLUDE_DIRS)
endif()
# Reset framework finding
set(CMAKE_FIND_FRAMEWORK "FIRST")

@ -54,7 +54,7 @@ IF (WIN32) #Windows
if ( MYGUI_STATIC )
set(LIB_SUFFIX "Static")
find_package(freetype)
find_package(Freetype)
endif ( MYGUI_STATIC )
find_library ( MYGUI_LIBRARIES_REL NAMES MyGUIEngine${LIB_SUFFIX}.lib HINTS ${MYGUI_LIB_DIR} PATH_SUFFIXES "" release relwithdebinfo minsizerel )
@ -116,19 +116,19 @@ IF (NOT WIN32) # This does not work on Windows for paths with spaces in them
SEPARATE_ARGUMENTS(MYGUI_LIBRARIES)
ENDIF (NOT WIN32)
SET(MYGUI_LIBRARIES ${MYGUI_LIBRARIES} ${FREETYPE_LIBRARIES})
SET(MYGUI_LIBRARIES ${MYGUI_LIBRARIES} ${Freetype_LIBRARIES})
SET(MYGUI_INCLUDE_DIRS ${MYGUI_INCLUDE_DIRS} CACHE PATH "")
SET(MYGUI_LIBRARIES ${MYGUI_LIBRARIES} CACHE STRING "")
SET(MYGUI_LIB_DIR ${MYGUI_LIB_DIR} CACHE PATH "")
IF (NOT APPLE OR NOT MYGUI_STATIC) # we need explicit freetype libs only on OS X for static build, for other cases just make it TRUE
SET(FREETYPE_LIBRARIES TRUE)
SET(Freetype_LIBRARIES TRUE)
ENDIF (NOT APPLE OR NOT MYGUI_STATIC)
IF (MYGUI_INCLUDE_DIRS AND MYGUI_LIBRARIES AND FREETYPE_LIBRARIES)
IF (MYGUI_INCLUDE_DIRS AND MYGUI_LIBRARIES AND Freetype_LIBRARIES)
SET(MYGUI_FOUND TRUE)
ENDIF (MYGUI_INCLUDE_DIRS AND MYGUI_LIBRARIES AND FREETYPE_LIBRARIES)
ENDIF (MYGUI_INCLUDE_DIRS AND MYGUI_LIBRARIES AND Freetype_LIBRARIES)
IF (MYGUI_FOUND)
MARK_AS_ADVANCED(MYGUI_LIB_DIR)
@ -152,7 +152,7 @@ ENDIF (MYGUI_FOUND)
include(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(MyGUI DEFAULT_MSG
MYGUI_INCLUDE_DIRS
FREETYPE_LIBRARIES
Freetype_LIBRARIES
MYGUI_LIBRARIES)
CMAKE_POLICY(POP)

Loading…
Cancel
Save