-
Notifications
You must be signed in to change notification settings - Fork 4
/
CMakeLists.txt
94 lines (81 loc) · 3.94 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
cmake_minimum_required (VERSION 3.0.2)
project(freetype-gl-cpp)
include(FeatureSummary)
include(CMakePackageConfigHelpers)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_LIST_DIR}/external/freetype-gl/cmake/Modules/")
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
set(CMAKE_CXX_STANDARD 14)
option(BUILD_EXAMPLES "Build freetype-gl-cpp examples" ON)
find_package(Freetype REQUIRED)
find_package(OpenGL REQUIRED)
find_package(GLEW)
find_package(Eigen3)
find_package(FontConfig)
if(BUILD_EXAMPLES)
find_package(glfw3 3.0)
endif()
function(make_includable input_file output_file)
file(READ ${input_file} content)
set(delim "for_c++_include")
set(content "R\"${delim}(\n${content})${delim}\"")
file(WRITE ${output_file} "${content}")
endfunction(make_includable)
# Build freetype-gl library
option(freetype-gl_USE_VAO "Use a VAO to render a vertex_buffer instance (required for forward compatible OpenGL 3.0 contexts)" OFF)
option(freetype-gl_BUILD_DEMOS "Build the freetype-gl example programs" OFF)
option(freetype-gl_BUILD_APIDOC "Build the freetype-gl API documentation" OFF)
option(freetype-gl_BUILD_HARFBUZZ "Build the freetype-gl harfbuzz support (experimental)" OFF)
option(freetype-gl_BUILD_MAKEFONT "Build the makefont tool" OFF)
option(freetype-gl_BUILD_TESTS "Build the tests" OFF)
add_subdirectory(external/freetype-gl)
# Embed required freetype-gl shaders
make_includable(external/freetype-gl/shaders/text.vert generated/text.vert)
make_includable(external/freetype-gl/shaders/text.frag generated/text.frag)
# Handle features
feature_summary(WHAT ALL)
if(EIGEN3_FOUND)
add_definitions(-DWITH_EIGEN)
#set(WITH_EIGEN 1)
endif()
if(FONTCONFIG_FOUND)
add_definitions(-DWITH_FONTCONFIG)
#set(WITH_FONTCONFIG 1)
else()
set(FONTCONFIG_INCLUDE_DIR "")
set(FONTCONFIG_LIBRARY "")
endif()
set(SOURCES freetype-gl-cpp.cpp)
set(HEADERS freetype-gl-cpp.h)
set(SOURCES_FREETYPEGL_ADDITIONAL external/freetype-gl/demos/mat4.c)
# Build freetype-gl-cpp
include_directories(${FONTCONFIG_INCLUDE_DIR} external/ external/freetype-gl external/freetype-gl/demos)
add_library(${PROJECT_NAME} SHARED ${SOURCES} ${SOURCES_FREETYPEGL_ADDITIONAL})
target_link_libraries(${PROJECT_NAME} PUBLIC freetype-gl PRIVATE ${FREETYPE_LIBRARIES} ${FONTCONFIG_LIBRARY})
# Install freetype-gl-cpp
set(INCLUDE_INSTALL_DIR include/)
set(LIB_INSTALL_DIR lib/)
install(TARGETS ${PROJECT_NAME} DESTINATION ${LIB_INSTALL_DIR}${PROJECT_NAME})
file(GLOB HEADERS_FREETYPEGL external/freetype-gl/*.h)
file(GLOB HEADERS_FREETYPEGL_DEMOS external/freetype-gl/demos/*.h)
file(GLOB GENERATED generated/*)
install(FILES ${HEADERS_FREETYPEGL} DESTINATION ${INCLUDE_INSTALL_DIR}${PROJECT_NAME}/freetype-gl)
install(FILES ${HEADERS_FREETYPEGL_DEMOS} DESTINATION ${INCLUDE_INSTALL_DIR}${PROJECT_NAME}/freetype-gl/demos)
install(FILES ${GENERATED} DESTINATION ${INCLUDE_INSTALL_DIR}${PROJECT_NAME}/generated)
install(FILES ${HEADERS} DESTINATION ${INCLUDE_INSTALL_DIR}${PROJECT_NAME})
# Generate config file
set(CMAKECONFIG_INSTALL_DIR "share/cmake/${PROJECT_NAME}" CACHE STRING "install path for cmake config file")
configure_package_config_file(Config.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake
INSTALL_DESTINATION ${CMAKECONFIG_INSTALL_DIR}
PATH_VARS INCLUDE_INSTALL_DIR)
write_basic_package_version_file(${CMAKE_CURRENT_BINARY_DIR}/ConfigVersion.cmake
VERSION 0.0.1
COMPATIBILITY SameMajorVersion)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake ${CMAKE_CURRENT_BINARY_DIR}/ConfigVersion.cmake
DESTINATION ${CMAKECONFIG_INSTALL_DIR})
# Build example
if(BUILD_EXAMPLES)
project (freetype-gl-cpp-example)
include_directories(${GLFW3_LIBRARY_DIR} ${GLEW_INCLUDE_PATH})
add_executable(example example/example.cpp)
target_link_libraries(example freetype-gl-cpp ${OPENGL_gl_LIBRARY} ${GLFW3_LIBRARY} ${GLEW_LIBRARY})
endif()