forked from SCIInstitute/fluorender
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
406 lines (364 loc) · 14.2 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
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
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
#/*
#For more information, please see: http://software.sci.utah.edu
#
#The MIT License
#
#Copyright (c) 2014 Scientific Computing and Imaging Institute,
#University of Utah.
#
#
#Permission is hereby granted, free of charge, to any person obtaining a
#copy of this software and associated documentation files (the "Software"),
#to deal in the Software without restriction, including without limitation
#the rights to use, copy, modify, merge, publish, distribute, sublicense,
#and/or sell copies of the Software, and to permit persons to whom the
#Software is furnished to do so, subject to the following conditions:
#
#The above copyright notice and this permission notice shall be included
#in all copies or substantial portions of the Software.
#
#THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
#OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
#FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
#THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
#LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
#FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
#DEALINGS IN THE SOFTWARE.
#*/
#This is an CMake configuration file for FluoRender
cmake_minimum_required ( VERSION 2.6 )
#for MSVC builds
if(${CMAKE_SYSTEM_NAME} MATCHES "Windows")
if(MSVC)
SET(MSVC_INCREMENTAL_DEFAULT OFF)
endif()
endif()
project ( FluoRender )
IF(COMMAND cmake_policy)
CMAKE_POLICY(SET CMP0040 NEW)
CMAKE_POLICY(SET CMP0043 NEW)
ENDIF(COMMAND cmake_policy)
if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
# Mac OS X
set(ARCHITECTURE 64)
else()
# Windows
if(${CMAKE_SIZEOF_VOID_P} MATCHES "8")
set(ARCHITECTURE 64)
else()
set(ARCHITECTURE 32)
endif()
endif()
if(${ARCHITECTURE} MATCHES "64")
add_definitions(-DFLUORENDER_ARCH="64bit")
else()
add_definitions(-DFLUORENDER_ARCH="32bit")
endif()
add_definitions(-DFLUORENDER_TITLE="FluoRender")
add_definitions(-DVERSION_MAJOR=2)
add_definitions(-DVERSION_MINOR=17)
add_definitions(-DVERSION_MAJOR_TAG="2")
add_definitions(-DVERSION_MINOR_TAG="17")
add_definitions(-DVERSION_COPYRIGHT="June 2015")
#static compile
add_definitions(-DSTATIC_COMPILE)
#teem required definitions
add_definitions(-DTEEM_DIO=0)
add_definitions(-DTEEM_ENDIAN=1234)
add_definitions(-DTEEM_QNANHIBIT=1)
#output directories
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BUILD_DIR})
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BUILD_DIR})
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
#wxWidgets
set(wxWidgets_USE_REL_AND_DBG ON)
if(${CMAKE_BUILD_TYPE} MATCHES "Release")
set(wxWidgets_CONFIGURATION mswu)
elseif(${CMAKE_BUILD_TYPE} MATCHES "Debug")
set(wxWidgets_CONFIGURATION mswud)
endif()
find_package(wxWidgets COMPONENTS core base aui html xml adv gl stc scintilla REQUIRED)
include(${wxWidgets_USE_FILE})
set(wxWidgets_USE_STATIC ON)
if (APPLE)
find_package(TIFF REQUIRED)
include_directories(${TIFF_INCLUDE_DIR})
else()
include_directories(${wxWidgets_ROOT_DIR}/src/tiff/libtiff)
endif()
add_definitions(-DUNICODE)
add_definitions(-D_UNICODE)
#solution for wxWidgets linking "ambiguous" errors
add_definitions(-D_WCHAR_H_CPLUSPLUS_98_CONFORMANCE_)
#fix the library names for OSX if needed.
if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
foreach(arg ${wxWidgets_LIBRARIES})
set(wxlib_out "${wxlib_out} ${arg}")
endforeach()
string(STRIP ${wxlib_out} wxWidgets_LIBRARIES)
string(REGEX REPLACE "libwx_osx_cocoau_scintilla" "libwxscintilla"
wxWidgets_LIBRARIES ${wxWidgets_LIBRARIES})
find_package(Freetype REQUIRED)
include_directories(${FREETYPE_INCLUDE_DIRS})
endif()
#OpenGL
find_package(OpenGL REQUIRED)
#Boost
set(Boost_USE_STATIC_LIBS ON) # only find static libs
set(Boost_USE_MULTITHREADED ON)
set(Boost_USE_STATIC_RUNTIME OFF)
find_package(Boost COMPONENTS system chrono REQUIRED)
include_directories(${Boost_INCLUDE_DIR})
#teem
include_directories(${FluoRender_SOURCE_DIR}/fluorender/teem)
include_directories(${FluoRender_SOURCE_DIR}/fluorender/teem/Biff)
include_directories(${FluoRender_SOURCE_DIR}/fluorender/teem/Air)
include_directories(${FluoRender_SOURCE_DIR}/fluorender/teem/Hest)
include_directories(${FluoRender_SOURCE_DIR}/fluorender/teem/Nrrd)
file(GLOB airsrc fluorender/teem/Air/*.c)
file(GLOB airhdr fluorender/teem/Air/*.h)
file(GLOB hestsrc fluorender/teem/Hest/*.c)
file(GLOB hesthdr fluorender/teem/Hest/*.h)
file(GLOB biffsrc fluorender/teem/Biff/*.c)
file(GLOB biffhdr fluorender/teem/Biff/*.h)
file(GLOB nrrdsrc fluorender/teem/Nrrd/*.c)
file(GLOB nrrdhdr fluorender/teem/Nrrd/*.h)
add_library(TEEM_OBJ OBJECT
${airsrc} ${hestsrc} ${nrrdsrc} ${biffsrc}
${airhdr} ${hesthdr} ${nrrdhdr} ${biffhdr})
#glew
include_directories(${FluoRender_SOURCE_DIR}/fluorender/glew)
include_directories(${FluoRender_SOURCE_DIR}/fluorender/glew/GL)
file(GLOB gl_srcs fluorender/glew/*.c)
file(GLOB gl_hdrs1 fluorender/glew/*.h)
file(GLOB gl_hdrs2 fluorender/glew/GL/*.h)
add_library(GLEW_OBJ OBJECT
${gl_srcs} ${gl_hdrs1} ${gl_hdrs2})
#pole
include_directories(${FluoRender_SOURCE_DIR}/fluorender/pole)
file(GLOB pole_srcs fluorender/pole/pole.cpp)
file(GLOB pole_hdrs fluorender/pole/pole.h)
add_library(POLE_OBJ OBJECT ${pole_srcs} ${pole_hdrs})
#ffmpeg
if(${CMAKE_SYSTEM_NAME} MATCHES "Windows")
include_directories(${FluoRender_SOURCE_DIR}/fluorender/ffmpeg/Win64/include)
file(GLOB ffmpeg_LIBRARIES ${FluoRender_SOURCE_DIR}/fluorender/ffmpeg/Win64/lib/*.lib)
add_definitions(-D__STDC_CONSTANT_MACROS)
else()
include_directories(${FluoRender_SOURCE_DIR}/fluorender/ffmpeg/OSX/include)
file(GLOB ffmpeg_LIBRARIES ${FluoRender_SOURCE_DIR}/fluorender/ffmpeg/OSX/lib/*.a)
endif()
#FluoRender
include_directories(${FluoRender_SOURCE_DIR}/fluorender)
include_directories(${FluoRender_SOURCE_DIR}/fluorender/FluoRender)
#Formats
include_directories(${FluoRender_SOURCE_DIR}/fluorender/FluoRender/Formats)
file(GLOB fmt_src fluorender/FluoRender/Formats/*.cpp)
file(GLOB fmt_hdr fluorender/FluoRender/Formats/*.h)
add_library(FORMATS_OBJ OBJECT
${fmt_src} ${fmt_hdr})
#Animators
include_directories(${FluoRender_SOURCE_DIR}/fluorender/FluoRender/Animators)
file(GLOB ani_src fluorender/FluoRender/Animator/*.cpp)
file(GLOB ani_hdr fluorender/FluoRender/Animator/*.h)
add_library(ANIMATORS_OBJ OBJECT
${ani_src} ${ani_hdr})
#NV
include_directories(${FluoRender_SOURCE_DIR}/fluorender/FluoRender/NV)
file(GLOB nv_src fluorender/FluoRender/NV/*.cpp)
file(GLOB nv_hdr fluorender/FluoRender/NV/*.h)
add_library(NV_OBJ OBJECT
${nv_src} ${nv_hdr})
#FLIVR
include_directories(${FluoRender_SOURCE_DIR}/fluorender/FluoRender/FLIVR)
file(GLOB fli_src fluorender/FluoRender/FLIVR/*.cpp)
file(GLOB fli_hdr fluorender/FluoRender/FLIVR/*.h)
add_library(FLIVR_OBJ OBJECT
${fli_src} ${fli_hdr})
#Converters
include_directories(${FluoRender_SOURCE_DIR}/fluorender/FluoRender/Converters)
file(GLOB cvt_src fluorender/FluoRender/Converters/*.cpp)
file(GLOB cvt_hdr fluorender/FluoRender/Converters/*.h)
add_library(CONVERTERS_OBJ OBJECT
${cvt_src} ${cvt_hdr})
#images
include_directories(${FluoRender_SOURCE_DIR}/fluorender/FluoRender/img)
file(GLOB pngs_hdr fluorender/FluoRender/img/*.h)
file(GLOB pngs_src fluorender/FluoRender/img/*.cpp)
add_library(IMAGES_OBJ OBJECT ${pngs_hdr} ${pngs_src})
#OpenCL
if(${CMAKE_SYSTEM_NAME} MATCHES "Windows")
include_directories(${FluoRender_SOURCE_DIR}/fluorender/OpenCL/include)
if(${ARCHITECTURE} MATCHES 64)
file(GLOB OPENCL_LIBRARIES ${FluoRender_SOURCE_DIR}/fluorender/OpenCL/lib/x86_64/*.lib)
elseif(${ARCHITECTURE} MATCHES 32)
file(GLOB OPENCL_LIBRARIES ${FluoRender_SOURCE_DIR}/fluorender/OpenCL/lib/x86/*.lib)
endif()
elseif(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
include(${CMAKE_SOURCE_DIR}/FindOpenCL.cmake)
include_directories( ${OPENCL_INCLUDE_DIRS})
endif()
#freetype
include_directories(${FluoRender_SOURCE_DIR}/fluorender/freetype/include)
if (WIN32)
file(GLOB FREETYPE_LIBRARIES ${FluoRender_SOURCE_DIR}/fluorender/freetype/lib/*.lib)
else()
find_package(Freetype REQUIRED)
include_directories(${FREETYPE_INCLUDE_DIRS})
endif()
#other sources
file(GLOB src fluorender/FluoRender/*.cpp)
file(GLOB hdr fluorender/FluoRender/*.h)
file(GLOB rsc fluorender/FluoRender/img/*.xpm)
#platform specific rules
if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
# Mac OS X
if(NOT OPEN_GL_HEADER_LOC)
add_definitions(-DOPEN_GL_HEADER_LOC=<OpenGL/gl.h>)
endif()
if(NOT OPEN_GLU_HEADER_LOC)
add_definitions(-DOPEN_GLU_HEADER_LOC=<OpenGL/glu.h>)
endif()
add_definitions(-D_DARWIN)
set(CFLAGS "-fPIC")
set(CXXFLAGS "-fPIC ")
include(BundleUtilities)
#icon file for Apple, bundle properties
set(ICON_FILE_PATH "FluoRender_icon")
SET( MACOSX_BUNDLE_ICON_FILE ${ICON_FILE_PATH} )
SET_SOURCE_FILES_PROPERTIES(${ICON_FILE_PATH} PROPERTIES
MACOSX_BUNDLE_LOCATION Resources)
add_executable(FluoRender MACOSX_BUNDLE
${src} ${hdr} ${rsc}
$<TARGET_OBJECTS:IMAGES_OBJ>
$<TARGET_OBJECTS:CONVERTERS_OBJ>
$<TARGET_OBJECTS:FLIVR_OBJ>
$<TARGET_OBJECTS:ANIMATORS_OBJ>
$<TARGET_OBJECTS:NV_OBJ>
$<TARGET_OBJECTS:FORMATS_OBJ>
$<TARGET_OBJECTS:GLEW_OBJ>
$<TARGET_OBJECTS:POLE_OBJ>
$<TARGET_OBJECTS:TEEM_OBJ>)
elseif(NOT ${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
#Windows
if(NOT OPEN_GL_HEADER_LOC)
add_definitions(-DOPEN_GL_HEADER_LOC=<GL/gl.h>)
endif()
if(NOT OPEN_GLU_HEADER_LOC)
add_definitions(-DOPEN_GLU_HEADER_LOC=<GL/glu.h>)
endif()
# windows
if(${CMAKE_SYSTEM_NAME} MATCHES "Windows")
add_definitions(-DWIN32)
add_definitions(-D_WIN32)
if(MSVC)
add_definitions(-DSEQAN_C++11_STANDARD=ON)
add_definitions(-D_CRT_NONSTDC_NO_DEPRECATE)
add_definitions(-D_CRT_SECURE_NO_DEPRECATE)
add_definitions(-Dinline=__inline)
add_definitions("/wd4273")
set(CFLAGS "")
set(CXXFLAGS "/EHsc")
#make sure the reference option is turned off and not incremental build linking
STRING(REPLACE "INCREMENTAL" "INCREMENTAL:NO" replacementFlags ${CMAKE_EXE_LINKER_FLAGS_DEBUG})
STRING(REPLACE "INCREMENTAL:NO:NO" "INCREMENTAL:NO" replacementFlags1 ${replacementFlags})
SET(CMAKE_EXE_LINKER_FLAGS_DEBUG "/INCREMENTAL:NO /OPT:NOREF ${replacementFlags1}" )
STRING(REPLACE "INCREMENTAL" "INCREMENTAL:NO" replacementFlags2 ${CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO})
STRING(REPLACE "INCREMENTAL:NO:NO" "INCREMENTAL:NO" replacementFlags3 ${replacementFlags2})
SET(CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO "/INCREMENTAL:NO /OPT:NOREF ${replacementFlags3}" )
SET(CMAKE_EXE_LINKER_FLAGS_RELEASE "/INCREMENTAL:NO /OPT:NOREF" )
endif()
include_directories(${FluoRender_SOURCE_DIR}/fluorender/FluoRender/WacUtils)
include_directories(${FluoRender_SOURCE_DIR}/fluorender/Wacom/Include)
file(GLOB wac_src fluorender/FluoRender/WacUtils/*.cpp)
file(GLOB wac_hdr fluorender/FluoRender/WacUtils/*.h)
add_library(WACUTILS_OBJ OBJECT
${wac_src} ${wac_hdr})
add_executable(FluoRender WIN32
${src} ${hdr} ${rsc}
$<TARGET_OBJECTS:IMAGES_OBJ>
$<TARGET_OBJECTS:CONVERTERS_OBJ>
$<TARGET_OBJECTS:FLIVR_OBJ>
$<TARGET_OBJECTS:ANIMATORS_OBJ>
$<TARGET_OBJECTS:NV_OBJ>
$<TARGET_OBJECTS:FORMATS_OBJ>
$<TARGET_OBJECTS:GLEW_OBJ>
$<TARGET_OBJECTS:POLE_OBJ>
$<TARGET_OBJECTS:TEEM_OBJ>
$<TARGET_OBJECTS:WACUTILS_OBJ>)
endif(${CMAKE_SYSTEM_NAME} MATCHES "Windows")
endif()
#architecture specific rules
if(${ARCHITECTURE} MATCHES 64)
if(NOT ${CMAKE_SYSTEM_NAME} MATCHES "Windows")
set(ARCH_FLAGS "-m64 -arch x86_64")
endif(NOT ${CMAKE_SYSTEM_NAME} MATCHES "Windows")
add_definitions(-DTEEM_32BIT=0)
set(CMAKE_C_FLAGS "${ARCH_FLAGS} ${CFLAGS}")
set(CMAKE_CXX_FLAGS "${ARCH_FLAGS} ${CXXFLAGS} ${CXX_11_FLAG}")
set(CMAKE_EXE_LINKER_FLAGS "${ARCH_FLAGS} ${CXX_11_FLAG}")
else()
if(NOT ${CMAKE_SYSTEM_NAME} MATCHES "Windows")
set(ARCH_FLAGS "-m32 -arch i386")
endif(NOT ${CMAKE_SYSTEM_NAME} MATCHES "Windows")
add_definitions(-DTEEM_32BIT=1)
set(CMAKE_C_FLAGS "${ARCH_FLAGS} ${CFLAGS}" )
set(CMAKE_CXX_FLAGS "${ARCH_FLAGS} ${CXXFLAGS} ${CXX_11_FLAG}")
set(CMAKE_EXE_LINKER_FLAGS "${ARCH_FLAGS} ${CXX_11_FLAG}")
endif()
if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
set(CMAKE_EXE_LINKER_FLAGS "-L/usr/local/lib -L/usr/lib ${CMAKE_EXE_LINKER_FLAGS} -lbz2 -framework OpenCL -framework CoreFoundation -framework CoreVideo -framework VideoDecodeAcceleration")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mmacosx-version-min=10.9 -DWX_PRECOMP -std=c++11 -stdlib=libc++")
#make sure png is static linked
string(REGEX REPLACE "-lpng" "/usr/local/lib/libpng.a"
wxWidgets_LIBRARIES ${wxWidgets_LIBRARIES})
string(REGEX REPLACE "-lpng" "/usr/local/lib/libpng.a"
CMAKE_MAKE_EXE_LINKER_FLAGS ${CMAKE_EXE_LINKER_FLAGS})
endif()
#link the libraries
target_link_libraries(FluoRender
${ffmpeg_LIBRARIES}
${OPENGL_LIBRARIES}
${Boost_LIBRARIES}
${OPENCL_LIBRARIES}
${FREETYPE_LIBRARIES}
${wxWidgets_LIBRARIES})
#build OpenCL examples copies.
#copy openCL examples to the binary directory
add_custom_command(TARGET FluoRender PRE_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_directory
"${FluoRender_SOURCE_DIR}/CL_code"
"$<TARGET_FILE_DIR:FluoRender>/CL_code")
add_custom_command(TARGET FluoRender PRE_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_directory
"${FluoRender_SOURCE_DIR}/CL_code"
"${CMAKE_BINARY_DIR}/CL_code")
#copy font dir to the binary directory
add_custom_command(TARGET FluoRender PRE_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_directory
"${FluoRender_SOURCE_DIR}/Fonts"
"$<TARGET_FILE_DIR:FluoRender>/Fonts")
add_custom_command(TARGET FluoRender PRE_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_directory
"${FluoRender_SOURCE_DIR}/Fonts"
"${CMAKE_BINARY_DIR}/Fonts")
#build DLL copy
if(${CMAKE_SYSTEM_NAME} MATCHES "Windows")
file(GLOB ffmpeg_DLLS fluorender/bin/*.dll)
foreach (f ${ffmpeg_DLLS})
add_custom_command(TARGET FluoRender PRE_BUILD
COMMAND ${CMAKE_COMMAND} -E copy
${f}
$<TARGET_FILE_DIR:FluoRender>)
endforeach()
endif()
#post build setting files copy
if(${CMAKE_SYSTEM_NAME} MATCHES "Windows")
file(GLOB settings_files Settings/*)
foreach (f ${settings_files})
add_custom_command(TARGET FluoRender PRE_BUILD
COMMAND ${CMAKE_COMMAND} -E copy
${f}
$<TARGET_FILE_DIR:FluoRender>)
endforeach()
endif()