-
-
Notifications
You must be signed in to change notification settings - Fork 12
/
CMakeLists.txt
273 lines (235 loc) · 7.91 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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
set(INCLUDE_FOLDER "${PROJECT_SOURCE_DIR}/include")
set(SOURCE_FOLDER "${PROJECT_SOURCE_DIR}/src")
file(GLOB ROOT_HEADER "${INCLUDE_FOLDER}/ada/*.h")
file(GLOB GL_HEADER "${INCLUDE_FOLDER}/ada/gl/*.h")
file(GLOB SCENE_HEADER "${INCLUDE_FOLDER}/ada/scene/*.h")
file(GLOB TOOLS_HEADER "${INCLUDE_FOLDER}/ada/tools/*.h")
file(GLOB SHADERS_HEADER "${INCLUDE_FOLDER}/ada/shaders/*.h")
set(ADA_SOURCES
app.cpp
draw.cpp
window.cpp
fs.cpp
time.cpp
string.cpp
pixel.cpp
font.cpp
geom/triangle.cpp
geom/line.cpp
geom/mesh.cpp
geom/meshes.cpp
geom/ops.cpp
gl/gl.cpp
gl/fbo.cpp
gl/vbo.cpp
gl/shader.cpp
gl/defines.cpp
gl/pingpong.cpp
gl/texture.cpp
gl/textureBump.cpp
gl/textureCube.cpp
gl/textureProps.cpp
gl/textureStreamAV.cpp
gl/textureStreamOMX.cpp
gl/textureStreamMMAL.cpp
gl/textureStreamAudio.cpp
gl/textureStreamSequence.cpp
gl/convolutionPyramid.cpp
gl/vertexLayout.cpp
scene/sky.cpp
scene/node.cpp
scene/model.cpp
scene/light.cpp
scene/label.cpp
scene/camera.cpp
scene/material.cpp
shaders/defaultShaders.cpp
devices/holoPlay.cpp
)
# C++ LIBRAY
#
add_library(ada ${ADA_SOURCES})
set_target_properties(ada PROPERTIES
CXX_STANDARD 11
CXX_STANDARD_REQUIRED ON
)
find_package(BROADCOM)
if (BROADCOM_FOUND)
message(STATUS "BROADCOM_DEFINITIONS: ${BROADCOM_DEFINITIONS}")
message(STATUS "BROADCOM_INCLUDE_DIRS: ${BROADCOM_INCLUDE_DIRS}")
message(STATUS "BROADCOM_LIBRARIES: ${BROADCOM_LIBRARIES}")
target_include_directories(ada PUBLIC ${BROADCOM_INCLUDE_DIRS})
target_link_libraries(ada PUBLIC ${BROADCOM_LIBRARIES})
target_compile_definitions(ada PUBLIC ${BROADCOM_DEFINITIONS})
endif()
if (BROADCOM_INCLUDE_DIR)
message(STATUS "PLATFORM RASPBERRYPI")
target_compile_definitions(ada PUBLIC PLATFORM_RPI)
endif()
find_package(ILCLIENT)
if (ILCLIENT_FOUND)
target_include_directories(ada PUBLIC ${ILCLIENT_INCLUDE_DIR} )
target_link_libraries(ada PUBLIC ${ILCLIENT_LIBRARY} )
endif()
find_package(OMAX)
if (OMAX_FOUND AND ILCLIENT_FOUND)
target_compile_definitions(ada PUBLIC ${OMAX_DEFINITIONS})
target_link_libraries(ada PUBLIC ${OMAX_LIBRARIES})
target_compile_definitions(ada PUBLIC SUPPORT_OMAX)
endif()
find_package(MMAL)
if (MMAL_FOUND)
target_link_libraries(ada PUBLIC ${MMAL_LIBRARIES})
target_compile_definitions(ada PUBLIC SUPPORT_MMAL)
endif()
find_package(FFMPEG)
if (FFMPEG_FOUND)
message(STATUS "LIBAV Supported")
target_include_directories(ada PUBLIC ${FFMPEG_INCLUDE_DIRS})
target_link_libraries(ada PUBLIC ${FFMPEG_LIBRARIES})
target_compile_definitions(ada PUBLIC SUPPORT_LIBAV )
else()
# We could not find it ourself, so let's resort to pkg_config that is better when is present
# but may be not available in some cases (I'm looking at you windows)
find_package(PkgConfig)
if (PkgConfig_FOUND)
pkg_check_modules(FFPMEG
IMPORTED_TARGET GLOBAL
libavdevice
libavfilter
libavformat
libavcodec
libswresample
libswscale
libavutil
)
if (FFPMEG_FOUND)
message(STATUS "LIBAV Supported")
target_link_libraries(ada PUBLIC PkgConfig::FFPMEG)
target_compile_definitions(ada PUBLIC SUPPORT_LIBAV)
endif()
endif()
endif()
if (NO_X11 OR FORCE_GBM)
if (BROADCOM_FOUND AND NOT FORCE_GBM)
message(STATUS "USING BROADCOM DRIVERS")
target_compile_definitions(ada PUBLIC DRIVER_BROADCOM )
target_link_libraries(ada PUBLIC
${BCM_EGL}
${BCM_GLESv2}
)
else()
message(STATUS "USING DRM and GBM DRIVERS")
target_compile_definitions(ada PUBLIC DRIVER_GBM)
find_package(DRM)
find_package(GBM)
target_include_directories(ada PUBLIC
${DRM_INCLUDE_DIRS}
${GBM_INCLUDE_DIRS}
)
target_link_libraries(ada PUBLIC
${DRM_LIBRARIES}
${GBM_LIBRARY}
)
find_package(EGL)
find_package(GLESv2)
message(STATUS "EGL_INCLUDE_DIRS: ${EGL_INCLUDE_DIRS}")
message(STATUS "EGL_LIBRARIES: ${EGL_LIBRARIES}")
message(STATUS "GLESv2_INCLUDE_DIRS: ${GLESv2_INCLUDE_DIRS}")
message(STATUS "GLESv2_LIBRARIES: ${GLESv2_LIBRARIES}")
target_include_directories(ada PUBLIC
${EGL_INCLUDE_DIRS}
${GLESv2_INCLUDE_DIRS}
)
target_link_libraries(ada PUBLIC
${EGL_LIBRARIES}
${GLESv2_LIBRARIES}
)
endif()
else()
message(STATUS "USING GLFW DRIVERS")
target_compile_definitions(ada PUBLIC
DRIVER_GLFW
GL_OPENGL
)
target_link_libraries(ada PUBLIC
glfw
${GLFW_LIBRARIES}
)
# OPENGL
if (APPLE)
message(STATUS "PLATFORM OSX")
target_compile_definitions(ada PUBLIC PLATFORM_OSX)
target_link_libraries(ada PUBLIC
"-framework OpenGL"
)
elseif (MSVC)
message(STATUS "PLATFORM WINDOWS")
target_compile_definitions(ada PUBLIC PLATFORM_WINDOWS)
target_include_directories(ada PUBLIC
"${PROJECT_SOURCE_DIR}/deps/glew/include"
)
target_link_libraries(ada PUBLIC
libglew_static
)
# RASPBERRY PI
elseif (BROADCOM_INCLUDE_DIR)
find_package(EGL)
find_package(GLESv2)
message(STATUS "EGL_INCLUDE_DIRS: ${EGL_INCLUDE_DIRS}")
message(STATUS "EGL_LIBRARIES: ${EGL_LIBRARIES}")
message(STATUS "GLESv2_INCLUDE_DIRS: ${GLESv2_INCLUDE_DIRS}")
message(STATUS "GLESv2_LIBRARIES: ${GLESv2_LIBRARIES}")
target_include_directories(ada PUBLIC
${EGL_INCLUDE_DIRS}
${GLESv2_INCLUDE_DIRS}
)
target_link_libraries(ada PUBLIC
${EGL_LIBRARIES}
${GLESv2_LIBRARIES}
${OPENGL_LIBRARIES}
)
elseif (EMSCRIPTEN)
message(STATUS "PLATFORM EMSCRIPTEN")
target_compile_definitions(ada PUBLIC PLATFORM_EMSCRIPTEN)
target_link_libraries(ada PUBLIC
${OPENGL_LIBRARIES}
)
# # UNCOMMENT FOR MULTIPLE THREAD SUPPORT FOR WASM
# # note: only works on desktop chrome
# set(LFLAGS "${LFLAGS} -pthread")
# set(LFLAGS "${LFLAGS} -s USE_PTHREADS=1")
# set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${LFLAGS}")
# set_target_properties(ada PROPERTIES LINK_FLAGS "${LFLAGS}")
# target_link_libraries(ada PUBLIC -pthread )
else()
message(STATUS "PLATFORM LINUX")
target_compile_definitions(ada PUBLIC PLATFORM_LINUX)
set(OpenGL_GL_PREFERENCE GLVND)
find_package(OpenGL REQUIRED)
target_link_libraries(ada PUBLIC
OpenGL::GL
)
endif()
endif()
# We need this directory, and users of our library will need it too
target_include_directories(ada PUBLIC
${INCLUDE_FOLDER}
"${PROJECT_SOURCE_DIR}/deps/glm"
"${PROJECT_SOURCE_DIR}/deps/stb"
"${PROJECT_SOURCE_DIR}/deps/glob"
"${PROJECT_SOURCE_DIR}/deps/skymodel"
"${PROJECT_SOURCE_DIR}/deps/fontstash"
"${PROJECT_SOURCE_DIR}/deps/miniaudio"
)
## DEPS
target_link_libraries(ada PUBLIC stb glob skymodel )
# IDEs should put the headers in a nice place
# source_group( TREE ${INCLUDE_FOLDER}
# PREFIX "Header Files" FILES ${ROOT_HEADER})
# install(TARGETS ${PROJECT_NAME} DESTINATION lib)
# install(FILES ${ROOT_HEADER} DESTINATION include/ada)
# install(FILES ${GL_HEADER} DESTINATION include/ada/gl)
# install(FILES ${SCENE_HEADER} DESTINATION include/ada/gl)
# install(FILES ${TOOLS_HEADER} DESTINATION include/ada/tools)
# install(FILES ${SHADERS_HEADER} DESTINATION include/ada/shaders)