forked from mmp/pbrt-v3
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
361 lines (314 loc) · 8.59 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
CMAKE_MINIMUM_REQUIRED ( VERSION 2.8 )
PROJECT ( PBRT-V3 )
ENABLE_TESTING()
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
message(STATUS "Setting build type to 'Release' as none was specified.")
set(CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build." FORCE)
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release"
"MinSizeRel" "RelWithDebInfo")
endif()
if(NOT IS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/src/ext/openexr/OpenEXR")
message(FATAL_ERROR "The OpenEXR submodule directory is missing! "
"You probably did not clone the project with --recursive. It is possible to recover "
"by running \"git submodule update --init --recursive\"")
endif()
if(NOT IS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/src/ext/glog")
message(FATAL_ERROR "The glog submodule directory is missing! "
"You probably did not clone the project with --recursive, or first checked out "
"pbrt before it was added. It is possible to recover by running "
"\"git submodule update --init --recursive\"")
endif()
IF(CMAKE_COMPILER_IS_GNUCXX)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++11")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-conversion-null")
ELSEIF(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated-register")
ELSEIF(CMAKE_CXX_COMPILER_ID STREQUAL "Intel")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
FIND_PROGRAM(XIAR xiar)
IF(XIAR)
SET(CMAKE_AR "${XIAR}")
ENDIF(XIAR)
MARK_AS_ADVANCED(XIAR)
FIND_PROGRAM(XILD xild)
IF(XILD)
SET(CMAKE_LINKER "${XILD}")
ENDIF(XILD)
MARK_AS_ADVANCED(XILD)
# ICC will default to -fp-model fast=1, which performs value-unsafe optimizations which will
# cause pbrt_test to fail. For safety, -fp-model precise is explicitly set here by default.
set(FP_MODEL "precise" CACHE STRING "The floating point model to compile with.")
set_property(CACHE FP_MODEL PROPERTY STRINGS "precise" "fast=1" "fast=2")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fp-model ${FP_MODEL}")
ENDIF()
IF(MSVC)
ADD_DEFINITIONS (/D _CRT_SECURE_NO_WARNINGS)
ADD_DEFINITIONS (/D YY_NO_UNISTD_H)
ENDIF()
FIND_PACKAGE ( Threads )
IF(CMAKE_BUILD_TYPE MATCHES RELEASE)
ADD_DEFINITIONS (-DNDEBUG)
ENDIF()
# Optionally use Bison and Flex to regenerate parser files
# Use pregenerated files otherwise (may be outdated)
FIND_PACKAGE ( BISON )
FIND_PACKAGE ( FLEX )
IF(BISON_FOUND AND FLEX_FOUND)
SET(BisonOutput ${CMAKE_BINARY_DIR}/pbrtparse.cpp)
ADD_CUSTOM_COMMAND(
OUTPUT ${BisonOutput} ${CMAKE_BINARY_DIR}/pbrtparse.h
DEPENDS ${CMAKE_SOURCE_DIR}/src/core/pbrtparse.y
COMMAND ${BISON_EXECUTABLE} -d -v -t
--output=${CMAKE_BINARY_DIR}/pbrtparse.c
${CMAKE_SOURCE_DIR}/src/core/pbrtparse.y
COMMAND ${CMAKE_COMMAND} -E rename ${CMAKE_BINARY_DIR}/pbrtparse.c ${CMAKE_BINARY_DIR}/pbrtparse.cpp
COMMENT "Generating pbrtparse.cpp and pbrtparse.h"
)
SET(FlexOutput ${CMAKE_BINARY_DIR}/pbrtlex.cpp)
ADD_CUSTOM_COMMAND(
OUTPUT ${FlexOutput}
DEPENDS ${CMAKE_BINARY_DIR}/pbrtparse.h ${CMAKE_SOURCE_DIR}/src/core/pbrtlex.ll
COMMAND ${FLEX_EXECUTABLE}
-o${FlexOutput}
${CMAKE_SOURCE_DIR}/src/core/pbrtlex.ll
COMMENT "Generating pbrtlex.cpp"
)
SET ( PBRT_YACC_LEX_SOURCE
${BisonOutput}
${FlexOutput}
)
ELSE()
SET ( PBRT_YACC_LEX_SOURCE
src/core/pbrtlex.cpp
src/core/pbrtparse.cpp
)
ENDIF()
IF(WIN32)
# Build zlib (only on Windows)
SET(ZLIB_BUILD_STATIC_LIBS ON CACHE BOOL " " FORCE)
SET(ZLIB_BUILD_SHARED_LIBS OFF CACHE BOOL " " FORCE)
ADD_SUBDIRECTORY(src/ext/zlib)
SET(ZLIB_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/src/ext/zlib")
SET(ZLIB_LIBRARY "${CMAKE_CURRENT_BINARY_DIR}/src/ext/zlib/$<CONFIGURATION>/zlibstatic.lib")
SET_PROPERTY(TARGET zlibstatic PROPERTY FOLDER "dependencies")
INCLUDE_DIRECTORIES(${ZLIB_INCLUDE_DIR} "${CMAKE_CURRENT_BINARY_DIR}/src/ext/zlib")
ENDIF()
SET(ILMBASE_NAMESPACE_VERSIONING OFF CACHE BOOL " " FORCE)
SET(OPENEXR_NAMESPACE_VERSIONING OFF CACHE BOOL " " FORCE)
SET(OPENEXR_BUILD_SHARED_LIBS OFF CACHE BOOL " " FORCE)
SET(ILMBASE_BUILD_SHARED_LIBS OFF CACHE BOOL " " FORCE)
ADD_SUBDIRECTORY(src/ext/openexr)
SET_PROPERTY(TARGET IexMath eLut toFloat b44ExpLogTable dwaLookups CopyIlmBaseLibs IlmThread Half Iex Imath IlmImf PROPERTY FOLDER "dependencies")
INCLUDE_DIRECTORIES (
src/ext/openexr/IlmBase/Imath
src/ext/openexr/IlmBase/Half
src/ext/openexr/IlmBase/Iex
src/ext/openexr/OpenEXR/IlmImf
${CMAKE_BINARY_DIR}/src/ext/openexr/IlmBase/config
${CMAKE_BINARY_DIR}/src/ext/openexr/OpenEXR/config
)
IF(WIN32)
SET(OPENEXR_LIBS IlmImf Imath Half zlibstatic)
ELSE()
SET(OPENEXR_LIBS IlmImf Imath Half)
ENDIF()
SET(WITH_GFLAGS OFF CACHE BOOL "Use gflags")
SET(BUILD_SHARED_LIBS OFF CACHE BOOL " " FORCE)
ADD_SUBDIRECTORY(src/ext/glog)
SET_PROPERTY(TARGET glog PROPERTY FOLDER "dependencies")
INCLUDE_DIRECTORIES (
src/ext/glog/src
${CMAKE_BINARY_DIR}/src/ext/glog
)
SET ( PBRT_CORE_SOURCE
src/core/api.cpp
src/core/bssrdf.cpp
src/core/camera.cpp
src/core/efloat.cpp
src/core/error.cpp
src/core/fileutil.cpp
src/core/film.cpp
src/core/filter.cpp
src/core/floatfile.cpp
src/core/geometry.cpp
src/core/imageio.cpp
src/core/integrator.cpp
src/core/interaction.cpp
src/core/interpolation.cpp
src/core/light.cpp
src/core/lightdistrib.cpp
src/core/lowdiscrepancy.cpp
src/core/material.cpp
src/core/medium.cpp
src/core/memory.cpp
src/core/microfacet.cpp
src/core/parallel.cpp
src/core/paramset.cpp
src/core/parser.cpp
src/core/primitive.cpp
src/core/progressreporter.cpp
src/core/quaternion.cpp
src/core/reflection.cpp
src/core/sampler.cpp
src/core/sampling.cpp
src/core/scene.cpp
src/core/shape.cpp
src/core/sobolmatrices.cpp
src/core/spectrum.cpp
src/core/stats.cpp
src/core/texture.cpp
src/core/transform.cpp
)
SET ( PBRT_CORE_HEADERS
src/core/api.h
src/core/bssrdf.h
src/core/camera.h
src/core/efloat.h
src/core/error.h
src/core/fileutil.h
src/core/film.h
src/core/filter.h
src/core/floatfile.h
src/core/geometry.h
src/core/imageio.h
src/core/integrator.h
src/core/interaction.h
src/core/interpolation.h
src/core/light.h
src/core/lowdiscrepancy.h
src/core/material.h
src/core/medium.h
src/core/memory.h
src/core/microfacet.h
src/core/mipmap.h
src/core/parallel.h
src/core/paramset.h
src/core/parser.h
src/core/pbrt.h
src/core/port.h
src/core/primitive.h
src/core/progressreporter.h
src/core/quaternion.h
src/core/reflection.h
src/core/rng.h
src/core/sampler.h
src/core/sampling.h
src/core/scene.h
src/core/shape.h
src/core/sobolmatrices.h
src/core/spectrum.h
src/core/stats.h
src/core/stringprint.h
src/core/texture.h
src/core/transform.h
)
FILE ( GLOB PBRT_SOURCE
src/ext/*.c
src/ext/*.cpp
src/accelerators/*.cpp
src/cameras/*.cpp
src/filters/*.cpp
src/integrators/*.cpp
src/lights/*.cpp
src/materials/*.cpp
src/samplers/*.cpp
src/shapes/*.cpp
src/textures/*.cpp
src/media/*.cpp
)
INCLUDE_DIRECTORIES ( src )
INCLUDE_DIRECTORIES ( src/core )
ADD_LIBRARY ( pbrt STATIC
${PBRT_YACC_LEX_SOURCE}
${PBRT_CORE_SOURCE}
${PBRT_CORE_HEADERS}
${PBRT_SOURCE}
)
IF (WIN32)
# Avoid a name clash when building on Visual Studio
SET_TARGET_PROPERTIES ( pbrt
PROPERTIES
OUTPUT_NAME libpbrt
)
ENDIF()
FIND_PACKAGE ( Threads )
# Main renderer
ADD_EXECUTABLE ( pbrt_exe
src/main/pbrt.cpp
)
SET_TARGET_PROPERTIES ( pbrt_exe
PROPERTIES
OUTPUT_NAME pbrt
)
TARGET_LINK_LIBRARIES ( pbrt_exe
pbrt
${CMAKE_THREAD_LIBS_INIT}
${OPENEXR_LIBS}
glog
)
# Tools
ADD_EXECUTABLE ( bsdftest
src/tools/bsdftest.cpp
)
ADD_EXECUTABLE ( imgtool
src/tools/imgtool.cpp
)
ADD_EXECUTABLE ( obj2pbrt
src/tools/obj2pbrt.cpp
)
ADD_EXECUTABLE ( cyhair2pbrt
src/tools/cyhair2pbrt.cpp
)
TARGET_LINK_LIBRARIES ( bsdftest
pbrt
${CMAKE_THREAD_LIBS_INIT}
${OPENEXR_LIBS}
glog
)
TARGET_LINK_LIBRARIES ( imgtool
pbrt
${CMAKE_THREAD_LIBS_INIT}
${OPENEXR_LIBS}
glog
)
TARGET_LINK_LIBRARIES ( obj2pbrt
pbrt
${CMAKE_THREAD_LIBS_INIT}
)
TARGET_LINK_LIBRARIES ( cyhair2pbrt
pbrt
${CMAKE_THREAD_LIBS_INIT}
)
# Unit test
FILE ( GLOB PBRT_TEST_SOURCE
src/tests/*.cpp
src/tests/gtest/*.cc
)
ADD_EXECUTABLE ( pbrt_test
${PBRT_TEST_SOURCE}
)
TARGET_LINK_LIBRARIES ( pbrt_test
pbrt
${CMAKE_THREAD_LIBS_INIT}
${OPENEXR_LIBS}
glog
)
ADD_TEST ( pbrt_unit_test
pbrt_test
)
# Installation
INSTALL ( TARGETS
pbrt_exe
bsdftest
imgtool
obj2pbrt
cyhair2pbrt
DESTINATION
bin
)
INSTALL ( TARGETS
pbrt
DESTINATION
lib
)