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 # - 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 # Once done, this will define
# #
# FREETYPE_FOUND - system has FreeType # Freetype_FOUND - system has FreeType
# FREETYPE_INCLUDE_DIRS - the FreeType include directories # Freetype_INCLUDE_DIRS - the FreeType include directories
# FREETYPE_LIBRARIES - link these to use FreeType # Freetype_LIBRARIES - link these to use FreeType
# Freetype_VERSION - version of FreeType
include(FindPkgMacros) #
findpkg_begin(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}} include(LibFindMacros)
getenv_path(FREETYPE_HOME) include(PreprocessorUtils)
# construct search paths set(_REGULAR_INSTALL_PATHS
set(FREETYPE_PREFIX_PATH ${FREETYPE_HOME} ${ENV_FREETYPE_HOME}) /usr/X11R6
create_search_paths(FREETYPE) /usr/local/X11R6
# redo search if prefix path changed /usr/local/X11
clear_if_changed(FREETYPE_PREFIX_PATH /usr/freeware
FREETYPE_LIBRARY_FWK ENV GTKMM_BASEPATH
FREETYPE_LIBRARY_REL [HKEY_CURRENT_USER\\SOFTWARE\\gtkmm\\2.4;Path]
FREETYPE_LIBRARY_DBG [HKEY_LOCAL_MACHINE\\SOFTWARE\\gtkmm\\2.4;Path]
FREETYPE_INCLUDE_DIR
) )
set(FREETYPE_LIBRARY_NAMES freetype2311 freetype239 freetype238 freetype235 freetype219 freetype) libfind_pkg_detect(Freetype freetype2
get_debug_names(FREETYPE_LIBRARY_NAMES) FIND_PATH ft2build.h
HINTS $ENV{FREETYPE_SDK}
use_pkgconfig(FREETYPE_PKGC freetype2) PATHS ${_REGULAR_INSTALL_PATHS}
PATH_SUFFIXES include freetype2
# prefer static library over framework FIND_LIBRARY freetype freetype2311 freetype239 freetype238 freetype235 freetype219
set(CMAKE_FIND_FRAMEWORK "LAST") HINTS $ENV{FREETYPE_SDK}
PATHS ${_REGULAR_INSTALL_PATHS}
message(STATUS "CMAKE_PREFIX_PATH: ${CMAKE_PREFIX_PATH}") PATH_SUFFIXES lib
findpkg_framework(FREETYPE) )
message(STATUS "CMAKE_PREFIX_PATH: ${CMAKE_PREFIX_PATH}") find_path(Freetype_OLD_INCLUDE_DIR
# in new versions of freetype old_include_dir equals to include_dir
find_path(FREETYPE_INCLUDE_DIR NAMES freetype/freetype.h HINTS ${FREETYPE_INC_SEARCH_PATH} ${FREETYPE_PKGC_INCLUDE_DIRS} PATH_SUFFIXES freetype2) # see explanation above
find_path(FREETYPE_FT2BUILD_INCLUDE_DIR NAMES ft2build.h HINTS ${FREETYPE_INC_SEARCH_PATH} ${FREETYPE_PKGC_INCLUDE_DIRS}) NAMES freetype/freetype.h freetype.h
PATHS ${Freetype_INCLUDE_DIR}
if (SYMBIAN) PATH_SUFFIXES freetype2
set(ORIGINAL_CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH}) NO_DEFAULT_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)
make_library_set(FREETYPE_LIBRARY) # 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()
findpkg_finish(FREETYPE) set(Freetype_PROCESS_INCLUDES Freetype_INCLUDE_DIR Freetype_OLD_INCLUDE_DIR)
mark_as_advanced(FREETYPE_FT2BUILD_INCLUDE_DIR) libfind_process(Freetype)
if (NOT FREETYPE_FT2BUILD_INCLUDE_DIR STREQUAL FREETYPE_INCLUDE_DIR)
set(FREETYPE_INCLUDE_DIRS ${FREETYPE_INCLUDE_DIRS} ${FREETYPE_FT2BUILD_INCLUDE_DIR})
endif ()
# Reset framework finding if (Freetype_INCLUDE_DIRS)
set(CMAKE_FIND_FRAMEWORK "FIRST") list(REMOVE_DUPLICATES Freetype_INCLUDE_DIRS)
endif()

@ -54,7 +54,7 @@ IF (WIN32) #Windows
if ( MYGUI_STATIC ) if ( MYGUI_STATIC )
set(LIB_SUFFIX "Static") set(LIB_SUFFIX "Static")
find_package(freetype) find_package(Freetype)
endif ( MYGUI_STATIC ) endif ( MYGUI_STATIC )
find_library ( MYGUI_LIBRARIES_REL NAMES MyGUIEngine${LIB_SUFFIX}.lib HINTS ${MYGUI_LIB_DIR} PATH_SUFFIXES "" release relwithdebinfo minsizerel ) 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) SEPARATE_ARGUMENTS(MYGUI_LIBRARIES)
ENDIF (NOT WIN32) 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_INCLUDE_DIRS ${MYGUI_INCLUDE_DIRS} CACHE PATH "")
SET(MYGUI_LIBRARIES ${MYGUI_LIBRARIES} CACHE STRING "") SET(MYGUI_LIBRARIES ${MYGUI_LIBRARIES} CACHE STRING "")
SET(MYGUI_LIB_DIR ${MYGUI_LIB_DIR} CACHE PATH "") 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 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) 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) 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) IF (MYGUI_FOUND)
MARK_AS_ADVANCED(MYGUI_LIB_DIR) MARK_AS_ADVANCED(MYGUI_LIB_DIR)
@ -152,7 +152,7 @@ ENDIF (MYGUI_FOUND)
include(FindPackageHandleStandardArgs) include(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(MyGUI DEFAULT_MSG FIND_PACKAGE_HANDLE_STANDARD_ARGS(MyGUI DEFAULT_MSG
MYGUI_INCLUDE_DIRS MYGUI_INCLUDE_DIRS
FREETYPE_LIBRARIES Freetype_LIBRARIES
MYGUI_LIBRARIES) MYGUI_LIBRARIES)
CMAKE_POLICY(POP) CMAKE_POLICY(POP)

Loading…
Cancel
Save