This repository has been archived by the owner on Oct 5, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
/
CMakeLists.txt
126 lines (100 loc) · 3.51 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
if(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR})
message(FATAL_ERROR "Prevented in-tree built. Please create a build directory outside of the SDL_ttf source code and call cmake from there")
endif()
##### general #####
cmake_minimum_required(VERSION 3.0)
project(SDL_ttf C)
if (ANDROID)
option(TTF_WITH_HARFBUZZ "use harfbuzz to improve text shaping" OFF)
add_library(SDL2_ttf SHARED)
target_sources(SDL2_ttf PRIVATE SDL_ttf.c)
if (TTF_WITH_HARFBUZZ)
set(HARFBUZZ_INCLUDE_DIRS ../../external/harfbuzz-2.3.1/src)
set(HARFBUZZ_LIBRARIES harfbuzz)
set(FREETYPE_INCLUDE_DIRS ../../external/freetype-2.10.1/include)
set(FREETYPE_LIBRARY freetype)
add_definitions("-DTTF_USE_HARFBUZZ=1")
set(HB_BUILD_TESTS OFF CACHE BOOL "" FORCE)
set(HB_HAVE_FREETYPE ON CACHE BOOL "" FORCE)
set(FT_WITH_HARFBUZZ ON CACHE BOOL "" FORCE)
add_subdirectory(external/harfbuzz-2.3.1)
target_include_directories(SDL2_ttf PUBLIC external/harfbuzz-2.3.1/src)
target_link_libraries(SDL2_ttf PRIVATE harfbuzz)
else()
set(FT_WITH_HARFBUZZ OFF CACHE BOOL "" FORCE)
endif()
add_subdirectory(external/freetype-2.10.1)
include_directories(external/freetype-2.10.1/include)
target_include_directories(SDL2_ttf PUBLIC .)
target_link_libraries(SDL2_ttf PRIVATE freetype SDL2)
else()
include(GNUInstallDirs)
include(CMakePackageConfigHelpers)
find_package(SDL2 REQUIRED)
find_package(Freetype REQUIRED)
find_package(PkgConfig QUIET)
set(SDL_TTF_MAJOR_VERSION 2)
set(SDL_TTF_MINOR_VERSION 0)
set(SDL_TTF_MICRO_VERSION 8)
set(SDL_TTF_INTERFACE_AGE 0)
set(SDL_TTF_BINARY_AGE 14)
set(SDL_TTF_VERSION "${SDL_TTF_MAJOR_VERSION}.${SDL_TTF_MINOR_VERSION}.${SDL_TTF_MICRO_VERSION}")
##### library generation #####
add_library(SDL2_ttf SDL_ttf.c SDL_ttf.h)
target_link_libraries(SDL2_ttf SDL2::SDL2 Freetype::Freetype)
target_include_directories(SDL2_ttf PUBLIC $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/SDL2>)
install(
TARGETS SDL2_ttf
EXPORT SDL2_ttfTargets
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
)
install(
FILES SDL_ttf.h
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/SDL2
)
##### export files #####
if (APPLE)
set(PKG_PREFIX "SDL2_ttf.framework/Resources")
elseif (WIN32)
set(PKG_PREFIX "cmake")
else ()
set(PKG_PREFIX "lib/cmake/SDL2")
endif ()
write_basic_package_version_file("${CMAKE_BINARY_DIR}/SDL2_ttfConfigVersion.cmake"
VERSION ${SDL_TTF_VERSION}
COMPATIBILITY AnyNewerVersion
)
install(
EXPORT SDL2_ttfTargets
FILE SDL2_ttfTargets.cmake
NAMESPACE SDL2_ttf::
DESTINATION ${PKG_PREFIX}
)
install(
FILES
${CMAKE_CURRENT_SOURCE_DIR}/SDL2_ttfConfig.cmake
${CMAKE_BINARY_DIR}/SDL2_ttfConfigVersion.cmake
DESTINATION ${PKG_PREFIX}
COMPONENT Devel
)
##### pkg-config #####
if (PKG_CONFIG_FOUND)
set(SDL_VERSION 2.0.0)
set(prefix ${CMAKE_INSTALL_PREFIX})
set(exec_prefix "\${prefix}")
set(libdir "\${exec_prefix}/lib${LIB_SUFFIX}")
set(bindir "\${exec_prefix}/bin")
set(includedir "\${prefix}/include")
configure_file("${SDL_ttf_SOURCE_DIR}/SDL2_ttf.pc.in"
"${SDL_ttf_BINARY_DIR}/SDL2_ttf.pc" @ONLY)
if (CMAKE_SYSTEM_NAME MATCHES FreeBSD)
# FreeBSD uses ${PREFIX}/libdata/pkgconfig
install(FILES ${SDL_ttf_BINARY_DIR}/SDL2_ttf.pc DESTINATION "libdata/pkgconfig")
else ()
install(FILES ${SDL_ttf_BINARY_DIR}/SDL2_ttf.pc
DESTINATION "lib${LIB_SUFFIX}/pkgconfig")
endif ()
endif ()
endif()