3 # Copyright 2013, 2014 by
4 # David Turner, Robert Wilhelm, and Werner Lemberg.
6 # Written by John Cary <cary@txcorp.com>
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
17 # cmake CMakeLists.txt
19 # to create a Makefile that builds a static version of the library.
21 # For a dynamic library, use
23 # cmake CMakeLists.txt -DBUILD_SHARED_LIBS:BOOL=true
25 # For a framework on OS X, use
27 # cmake CMakeLists.txt -DBUILD_FRAMEWORK:BOOL=true -G Xcode
31 # For an iOS static library, use
33 # cmake CMakeLists.txt -DIOS_PLATFORM=OS -G Xcode
37 # cmake CMakeLists.txt -DIOS_PLATFORM=SIMULATOR -G Xcode
39 # Please refer to the cmake manual for further options, in particular, how
40 # to modify compilation and linking parameters.
44 # . `cmake' will overwrite FreeType's original (top-level) `Makefile' file.
46 # . You can use `cmake' directly on a freshly cloned FreeType git
49 # . `CMakeLists.txt' is provided as-is since it is not used by the
53 cmake_minimum_required(VERSION 2.6)
55 # CMAKE_TOOLCHAIN_FILE must be set before `project' is called, which
56 # configures the base build environment and references the toolchain file
58 if (DEFINED IOS_PLATFORM)
59 if (NOT "${IOS_PLATFORM}" STREQUAL "OS"
60 AND NOT "${IOS_PLATFORM}" STREQUAL "SIMULATOR")
62 "IOS_PLATFORM must be set to either OS or SIMULATOR")
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.")
68 if (BUILD_SHARED_LIBS)
70 "BUILD_SHARED_LIBS can not be on with IOS_PLATFORM enabled")
74 "BUILD_FRAMEWORK can not be on with IOS_PLATFORM enabled")
77 # iOS only uses static libraries
78 set(BUILD_SHARED_LIBS OFF)
80 set(CMAKE_TOOLCHAIN_FILE
81 ${PROJECT_SOURCE_DIR}/builds/cmake/iOS.cmake)
84 if (DEFINED IOS_PLATFORM)
85 message(FATAL_ERROR "IOS_PLATFORM is not supported on this platform")
92 if (NOT "${CMAKE_GENERATOR}" STREQUAL "Xcode")
94 "You should use Xcode generator with BUILD_FRAMEWORK enabled")
96 set(CMAKE_OSX_ARCHITECTURES "$(ARCHS_STANDARD_32_64_BIT)")
97 set(BUILD_SHARED_LIBS ON)
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})
105 # Compiler definitions for building the library
106 add_definitions(-DFT2_BUILD_LIBRARY)
108 # Specify library include directories
109 include_directories("${PROJECT_SOURCE_DIR}/include")
111 # Create the configuration file
112 message(STATUS "Creating directory, ${PROJECT_BINARY_DIR}/include/freetype2.")
113 file(MAKE_DIRECTORY ${PROJECT_BINARY_DIR}/include/freetype2)
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.")
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
124 file(GLOB PUBLIC_HEADERS "include/*.h")
125 file(GLOB PUBLIC_CONFIG_HEADERS "include/config/*.h")
126 file(GLOB PRIVATE_HEADERS "include/internal/*.h")
129 src/autofit/autofit.c
172 src/pshinter/pshinter.c
173 src/psnames/psmodule.c
177 src/truetype/truetype.c
180 src/winfonts/winfnt.c
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")
194 builds/mac/freetype-Info.plist
200 ${PUBLIC_CONFIG_HEADERS}
206 set_property(SOURCE ${PUBLIC_CONFIG_HEADERS}
207 PROPERTY MACOSX_PACKAGE_LOCATION Headers/config
209 set_target_properties(freetype PROPERTIES
211 MACOSX_FRAMEWORK_INFO_PLIST builds/mac/freetype-Info.plist
212 PUBLIC_HEADER "${PUBLIC_HEADERS}"
213 XCODE_ATTRIBUTE_INSTALL_PATH "@rpath"
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
223 install(TARGETS freetype
224 RUNTIME DESTINATION bin
225 LIBRARY DESTINATION lib
226 ARCHIVE DESTINATION lib
227 FRAMEWORK DESTINATION Library/Frameworks
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}")
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"
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)
250 # add make dist target
251 add_custom_target(dist COMMAND ${CMAKE_MAKE_PROGRAM} package_source)