forked from RenderKit/embree
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
299 lines (239 loc) · 8.84 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
## ======================================================================== ##
## Copyright 2009-2015 Intel Corporation ##
## ##
## Licensed under the Apache License, Version 2.0 (the "License"); ##
## you may not use this file except in compliance with the License. ##
## You may obtain a copy of the License at ##
## ##
## http://www.apache.org/licenses/LICENSE-2.0 ##
## ##
## Unless required by applicable law or agreed to in writing, software ##
## distributed under the License is distributed on an "AS IS" BASIS, ##
## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ##
## See the License for the specific language governing permissions and ##
## limitations under the License. ##
## ======================================================================== ##
SET(EMBREE_VERSION_MAJOR 2)
SET(EMBREE_VERSION_MINOR 7)
SET(EMBREE_VERSION_PATCH 0)
SET(EMBREE_VERSION_NOTE "")
SET(EMBREE_VERSION ${EMBREE_VERSION_MAJOR}.${EMBREE_VERSION_MINOR}.${EMBREE_VERSION_PATCH})
MATH(EXPR EMBREE_VERSION_NUMBER "10000*${EMBREE_VERSION_MAJOR} + 100*${EMBREE_VERSION_MINOR} + ${EMBREE_VERSION_PATCH}")
SET(CPACK_RPM_PACKAGE_RELEASE 1)
PROJECT(embree${EMBREE_VERSION_MAJOR})
CMAKE_MINIMUM_REQUIRED(VERSION 2.8.11)
CONFIGURE_FILE(
"${PROJECT_SOURCE_DIR}/kernels/version.h.in"
"${PROJECT_BINARY_DIR}/version.h"
)
INCLUDE_DIRECTORIES("${PROJECT_BINARY_DIR}")
IF(COMMAND cmake_policy)
if (POLICY CMP0003)
cmake_policy(SET CMP0003 NEW)
endif()
if (POLICY CMP0042)
cmake_policy(SET CMP0042 OLD)
endif()
ENDIF(COMMAND cmake_policy)
MARK_AS_ADVANCED(CMAKE_BACKWARDS_COMPATIBILITY)
MARK_AS_ADVANCED(EXECUTABLE_OUTPUT_PATH)
MARK_AS_ADVANCED(LIBRARY_OUTPUT_PATH)
MARK_AS_ADVANCED(CMAKE_OSX_ARCHITECTURES)
MARK_AS_ADVANCED(CMAKE_OSX_DEPLOYMENT_TARGET)
MARK_AS_ADVANCED(CMAKE_OSX_SYSROOT)
MARK_AS_ADVANCED(GLUT_cocoa_LIBRARY)
SET(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/common/cmake ${CMAKE_MODULE_PATH})
##############################################################
# Create Binary Packages
##############################################################
include(package)
##############################################################
# Embree configuration
##############################################################
OPTION(ENABLE_STATIC_LIB "Build Embree as a static library." OFF)
IF (ENABLE_STATIC_LIB)
SET(EMBREE_LIB_TYPE STATIC)
ADD_DEFINITIONS(-DENABLE_STATIC_LIB)
ELSE()
SET(EMBREE_LIB_TYPE SHARED)
ENDIF()
OPTION(ENABLE_ISPC_SUPPORT "Build Embree with support for ISPC applications." ON)
OPTION(ENABLE_TUTORIALS "Enable to build Embree tutorials" ON)
# only support Xeon Phi on Linux
IF (NOT WIN32 AND NOT APPLE)
OPTION(ENABLE_XEON_PHI_SUPPORT "Generates code path for Xeon Phi.")
ELSE()
SET(ENABLE_XEON_PHI_SUPPORT OFF CACHE INTERNAL "Xeon Phi only supported on Linux.")
ENDIF()
IF (ENABLE_XEON_PHI_SUPPORT)
SET(ENABLE_ISPC_SUPPORT ON CACHE BOOL "Build Embree with support for ISPC applications." FORCE)
ENDIF ()
OPTION(RTCORE_RAY_MASK "Enables ray mask support.")
OPTION(RTCORE_STAT_COUNTERS "Enables statistic counters.")
OPTION(RTCORE_BACKFACE_CULLING "Enables backface culling.")
OPTION(RTCORE_INTERSECTION_FILTER "Enables intersection filter callback." ON)
OPTION(RTCORE_BUFFER_STRIDE "Enables buffer strides." ON)
OPTION(RTCORE_EXPORT_ALL_SYMBOLS "Lets Embree library export all symbols.")
OPTION(RTCORE_ENABLE_RAYSTREAM_LOGGER "Enables ray stream logger.")
OPTION(RTCORE_IGNORE_INVALID_RAYS "Ignores invalid rays." OFF) # FIXME: enable by default?
OPTION(RTCORE_RAY_PACKETS "Enabled support for ray packets." ON)
SET(RTCORE_TASKING_SYSTEM "TBB" CACHE STRING "Selects tasking system")
SET_PROPERTY(CACHE RTCORE_TASKING_SYSTEM PROPERTY STRINGS TBB INTERNAL)
IF (RTCORE_TASKING_SYSTEM STREQUAL "TBB")
SET(TASKING_TBB ON)
FIND_PACKAGE(TBB REQUIRED)
INCLUDE_DIRECTORIES(${TBB_INCLUDE_DIRS})
ELSE()
SET(TASKING_INTERNAL ON)
ENDIF()
CONFIGURE_FILE(
"${PROJECT_SOURCE_DIR}/kernels/config.h.in"
"${PROJECT_BINARY_DIR}/config.h"
)
##############################################################
# Compiler
##############################################################
SET(CONFIGURATION_TYPES "Debug;Release;RelWithDebInfo")
IF (WIN32)
IF (NOT DEFAULT_CMAKE_CONFIGURATION_TYPES_SET)
SET(CMAKE_CONFIGURATION_TYPES "${CONFIGURATION_TYPES}" CACHE STRING "List of generated configurations." FORCE)
SET(DEFAULT_CMAKE_CONFIGURATION_TYPES_SET ON CACHE INTERNAL "Default CMake configuration types set.")
ENDIF()
SET_PROPERTY(GLOBAL PROPERTY USE_FOLDERS ON)
INCLUDE (msvc)
ELSE (WIN32)
SET(COMPILER "GCC" CACHE STRING "Selects compiler to use.")
SET_PROPERTY(CACHE COMPILER PROPERTY STRINGS GCC CLANG ICC)
IF (COMPILER STREQUAL "GCC")
INCLUDE (gcc)
ELSEIF (COMPILER STREQUAL "CLANG")
INCLUDE (clang)
ELSEIF (COMPILER STREQUAL "ICC")
INCLUDE (icc)
ELSE ()
MESSAGE(FATAL_ERROR "Unknown compiler specified: " ${COMPILER})
ENDIF ()
IF(NOT CMAKE_BUILD_TYPE)
SET(CMAKE_BUILD_TYPE "Release" CACHE STRING "Specifies the build type." FORCE)
SET_PROPERTY(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS ${CONFIGURATION_TYPES})
ENDIF(NOT CMAKE_BUILD_TYPE)
OPTION(CMAKE_VERBOSE_MAKEFILE "Enables verbose mode.")
MARK_AS_ADVANCED(CLEAR CMAKE_VERBOSE_MAKEFILE)
ENDIF (WIN32)
##############################################################
# ISA configuration
##############################################################
IF(APPLE)
SET(XEON_ISA "AVX2" CACHE STRING "Selects highest ISA to support.")
ELSEIF(NOT COMPILER STREQUAL "ICC")
SET(XEON_ISA "AVX2" CACHE STRING "Selects highest ISA to support.")
ELSE()
SET(XEON_ISA "AVX512" CACHE STRING "Selects highest ISA to support.")
ENDIF ()
SET_PROPERTY(CACHE XEON_ISA PROPERTY STRINGS SSE2 SSE3 SSSE3 SSE4.1 SSE4.2 AVX AVX-I AVX2 AVX512)
IF (XEON_ISA STREQUAL "SSE2")
SET(ISA 1)
ENDIF ()
IF (XEON_ISA STREQUAL "SSE3")
SET(ISA 2)
ENDIF ()
IF (XEON_ISA STREQUAL "SSSE3")
SET(ISA 3)
ENDIF ()
IF (XEON_ISA STREQUAL "SSE4.1")
SET(ISA 4)
ENDIF ()
IF (XEON_ISA STREQUAL "SSE4.2")
SET(ISA 5)
ENDIF ()
IF (XEON_ISA STREQUAL "AVX")
SET(ISA 6)
ENDIF ()
IF (XEON_ISA STREQUAL "AVX-I")
SET(ISA 7)
ENDIF ()
IF (XEON_ISA STREQUAL "AVX2")
SET(ISA 8)
ENDIF ()
IF (XEON_ISA STREQUAL "AVX512")
SET(ISA 9)
ENDIF ()
SET(TARGET_SSE2 OFF)
SET(TARGET_SSE3 OFF)
SET(TARGET_SSSE3 OFF)
SET(TARGET_SSE41 OFF)
SET(TARGET_SSE42 OFF)
SET(TARGET_AVX OFF)
SET(TARGET_AVXI OFF)
SET(TARGET_AVX2 OFF)
SET(TARGET_AVX512 OFF)
IF (ISA GREATER 0)
SET(TARGET_SSE2 ON)
SET(ISPC_TARGETS "sse2")
ENDIF ()
IF (ISA GREATER 1)
SET(TARGET_SSE3 ON)
ENDIF ()
IF (ISA GREATER 2)
SET(TARGET_SSSE3 ON)
ENDIF ()
IF (ISA GREATER 3)
SET(TARGET_SSE41 ON)
LIST(APPEND ISPC_TARGETS "sse4")
ENDIF ()
IF (ISA GREATER 4)
SET(TARGET_SSE42 ON)
ENDIF ()
IF (ISA GREATER 5)
SET(TARGET_AVX ON)
LIST(APPEND ISPC_TARGETS "avx")
ENDIF ()
IF (ISA GREATER 6)
SET(TARGET_AVXI ON)
ENDIF ()
IF (ISA GREATER 7)
SET(TARGET_AVX2 ON)
LIST(APPEND ISPC_TARGETS "avx2")
ENDIF ()
IF (ISA GREATER 8)
SET(TARGET_AVX512 ON)
LIST(APPEND ISPC_TARGETS "avx512knl-i32x16")
ENDIF ()
INCLUDE (ispc)
##############################################################
# Search paths
##############################################################
INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/include)
##############################################################
# Output paths
##############################################################
SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}")
SET(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}")
SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}")
##############################################################
# Directories to compile
##############################################################
ADD_SUBDIRECTORY(common)
ADD_SUBDIRECTORY(kernels)
IF (ENABLE_TUTORIALS)
ADD_SUBDIRECTORY(tutorials)
SET (__XEON__ 1)
ADD_SUBDIRECTORY(tests)
IF (ENABLE_XEON_PHI_SUPPORT)
SET (__XEON__ 0)
ADD_SUBDIRECTORY(tests tests_xeonphi)
ENDIF ()
ENDIF()
##############################################################
# Uninstall
##############################################################
configure_file(
"${CMAKE_CURRENT_SOURCE_DIR}/common/cmake/uninstall.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/uninstall.cmake"
IMMEDIATE @ONLY)
add_custom_target(uninstall
COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/uninstall.cmake)
##############################################################
# Has to be last
##############################################################
INCLUDE(CPack)