forked from TACC/GLuRay
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
234 lines (205 loc) · 7.34 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
#/**********************************************************************************
#* Copyright (c) 2013-2015 Carson Brownlee
#* Texas Advanced Computing Center, University of Texas at Austin
#* All rights reserved
#*
#* This library is free software; you can redistribute it and/or
#* modify it under the terms of the GNU Lesser General Public
#* License as published by the Free Software Foundation; either
#* version 2.1 of the License, or (at your option) any later version.
#*
#* This library is distributed in the hope that it will be useful,
#* but WITHOUT ANY WARRANTY; without even the implied warranty of
#* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
#* Lesser General Public License for more details.
#*
#* You should have received a copy of the GNU Lesser General Public
#* License along with this library; if not, write to the Free Software
#* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
#**********************************************************************************/
CMAKE_MINIMUM_REQUIRED(VERSION 2.6.4)
PROJECT(GLuRay)
SET(CMAKE_CXX_FLAGS "-std=c++0x -fPIC")
SET(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/CMake)
FIND_PACKAGE(Manta)
FIND_PACKAGE(OpenGL)
#FIND_PACKAGE(Boost)
SET(GLURAY_SRC
src/Core/gluray.cc
src/Modules/Manta/DirtyInstance.cc
src/Modules/Manta/MRenderable.cc
src/Modules/Manta/MantaRenderer.cc
src/Modules/Manta/MScene.cc
src/Core/Work.cc
src/Modules/Manta/AccelWork.cc
src/Core/RenderManager.cc
src/Core/Renderer.cc
src/Core/OBJScene.cc
)
SET(GLURAY_HDR
src/Core/defines.h
src/Core/gluray.h
src/Core/GLuRayRenderParameters.h
src/Modules/Manta/MantaRenderer.h
src/Core/RenderManager.h
src/Core/Renderer.h
src/Core/Renderable.h
src/Modules/Manta/MRenderable.h
src/Core/Work.h
src/Modules/Manta/AccelWork.h
src/Modules/Manta/MScene.h
src/Modules/Manta/DirtyInstance.h
src/Core/CDTimer.h
src/Core/OBJScene.h
)
###############################################################################
## Configure distributed version of manta for an MPI-based cluster
SET (ENABLE_MPI FALSE CACHE BOOL "Build MPI version of manta for running on clusters.")
IF (ENABLE_MPI)
SET(USE_MPI_DEF "1" CACHE INTERNAL "Use MPI")
ELSE (ENABLE_MPI)
SET(USE_MPI_DEF "0" CACHE INTERNAL "Use MPI")
ENDIF (ENABLE_MPI)
IF(ENABLE_MPI)
SET(GLURAY_SRC ${GLURAY_SRC}
src/Modules/Manta/ice_semaphore.cc
src/Modules/Manta/CDComm.cc
src/Modules/Manta/DynBVH_D.cc
src/Modules/Manta/Mesh_DSM.cc
)
SET(GLURAY_HDR ${GLURAY_HDR}
src/Modules/Manta/DSM_Data.h
src/Modules/Manta/ice_semaphore.h
src/Modules/Manta/CDComm.h
src/Modules/Manta/DynBVH_D.h
src/Modules/Manta/Mesh_DSM.h
)
ENDIF(ENABLE_MPI)
SET(USE_RIVL NO CACHE BOOL "using intels rivl")
SET(USE_EMBREE NO CACHE BOOL "using intels embree")
SET(USE_OSPRAY NO CACHE BOOL "using intels ospray")
SET(USE_OPTIX NO CACHE BOOL "using nvidia optix")
SET(USE_GVT NO CACHE BOOL "using gvt")
INCLUDE_DIRECTORIES(src/Core src/Modules/Manta src/Modules/RIVL
${CMAKE_BINARY_DIR}/include
src/Modules/Embree src/Modules/Gvt src)
#INCLUDE_DIRECTORIES( ${MANTA_INCLUDE} )
#include_directories(${OPENGL_INCLUDE_DIR})
link_directories(${OpenGL_LIBRARY_DIRS})
add_definitions(${OpenGL_DEFINITIONS})
ADD_LIBRARY(GLuRay SHARED ${GLURAY_SRC} ${GLURAY_HDR})
SET(GLURAY_LIBS ${MANTA_TARGET_LINK_LIBRARIES})
SET(CMAKE_DEFINES "")
IF(USE_RIVL)
SET(GLURAY_LIBS ${GLURAY_LIBS} GLuRay_RIVL)
SET(CMAKE_DEFINES "${CMAKE_DEFINES}#define USE_RIVL 1\n")
SUBDIRS(src/Modules/RIVL)
ENDIF(USE_RIVL)
IF(USE_EMBREE)
SET(MANTA_SSE NO)
IF(USE_RIVL)
MESSAGE( FATAL_ERROR "can't use multiple renderers for now, RIVL and
EMBREE enabled")
ENDIF(USE_RIVL)
SET(CMAKE_DEFINES "${CMAKE_DEFINES}#define USE_EMBREE 1\n")
#SET(GLURAY_LIBS ${GLURAY_LIBS} GLuRay_EMBREE)
SUBDIRS(src/Modules/Embree)
SET(GLURAY_LIBS ${GLURAY_LIBS} GLuRay_EMBREE)
ENDIF(USE_EMBREE)
IF(USE_OSPRAY)
SET(MANTA_SSE NO)
IF(USE_RIVL)
MESSAGE( FATAL_ERROR "can't use multiple renderers for now, RIVL and
EMBREE enabled")
ENDIF(USE_RIVL)
IF(USE_EMBREE)
MESSAGE( FATAL_ERROR "can't use multiple renderers for now, RIVL and
EMBREE enabled")
ENDIF(USE_EMBREE)
SET(CMAKE_DEFINES "${CMAKE_DEFINES}#define USE_OSPRAY 1\n")
#SET(GLURAY_LIBS ${GLURAY_LIBS} GLuRay_EMBREE)
SUBDIRS(src/Modules/OSPRay)
SET(GLURAY_LIBS ${GLURAY_LIBS} GLuRay_OSPRay)
ENDIF(USE_OSPRAY)
IF (USE_OPTIX)
SET(CMAKE_DEFINES "${CMAKE_DEFINES}#define USE_OPTIX 1\n")
SUBDIRS(src/Modules/OptiX)
SET(GLURAY_LIBS ${GLURAY_LIBS} GLuRay_Optix)
ENDIF()
IF(USE_GVT)
SUBDIRS(src/Modules/Gvt)
ENDIF(USE_GVT)
#SET(GLURAY_LIBS "")
MESSAGE(STATUS "GLURAY_LIBS: " ${GLURAY_LIBS})
TARGET_LINK_LIBRARIES(GLuRay ${GLURAY_LIBS} ${OPENGL_gl_LIBRARY})
CONFIGURE_FILE(
${MANTA_SOURCE_DIR}/include/UseMPI.h.CMakeTemplate
${MANTA_BUILD_PREFIX}/include/UseMPI.h
)
#
#set cmake defines accessable by source files
#
SET(DEBUG_MSGS NO CACHE BOOL "Debug messages")
SET(DEBUG_GL NO CACHE BOOL "output gl calls")
SET(USE_GL NO CACHE BOOL "use opengl draw calls")
SET(USE_GLURAY YES CACHE BOOL "use gluray calls")
SET(RUN_CLIENT NO CACHE BOOL "run gui client")
IF(DEBUG_MSGS)
SET(CMAKE_DEFINES "${CMAKE_DEFINES}#define DEBUG_MSGS 1\n")
ELSE(DEBUG_MSGS)
SET(CMAKE_DEFINES "${CMAKE_DEFINES}#define DEBUG_MSGS 0\n")
ENDIF(DEBUG_MSGS)
IF(DEBUG_GL)
SET(CMAKE_DEFINES "${CMAKE_DEFINES}#define DEBUG_GL 1\n")
ELSE(DEBUG_GL)
SET(CMAKE_DEFINES "${CMAKE_DEFINES}#define DEBUG_GL 0\n")
ENDIF(DEBUG_GL)
IF(USE_GL)
SET(CMAKE_DEFINES "${CMAKE_DEFINES}#define USE_GL 1\n")
ELSE(USE_GL)
SET(CMAKE_DEFINES "${CMAKE_DEFINES}#define USE_GL 0\n")
ENDIF(USE_GL)
IF(USE_GLURAY)
SET(CMAKE_DEFINES "${CMAKE_DEFINES}#define USE_GLURAY 1\n")
ELSE(USE_GLURAY)
SET(CMAKE_DEFINES "${CMAKE_DEFINES}#define USE_GLURAY 0\n")
ENDIF(USE_GLURAY)
IF(RUN_CLIENT)
SET(CMAKE_DEFINES "${CMAKE_DEFINES}#define RUN_CLIENT 1\n")
ELSE(RUN_CLIENT)
SET(CMAKE_DEFINES "${CMAKE_DEFINES}#define RUN_CLIENT 0\n")
ENDIF(RUN_CLIENT)
MESSAGE(STATUS ${OPENGL_gl_LIBRARY})
SET(CMAKE_DEFINES "${CMAKE_DEFINES}#define OPENGLLIB \"${OPENGL_gl_LIBRARY}\"\n")
FILE(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/include)
FILE(WRITE ${CMAKE_BINARY_DIR}/include/CMakeDefines.h ${CMAKE_DEFINES})
PROJECT(fakeGL)
FIND_PACKAGE(Manta)
FIND_PACKAGE(OpenGL REQUIRED)
ADD_LIBRARY(fakeGL SHARED libfakeGL.c)
include_directories(${OPENGL_INCLUDE_DIR})
message("opengl include directories: ${OPENGL_INCLUDE_DIR}")
link_directories(${OpenGL_LIBRARY_DIRS})
add_definitions(${OpenGL_DEFINITIONS})
#TARGET_LINK_LIBRARIES(fakeGL ${MANTA_TARGET_LINK_LIBRARIES} GLuRay)
TARGET_LINK_LIBRARIES(fakeGL ${GLURAY_LIBS} GLuRay ${OPENGL_gl_LIBRARY})
IF (ENABLE_MPI)
FIND_PACKAGE(MPI REQUIRED)
INCLUDE_DIRECTORIES(${MPI_INCLUDE_PATH})
TARGET_LINK_LIBRARIES(fakeGL ${MPI_LIBRARIES})
if(MPI_COMPILE_FLAGS)
set_target_properties(fakeGL PROPERTIES
COMPILE_FLAGS "${MPI_COMPILE_FLAGS}")
endif()
if(MPI_LINK_FLAGS)
set_target_properties(fakeGL PROPERTIES
LINK_FLAGS "${MPI_LINK_FLAGS}")
endif()
ENDIF (ENABLE_MPI)
TARGET_LINK_LIBRARIES(fakeGL ${CMAKE_DL_LIBS})
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_GNU_SOURCE")
FILE(REMOVE ${PROJECT_BINARY_DIR}/gluray)
FILE(WRITE ${PROJECT_BINARY_DIR}/gluray
"#!/bin/sh\nLD_PRELOAD=\${LD_PRELOAD}:\"${PROJECT_BINARY_DIR}/libfakeGL.so\" \${1+\"\$@\"}\n"
)
EXECUTE_PROCESS(COMMAND chmod +x ${PROJECT_BINARY_DIR}/gluray)