Merge branch 'main/rendor-staging' into main/atys-live
[ryzomcore.git] / CMakeModules / FindFreeType.cmake
blobd101607b481ee21b4afd97eaedb1b6af601e85e4
1 # - Locate FreeType library
2 # This module defines
3 #  FREETYPE_LIBRARIES, libraries to link against
4 #  FREETYPE_FOUND, if false, do not try to link to FREETYPE
5 #  FREETYPE_INCLUDE_DIRS, where to find headers.
7 IF(FREETYPE_LIBRARIES AND FREETYPE_INCLUDE_DIRS)
8   # in cache already
9   SET(Freetype_FIND_QUIETLY TRUE)
10 ENDIF()
12 FIND_PATH(FREETYPE_INCLUDE_DIRS
13   freetype
14   PATHS
15   $ENV{FREETYPE_DIR}/include
16   /usr/local/include
17   /usr/include
18   /sw/include
19   /opt/local/include
20   /opt/csw/include
21   /opt/include
22   PATH_SUFFIXES freetype2
25 IF(NOT FREETYPE_INCLUDE_DIRS)
26   SET(FREETYPE_INCLUDE_DIRS "")
27 ENDIF()
29 # ft2build.h does not reside in the freetype include dir
30 FIND_PATH(FREETYPE_ADDITIONAL_INCLUDE_DIR
31   ft2build.h
32   PATHS
33   /usr/local/include
34   /usr/include
35   /sw/include
36   /opt/local/include
37   /opt/csw/include
38   /opt/include
39   PATH_SUFFIXES freetype2
42 # combine both include directories into one variable
43 IF(FREETYPE_ADDITIONAL_INCLUDE_DIR)
44   SET(FREETYPE_INCLUDE_DIRS ${FREETYPE_INCLUDE_DIRS} ${FREETYPE_ADDITIONAL_INCLUDE_DIR})
45 ENDIF()
47 FIND_LIBRARY(FREETYPE_LIBRARY_RELEASE
48   NAMES freetype libfreetype freetype219 freetype246
49   PATHS
50   $ENV{FREETYPE_DIR}/lib
51   /usr/local/lib
52   /usr/lib
53   /usr/local/X11R6/lib
54   /usr/X11R6/lib
55   /sw/lib
56   /opt/local/lib
57   /opt/csw/lib
58   /opt/lib
59   /usr/freeware/lib64
60   /usr/lib/x86_64-linux-gnu
63 FIND_LIBRARY(FREETYPE_LIBRARY_DEBUG
64   NAMES freetyped libfreetyped freetype219d freetype246d
65   PATHS
66   $ENV{FREETYPE_DIR}/lib
67   /usr/local/lib
68   /usr/lib
69   /usr/local/X11R6/lib
70   /usr/X11R6/lib
71   /sw/lib
72   /opt/local/lib
73   /opt/csw/lib
74   /opt/lib
75   /usr/freeware/lib64
76   /usr/lib/x86_64-linux-gnu
79 IF(FREETYPE_INCLUDE_DIRS)
80   IF(FREETYPE_LIBRARY_RELEASE AND FREETYPE_LIBRARY_DEBUG)
81     # Case where both Release and Debug versions are provided
82     SET(FREETYPE_FOUND ON)
83     SET(FREETYPE_LIBRARIES optimized ${FREETYPE_LIBRARY_RELEASE} debug ${FREETYPE_LIBRARY_DEBUG})
84   ELSEIF(FREETYPE_LIBRARY_RELEASE)
85     # Normal case
86     SET(FREETYPE_FOUND ON)
87     SET(FREETYPE_LIBRARIES ${FREETYPE_LIBRARY_RELEASE})
88   ELSEIF(FREETYPE_LIBRARY_DEBUG)
89     # Case where Freetype is compiled from sources (debug version is compiled by default)
90     SET(FREETYPE_FOUND ON)
91     SET(FREETYPE_LIBRARIES ${FREETYPE_LIBRARY_DEBUG})
92   ENDIF()
93 ENDIF()
95 IF(FREETYPE_FOUND)
96   IF(WITH_STATIC_EXTERNAL AND APPLE)
97     FIND_PACKAGE(BZip2)
98     IF(BZIP2_FOUND)
99       SET(FREETYPE_INCLUDE_DIRS ${FREETYPE_INCLUDE_DIRS} ${BZIP2_INCLUDE_DIR})
100       SET(FREETYPE_LIBRARIES ${FREETYPE_LIBRARIES} ${BZIP2_LIBRARIES})
101     ENDIF()
102   ENDIF()
103   IF(NOT Freetype_FIND_QUIETLY)
104     MESSAGE(STATUS "Found FreeType: ${FREETYPE_LIBRARIES}")
105   ENDIF()
106 ELSE()
107   IF(NOT Freetype_FIND_QUIETLY)
108     MESSAGE(STATUS "Warning: Unable to find FreeType!")
109   ENDIF()
110 ENDIF()