-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathCMakeLists.txt
67 lines (57 loc) · 2.1 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
cmake_minimum_required(VERSION 3.10)
project(drawtext-gl-freetype-harfbuzz)
set(CMAKE_CXX_STANDARD 11)
# Compile GLFW
set(GLFW_BUILD_EXAMPLES OFF CACHE BOOL " " FORCE)
set(GLFW_BUILD_TESTS OFF CACHE BOOL " " FORCE)
set(GLFW_BUILD_DOCS OFF CACHE BOOL " " FORCE)
set(GLFW_INSTALL OFF CACHE BOOL " " FORCE)
add_subdirectory(deps/glfw)
# Compile FreeType2
set(CMAKE_DISABLE_FIND_PACKAGE_ZLIB TRUE CACHE BOOL " " FORCE)
set(CMAKE_DISABLE_FIND_PACKAGE_BZip2 TRUE CACHE BOOL " " FORCE)
set(CMAKE_DISABLE_FIND_PACKAGE_PNG TRUE CACHE BOOL " " FORCE)
set(CMAKE_DISABLE_FIND_PACKAGE_HarfBuzz TRUE CACHE BOOL " " FORCE)
set(CMAKE_DISABLE_FIND_PACKAGE_BrotliDec TRUE CACHE BOOL " " FORCE)
add_subdirectory(deps/freetype)
# Compile HarfBuzz
set(HB_BUILD_SUBSET OFF CACHE BOOL " " FORCE)
# harfbuzz's CMakeLists.txt use FindFreetype cmake module. don't know how to use the inclusion freetype.
# set(HB_HAVE_FREETYPE ON CACHE BOOL " " FORCE)
# set(ENV{FREETYPE_DIR} "${CMAKE_CURRENT_SOURCE_DIR}/deps/freetype")
add_subdirectory(deps/harfbuzz)
# drawtext
add_executable(drawtext
main.cpp
scope_guard.h
font.h
font.cpp
skyline_binpack.h
skyline_binpack.cpp
texture_atlas.h
texture_atlas.cpp
shader.h
shader.cpp
text_render.h
text_render.cpp
text_run.h
text_run.cpp
deps/glad/src/glad.c)
# Workaround for HarfBuzz FreeType integration
target_sources(drawtext PUBLIC deps/harfbuzz/src/hb-ft.cc)
set_source_files_properties(deps/harfbuzz/src/hb-ft.cc
PROPERTIES COMPILE_DEFINITIONS HAVE_FREETYPE)
# https://docs.microsoft.com/en-us/cpp/build/reference/utf-8-set-source-and-executable-character-sets-to-utf-8?view=msvc-160
if (MSVC)
target_compile_options(drawtext PRIVATE /source-charset:utf-8)
endif()
target_include_directories(drawtext
PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/deps/glad/include"
PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/deps/glfw/include"
PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/deps/glm"
PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/deps/freetype/include"
PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/deps/harfbuzz/src")
target_link_libraries(drawtext
glfw
freetype
harfbuzz)