-
Notifications
You must be signed in to change notification settings - Fork 232
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
388 lines (332 loc) · 12.3 KB
/
CMakeLists.txt
File metadata and controls
388 lines (332 loc) · 12.3 KB
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
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
# Maybe stop from CMAKEing in the wrong place
if (CMAKE_BINARY_DIR STREQUAL CMAKE_SOURCE_DIR)
message(FATAL_ERROR "Source and build directories cannot be the same. Go use the /build directory.")
endif()
SET(INCLUDE_ROOT "${CMAKE_CURRENT_SOURCE_DIR}/../include/polyscope/")
# We need the shared openGL backend if either of these backends are enabled
if(POLYSCOPE_BACKEND_OPENGL3_GLFW OR POLYSCOPE_BACKEND_OPENGL3_EGL)
SET(POLYSCOPE_BACKEND_OPENGL3 TRUE)
add_definitions(-DPOLYSCOPE_BACKEND_OPENGL3_ENABLED)
else()
SET(POLYSCOPE_BACKEND_OPENGL3 FALSE)
endif()
# Lists that will be populated for the render backend
# Add the main _engine file no matter what. All of the interesting parts are ifdef'd out, and this
# allows us to resolve stubs.
list (APPEND BACKEND_SRCS
render/opengl/gl_engine.cpp
render/opengl/gl_engine_glfw.cpp
render/opengl/gl_engine_egl.cpp
render/mock_opengl/mock_gl_engine.cpp
render/opengl/shaders/texture_draw_shaders.cpp
render/opengl/shaders/lighting_shaders.cpp
render/opengl/shaders/grid_shaders.cpp
render/opengl/shaders/ground_plane_shaders.cpp
render/opengl/shaders/gizmo_shaders.cpp
render/opengl/shaders/histogram_shaders.cpp
render/opengl/shaders/surface_mesh_shaders.cpp
render/opengl/shaders/volume_mesh_shaders.cpp
render/opengl/shaders/vector_shaders.cpp
render/opengl/shaders/sphere_shaders.cpp
render/opengl/shaders/ribbon_shaders.cpp
render/opengl/shaders/cylinder_shaders.cpp
render/opengl/shaders/rules.cpp
render/opengl/shaders/common.cpp
)
# Configure the render backend(s)
if("${POLYSCOPE_BACKEND_OPENGL3_GLFW}")
message("Polyscope backend openGL3_glfw enabled")
list(APPEND BACKEND_HEADERS
${INCLUDE_ROOT}render/opengl/gl_engine_glfw.h
${INCLUDE_ROOT}render/opengl/shaders/common.h
)
# Link settings
list(APPEND BACKEND_LIBS
glfw
)
if(APPLE)
# On macOS, get openGL & friends from Frameworks; do not use GLAD at all
# NOTE: This code is essentially duplicated here and in deps/imgui/CMakeLists.txt
# Apple is playing hardball and deprecating openGL... we'll cross that bridge when we come to it
# Silence warnings about openGL deprecation
add_definitions(-DGL_SILENCE_DEPRECATION)
find_library(cocoa_library Cocoa)
find_library(opengl_library OpenGL)
find_library(corevideo_library CoreVideo)
find_library(iokit_library IOKit)
list(APPEND BACKEND_LIBS ${cocoa_library} ${opengl_library} ${corevideo_library} ${iokit_library})
else()
# On Windows/Linux, use the glad openGL loader
list(APPEND BACKEND_LIBS glad)
endif()
add_definitions(-DPOLYSCOPE_BACKEND_OPENGL3_GLFW_ENABLED)
endif()
## some logic to decide whether or not EGL is available and whether we want to build with it
include(CheckIncludeFileCXX)
CHECK_INCLUDE_FILE_CXX("EGL/egl.h" HAVE_EGL_LIB)
if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
set(IS_LINUX TRUE)
else()
set(IS_LINUX FALSE)
endif()
if(POLYSCOPE_BACKEND_OPENGL3_EGL STREQUAL "AUTO")
if(IS_LINUX AND HAVE_EGL_LIB) # "AUTO" policy: only enable if we're on linux and EGL libs seem to be present
set(POLYSCOPE_BACKEND_OPENGL3_EGL ON)
else()
set(POLYSCOPE_BACKEND_OPENGL3_EGL OFF)
endif()
elseif(POLYSCOPE_BACKEND_OPENGL3_EGL) # if "TRUE" (or "ON" or "YES" etc etc)
# sanity check that we can actually use the EGL backend
if(NOT IS_LINUX)
message(FATAL_ERROR "EGL backend is only supported on linux. Disable it with POLYSCOPE_BACKEND_OPENGL3_EGL=False")
endif()
if(NOT HAVE_EGL_LIB)
message(FATAL_ERROR "EGL backend requires EGL headers, but 'EGL/egl.h' was not found. On Ubuntu, try 'apt-get install libegl1-mesa-dev'")
endif()
# we should be good-to-go for EGL
else()
# nothing to do, already disabled
endif()
if("${POLYSCOPE_BACKEND_OPENGL3_EGL}")
message("Polyscope backend openGL3_egl enabled")
# this only supports headless rendering, and as of Mar 2024 headless rendering seems to only be available on nvidia drivers.
list(APPEND BACKEND_HEADERS
${INCLUDE_ROOT}render/opengl/gl_engine_egl.h
${INCLUDE_ROOT}render/opengl/shaders/common.h
)
if(APPLE)
message(FATAL_ERROR "Compiling EGL backed on APPLE is not supported. Set POLYSCOPE_BACKEND_OPENGL3_EGL=False")
else()
# On Windows/Linux, use the glad openGL loader
list(APPEND BACKEND_LIBS glad)
if(WIN32)
message(FATAL_ERROR "Compiling EGL backed on Windows is not supported. Set POLYSCOPE_BACKEND_OPENGL3_EGL=False")
else() # linux
# only linux is actually supported for EGL
# We intentionally *do not* list this as a shared library dependency, it gets loaded optionally at runtime
# via dlopen(). See explanation in gl_engine_egl.cpp.
# list(APPEND BACKEND_LIBS EGL)
endif()
endif()
add_definitions(-DPOLYSCOPE_BACKEND_OPENGL3_EGL_ENABLED)
endif()
if("${POLYSCOPE_BACKEND_OPENGL_MOCK}")
message("Polyscope backend openGL_mock enabled")
list(APPEND BACKEND_HEADERS
${INCLUDE_ROOT}render/mock_opengl/mock_gl_engine.h
${INCLUDE_ROOT}render/opengl/shaders/common.h
)
add_definitions(-DPOLYSCOPE_BACKEND_OPENGL_MOCK_ENABLED)
endif()
SET(SRCS
# Core functionality
polyscope.cpp
options.cpp
internal.cpp
state.cpp
structure.cpp
quantity.cpp
group.cpp
utilities.cpp
view.cpp
screenshot.cpp
messages.cpp
pick.cpp
widget.cpp
# Rendering stuff
render/engine.cpp
render/color_maps.cpp
render/ground_plane.cpp
render/materials.cpp
render/initialize_backend.cpp
render/shader_builder.cpp
render/managed_buffer.cpp
render/templated_buffers.cpp
# General utilities
disjoint_sets.cpp
file_helpers.cpp
camera_parameters.cpp
color_bar.cpp
persistent_value.cpp
color_management.cpp
transformation_gizmo.cpp
slice_plane.cpp
weak_handle.cpp
marching_cubes.cpp
elementary_geometry.cpp
## Structures
# Point cloud
point_cloud.cpp
point_cloud_color_quantity.cpp
point_cloud_scalar_quantity.cpp
point_cloud_vector_quantity.cpp
point_cloud_parameterization_quantity.cpp
# Surface
surface_mesh.cpp
surface_color_quantity.cpp
surface_scalar_quantity.cpp
surface_vector_quantity.cpp
surface_parameterization_quantity.cpp
# Curve network
curve_network.cpp
curve_network_color_quantity.cpp
curve_network_scalar_quantity.cpp
curve_network_vector_quantity.cpp
# Volume mesh
volume_mesh.cpp
volume_mesh_color_quantity.cpp
volume_mesh_scalar_quantity.cpp
volume_mesh_vector_quantity.cpp
# Volume grid
volume_grid.cpp
volume_grid_scalar_quantity.cpp
# Camera view
camera_view.cpp
# Simple triangle mesh
simple_triangle_mesh.cpp
# Floating quantities
floating_quantity_structure.cpp
floating_quantity.cpp
image_quantity_base.cpp
scalar_image_quantity.cpp
color_image_quantity.cpp
render_image_quantity_base.cpp
depth_render_image_quantity.cpp
color_render_image_quantity.cpp
scalar_render_image_quantity.cpp
raw_color_render_image_quantity.cpp
raw_color_alpha_render_image_quantity.cpp
# Rendering utilities
imgui_config.cpp
fullscreen_artist.cpp
## Embedded binary data
render/bindata/bindata_font_lato_regular.cpp
render/bindata/bindata_font_cousine_regular.cpp
render/bindata/bindata_font_lucide_icons.cpp
render/bindata/concrete_seamless.cpp
render/bindata/bindata_clay.cpp
render/bindata/bindata_wax.cpp
render/bindata/bindata_candy.cpp
render/bindata/bindata_flat.cpp
render/bindata/bindata_mud.cpp
render/bindata/bindata_ceramic.cpp
render/bindata/bindata_jade.cpp
render/bindata/bindata_normal.cpp
)
# Setting headers is useful for some build systems. For instance, in Visual Studio this is necessary for the header files to be indexed as a part of the project.
SET(HEADERS
${INCLUDE_ROOT}/affine_remapper.h
${INCLUDE_ROOT}/affine_remapper.ipp
${INCLUDE_ROOT}/camera_parameters.h
${INCLUDE_ROOT}/camera_parameters.ipp
${INCLUDE_ROOT}/camera_view.h
${INCLUDE_ROOT}/camera_view.ipp
${INCLUDE_ROOT}/check_invalid_values.h
${INCLUDE_ROOT}/color_bar.h
${INCLUDE_ROOT}/color_management.h
${INCLUDE_ROOT}/color_image_quantity.h
${INCLUDE_ROOT}/color_render_image_quantity.h
${INCLUDE_ROOT}/colors.h
${INCLUDE_ROOT}/color_quantity.h
${INCLUDE_ROOT}/color_quantity.ipp
${INCLUDE_ROOT}/combining_hash_functions.h
${INCLUDE_ROOT}/context.h
${INCLUDE_ROOT}/curve_network.h
${INCLUDE_ROOT}/curve_network.ipp
${INCLUDE_ROOT}/curve_network_color_quantity.h
${INCLUDE_ROOT}/curve_network_quantity.h
${INCLUDE_ROOT}/curve_network_scalar_quantity.h
${INCLUDE_ROOT}/curve_network_vector_quantity.h
${INCLUDE_ROOT}/disjoint_sets.h
${INCLUDE_ROOT}/depth_render_image_quantity.h
${INCLUDE_ROOT}/elementary_geometry.h
${INCLUDE_ROOT}/file_helpers.h
${INCLUDE_ROOT}/floating_quantity_structure.h
${INCLUDE_ROOT}/floating_quantity.h
${INCLUDE_ROOT}/floating_quantities.h
${INCLUDE_ROOT}/group.h
${INCLUDE_ROOT}/image_quantity.h
${INCLUDE_ROOT}/imgui_config.h
${INCLUDE_ROOT}/implicit_helpers.h
${INCLUDE_ROOT}/implicit_helpers.ipp
${INCLUDE_ROOT}/messages.h
${INCLUDE_ROOT}/numeric_helpers.h
${INCLUDE_ROOT}/options.h
${INCLUDE_ROOT}/parameterization_quantity.h
${INCLUDE_ROOT}/parameterization_quantity.ipp
${INCLUDE_ROOT}/persistent_value.h
${INCLUDE_ROOT}/pick.h
${INCLUDE_ROOT}/pick.ipp
${INCLUDE_ROOT}/point_cloud.h
${INCLUDE_ROOT}/point_cloud.ipp
${INCLUDE_ROOT}/point_cloud_color_quantity.h
${INCLUDE_ROOT}/point_cloud_quantity.h
${INCLUDE_ROOT}/point_cloud_scalar_quantity.h
${INCLUDE_ROOT}/point_cloud_parameterization_quantity.h
${INCLUDE_ROOT}/point_cloud_vector_quantity.h
${INCLUDE_ROOT}/polyscope.h
${INCLUDE_ROOT}/quantity.h
${INCLUDE_ROOT}/quantity.ipp
${INCLUDE_ROOT}/raw_color_render_image_quantity.h
${INCLUDE_ROOT}/render/color_maps.h
${INCLUDE_ROOT}/render/engine.h
${INCLUDE_ROOT}/render/engine.ipp
${INCLUDE_ROOT}/render/ground_plane.h
${INCLUDE_ROOT}/render/managed_buffer.h
${INCLUDE_ROOT}/render/managed_buffer.ipp
${INCLUDE_ROOT}/render/material_defs.h
${INCLUDE_ROOT}/render/materials.h
${INCLUDE_ROOT}/render_image_quantity_base.h
${INCLUDE_ROOT}/scaled_value.h
${INCLUDE_ROOT}/scalar_quantity.h
${INCLUDE_ROOT}/scalar_quantity.ipp
${INCLUDE_ROOT}/screenshot.h
${INCLUDE_ROOT}/simple_triangle_mesh.h
${INCLUDE_ROOT}/simple_triangle_mesh.ipp
${INCLUDE_ROOT}/slice_plane.h
${INCLUDE_ROOT}/standardize_data_array.h
${INCLUDE_ROOT}/structure.h
${INCLUDE_ROOT}/structure.ipp
${INCLUDE_ROOT}/surface_color_quantity.h
${INCLUDE_ROOT}/surface_mesh.h
${INCLUDE_ROOT}/surface_mesh.ipp
${INCLUDE_ROOT}/surface_mesh_quantity.h
${INCLUDE_ROOT}/surface_parameterization_quantity.h
${INCLUDE_ROOT}/surface_scalar_quantity.h
${INCLUDE_ROOT}/surface_vector_quantity.h
${INCLUDE_ROOT}/texture_map_quantity.h
${INCLUDE_ROOT}/texture_map_quantity.ipp
${INCLUDE_ROOT}/types.h
${INCLUDE_ROOT}/utilities.h
${INCLUDE_ROOT}/view.h
${INCLUDE_ROOT}/vector_quantity.h
${INCLUDE_ROOT}/vector_quantity.ipp
${INCLUDE_ROOT}/volume_mesh.h
${INCLUDE_ROOT}/volume_mesh.ipp
${INCLUDE_ROOT}/volume_mesh_quantity.h
${INCLUDE_ROOT}/volume_mesh_scalar_quantity.h
${INCLUDE_ROOT}/volume_mesh_color_quantity.h
${INCLUDE_ROOT}/volume_mesh_vector_quantity.h
${INCLUDE_ROOT}/volume_grid.h
${INCLUDE_ROOT}/volume_grid.ipp
${INCLUDE_ROOT}/volume_grid_quantity.h
${INCLUDE_ROOT}/volume_grid_scalar_quantity.h
${INCLUDE_ROOT}/weak_handle.h
)
# Create a single library for the project
add_library(polyscope ${SRCS} ${BACKEND_SRCS} ${HEADERS} ${BACKEND_HEADERS})
# Mark the library target and its headers as installable
install(TARGETS polyscope)
install(DIRECTORY ${INCLUDE_ROOT}/ DESTINATION "${CMAKE_INSTALL_PREFIX}/include/polyscope")
# Required compiler settings
set_property(TARGET polyscope PROPERTY CXX_STANDARD 11)
set_property(TARGET polyscope PROPERTY CXX_STANDARD_REQUIRED TRUE)
set_target_properties(polyscope PROPERTIES POSITION_INDEPENDENT_CODE TRUE)
add_definitions(-DNOMINMAX)
# Include settings
target_include_directories(polyscope PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/../include")
# Link settings
target_link_libraries(polyscope PUBLIC imgui glm::glm)
target_link_libraries(polyscope PRIVATE "${BACKEND_LIBS}" stb nlohmann_json::nlohmann_json MarchingCube::MarchingCube)
# For now, make this private, until we are sure we want to commit to it. We may expose it as public in the future.
target_link_libraries(polyscope PRIVATE IconFontCppHeaders)