-
Notifications
You must be signed in to change notification settings - Fork 1
/
CMakeLists.txt
282 lines (229 loc) · 8.35 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
273
274
275
276
277
278
279
280
281
282
cmake_minimum_required(VERSION 2.8.12)
project(medleap)
# Directory for cmake modules
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/")
# output the executable in the build directory (not Debug/Release subdir)
foreach(OUTPUTCONFIG ${CMAKE_CONFIGURATION_TYPES})
string(TOUPPER ${OUTPUTCONFIG} OUTPUTCONFIG)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_${OUTPUTCONFIG} ${CMAKE_CURRENT_BINARY_DIR})
endforeach(OUTPUTCONFIG CMAKE_CONFIGURATION_TYPES)
# make sure resources are copied into the build directory
set(DATA_SHADERS
shaders/color.vert
shaders/color.frag
shaders/slice_clut.vert
shaders/slice_clut.frag
shaders/volume_clut.vert
shaders/volume_clut.frag
shaders/histo_line.vert
shaders/histo_line.frag
shaders/clut_strip.vert
shaders/clut_strip.frag
shaders/texture_2D.vert
shaders/texture_2D.frag
shaders/menu.vert
shaders/menu.frag
shaders/color_pick_hsv_circle.vert
shaders/color_pick_hsv_circle.frag
shaders/color_pick_selected.vert
shaders/color_pick_selected.frag
shaders/color_pick_gradient.vert
shaders/color_pick_gradient.frag
shaders/tf1d_histo.vert
shaders/tf1d_histo.frag
shaders/tf1d_histo_outline.vert
shaders/tf1d_histo_outline.frag
shaders/orientation_cube.vert
shaders/orientation_cube.frag
shaders/icon.vert
shaders/icon.frag
)
set(DATA_FONTS
fonts/menlo14.bmp
fonts/menlo14.dat
fonts/menlo18.bmp
fonts/menlo18.dat
fonts/menlo24.bmp
fonts/menlo24.dat
)
set(DATA_ICONS
icons/carry.png
icons/fist.png
icons/l_closed.png
icons/l_open.png
icons/palms_face.png
icons/pinch.png
icons/point.png
icons/point2.png
icons/three.png
icons/thumb.png
icons/v_closed.png
icons/v_open.png
)
foreach(item IN LISTS DATA_SHADERS DATA_FONTS DATA_ICONS)
add_custom_command(
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${item}"
COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_CURRENT_SOURCE_DIR}/${item}" "${CMAKE_CURRENT_BINARY_DIR}/${item}"
DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/${item}"
)
endforeach()
add_custom_target(SHADER_COPY ALL DEPENDS ${DATA_SHADERS} ${DATA_FONTS} ${DATA_ICONS})
# source group naming for IDEs
source_group("shaders" FILES ${DATA_SHADERS})
source_group("fonts" FILES ${DATA_FONTS})
source_group("icons" FILES ${DATA_ICONS})
file(GLOB SOURCE_GL src/gl/*.cpp src/gl/*.c src/gl/*.h)
source_group("gl" FILES ${SOURCE_GL})
file(GLOB SOURCE_GL_GEOM src/gl/geom/*.cpp src/gl/geom/*.h)
source_group("gl\\geom" FILES ${SOURCE_GL_GEOM})
file(GLOB SOURCE_GL_UTIL src/gl/util/*.cpp src/gl/util/*.h)
source_group("gl\\util" FILES ${SOURCE_GL_UTIL})
file(GLOB SOURCE_GL_MATH src/gl/math/*.cpp src/gl/math/*.h)
source_group("gl\\math" FILES ${SOURCE_GL_MATH})
file(GLOB SOURCE_MAIN src/main/*.cpp src/main/*.h)
source_group("main" FILES ${SOURCE_MAIN})
file(GLOB SOURCE_DATA src/data/*.cpp src/data/*.h)
source_group("data" FILES ${SOURCE_DATA})
file(GLOB SOURCE_LEAP src/leap/*.cpp src/leap/*.h)
source_group("leap" FILES ${SOURCE_LEAP})
file(GLOB SOURCE_UTIL src/util/*.cpp src/util/*.h src/util/*.c)
source_group("util" FILES ${SOURCE_UTIL})
file(GLOB SOURCE_LAYERS src/layers/*.cpp src/layers/*.h)
source_group("layers" FILES ${SOURCE_LAYERS})
file(GLOB SOURCE_LAYER_SLICE src/layers/slice/*.cpp src/layers/slice/*.h)
source_group("layers\\slice" FILES ${SOURCE_LAYER_SLICE})
file(GLOB SOURCE_LAYER_TFN1D src/layers/transfer_1D/*.cpp src/layers/transfer_1D/*.h)
source_group("layers\\transfer_1D" FILES ${SOURCE_LAYER_TFN1D})
file(GLOB SOURCE_LAYER_TFN2D src/layers/transfer_2D/*.cpp src/layers/transfer_2D/*.h)
source_group("layers\\transfer_2D" FILES ${SOURCE_LAYER_TFN2D})
file(GLOB SOURCE_LAYER_VOLUME src/layers/volume/*.cpp src/layers/volume/*.h)
source_group("layers\\volume" FILES ${SOURCE_LAYER_VOLUME})
file(GLOB SOURCE_LAYER_VOLINFO src/layers/volume_info/*.cpp src/layers/volume_info/*.h)
source_group("layers\\volume_info" FILES ${SOURCE_LAYER_VOLINFO})
file(GLOB SOURCE_LAYER_VOLORNT src/layers/volume_orientation/*.cpp src/layers/volume_orientation/*.h)
source_group("layers\\volume_orientation" FILES ${SOURCE_LAYER_VOLORNT})
file(GLOB SOURCE_LAYER_MENU src/layers/menu/*.cpp src/layers/menu/*.h)
source_group("layers\\menu" FILES ${SOURCE_LAYER_MENU})
file(GLOB SOURCE_LAYER_COLORPICK src/layers/color_pick/*.cpp src/layers/color_pick/*.h)
source_group("layers\\color_pick" FILES ${SOURCE_LAYER_COLORPICK})
file(GLOB SOURCE_LAYER_ORIENTATION src/layers/orientation/*.cpp src/layers/orientation/*.h)
source_group("layers\\orientation" FILES ${SOURCE_LAYER_ORIENTATION})
file(GLOB SOURCE_LAYER_CLIP src/layers/clip/*.cpp src/layers/clip/*.h)
source_group("layers\\clip" FILES ${SOURCE_LAYER_CLIP})
file(GLOB SOURCE_LAYER_MASK src/layers/mask/*.cpp src/layers/mask/*.h)
source_group("layers\\mask" FILES ${SOURCE_LAYER_MASK})
file(GLOB SOURCE_LAYER_FOCUS src/layers/focus/*.cpp src/layers/focus/*.h)
source_group("layers\\focus" FILES ${SOURCE_LAYER_FOCUS})
file(GLOB SOURCE_LAYER_LEAP_STATE src/layers/leap_state/*.cpp src/layers/leap_state/*.h)
source_group("layers\\leap_state" FILES ${SOURCE_LAYER_LEAP_STATE})
file(GLOB SOURCE_LAYER_LOAD src/layers/load/*.cpp src/layers/load/*.h)
source_group("layers\\load" FILES ${SOURCE_LAYER_LOAD})
set(SOURCE_AND_RESOURCES
${SOURCE_MAIN}
${SOURCE_DATA}
${SOURCE_LEAP}
${SOURCE_LAYERS}
${SOURCE_LAYER_SLICE}
${SOURCE_LAYER_TFN1D}
${SOURCE_LAYER_TFN2D}
${SOURCE_LAYER_VOLUME}
${SOURCE_LAYER_VOLINFO}
${SOURCE_LAYER_VOLORNT}
${SOURCE_LAYER_MENU}
${SOURCE_LAYER_COLORPICK}
${SOURCE_LAYER_ORIENTATION}
${SOURCE_LAYER_CLIP}
${SOURCE_LAYER_MASK}
${SOURCE_LAYER_FOCUS}
${SOURCE_LAYER_LEAP_STATE}
${SOURCE_LAYER_LOAD}
${SOURCE_GL}
${SOURCE_GL_MATH}
${SOURCE_GL_GEOM}
${SOURCE_GL_UTIL}
${SOURCE_UTIL}
${DATA_SHADERS}
${DATA_FONTS}
${DATA_ICONS}
)
# set root of source directory for finding headers
include_directories(src)
# Find the libraries (must have LEAP_DIR and possibly GDCM_DIR/GLFW_DIR env variables)
find_package(GDCM CONFIG REQUIRED)
include_directories(${GDCM_INCLUDE_DIRS})
find_package(GLFW CONFIG REQUIRED)
include_directories(${GLFW_INCLUDE_DIR})
find_package(Leap REQUIRED)
include_directories(${LEAP_INCLUDE_DIR})
message(STATUS ${LEAP_INCLUDE_DIR})
if (APPLE)
add_executable(${PROJECT_NAME} MACOSX_BUNDLE ${SOURCE_AND_RESOURCES})
# Copy resources to the right place in the app bundle
SET_SOURCE_FILES_PROPERTIES(
${DATA_SHADERS}
PROPERTIES
MACOSX_PACKAGE_LOCATION
Resources/shaders
)
SET_SOURCE_FILES_PROPERTIES(
${DATA_FONTS}
PROPERTIES
MACOSX_PACKAGE_LOCATION
Resources/fonts
)
SET_SOURCE_FILES_PROPERTIES(
${DATA_ICONS}
PROPERTIES
MACOSX_PACKAGE_LOCATION
Resources/icons
)
# for C++11
set(CMAKE_CXX_FLAGS "-std=c++11 -stdlib=libc++")
# GLFW needs OpenGL, Cocoa, IOKit, and CoreVideo frameworks linked
find_library(OPENGL_LIBRARY OpenGL)
find_library(COCOA_LIBRARY Cocoa)
find_library(IOKIT_LIBRARY IOKit)
find_library(COREVIDEO_LIBRARY CoreVideo)
# Link all the libraries
target_link_libraries(
${PROJECT_NAME}
gdcmMSFF
${GLFW_LIBRARY}
${OPENGL_LIBRARY}
${COCOA_LIBRARY}
${IOKIT_LIBRARY}
${COREVIDEO_LIBRARY}
${LEAP_LIBRARY}
)
# Copy libLeap.dylib to output directory
add_custom_command(
TARGET ${PROJECT_NAME}
POST_BUILD
COMMAND ${CMAKE_COMMAND} ARGS -E copy
${LEAP_LIBRARY}
$<TARGET_FILE_DIR:${PROJECT_NAME}>
)
endif(APPLE)
if (WIN32)
add_executable(${PROJECT_NAME} ${SOURCE_AND_RESOURCES})
# is this still needed? check
add_definitions(-DGLEW_STATIC)
target_link_libraries(
${PROJECT_NAME}
gdcmMSFF
opengl32
${GLFW_LIBRARY}
)
# use Leap.lib for RELEASE or Leapd.lib for DEBUG
target_link_libraries (${PROJECT_NAME} optimized ${LEAP_LIB_RELEASE} debug ${LEAP_LIB_DEBUG})
# copy Leap.dll for RELEASE or Leapd.dll for DEBUG into output directory
add_custom_command(
TARGET ${PROJECT_NAME}
POST_BUILD
COMMAND ${CMAKE_COMMAND} ARGS -E copy
"$<$<CONFIG:debug>:${LEAP_DLL_DEBUG}>$<$<CONFIG:release>:${LEAP_DLL_RELEASE}>"
$<TARGET_FILE_DIR:${PROJECT_NAME}>
)
endif(WIN32)
# Ensure shaders are copied whenever modified
add_dependencies(${PROJECT_NAME} SHADER_COPY)