forked from micahpearlman/MonkVG
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
141 lines (114 loc) · 4.58 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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
cmake_minimum_required(VERSION 3.0.0)
project(monkvg VERSION 0.1.0)
# configuration
option(MKVG_DO_VULKAN_BACKEND "Use Vulkan as the rendering backend. NOT IMPLEMENTED" OFF) # Not Implemented Yet
option(MKVG_DO_OPENGL_BACKEND "Use OpenGL as the rendering backend." ON)
option(MKVG_DO_GLU_TESSELATION "Use GLU tesselator" ON)
option(MKVG_DO_EXAMPLES "Build examples in the ./examples directory" ON)
# require PkgConfig
find_package(PkgConfig REQUIRED)
# External Project Handler
include(build_external_proj.cmake)
if(MKVG_DO_GLU_TESSELATION)
add_subdirectory(thirdparty/glu)
set(GLU_LIBRARIES glu_tess glu_util)
set(GLU_INCLUDE_DIRS thirdparty/glu/include)
endif()
if(MKVG_DO_OPENGL_BACKEND)
find_package(OpenGL REQUIRED)
set(BACKEND_SOURCE ${BACKEND_SOURCE}
./src/opengl/glBatch.cpp
./src/opengl/glContext.cpp
./src/opengl/glFont.cpp
./src/opengl/glImage.cpp
./src/opengl/glPaint.cpp
./src/opengl/glPath.cpp)
set(BACKEND_INCLUDE ${BACKEND_INCLUDE}
./src/opengl
${GLU_INCLUDE_DIRS}
./thirdparty/gles2-bc/Sources/OpenGLES
./thirdparty/gles2-bc/Sources/OpenGLES/OpenGLES11
./thirdparty/gles2-bc/Sources/OpenGLES/OpenGLES20)
endif()
set(COMMON_SOURCE ${COMMON_SOURCE}
./src/mkBaseObject.cpp
./src/mkBatch.cpp
./src/mkContext.cpp
./src/mkFont.cpp
./src/mkImage.cpp
./src/mkMath.cpp
./src/mkPaint.cpp
./src/mkParameter.cpp
./src/mkPath.cpp
./src/mkVGU.cpp
)
set(COMMON_INCLUDE ${COMMON_INCLUDE} ${CMAKE_CURRENT_SOURCE_DIR}/src)
# GLES2-BC library
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/gles2-bc)
## Build the MonkVG library
add_library(monkvg ${COMMON_SOURCE} ${BACKEND_SOURCE})
add_dependencies(monkvg ${GLU_LIBRARIES} gles2-bc)
target_include_directories(monkvg
PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}/include
PRIVATE
${COMMON_INCLUDE}
${BACKEND_INCLUDE})
target_link_libraries(monkvg ${GLU_LIBRARIES} gles2-bc)
if (MKVG_DO_EXAMPLES)
## Build Examples
include(ExternalProject)
# Platform Specific librarys like GLX on Linux
set(PLATFORM_LIBS )
if (${CMAKE_SYSTEM_NAME} MATCHES Linux)
set(PLATFORM_LIBS ${PLATFORM_LIBS} OpenGL::GLX)
find_package(glfw3 REQUIRED)
endif()
find_package(glm REQUIRED)
if (APPLE)
find_package(glfw3 3.4 REQUIRED)
# M1s have an issue with GLFW includes. See: https://stackoverflow.com/questions/67373307/macos-m1-fatal-error-glfw-glfw3-h-file-not-found
set(PLATFORM_LIBS ${PLATFORM_LIBS} "-framework Cocoa" "-framework OpenGL" "-framework IOKit")
set(GLM_INCLUDE_DIRS ${GLM_INCLUDE_DIRS} /opt/homebrew/include)
endif(APPLE)
# GLFW Hello World
add_executable(glfw_hello_world examples/glfw_hello_world.cpp)
add_dependencies(glfw_hello_world monkvg)
target_include_directories(glfw_hello_world
PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/include/MonkVG
${GLM_INCLUDE_DIRS}
${GLFW_INCLUDE_DIRS}
)
target_link_libraries(glfw_hello_world PUBLIC
monkvg
${GLU_LIBRARIES} # Required by MonkVG
glfw
OpenGL::GL
${PLATFORM_LIBS}
${CMAKE_DL_LIBS}
pthread
)
# Tiger
add_executable(tiger examples/tiger.cpp examples/tiger_paths.c)
add_dependencies(tiger monkvg)
target_include_directories(tiger
PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/.
${CMAKE_CURRENT_SOURCE_DIR}/include/MonkVG
${GLM_INCLUDE_DIRS}
${GLFW_INCLUDE_DIRS}
)
target_link_libraries(tiger PUBLIC
monkvg
${GLU_LIBRARIES} # Required by MonkVG
glfw
OpenGL::GL
${PLATFORM_LIBS}
${CMAKE_DL_LIBS}
pthread
)
endif()
set(CPACK_PROJECT_NAME ${PROJECT_NAME})
set(CPACK_PROJECT_VERSION ${PROJECT_VERSION})
include(CPack)