[License] apply SPDX identifier FTL
[platform/upstream/freetype2.git] / CMakeLists.txt
1 # CMakeLists.txt
2 #
3 # Copyright 2013, 2014 by
4 # David Turner, Robert Wilhelm, and Werner Lemberg.
5 #
6 # Written by John Cary <cary@txcorp.com>
7 #
8 # This file is part of the FreeType project, and may only be used, modified,
9 # and distributed under the terms of the FreeType project license,
10 # LICENSE.TXT.  By continuing to use, modify, or distribute this file you
11 # indicate that you have read the license and understand and accept it
12 # fully.
13 #
14 #
15 # Say
16 #
17 #   cmake CMakeLists.txt
18 #
19 # to create a Makefile that builds a static version of the library.
20 #
21 # For a dynamic library, use
22 #
23 #   cmake CMakeLists.txt -DBUILD_SHARED_LIBS:BOOL=true
24 #
25 # For a framework on OS X, use
26 #
27 #   cmake CMakeLists.txt -DBUILD_FRAMEWORK:BOOL=true -G Xcode
28 #
29 # instead.
30 #
31 # For an iOS static library, use
32 #
33 #   cmake CMakeLists.txt -DIOS_PLATFORM=OS -G Xcode
34 #
35 # or
36 #
37 #   cmake CMakeLists.txt -DIOS_PLATFORM=SIMULATOR -G Xcode
38 #
39 # Please refer to the cmake manual for further options, in particular, how
40 # to modify compilation and linking parameters.
41 #
42 # Some notes.
43 #
44 # . `cmake' will overwrite FreeType's original (top-level) `Makefile' file.
45 #
46 # . You can use `cmake' directly on a freshly cloned FreeType git
47 #   repository.
48 #
49 # . `CMakeLists.txt'  is provided as-is since it is not used by the
50 #   developer team.
51
52
53 cmake_minimum_required(VERSION 2.6)
54
55 # CMAKE_TOOLCHAIN_FILE must be set before `project' is called, which
56 # configures the base build environment and references the toolchain file
57 if (APPLE)
58   if (DEFINED IOS_PLATFORM)
59     if (NOT "${IOS_PLATFORM}" STREQUAL "OS"
60         AND NOT "${IOS_PLATFORM}" STREQUAL "SIMULATOR")
61       message(FATAL_ERROR
62         "IOS_PLATFORM must be set to either OS or SIMULATOR")
63     endif ()
64     if (NOT "${CMAKE_GENERATOR}" STREQUAL "Xcode")
65       message(AUTHOR_WARNING
66         "You should use Xcode generator with IOS_PLATFORM enabled to get Universal builds.")
67     endif ()
68     if (BUILD_SHARED_LIBS)
69       message(FATAL_ERROR
70         "BUILD_SHARED_LIBS can not be on with IOS_PLATFORM enabled")
71     endif ()
72     if (BUILD_FRAMEWORK)
73       message(FATAL_ERROR
74         "BUILD_FRAMEWORK can not be on with IOS_PLATFORM enabled")
75     endif ()
76
77     # iOS only uses static libraries
78     set(BUILD_SHARED_LIBS OFF)
79
80     set(CMAKE_TOOLCHAIN_FILE
81       ${PROJECT_SOURCE_DIR}/builds/cmake/iOS.cmake)
82   endif ()
83 else ()
84   if (DEFINED IOS_PLATFORM)
85     message(FATAL_ERROR "IOS_PLATFORM is not supported on this platform")
86   endif ()
87 endif ()
88
89 project(freetype)
90
91 if (BUILD_FRAMEWORK)
92   if (NOT "${CMAKE_GENERATOR}" STREQUAL "Xcode")
93     message(FATAL_ERROR
94       "You should use Xcode generator with BUILD_FRAMEWORK enabled")
95   endif ()
96   set(CMAKE_OSX_ARCHITECTURES "$(ARCHS_STANDARD_32_64_BIT)")
97   set(BUILD_SHARED_LIBS ON)
98 endif ()
99
100 set(VERSION_MAJOR "2")
101 set(VERSION_MINOR "5")
102 set(VERSION_PATCH "5")
103 set(PROJECT_VERSION ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH})
104
105 # Compiler definitions for building the library
106 add_definitions(-DFT2_BUILD_LIBRARY)
107
108 # Specify library include directories
109 include_directories("${PROJECT_SOURCE_DIR}/include")
110
111 # Create the configuration file
112 message(STATUS "Creating directory, ${PROJECT_BINARY_DIR}/include/freetype2.")
113 file(MAKE_DIRECTORY ${PROJECT_BINARY_DIR}/include/freetype2)
114
115 # For the auto-generated ftconfig.h file
116 include_directories(BEFORE "${PROJECT_BINARY_DIR}/include/freetype2")
117 message(STATUS "Creating ${PROJECT_BINARY_DIR}/include/freetype2/ftconfig.h.")
118 execute_process(
119   COMMAND sed -e "s/FT_CONFIG_OPTIONS_H/<ftoption.h>/" -e "s/FT_CONFIG_STANDARD_LIBRARY_H/<ftstdlib.h>/" -e "s?/undef ?#undef ?"
120   INPUT_FILE ${PROJECT_SOURCE_DIR}/builds/unix/ftconfig.in
121   OUTPUT_FILE ${PROJECT_BINARY_DIR}/include/freetype2/ftconfig.h
122 )
123
124 file(GLOB PUBLIC_HEADERS "include/*.h")
125 file(GLOB PUBLIC_CONFIG_HEADERS "include/config/*.h")
126 file(GLOB PRIVATE_HEADERS "include/internal/*.h")
127
128 set(BASE_SRCS
129   src/autofit/autofit.c
130   src/base/ftadvanc.c
131   src/base/ftbbox.c
132   src/base/ftbdf.c
133   src/base/ftbitmap.c
134   src/base/ftcalc.c
135   src/base/ftcid.c
136   src/base/ftdbgmem.c
137   src/base/ftdebug.c
138   src/base/ftfstype.c
139   src/base/ftgasp.c
140   src/base/ftgloadr.c
141   src/base/ftglyph.c
142   src/base/ftgxval.c
143   src/base/ftinit.c
144   src/base/ftlcdfil.c
145   src/base/ftmm.c
146   src/base/ftobjs.c
147   src/base/ftotval.c
148   src/base/ftoutln.c
149   src/base/ftpatent.c
150   src/base/ftpfr.c
151   src/base/ftrfork.c
152   src/base/ftsnames.c
153   src/base/ftstream.c
154   src/base/ftstroke.c
155   src/base/ftsynth.c
156   src/base/ftsystem.c
157   src/base/fttrigon.c
158   src/base/fttype1.c
159   src/base/ftutil.c
160   src/base/ftwinfnt.c
161   src/base/ftxf86.c
162   src/bdf/bdf.c
163   src/bzip2/ftbzip2.c
164   src/cache/ftcache.c
165   src/cff/cff.c
166   src/cid/type1cid.c
167   src/gzip/ftgzip.c
168   src/lzw/ftlzw.c
169   src/pcf/pcf.c
170   src/pfr/pfr.c
171   src/psaux/psaux.c
172   src/pshinter/pshinter.c
173   src/psnames/psmodule.c
174   src/raster/raster.c
175   src/sfnt/sfnt.c
176   src/smooth/smooth.c
177   src/truetype/truetype.c
178   src/type1/type1.c
179   src/type42/type42.c
180   src/winfonts/winfnt.c
181 )
182
183 include_directories("src/truetype")
184 include_directories("src/sfnt")
185 include_directories("src/autofit")
186 include_directories("src/smooth")
187 include_directories("src/raster")
188 include_directories("src/psaux")
189 include_directories("src/psnames")
190
191 if (BUILD_FRAMEWORK)
192   set(BASE_SRCS
193     ${BASE_SRCS}
194     builds/mac/freetype-Info.plist
195   )
196 endif ()
197
198 add_library(freetype
199   ${PUBLIC_HEADERS}
200   ${PUBLIC_CONFIG_HEADERS}
201   ${PRIVATE_HEADERS}
202   ${BASE_SRCS}
203 )
204
205 if (BUILD_FRAMEWORK)
206   set_property(SOURCE ${PUBLIC_CONFIG_HEADERS}
207     PROPERTY MACOSX_PACKAGE_LOCATION Headers/config
208   )
209   set_target_properties(freetype PROPERTIES
210     FRAMEWORK TRUE
211     MACOSX_FRAMEWORK_INFO_PLIST builds/mac/freetype-Info.plist
212     PUBLIC_HEADER "${PUBLIC_HEADERS}"
213     XCODE_ATTRIBUTE_INSTALL_PATH "@rpath"
214   )
215 endif ()
216
217 # Installations
218 # Note the trailing slash in the argument to the `DIRECTORY' directive
219 install(DIRECTORY ${PROJECT_SOURCE_DIR}/include/
220   DESTINATION include/freetype2
221   PATTERN "internal" EXCLUDE
222 )
223 install(TARGETS freetype
224   RUNTIME DESTINATION bin
225   LIBRARY DESTINATION lib
226   ARCHIVE DESTINATION lib
227   FRAMEWORK DESTINATION Library/Frameworks
228 )
229
230 # Packaging
231 # CPack version numbers for release tarball name.
232 set(CPACK_PACKAGE_VERSION_MAJOR ${VERSION_MAJOR})
233 set(CPACK_PACKAGE_VERSION_MINOR ${VERSION_MINOR})
234 set(CPACK_PACKAGE_VERSION_PATCH ${VERSION_PATCH}})
235 if (NOT DEFINED CPACK_PACKAGE_DESCRIPTION_SUMMARY)
236   set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "${CMAKE_PROJECT_NAME}")
237 endif ()
238 if (NOT DEFINED CPACK_SOURCE_PACKAGE_FILE_NAME)
239   set(CPACK_SOURCE_PACKAGE_FILE_NAME
240     "${CMAKE_PROJECT_NAME}-${PROJECT_VERSION}-r${PROJECT_REV}"
241     CACHE INTERNAL "tarball basename"
242   )
243 endif ()
244 set(CPACK_SOURCE_GENERATOR TGZ)
245 set(CPACK_SOURCE_IGNORE_FILES
246   "/CVS/;/.svn/;.swp$;.#;/#;/build/;/serial/;/ser/;/parallel/;/par/;~;/preconfig.out;/autom4te.cache/;/.config")
247 set(CPACK_GENERATOR TGZ)
248 include(CPack)
249
250 # add make dist target
251 add_custom_target(dist COMMAND ${CMAKE_MAKE_PROGRAM} package_source)
252
253 # eof