Implementation of OpenVDB as a possible cache format for smoke
[blender.git] / CMakeLists.txt
1 # ***** BEGIN GPL LICENSE BLOCK *****
2 #
3 # This program is free software; you can redistribute it and/or
4 # modify it under the terms of the GNU General Public License
5 # as published by the Free Software Foundation; either version 2
6 # of the License, or (at your option) any later version.
7 #
8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11 # GNU General Public License for more details.
12 #
13 # You should have received a copy of the GNU General Public License
14 # along with this program; if not, write to the Free Software Foundation,
15 # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16 #
17 # The Original Code is Copyright (C) 2006, Blender Foundation
18 # All rights reserved.
19 #
20 # The Original Code is: all of this file.
21 #
22 # Contributor(s): Jacques Beaurain.
23 #
24 # ***** END GPL LICENSE BLOCK *****
25
26 #-----------------------------------------------------------------------------
27 # We don't allow in-source builds. This causes no end of troubles because
28 # all out-of-source builds will use the CMakeCache.txt file there and even
29 # build the libs and objects in it.
30
31 if(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR})
32         if(NOT DEFINED WITH_IN_SOURCE_BUILD)
33                 message(FATAL_ERROR
34                         "CMake generation for blender is not allowed within the source directory!"
35                         "\n Remove the CMakeCache.txt file and try again from another folder, e.g.:"
36                         "\n "
37                         "\n rm CMakeCache.txt"
38                         "\n cd .."
39                         "\n mkdir cmake-make"
40                         "\n cd cmake-make"
41                         "\n cmake ../blender"
42                         "\n "
43                         "\n Alternately define WITH_IN_SOURCE_BUILD to force this option (not recommended!)"
44                 )
45         endif()
46 endif()
47
48 cmake_minimum_required(VERSION 2.8)
49
50 if(NOT EXECUTABLE_OUTPUT_PATH)
51         set(FIRST_RUN TRUE)
52 else()
53         set(FIRST_RUN FALSE)
54 endif()
55
56 # this starts out unset
57 list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/build_files/cmake/Modules")
58
59 # avoid having empty buildtype
60 set(CMAKE_BUILD_TYPE_INIT "Release")
61
62 # quiet output for Makefiles, 'make -s' helps too
63 # set_property(GLOBAL PROPERTY RULE_MESSAGES OFF)
64
65 # global compile definitions since add_definitions() adds for all.
66
67 if(NOT (${CMAKE_VERSION} VERSION_LESS 3.0))
68         set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS
69                 $<$<CONFIG:Debug>:DEBUG;_DEBUG>
70                 $<$<CONFIG:Release>:NDEBUG>
71                 $<$<CONFIG:MinSizeRel>:NDEBUG>
72                 $<$<CONFIG:RelWithDebInfo>:NDEBUG>
73         )
74 else()
75         # keep until CMake-3.0 is min requirement
76         set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS_DEBUG           DEBUG _DEBUG)
77         set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS_RELEASE         NDEBUG)
78         set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS_MINSIZEREL      NDEBUG)
79         set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS_RELWITHDEBINFO  NDEBUG)
80 endif()
81
82 #-----------------------------------------------------------------------------
83 # Set policy
84
85 # see "cmake --help-policy CMP0003"
86 # So library linking is more sane
87 cmake_policy(SET CMP0003 NEW)
88
89 # So BUILDINFO and BLENDERPATH strings are automatically quoted
90 cmake_policy(SET CMP0005 NEW)
91
92 # So syntax problems are errors
93 cmake_policy(SET CMP0010 NEW)
94
95 # Input directories must have CMakeLists.txt
96 cmake_policy(SET CMP0014 NEW)
97
98 #-----------------------------------------------------------------------------
99 # Load some macros.
100 include(build_files/cmake/macros.cmake)
101
102
103 #-----------------------------------------------------------------------------
104 # Initialize project.
105
106 blender_project_hack_pre()
107
108 project(Blender)
109
110 blender_project_hack_post()
111
112 enable_testing()
113
114 #-----------------------------------------------------------------------------
115 # Redirect output files
116
117 set(EXECUTABLE_OUTPUT_PATH ${CMAKE_BINARY_DIR}/bin CACHE INTERNAL "" FORCE)
118 set(LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR}/lib CACHE INTERNAL "" FORCE)
119 set(TESTS_OUTPUT_DIR ${EXECUTABLE_OUTPUT_PATH}/tests CACHE INTERNAL "" FORCE)
120
121 #-----------------------------------------------------------------------------
122 # Set default config options
123
124 get_blender_version()
125
126
127 #-----------------------------------------------------------------------------
128 # Platform Specific Defaults
129
130 # list of var-names
131 set(_init_vars)
132
133 # initialize to ON
134 macro(option_defaults_init)
135         foreach(_var ${ARGV})
136                 set(${_var} ON)
137                 list(APPEND _init_vars "${_var}")
138         endforeach()
139         unset(_var)
140 endmacro()
141
142 # remove from namespace
143 macro(option_defaults_clear)
144         foreach(_var ${_init_vars})
145                 unset(${_var})
146         endforeach()
147         unset(_var)
148         unset(_init_vars)
149 endmacro()
150
151
152 # values to initialize WITH_****
153 option_defaults_init(
154         _init_BUILDINFO
155         _init_CODEC_FFMPEG
156         _init_CYCLES_OSL
157         _init_IMAGE_OPENEXR
158         _init_IMAGE_REDCODE
159         _init_INPUT_NDOF
160         _init_JACK
161         _init_LIBMV_SCHUR_SPECIALIZATION
162         _init_OPENCOLLADA
163         _init_OPENCOLORIO
164         _init_SDL
165         _init_FFTW3
166         _init_GAMEENGINE
167         _init_OPENSUBDIV
168 )
169
170 # customize...
171 if (UNIX AND NOT APPLE)
172         # some of these libraries are problematic on Linux
173         # disable less important dependencies by default
174         set(_init_CODEC_FFMPEG                   OFF)
175         set(_init_CYCLES_OSL                     OFF)
176         set(_init_IMAGE_OPENEXR                  OFF)
177         set(_init_IMAGE_REDCODE                  OFF)
178         set(_init_INPUT_NDOF                     OFF)
179         set(_init_JACK                           OFF)
180         set(_init_OPENCOLLADA                    OFF)
181         set(_init_OPENCOLORIO                    OFF)
182         set(_init_SDL                            OFF)
183         set(_init_FFTW3                          OFF)
184         set(_init_OPENSUBDIV                     OFF)
185 elseif(WIN32)
186         set(_init_JACK                           OFF)
187 elseif(APPLE)
188         set(_init_INPUT_NDOF                     OFF)
189         set(_init_JACK                           OFF)
190         set(_init_OPENSUBDIV                     OFF)
191 endif()
192
193
194 #-----------------------------------------------------------------------------
195 # Options
196
197 # First platform spesific non-cached vars
198 if(UNIX AND NOT APPLE)
199         set(WITH_X11 ON)
200 endif()
201
202 # Blender internal features
203 option(WITH_BLENDER "Build blender (disable to build only the blender player)" ON)
204 mark_as_advanced(WITH_BLENDER)
205
206 option(WITH_INTERNATIONAL "Enable I18N (International fonts and text)" ON)
207
208 option(WITH_PYTHON        "Enable Embedded Python API  (only disable for development)" ON)
209 option(WITH_PYTHON_SECURITY "Disables execution of scripts within blend files by default" ON) 
210 mark_as_advanced(WITH_PYTHON)  # dont want people disabling this unless they really know what they are doing.
211 mark_as_advanced(WITH_PYTHON_SECURITY)  # some distributions see this as a security issue, rather than have them patch it, make a build option.
212
213 option(WITH_PYTHON_SAFETY "Enable internal API error checking to track invalid data to prevent crash on access (at the expense of some effeciency, only enable for development)." OFF)
214 mark_as_advanced(WITH_PYTHON_SAFETY)
215 option(WITH_PYTHON_MODULE "Enable building as a python module which runs without a user interface, like running regular blender in background mode (experimental, only enable for development), installs to PYTHON_SITE_PACKAGES (or CMAKE_INSTALL_PREFIX if WITH_INSTALL_PORTABLE is enabled)." OFF)
216 if(APPLE)
217         option(WITH_PYTHON_FRAMEWORK "Enable building using the Python available in the framework (OSX only)" OFF)
218 endif()
219
220 option(WITH_BUILDINFO     "Include extra build details (only disable for development & faster builds)" ${_init_BUILDINFO})
221 if(${CMAKE_VERSION} VERSION_LESS 2.8.8)
222         # add_library OBJECT arg unsupported
223         set(WITH_BUILDINFO OFF)
224 endif()
225
226 option(WITH_IK_ITASC      "Enable ITASC IK solver (only disable for development & for incompatible C++ compilers)" ON)
227 option(WITH_IK_SOLVER     "Enable Legacy IK solver (only disable for development)" ON)
228 option(WITH_FFTW3         "Enable FFTW3 support (Used for smoke and audio effects)" ${_init_FFTW3})
229 option(WITH_BULLET        "Enable Bullet (Physics Engine)" ON)
230 option(WITH_SYSTEM_BULLET "Use the systems bullet library (currently unsupported due to missing features in upstream!)" )
231 mark_as_advanced(WITH_SYSTEM_BULLET)
232 option(WITH_GAMEENGINE    "Enable Game Engine" ${_init_GAMEENGINE})
233 option(WITH_PLAYER        "Build Player" OFF)
234 option(WITH_OPENCOLORIO   "Enable OpenColorIO color management" ${_init_OPENCOLORIO})
235
236 # Compositor
237 option(WITH_COMPOSITOR         "Enable the tile based nodal compositor" ON)
238 option(WITH_COMPOSITOR_WERROR  "Treat warnings as errors in compositor code" OFF)
239 mark_as_advanced(WITH_COMPOSITOR_WERROR)
240
241 option(WITH_OPENSUBDIV    "Enable OpenSubdiv for surface subdivision" _init_OPENSUBDIV)
242 option(WITH_SUBSURF_WERROR  "Treat warnings as errors in subsurf code" OFF)
243 mark_as_advanced(WITH_COMPOSITOR_WERROR)
244
245 option(WITH_OPENVDB       "Enable features relying on OpenVDB" OFF)
246 option(WITH_OPENVDB_BLOSC "Enable blosc compression for OpenVDB, only enable if OpenVDB was built with blosc support" OFF)
247
248 # GHOST Windowing Library Options
249 option(WITH_GHOST_DEBUG   "Enable debugging output for the GHOST library" OFF)
250 mark_as_advanced(WITH_GHOST_DEBUG)
251
252 option(WITH_GHOST_SDL    "Enable building Blender against SDL for windowing rather than the native APIs" OFF)
253 mark_as_advanced(WITH_GHOST_SDL)
254
255 if(WITH_X11)
256         option(WITH_GHOST_XDND    "Enable drag'n'drop support on X11 using XDND protocol" ON)
257 endif()
258
259 # Misc...
260 option(WITH_HEADLESS      "Build without graphical support (renderfarm, server mode only)" OFF)
261 mark_as_advanced(WITH_HEADLESS)
262
263 option(WITH_AUDASPACE    "Build with blenders audio library (only disable if you know what you're doing!)" ON)
264 option(WITH_SYSTEM_AUDASPACE "Build with external audaspace library installed on the system (only enable if you know what you're doing!)" OFF)
265 mark_as_advanced(WITH_AUDASPACE)
266 mark_as_advanced(WITH_SYSTEM_AUDASPACE)
267
268 if(NOT WITH_AUDASPACE)
269         set(WITH_SYSTEM_AUDASPACE OFF)
270 endif()
271
272 option(WITH_OPENMP        "Enable OpenMP (has to be supported by the compiler)" ON)
273 if(UNIX AND NOT APPLE)
274         option(WITH_OPENMP_STATIC "Link OpenMP statically (only used by the release environment)" OFF)
275         mark_as_advanced(WITH_OPENMP_STATIC)
276 endif()
277
278 if(WITH_X11)
279         option(WITH_X11_XINPUT    "Enable X11 Xinput (tablet support and unicode input)"  ON)
280         option(WITH_X11_XF86VMODE "Enable X11 video mode switching"                       ON)
281 endif()
282
283 if(UNIX AND NOT APPLE)
284         option(WITH_SYSTEM_GLEW "Use GLEW OpenGL wrapper library provided by the operating system" ON)
285         option(WITH_SYSTEM_GLES "Use OpenGL ES library provided by the operating system"           ON)
286 else()
287         # not an option for other OS's
288         set(WITH_SYSTEM_GLEW OFF)
289         set(WITH_SYSTEM_GLES OFF)
290 endif()
291
292
293 # (unix defaults to System OpenJPEG On)
294 option(WITH_SYSTEM_OPENJPEG "Use the operating systems OpenJPEG library" OFF)
295
296 if(UNIX AND NOT APPLE)
297         option(WITH_SYSTEM_EIGEN3 "Use the systems Eigen3 library" OFF)
298 endif()
299
300
301 # Modifiers
302 option(WITH_MOD_FLUID           "Enable Elbeem Modifier (Fluid Simulation)" ON)
303 option(WITH_MOD_SMOKE           "Enable Smoke Modifier (Smoke Simulation)" ON)
304 option(WITH_MOD_BOOLEAN         "Enable Boolean Modifier" ON)
305 option(WITH_MOD_REMESH          "Enable Remesh Modifier" ON)
306 # option(WITH_MOD_CLOTH_ELTOPO    "Enable Experimental cloth solver" OFF)  # this is now only available in a branch
307 # mark_as_advanced(WITH_MOD_CLOTH_ELTOPO)
308 option(WITH_MOD_OCEANSIM        "Enable Ocean Modifier" OFF)
309
310 # Image format support
311 option(WITH_OPENIMAGEIO         "Enable OpenImageIO Support (http://www.openimageio.org)" ON)
312 option(WITH_IMAGE_OPENEXR       "Enable OpenEXR Support (http://www.openexr.com)" ${_init_IMAGE_OPENEXR})
313 option(WITH_IMAGE_OPENJPEG      "Enable OpenJpeg Support (http://www.openjpeg.org)" ON)
314 option(WITH_IMAGE_TIFF          "Enable LibTIFF Support" ON)
315 option(WITH_IMAGE_DDS           "Enable DDS Image Support" ON)
316 option(WITH_IMAGE_CINEON        "Enable CINEON and DPX Image Support" ON)
317 option(WITH_IMAGE_HDR           "Enable HDR Image Support" ON)
318 option(WITH_IMAGE_REDCODE       "Enable RedCode Image Support" ${_init_IMAGE_REDCODE})
319 option(WITH_IMAGE_FRAMESERVER   "Enable image FrameServer Support for rendering" ON)
320
321 # Audio/Video format support
322 option(WITH_CODEC_AVI           "Enable Blenders own AVI file support (raw/jpeg)" ON)
323 option(WITH_CODEC_FFMPEG        "Enable FFMPeg Support (http://ffmpeg.org)" ${_init_CODEC_FFMPEG})
324 option(WITH_CODEC_SNDFILE       "Enable libsndfile Support (http://www.mega-nerd.com/libsndfile)" OFF)
325
326 if(APPLE)
327         option(WITH_CODEC_QUICKTIME     "Enable Quicktime Support" ON)
328 endif()
329
330 # 3D format support
331 # Disable opencollada when we don't have precompiled libs
332 option(WITH_OPENCOLLADA   "Enable OpenCollada Support (http://www.opencollada.org)" ${_init_OPENCOLLADA})
333
334 # Sound output
335 option(WITH_SDL           "Enable SDL for sound and joystick support" ${_init_SDL})
336 option(WITH_OPENAL        "Enable OpenAL Support (http://www.openal.org)" ON)
337 option(WITH_JACK          "Enable Jack Support (http://www.jackaudio.org)" ${_init_JACK})
338 if(UNIX AND NOT APPLE)
339         option(WITH_JACK_DYNLOAD  "Enable runtime dynamic Jack libraries loading" OFF)
340 endif()
341 if(UNIX AND NOT APPLE)
342         option(WITH_SDL_DYNLOAD  "Enable runtime dynamic SDL libraries loading" OFF)
343 endif()
344
345 # Compression
346 option(WITH_LZO           "Enable fast LZO compression (used for pointcache)" ON)
347 option(WITH_LZMA          "Enable best LZMA compression, (used for pointcache)" ON)
348 if(UNIX AND NOT APPLE)
349         option(WITH_SYSTEM_LZO    "Use the system LZO library" OFF)
350 endif()
351
352 # Camera/motion tracking
353 option(WITH_LIBMV         "Enable Libmv structure from motion library" ON)
354 option(WITH_LIBMV_SCHUR_SPECIALIZATIONS "Enable fixed-size schur specializations." ${_init_LIBMV_SCHUR_SPECIALIZATION})
355 option(WITH_LIBMV_WERROR  "Treat warnings as errors in Libmv (and Blender's motion tracking) code")
356 mark_as_advanced(WITH_LIBMV_SCHUR_SPECIALIZATIONS)
357 mark_as_advanced(WITH_LIBMV_WERROR)
358
359 # Freestyle
360 option(WITH_FREESTYLE     "Enable Freestyle (advanced edges rendering)" ON)
361
362 # Misc
363 if(WIN32)
364         option(WITH_INPUT_IME "Enable Input Method Editor (IME) for complex Asian character input" ON)
365 endif()
366 option(WITH_INPUT_NDOF "Enable NDOF input devices (SpaceNavigator and friends)" ${_init_INPUT_NDOF})
367 option(WITH_RAYOPTIMIZATION     "Enable use of SIMD (SSE) optimizations for the raytracer" ON)
368 if(UNIX AND NOT APPLE)
369         option(WITH_INSTALL_PORTABLE "Install redistributeable runtime, otherwise install into CMAKE_INSTALL_PREFIX" ON)
370         option(WITH_STATIC_LIBS "Try to link with static libraries, as much as possible, to make blender more portable across distributions" OFF)
371         if(WITH_STATIC_LIBS)
372                 option(WITH_BOOST_ICU "Boost uses ICU library (required for linking with static Boost built with libicu)." OFF)
373                 mark_as_advanced(WITH_BOOST_ICU)
374         endif()
375 endif()
376 option(WITH_PYTHON_INSTALL       "Copy system python into the blender install folder" ON)
377 option(WITH_PYTHON_INSTALL_NUMPY "Copy system numpy into the blender install folder"  ON)
378 set(PYTHON_NUMPY_PATH            "" CACHE PATH "Path to python site-packages or dist-packages containing 'numpy' module")
379 mark_as_advanced(PYTHON_NUMPY_PATH)
380 option(WITH_CPU_SSE              "Enable SIMD instruction if they're detected on the host machine" ON)
381 mark_as_advanced(WITH_CPU_SSE)
382
383 if(UNIX AND NOT APPLE)
384         option(WITH_PYTHON_INSTALL_REQUESTS "Copy system requests into the blender install folder" ON)
385         set(PYTHON_REQUESTS_PATH "" CACHE PATH "Path to python site-packages or dist-packages containing 'requests' module")
386         mark_as_advanced(PYTHON_REQUESTS_PATH)
387 endif()
388
389 # Cycles
390 option(WITH_CYCLES                                      "Enable Cycles Render Engine" ON)
391 option(WITH_CYCLES_STANDALONE           "Build Cycles standalone application" OFF)
392 option(WITH_CYCLES_STANDALONE_GUI       "Build Cycles standalone with GUI" OFF)
393 option(WITH_CYCLES_OSL                          "Build Cycles with OSL support" ${_init_CYCLES_OSL})
394 option(WITH_CYCLES_CUDA_BINARIES        "Build Cycles CUDA binaries" OFF)
395 set(CYCLES_CUDA_BINARIES_ARCH sm_20 sm_21 sm_30 sm_35 sm_50 sm_52 CACHE STRING "CUDA architectures to build binaries for")
396 mark_as_advanced(CYCLES_CUDA_BINARIES_ARCH)
397 unset(PLATFORM_DEFAULT)
398 option(WITH_CYCLES_LOGGING      "Build Cycles with logging support" ON)
399 option(WITH_CYCLES_DEBUG        "Build Cycles with extra debug capabilities" OFF)
400 option(WITH_CYCLES_WERROR       "Treat warnings as errors in Cycles code" OFF)
401 mark_as_advanced(WITH_CYCLES_LOGGING)
402 mark_as_advanced(WITH_CYCLES_DEBUG)
403 mark_as_advanced(WITH_CYCLES_WERROR)
404
405 option(WITH_CUDA_DYNLOAD "Dynamically load CUDA libraries at runtime" ON)
406 mark_as_advanced(WITH_CUDA_DYNLOAD)
407
408 # LLVM
409 option(WITH_LLVM                                        "Use LLVM" OFF)
410 if(APPLE)
411         option(LLVM_STATIC                                      "Link with LLVM static libraries" ON) # we prefer static llvm build on Apple, dyn build possible though
412 else()
413         option(LLVM_STATIC                                      "Link with LLVM static libraries" OFF)
414 endif()
415 mark_as_advanced(LLVM_STATIC)
416
417 # disable for now, but plan to support on all platforms eventually
418 option(WITH_MEM_JEMALLOC   "Enable malloc replacement (http://www.canonware.com/jemalloc)" ON)
419 mark_as_advanced(WITH_MEM_JEMALLOC)
420
421 # currently only used for BLI_mempool
422 option(WITH_MEM_VALGRIND "Enable extended valgrind support for better reporting" OFF)
423 mark_as_advanced(WITH_MEM_VALGRIND)
424
425 # Debug
426 option(WITH_CXX_GUARDEDALLOC "Enable GuardedAlloc for C++ memory allocation tracking (only enable for development)" OFF)
427 mark_as_advanced(WITH_CXX_GUARDEDALLOC)
428
429 option(WITH_ASSERT_ABORT "Call abort() when raising an assertion through BLI_assert()" OFF)
430 mark_as_advanced(WITH_ASSERT_ABORT)
431
432 option(WITH_BOOST                                       "Enable features depending on boost" ON)
433
434 # Unit testsing
435 option(WITH_GTESTS "Enable GTest unit testing" OFF)
436
437
438 # Documentation
439 if(UNIX AND NOT APPLE)
440         option(WITH_DOC_MANPAGE "Create a manual page (Unix manpage)" OFF)
441 endif()
442
443
444 # OpenGL
445
446 option(WITH_GLEW_MX             "Support multiple GLEW contexts (experimental)"                                                                     OFF )
447 option(WITH_GLEW_ES             "Switches to experimental copy of GLEW that has support for OpenGL ES. (temporary option for development purposes)" OFF)
448 option(WITH_GL_EGL              "Use the EGL OpenGL system library instead of the platform specific OpenGL system library (CGL, glX, or WGL)"       OFF)
449 option(WITH_GL_PROFILE_COMPAT   "Support using the OpenGL 'compatibility' profile. (deprecated)"                                                    ON )
450 option(WITH_GL_PROFILE_CORE     "Support using the OpenGL 3.2+ 'core' profile."                                                                     OFF)
451 option(WITH_GL_PROFILE_ES20     "Support using OpenGL ES 2.0. (thru either EGL or the AGL/WGL/XGL 'es20' profile)"                                  OFF)
452
453 mark_as_advanced(
454         WITH_GLEW_MX
455         WITH_GLEW_ES
456         WITH_GL_EGL
457         WITH_GL_PROFILE_COMPAT
458         WITH_GL_PROFILE_CORE
459         WITH_GL_PROFILE_ES20
460 )
461
462 if(WITH_GL_PROFILE_COMPAT)
463         set(WITH_GLU ON)
464 else()
465         set(WITH_GLU OFF)
466 endif()
467
468 if(WIN32)
469         option(WITH_GL_ANGLE "Link with the ANGLE library, an OpenGL ES 2.0 implementation based on Direct3D, instead of the system OpenGL library." OFF)
470         mark_as_advanced(WITH_GL_ANGLE)
471 endif()
472
473 if(WITH_GLEW_ES AND WITH_SYSTEM_GLEW)
474         message(WARNING Ignoring WITH_SYSTEM_GLEW and using WITH_GLEW_ES)
475         set(WITH_SYSTEM_GLEW OFF)
476 endif()
477
478 if(WIN32)
479         getDefaultWindowsPrefixBase(CMAKE_GENERIC_PROGRAM_FILES)
480         set(CPACK_INSTALL_PREFIX ${CMAKE_GENERIC_PROGRAM_FILES}/${})
481 endif()
482
483 # Experimental support of C++11
484 option(WITH_CPP11 "Build with C++11 standard enabled, for development use only!" OFF)
485 mark_as_advanced(WITH_CPP11)
486
487 # Dependency graph
488 option(WITH_LEGACY_DEPSGRAPH "Build Blender with legacy dependency graph" ON)
489 mark_as_advanced(WITH_LEGACY_DEPSGRAPH)
490
491 # avoid using again
492 option_defaults_clear()
493
494 # end option(...)
495
496
497
498 # By default we want to install to the directory we are compiling our executables
499 # unless specified otherwise, which we currently do not allow
500 if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
501         if(WIN32)
502                 set(CMAKE_INSTALL_PREFIX ${EXECUTABLE_OUTPUT_PATH}/\${BUILD_TYPE} CACHE PATH "default install path" FORCE)
503         elseif(APPLE)
504                 set(CMAKE_INSTALL_PREFIX ${EXECUTABLE_OUTPUT_PATH}/\${BUILD_TYPE} CACHE PATH "default install path" FORCE)
505         else()
506                 if(WITH_INSTALL_PORTABLE)
507                         set(CMAKE_INSTALL_PREFIX ${EXECUTABLE_OUTPUT_PATH} CACHE PATH "default install path" FORCE)
508                 endif()
509         endif()
510 endif()
511
512
513
514 # Apple
515
516 if(APPLE)
517         if(${CMAKE_VERSION} VERSION_LESS 3.0) # else breaks setting CMP0043 policy
518                 cmake_minimum_required(VERSION 2.8.8)
519                 cmake_policy(VERSION 2.8.8)
520         endif()
521
522         if(NOT CMAKE_OSX_ARCHITECTURES)
523                 set(CMAKE_OSX_ARCHITECTURES x86_64 CACHE STRING
524                 "Choose the architecture you want to build Blender for: i386, x86_64 or ppc"
525                 FORCE)
526         endif()
527         
528         execute_process(COMMAND uname -r OUTPUT_VARIABLE MAC_SYS) # check for actual system-version
529         if(${MAC_SYS} MATCHES 15)
530                 set(OSX_SYSTEM 10.11)
531                 # throw an error here, older cmake cannot handle 2 digit subversion!
532                 cmake_minimum_required(VERSION 3.0.0)
533         elseif(${MAC_SYS} MATCHES 14)
534                 set(OSX_SYSTEM 10.10)
535                 # throw an error here, older cmake cannot handle 2 digit subversion!
536                 cmake_minimum_required(VERSION 3.0.0)
537         elseif(${MAC_SYS} MATCHES 13)
538                 set(OSX_SYSTEM 10.9)
539         elseif(${MAC_SYS} MATCHES 12)
540                 set(OSX_SYSTEM 10.8)
541         elseif(${MAC_SYS} MATCHES 11)
542                 set(OSX_SYSTEM 10.7)
543         elseif(${MAC_SYS} MATCHES 10)
544                 set(OSX_SYSTEM 10.6)
545         elseif(${MAC_SYS} MATCHES 9)
546                 set(OSX_SYSTEM 10.5)
547         else()
548                 set(OSX_SYSTEM unsupported)
549         endif()
550         
551         # workaround for incorrect cmake xcode lookup for developer previews - XCODE_VERSION does not take xcode-select path into accout
552         # but would always look into /Applications/Xcode.app while dev versions are named Xcode<version>-DP<preview_number>
553         execute_process(COMMAND xcode-select --print-path  OUTPUT_VARIABLE XCODE_CHECK OUTPUT_STRIP_TRAILING_WHITESPACE)
554         string(REPLACE "/Contents/Developer" "" XCODE_BUNDLE ${XCODE_CHECK}) # truncate to bundlepath in any case
555         
556         if(${CMAKE_GENERATOR} MATCHES "Xcode")
557         
558                 if(${XCODE_VERSION} VERSION_GREATER 4.2) # earlier xcode has no bundled developer dir, no sense in getting xcode path from
559                         string(SUBSTRING "${XCODE_CHECK}" 14 6 DP_NAME) # reduce to XCode name without dp extension
560                         if(${DP_NAME} MATCHES Xcode5)
561                                 set(XCODE_VERSION 5)
562                         endif()
563                 endif()
564
565                 ##### cmake incompatibility with xcode  4.3 and higher #####
566                 if(${XCODE_VERSION} MATCHES '') # cmake fails due looking for xcode in the wrong path, thus will be empty var
567                         message(FATAL_ERROR "Xcode 4.3 and higher must be used with cmake 2.8-8 or higher")
568                 endif()
569                 ### end cmake incompatibility with xcode 4.3 and higher ###
570                 
571                 if(${XCODE_VERSION} VERSION_EQUAL 4 OR ${XCODE_VERSION} VERSION_GREATER 4 AND ${XCODE_VERSION} VERSION_LESS 4.3)
572                         # Xcode 4 defaults to the Apple LLVM Compiler.
573                         # Override the default compiler selection because Blender only compiles with gcc up to xcode 4.2
574                         set(CMAKE_XCODE_ATTRIBUTE_GCC_VERSION "com.apple.compilers.llvmgcc42")
575                         message(STATUS "Setting compiler to: " ${CMAKE_XCODE_ATTRIBUTE_GCC_VERSION})
576                 endif()
577         else() # unix makefile generator does not fill XCODE_VERSION var, so we get it with a command
578                 execute_process(COMMAND xcodebuild -version OUTPUT_VARIABLE XCODE_VERS_BUILD_NR)
579                 string(SUBSTRING "${XCODE_VERS_BUILD_NR}" 6 3 XCODE_VERSION) # truncate away build-nr
580                 unset(XCODE_VERS_BUILD_NR)
581         endif()
582
583         message(STATUS "Detected OS X ${OSX_SYSTEM} and Xcode ${XCODE_VERSION} at ${XCODE_BUNDLE}")
584
585         if(${XCODE_VERSION} VERSION_LESS 4.3)
586                 set(CMAKE_OSX_SYSROOT /Developer/SDKs/MacOSX${OSX_SYSTEM}.sdk CACHE PATH "" FORCE)  # use guaranteed existing sdk
587         else()
588                 # note: xcode-select path could be ambigous, cause /Applications/Xcode.app/Contents/Developer or /Applications/Xcode.app would be allowed
589                 # so i use a selfcomposed bundlepath here  
590                 set(OSX_SYSROOT_PREFIX ${XCODE_BUNDLE}/Contents/Developer/Platforms/MacOSX.platform)
591                 message(STATUS "OSX_SYSROOT_PREFIX: " ${OSX_SYSROOT_PREFIX})
592                 set(OSX_DEVELOPER_PREFIX /Developer/SDKs/MacOSX${OSX_SYSTEM}.sdk) # use guaranteed existing sdk
593                 set(CMAKE_OSX_SYSROOT ${OSX_SYSROOT_PREFIX}/${OSX_DEVELOPER_PREFIX} CACHE PATH "" FORCE)
594                 if(${CMAKE_GENERATOR} MATCHES "Xcode")
595                         set(CMAKE_XCODE_ATTRIBUTE_SDKROOT macosx${OSX_SYSTEM}) # to silence sdk not found warning, just overrides CMAKE_OSX_SYSROOT
596                 endif()
597         endif()
598
599         if(OSX_SYSTEM MATCHES 10.9)
600                 set(CMAKE_FIND_ROOT_PATH ${CMAKE_OSX_SYSROOT}) # make sure syslibs and headers are looked up in sdk ( expecially for 10.9 openGL atm. )
601         endif()
602
603         if(NOT CMAKE_OSX_DEPLOYMENT_TARGET)
604                 set(CMAKE_OSX_DEPLOYMENT_TARGET "10.6" CACHE STRING "" FORCE) # 10.6 is our min. target, if you use higher sdk, weak linking happens
605         endif()
606         
607         if(NOT ${CMAKE_GENERATOR} MATCHES "Xcode")
608                 # force CMAKE_OSX_DEPLOYMENT_TARGET for makefiles, will not work else ( cmake bug ? )
609                 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mmacosx-version-min=${CMAKE_OSX_DEPLOYMENT_TARGET}")
610                 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mmacosx-version-min=${CMAKE_OSX_DEPLOYMENT_TARGET}")
611                 add_definitions("-DMACOSX_DEPLOYMENT_TARGET=${CMAKE_OSX_DEPLOYMENT_TARGET}")
612         endif()
613
614         option(WITH_LIBS10.5  "Use 10.5 libs (needed for 64bit builds)" OFF)
615 endif()
616
617
618 #-----------------------------------------------------------------------------
619 # Check for conflicting/unsupported configurations
620
621 if(NOT WITH_BLENDER AND NOT WITH_PLAYER AND NOT WITH_CYCLES_STANDALONE)
622         message(FATAL_ERROR "At least one of WITH_BLENDER or WITH_PLAYER or WITH_CYCLES_STANDALONE must be enabled, nothing to do!")
623 endif()
624
625 if(NOT WITH_GAMEENGINE AND WITH_PLAYER)
626         message(FATAL_ERROR "WITH_PLAYER requires WITH_GAMEENGINE")
627 endif()
628
629 if(NOT WITH_AUDASPACE)
630         if(WITH_OPENAL)
631                 message(FATAL_ERROR "WITH_OPENAL requires WITH_AUDASPACE")
632         endif()
633         if(WITH_JACK)
634                 message(FATAL_ERROR "WITH_JACK requires WITH_AUDASPACE")
635         endif()
636         if(WITH_GAMEENGINE)
637                 message(FATAL_ERROR "WITH_GAMEENGINE requires WITH_AUDASPACE")
638         endif()
639 endif()
640
641 if(NOT WITH_SDL AND WITH_GHOST_SDL)
642         message(FATAL_ERROR "WITH_GHOST_SDL requires WITH_SDL")
643 endif()
644
645 if(WITH_IMAGE_REDCODE AND ((NOT WITH_IMAGE_OPENJPEG) OR (NOT WITH_CODEC_FFMPEG)))
646         message(FATAL_ERROR "WITH_IMAGE_REDCODE requires WITH_IMAGE_OPENJPEG and WITH_CODEC_FFMPEG")
647 endif()
648
649 # python module, needs some different options
650 if(WITH_PYTHON_MODULE AND WITH_PLAYER)
651         message(FATAL_ERROR "WITH_PYTHON_MODULE requires WITH_PLAYER to be OFF")
652 endif()
653
654 if(WITH_PYTHON_MODULE AND WITH_PYTHON_INSTALL)
655         message(FATAL_ERROR "WITH_PYTHON_MODULE requires WITH_PYTHON_INSTALL to be OFF")
656 endif()
657
658
659 # may as well build python module without a UI
660 if(WITH_PYTHON_MODULE)
661         set(WITH_HEADLESS ON)
662 endif()
663
664 if(NOT WITH_PYTHON)
665         set(WITH_CYCLES OFF)
666 endif()
667
668 # enable boost for cycles, audaspace or i18n
669 # otherwise if the user disabled
670 if(NOT WITH_BOOST)
671         # Explicitly disabled. so disable all deps.
672         macro(set_and_warn
673                 _setting _val)
674                 if(${${_setting}})
675                         message(STATUS "'WITH_BOOST' is disabled: forceing 'set(${_setting} ${_val})'")
676                 endif()
677                 set(${_setting} ${_val})
678         endmacro()
679
680         set_and_warn(WITH_CYCLES         OFF)
681         set_and_warn(WITH_AUDASPACE      OFF)
682         set_and_warn(WITH_INTERNATIONAL  OFF)
683         set_and_warn(WITH_OPENVDB        OFF)
684
685         set_and_warn(WITH_OPENAL         OFF)  # depends on AUDASPACE
686         set_and_warn(WITH_GAMEENGINE     OFF)  # depends on AUDASPACE
687 elseif(WITH_CYCLES OR WITH_OPENIMAGEIO OR WITH_AUDASPACE OR WITH_INTERNATIONAL OR WITH_OPENVDB)
688         # Keep enabled
689 else()
690         # Enabled but we don't need it
691         set(WITH_BOOST OFF)
692 endif()
693
694 # auto enable openimageio for cycles
695 if(WITH_CYCLES)
696         set(WITH_OPENIMAGEIO ON)
697
698         # auto enable llvm for cycles_osl
699         if(WITH_CYCLES_OSL)
700                 set(WITH_LLVM ON CACHE BOOL "" FORCE)
701         endif()
702 else()
703         set(WITH_CYCLES_OSL OFF)
704 endif()
705
706 # auto enable openimageio linking dependencies
707 if(WITH_OPENIMAGEIO)
708         set(WITH_IMAGE_OPENEXR ON)
709         set(WITH_IMAGE_TIFF ON)
710 endif()
711
712 # don't store paths to libs for portable distribution
713 if(WITH_INSTALL_PORTABLE)
714         set(CMAKE_SKIP_BUILD_RPATH TRUE)
715 endif()
716
717 if(WITH_GHOST_SDL OR WITH_HEADLESS)
718         set(WITH_X11           OFF)
719         set(WITH_X11_XINPUT    OFF)
720         set(WITH_X11_XF86VMODE OFF)
721         set(WITH_GHOST_XDND    OFF)
722         set(WITH_INPUT_IME     OFF)
723 endif()
724
725 if(WITH_CPU_SSE)
726         TEST_SSE_SUPPORT(COMPILER_SSE_FLAG COMPILER_SSE2_FLAG)
727 else()
728         message(STATUS "SSE and SSE2 optimizations are DISABLED!")
729         set(COMPILER_SSE_FLAG)
730         set(COMPILER_SSE2_FLAG)
731 endif()
732
733 TEST_SHARED_PTR_SUPPORT()
734 TEST_UNORDERED_MAP_SUPPORT()
735
736 if(WITH_AUDASPACE)
737         if(WITH_SYSTEM_AUDASPACE)
738                 set(AUDASPACE_DEFINITIONS
739                         -DWITH_AUDASPACE
740                         -DWITH_SYSTEM_AUDASPACE
741                         "-DAUD_DEVICE_H=<AUD_Device.h>"
742                         "-DAUD_SPECIAL_H=<AUD_Special.h>"
743                         "-DAUD_SOUND_H=<AUD_Sound.h>"
744                         "-DAUD_HANDLE_H=<AUD_Handle.h>"
745                         "-DAUD_SEQUENCE_H=<AUD_Sequence.h>"
746                         "-DAUD_TYPES_H=<AUD_Types.h>"
747                         "-DAUD_PYTHON_H=<python/PyAPI.h>"
748                 )
749         else()
750                 set(AUDASPACE_C_INCLUDE_DIRS "${CMAKE_SOURCE_DIR}/intern/audaspace/intern")
751                 set(AUDASPACE_PY_INCLUDE_DIRS "${CMAKE_SOURCE_DIR}/intern/audaspace/intern")
752                 set(AUDASPACE_DEFINITIONS
753                         -DWITH_AUDASPACE
754                         "-DAUD_DEVICE_H=<AUD_C-API.h>"
755                         "-DAUD_SPECIAL_H=<AUD_C-API.h>"
756                         "-DAUD_SOUND_H=<AUD_C-API.h>"
757                         "-DAUD_HANDLE_H=<AUD_C-API.h>"
758                         "-DAUD_SEQUENCE_H=<AUD_C-API.h>"
759                         "-DAUD_TYPES_H=<AUD_Space.h>"
760                 )
761         endif()
762 endif()
763
764 #-----------------------------------------------------------------------------
765 # Check for valid directories
766 # ... a partial checkout may cause this.
767 #
768 # note: we need to check for a known subdir in both cases.
769 #       since uninitialized git submodules will give blank dirs
770
771 if(WITH_INTERNATIONAL)
772         if(NOT EXISTS "${CMAKE_SOURCE_DIR}/release/datafiles/locale/languages")
773                 message(WARNING "Translation path '${CMAKE_SOURCE_DIR}/release/datafiles/locale' is missing, "
774                                                 "This is a 'git submodule', which are known not to work with bridges to other version "
775                                                 "control systems, disabling 'WITH_INTERNATIONAL'.")
776                 set(WITH_INTERNATIONAL OFF)
777         endif()
778 endif()
779
780 if(WITH_PYTHON)
781         if(NOT EXISTS "${CMAKE_SOURCE_DIR}/release/scripts/addons/modules")
782                 message(WARNING "Addons path '${CMAKE_SOURCE_DIR}/release/scripts/addons' is missing, "
783                                                 "This is a 'git submodule', which are known not to work with bridges to other version "
784                                                 "control systems: * CONTINUING WITHOUT ADDONS *")
785         endif()
786 endif()
787
788 #-----------------------------------------------------------------------------
789 # Initialize un-cached vars, avoid unused warning
790
791 # linux only, not cached
792 set(WITH_BINRELOC OFF)
793
794 # MAXOSX only, set to avoid uninitialized
795 set(EXETYPE "")
796
797 # C/C++ flags
798 set(PLATFORM_CFLAGS)
799
800 # these are added to later on.
801 set(C_WARNINGS)
802 set(CXX_WARNINGS)
803
804 # for gcc -Wno-blah-blah
805 set(CC_REMOVE_STRICT_FLAGS)
806
807 # libraries to link the binary with passed to target_link_libraries()
808 # known as LLIBS to scons
809 set(PLATFORM_LINKLIBS "")
810
811 # Added to linker flags in setup_liblinks
812 # - CMAKE_EXE_LINKER_FLAGS
813 # - CMAKE_EXE_LINKER_FLAGS_DEBUG
814 set(PLATFORM_LINKFLAGS "")
815 set(PLATFORM_LINKFLAGS_DEBUG "")
816
817
818 # For alternate Python locations the commandline can be used to override detected/default cache settings, e.g:
819 # On Unix:
820 #   cmake ../blender \
821 #         -D PYTHON_VERSION=3.5 \
822 #         -D PYTHON_INCLUDE_DIR=/opt/py35/include/python3.5d \
823 #         -D PYTHON_LIBRARY=/opt/py35/lib/libpython3.5d.so
824 #
825 # On Macs:
826 #   cmake ../blender \
827 #         -D PYTHON_INCLUDE_DIR=/System/Library/Frameworks/Python.framework/Versions/3.5/include/python3.5 \
828 #         -D PYTHON_LIBPATH=/System/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/config \
829 #         -G Xcode
830 #
831 # When changing any of this remember to update the notes in doc/build_systems/cmake.txt
832
833 #-----------------------------------------------------------------------------
834 #Platform specifics
835
836 if(WITH_X11)
837         find_package(X11 REQUIRED)
838
839         find_path(X11_XF86keysym_INCLUDE_PATH X11/XF86keysym.h ${X11_INC_SEARCH_PATH})
840         mark_as_advanced(X11_XF86keysym_INCLUDE_PATH)
841
842         list(APPEND PLATFORM_LINKLIBS ${X11_X11_LIB})
843
844         if(WITH_X11_XINPUT)
845                 if(X11_Xinput_LIB)
846                         list(APPEND PLATFORM_LINKLIBS ${X11_Xinput_LIB})
847                 else()
848                         set(WITH_X11_XINPUT OFF)
849                 endif()
850         endif()
851
852         if(WITH_X11_XF86VMODE)
853                 # XXX, why dont cmake make this available?
854                 find_library(X11_Xxf86vmode_LIB Xxf86vm   ${X11_LIB_SEARCH_PATH})
855                 mark_as_advanced(X11_Xxf86vmode_LIB)
856                 if(X11_Xxf86vmode_LIB)
857                         list(APPEND PLATFORM_LINKLIBS ${X11_Xxf86vmode_LIB})
858                 else()
859                         set(WITH_X11_XF86VMODE OFF)
860                 endif()
861         endif()
862
863 endif()
864
865
866 # ----------------------------------------------------------------------------
867 # Main Platform Checks
868 #
869 # - UNIX
870 # - WIN32
871 # - APPLE
872
873 if(UNIX AND NOT APPLE)
874         macro(find_package_wrapper)
875                 if(WITH_STATIC_LIBS)
876                         find_package_static(${ARGV})
877                 else()
878                         find_package(${ARGV})
879                 endif()
880         endmacro()
881
882         find_package_wrapper(JPEG REQUIRED)
883         find_package_wrapper(PNG REQUIRED)
884         find_package_wrapper(ZLIB REQUIRED)
885         find_package_wrapper(Freetype REQUIRED)
886
887         if(WITH_LZO AND WITH_SYSTEM_LZO)
888                 find_package_wrapper(LZO)
889                 if(NOT LZO_FOUND)
890                         message(FATAL_ERROR "Failed finding system LZO version!")
891                 endif()
892         endif()
893
894         if(WITH_SYSTEM_EIGEN3)
895                 find_package_wrapper(Eigen3)
896                 if(NOT EIGEN3_FOUND)
897                         message(FATAL_ERROR "Failed finding system Eigen3 version!")
898                 endif()
899         endif()
900         # else values are set below for all platforms
901
902         if(WITH_PYTHON)
903                 # No way to set py35, remove for now.
904                 # find_package(PythonLibs)
905
906                 # Use our own instead, since without py is such a rare case,
907                 # require this package
908                 # XXX Linking errors with debian static python :/
909 #               find_package_wrapper(PythonLibsUnix REQUIRED)
910                 find_package(PythonLibsUnix REQUIRED)
911         endif()
912
913         if(WITH_IMAGE_OPENEXR)
914                 find_package_wrapper(OpenEXR)  # our own module
915                 if(NOT OPENEXR_FOUND)
916                         set(WITH_IMAGE_OPENEXR OFF)
917                 endif()
918         endif()
919
920         if(WITH_IMAGE_OPENJPEG)
921                 find_package_wrapper(OpenJPEG)
922                 if(NOT OPENJPEG_FOUND)
923                         set(WITH_IMAGE_OPENJPEG OFF)
924                 endif()
925         endif()
926
927         if(WITH_IMAGE_TIFF)
928                 # XXX Linking errors with debian static tiff :/
929 #               find_package_wrapper(TIFF)
930                 find_package(TIFF)
931                 if(NOT TIFF_FOUND)
932                         set(WITH_IMAGE_TIFF OFF)
933                 endif()
934         endif()
935
936         # Audio IO
937         if(WITH_SYSTEM_AUDASPACE)
938                 find_package_wrapper(Audaspace)
939                 if(NOT AUDASPACE_FOUND OR NOT AUDASPACE_C_FOUND)
940                         message(FATAL_ERROR "Audaspace external library not found!")
941                 endif()
942         endif()
943
944         if(WITH_OPENAL)
945                 find_package_wrapper(OpenAL)
946                 if(NOT OPENAL_FOUND)
947                         set(WITH_OPENAL OFF)
948                 endif()
949         endif()
950
951         if(WITH_SDL)
952                 if(WITH_SDL_DYNLOAD)
953                         set(SDL_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/extern/sdlew/include/SDL2")
954                         set(SDL_LIBRARY)
955                 else()
956                         find_package_wrapper(SDL2)
957                         if(SDL2_FOUND)
958                                 # Use same names for both versions of SDL until we move to 2.x.
959                                 set(SDL_INCLUDE_DIR "${SDL2_INCLUDE_DIR}")
960                                 set(SDL_LIBRARY "${SDL2_LIBRARY}")
961                                 set(SDL_FOUND "${SDL2_FOUND}")
962                         else()
963                                 find_package_wrapper(SDL)
964                         endif()
965                         mark_as_advanced(
966                                 SDL_INCLUDE_DIR
967                                 SDL_LIBRARY
968                         )
969                         # unset(SDLMAIN_LIBRARY CACHE)
970                         if(NOT SDL_FOUND)
971                                 set(WITH_SDL OFF)
972                         endif()
973                 endif()
974         endif()
975
976         if(WITH_JACK)
977                 find_package_wrapper(Jack)
978                 if(NOT JACK_FOUND)
979                         set(WITH_JACK OFF)
980                 endif()
981         endif()
982
983         # Codecs
984         if(WITH_CODEC_SNDFILE)
985                 find_package_wrapper(SndFile)
986                 if(NOT SNDFILE_FOUND)
987                         set(WITH_CODEC_SNDFILE OFF)
988                 endif()
989         endif()
990
991         if(WITH_CODEC_FFMPEG)
992                 set(FFMPEG /usr CACHE PATH "FFMPEG Directory")
993                 set(FFMPEG_LIBRARIES avformat avcodec avutil avdevice swscale CACHE STRING "FFMPEG Libraries")
994
995                 mark_as_advanced(FFMPEG)
996
997                 # lame, but until we have proper find module for ffmpeg
998                 set(FFMPEG_INCLUDE_DIRS ${FFMPEG}/include)
999                 if(EXISTS "${FFMPEG}/include/ffmpeg/")
1000                         list(APPEND FFMPEG_INCLUDE_DIRS "${FFMPEG}/include/ffmpeg")
1001                 endif()
1002                 # end lameness
1003
1004                 mark_as_advanced(FFMPEG_LIBRARIES)
1005                 set(FFMPEG_LIBPATH ${FFMPEG}/lib)
1006         endif()
1007
1008         if(WITH_FFTW3)
1009                 find_package_wrapper(Fftw3)
1010                 if(NOT FFTW3_FOUND)
1011                         set(WITH_FFTW3 OFF)
1012                 endif()
1013         endif()
1014
1015         if(WITH_OPENCOLLADA)
1016                 find_package_wrapper(OpenCOLLADA)
1017                 if(OPENCOLLADA_FOUND)
1018                         find_package_wrapper(XML2)
1019                         find_package_wrapper(PCRE)
1020                 else()
1021                         set(WITH_OPENCOLLADA OFF)
1022                 endif()
1023         endif()
1024
1025         if(WITH_MEM_JEMALLOC)
1026                 find_package_wrapper(JeMalloc)
1027                 if(NOT JEMALLOC_FOUND)
1028                         set(WITH_MEM_JEMALLOC OFF)
1029                 endif()
1030         endif()
1031
1032         if(WITH_INPUT_NDOF)
1033                 find_package_wrapper(Spacenav)
1034                 if(NOT SPACENAV_FOUND)
1035                         set(WITH_INPUT_NDOF OFF)
1036                 endif()
1037
1038                 # use generic names within blenders buildsystem.
1039                 if(SPACENAV_FOUND)
1040                         set(NDOF_INCLUDE_DIRS ${SPACENAV_INCLUDE_DIRS})
1041                         set(NDOF_LIBRARIES ${SPACENAV_LIBRARIES})
1042                 endif()
1043         endif()
1044
1045         if(WITH_CYCLES_OSL)
1046                 set(CYCLES_OSL ${LIBDIR}/osl CACHE PATH "Path to OpenShadingLanguage installation")
1047                 if(NOT OSL_ROOT)
1048                         set(OSL_ROOT ${CYCLES_OSL})
1049                 endif()
1050                 find_package_wrapper(OpenShadingLanguage)
1051                 if(OSL_FOUND)
1052                         if(${OSL_LIBRARY_VERSION_MAJOR} EQUAL "1" AND ${OSL_LIBRARY_VERSION_MINOR} LESS "6")
1053                                 # Note: --whole-archive is needed to force loading of all symbols in liboslexec,
1054                                 # otherwise LLVM is missing the osl_allocate_closure_component function
1055                                 set(OSL_LIBRARIES ${OSL_OSLCOMP_LIBRARY} -Wl,--whole-archive ${OSL_OSLEXEC_LIBRARY} -Wl,--no-whole-archive ${OSL_OSLQUERY_LIBRARY})
1056                         endif()
1057                 else()
1058                         message(STATUS "OSL not found, disabling it from Cycles")
1059                         set(WITH_CYCLES_OSL OFF)
1060                 endif()
1061         endif()
1062
1063         if(WITH_OPENVDB)
1064                 find_package_wrapper(OpenVDB)
1065
1066                 set(TBB ${LIBDIR}/tbb)
1067                 set(TBB_LIBRARIES tbb)
1068                 set(TBB_LIBPATH ${TBB}/lib)
1069
1070                 set(OPENVDB_LIBRARIES ${OPENVDB_LIBRARIES} ${BOOST_LIBRARIES} ${ZLIB_LIBRARIES} ${TBB_LIBRARIES})
1071                 set(OPENVDB_LIBPATH)  # TODO, remove and reference the absolute path everywhere
1072                 set(OPENVDB_DEFINITIONS)
1073
1074                 if(NOT OPENVDB_FOUND)
1075                         set(WITH_OPENVDB OFF)
1076                         set(WITH_OPENVDB_BLOSC OFF)
1077                         message(STATUS "OpenVDB not found")
1078                 endif()
1079         endif()
1080
1081         if(WITH_BOOST)
1082                 # uses in build instructions to override include and library variables
1083                 if(NOT BOOST_CUSTOM)
1084                         if(WITH_STATIC_LIBS)
1085                                 set(Boost_USE_STATIC_LIBS ON)
1086                         endif()
1087                         set(Boost_USE_MULTITHREADED ON)
1088                         set(__boost_packages filesystem regex system thread date_time)
1089                         if(WITH_CYCLES_OSL)
1090                                 if(NOT (${OSL_LIBRARY_VERSION_MAJOR} EQUAL "1" AND ${OSL_LIBRARY_VERSION_MINOR} LESS "6"))
1091                                         list(APPEND __boost_packages wave)
1092                                 else()
1093                                 endif()
1094                         endif()
1095                         if(WITH_INTERNATIONAL)
1096                                 list(APPEND __boost_packages locale)
1097                         endif()
1098                         if(WITH_CYCLES_NETWORK)
1099                                 list(APPEND __boost_packages serialization)
1100                         endif()
1101                         if(WITH_OPENVDB)
1102                                 list(APPEND __boost_packages iostreams)
1103                         endif()
1104                         find_package(Boost 1.48 COMPONENTS ${__boost_packages})
1105                         if(NOT Boost_FOUND)
1106                                 # try to find non-multithreaded if -mt not found, this flag
1107                                 # doesn't matter for us, it has nothing to do with thread
1108                                 # safety, but keep it to not disturb build setups
1109                                 set(Boost_USE_MULTITHREADED OFF)
1110                                 find_package(Boost 1.48 COMPONENTS ${__boost_packages})
1111                         endif()
1112                         unset(__boost_packages)
1113                         if(Boost_USE_STATIC_LIBS AND WITH_BOOST_ICU)
1114                                 find_package(IcuLinux)
1115                         endif()
1116                         mark_as_advanced(Boost_DIR)  # why doesnt boost do this?
1117                 endif()
1118
1119                 set(BOOST_INCLUDE_DIR ${Boost_INCLUDE_DIRS})
1120                 set(BOOST_LIBRARIES ${Boost_LIBRARIES})
1121                 set(BOOST_LIBPATH ${Boost_LIBRARY_DIRS})
1122                 set(BOOST_DEFINITIONS "-DBOOST_ALL_NO_LIB")
1123         endif()
1124
1125         if(WITH_OPENIMAGEIO)
1126                 find_package_wrapper(OpenImageIO)
1127                 if(NOT OPENIMAGEIO_PUGIXML_FOUND AND WITH_CYCLES_STANDALONE)
1128                         find_package_wrapper(PugiXML)
1129                 else()
1130                         set(PUGIXML_INCLUDE_DIR "${OPENIMAGEIO_INCLUDE_DIR/OpenImageIO}")
1131                         set(PUGIXML_LIBRARIES "")
1132                 endif()
1133
1134                 set(OPENIMAGEIO_LIBRARIES ${OPENIMAGEIO_LIBRARIES} ${PNG_LIBRARIES} ${JPEG_LIBRARIES} ${ZLIB_LIBRARIES} ${BOOST_LIBRARIES})
1135                 set(OPENIMAGEIO_LIBPATH)  # TODO, remove and reference the absolute path everywhere
1136                 set(OPENIMAGEIO_DEFINITIONS "")
1137
1138                 if(WITH_IMAGE_TIFF)
1139                         list(APPEND OPENIMAGEIO_LIBRARIES "${TIFF_LIBRARY}")
1140                 endif()
1141                 if(WITH_IMAGE_OPENEXR)
1142                         list(APPEND OPENIMAGEIO_LIBRARIES "${OPENEXR_LIBRARIES}")
1143                 endif()
1144
1145                 if(NOT OPENIMAGEIO_FOUND)
1146                         set(WITH_OPENIMAGEIO OFF)
1147                         message(STATUS "OpenImageIO not found, disabling WITH_CYCLES")
1148                 endif()
1149         endif()
1150
1151         if(WITH_OPENCOLORIO)
1152                 find_package_wrapper(OpenColorIO)
1153
1154                 set(OPENCOLORIO_LIBRARIES ${OPENCOLORIO_LIBRARIES})
1155                 set(OPENCOLORIO_LIBPATH)  # TODO, remove and reference the absolute path everywhere
1156                 set(OPENCOLORIO_DEFINITIONS)
1157
1158                 if(NOT OPENCOLORIO_FOUND)
1159                         set(WITH_OPENCOLORIO OFF)
1160                         message(STATUS "OpenColorIO not found")
1161                 endif()
1162         endif()
1163
1164         if(WITH_LLVM)
1165                 find_package_wrapper(LLVM)
1166
1167                 if(NOT LLVM_FOUND)
1168                         set(WITH_LLVM OFF)
1169                         message(STATUS "LLVM not found")
1170                 endif()
1171         endif()
1172
1173         if(WITH_LLVM OR WITH_SDL_DYNLOAD)
1174                 # Fix for conflict with Mesa llvmpipe
1175                 set(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} -Wl,--version-script='${CMAKE_SOURCE_DIR}/source/creator/blender.map'")
1176         endif()
1177
1178         if(WITH_OPENSUBDIV)
1179                 find_package_wrapper(OpenSubdiv)
1180
1181                 set(OPENSUBDIV_LIBRARIES ${OPENSUBDIV_LIBRARIES})
1182                 set(OPENSUBDIV_LIBPATH)  # TODO, remove and reference the absolute path everywhere
1183
1184                 if(NOT OPENSUBDIV_FOUND)
1185                         set(WITH_OPENSUBDIV OFF)
1186                         message(STATUS "OpenSubdiv not found")
1187                 endif()
1188         endif()
1189
1190         # OpenSuse needs lutil, ArchLinux not, for now keep, can avoid by using --as-needed
1191         list(APPEND PLATFORM_LINKLIBS -lutil -lc -lm)
1192
1193         find_package(Threads REQUIRED)
1194         list(APPEND PLATFORM_LINKLIBS ${CMAKE_THREAD_LIBS_INIT})
1195         # used by other platforms
1196         set(PTHREADS_LIBRARIES ${CMAKE_THREAD_LIBS_INIT})
1197
1198         if(CMAKE_DL_LIBS)
1199                 list(APPEND PLATFORM_LINKLIBS ${CMAKE_DL_LIBS})
1200         endif()
1201
1202         if(CMAKE_SYSTEM_NAME MATCHES "Linux")
1203                 if(NOT WITH_PYTHON_MODULE)
1204                         # binreloc is linux only
1205                         set(BINRELOC_INCLUDE_DIRS ${CMAKE_SOURCE_DIR}/extern/binreloc/include)
1206                         set(WITH_BINRELOC ON)
1207                 endif()
1208         endif()
1209
1210         # lfs on glibc, all compilers should use
1211         add_definitions(-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE)
1212
1213         # GNU Compiler
1214         if(CMAKE_COMPILER_IS_GNUCC)
1215                 set(PLATFORM_CFLAGS "-pipe -fPIC -funsigned-char -fno-strict-aliasing")
1216
1217                 # use ld.gold linker if available, could make optional
1218                 execute_process(
1219                         COMMAND ${CMAKE_C_COMPILER} -fuse-ld=gold -Wl,--version
1220                         ERROR_QUIET OUTPUT_VARIABLE LD_VERSION)
1221                 if("${LD_VERSION}" MATCHES "GNU gold")
1222                         set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fuse-ld=gold")
1223                         set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fuse-ld=gold")
1224                 else()
1225                         message(STATUS "GNU gold linker isn't available, using the default system linker.")
1226                 endif()
1227                 unset(LD_VERSION)
1228
1229         # CLang is the same as GCC for now.
1230         elseif(CMAKE_C_COMPILER_ID MATCHES "Clang")
1231                 set(PLATFORM_CFLAGS "-pipe -fPIC -funsigned-char -fno-strict-aliasing")
1232         # Solaris CC
1233         elseif(CMAKE_C_COMPILER_ID MATCHES "SunPro")
1234                 set(PLATFORM_CFLAGS "-pipe -features=extensions -fPIC -D__FUNCTION__=__func__")
1235                 
1236         # Intel C++ Compiler
1237         elseif(CMAKE_C_COMPILER_ID MATCHES "Intel")
1238                 # think these next two are broken
1239                 find_program(XIAR xiar)
1240                 if(XIAR)
1241                         set(CMAKE_AR "${XIAR}")
1242                 endif()
1243                 mark_as_advanced(XIAR)
1244
1245                 find_program(XILD xild)
1246                 if(XILD)
1247                         set(CMAKE_LINKER "${XILD}")
1248                 endif()
1249                 mark_as_advanced(XILD)
1250
1251                 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fp-model precise -prec_div -parallel")
1252                 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fp-model precise -prec_div -parallel")
1253
1254                 # set(PLATFORM_CFLAGS "${PLATFORM_CFLAGS} -diag-enable sc3")
1255                 set(PLATFORM_CFLAGS "-pipe -fPIC -funsigned-char -fno-strict-aliasing")
1256                 set(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} -static-intel")
1257         endif()
1258
1259 elseif(WIN32)
1260
1261         add_definitions(-DWIN32)
1262
1263         if(MSVC)
1264
1265                 # needed for some MSVC installations
1266                 set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /SAFESEH:NO")
1267                 set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /SAFESEH:NO")
1268                 set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} /SAFESEH:NO")
1269
1270                 list(APPEND PLATFORM_LINKLIBS ws2_32 vfw32 winmm kernel32 user32 gdi32 comdlg32 advapi32 shfolder shell32 ole32 oleaut32 uuid psapi Dbghelp)
1271
1272                 if(WITH_INPUT_IME)
1273                         list(APPEND PLATFORM_LINKLIBS imm32)
1274                 endif()
1275
1276                 add_definitions(
1277                         -D_CRT_NONSTDC_NO_DEPRECATE
1278                         -D_CRT_SECURE_NO_DEPRECATE
1279                         -D_SCL_SECURE_NO_DEPRECATE
1280                         -D_CONSOLE
1281                         -D_LIB
1282                 )
1283
1284                 # MSVC11 needs _ALLOW_KEYWORD_MACROS to build
1285                 add_definitions(-D_ALLOW_KEYWORD_MACROS)
1286
1287                 if(CMAKE_CL_64)
1288                         # We want to support Vista level ABI for x64
1289                         add_definitions(-D_WIN32_WINNT=0x600)
1290                 endif()
1291
1292                 # Make cmake find the msvc redistributables
1293                 set(CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS_SKIP TRUE)
1294                 include(InstallRequiredSystemLibraries)
1295
1296                 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /nologo /J /Gd /MP /EHsc")
1297                 set(CMAKE_C_FLAGS     "${CMAKE_C_FLAGS} /nologo /J /Gd /MP")
1298
1299                 set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MTd")
1300                 set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} /MTd")
1301                 set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /MT")
1302                 set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} /MT")
1303                 set(CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS_MINSIZEREL} /MT")
1304                 set(CMAKE_C_FLAGS_MINSIZEREL "${CMAKE_C_FLAGS_MINSIZEREL} /MT")
1305                 set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} /MT")
1306                 set(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO} /MT")
1307
1308                 set(PLATFORM_LINKFLAGS "/SUBSYSTEM:CONSOLE /STACK:2097152 /INCREMENTAL:NO /NODEFAULTLIB:msvcrt.lib /NODEFAULTLIB:msvcmrt.lib /NODEFAULTLIB:msvcurt.lib /NODEFAULTLIB:msvcrtd.lib")
1309
1310                 # MSVC only, Mingw doesnt need
1311                 if(CMAKE_CL_64)
1312                         set(PLATFORM_LINKFLAGS "/MACHINE:X64 /OPT:NOREF ${PLATFORM_LINKFLAGS}")
1313                 else()
1314                         set(PLATFORM_LINKFLAGS "/MACHINE:IX86 /LARGEADDRESSAWARE ${PLATFORM_LINKFLAGS}")
1315                 endif()
1316
1317                 set(PLATFORM_LINKFLAGS_DEBUG "/IGNORE:4099 /NODEFAULTLIB:libcmt.lib /NODEFAULTLIB:libc.lib")
1318
1319                 if(NOT DEFINED LIBDIR)
1320
1321                         # Setup 64bit and 64bit windows systems
1322                         if(CMAKE_CL_64)
1323                                 message(STATUS "64 bit compiler detected.")
1324                                 set(LIBDIR_BASE "win64")
1325                         else()
1326                                 message(STATUS "32 bit compiler detected.")
1327                                 set(LIBDIR_BASE "windows")
1328                         endif()
1329
1330                         if(MSVC_VERSION EQUAL 1900)
1331                                 message(STATUS "Visual Studio 2015 detected.")
1332                                 set(LIBDIR ${CMAKE_SOURCE_DIR}/../lib/${LIBDIR_BASE}_vc14)
1333                         else()
1334                                 message(STATUS "Visual Studio 2013 detected.")
1335                                 set(LIBDIR ${CMAKE_SOURCE_DIR}/../lib/${LIBDIR_BASE}_vc12)
1336                         endif()
1337                 else()
1338                         message(STATUS using LIBDIR  ${LIBDIR})
1339                 endif()
1340
1341                 # Add each of our libraries to our cmake_prefix_path so find_package() could work
1342                 file(GLOB children RELATIVE ${LIBDIR} ${LIBDIR}/*)
1343                 foreach(child ${children})
1344                 if(IS_DIRECTORY ${LIBDIR}/${child})
1345                         list(APPEND CMAKE_PREFIX_PATH  ${LIBDIR}/${child})
1346                 endif()
1347                 endforeach()
1348
1349                 set(ZLIB_INCLUDE_DIRS ${LIBDIR}/zlib/include)
1350                 set(ZLIB_LIBRARIES ${LIBDIR}/zlib/lib/libz_st.lib)
1351                 set(ZLIB_INCLUDE_DIR ${LIBDIR}/zlib/include)
1352                 set(ZLIB_LIBRARY ${LIBDIR}/zlib/lib/libz_st.lib)
1353                 set(ZLIB_DIR ${LIBDIR}/zlib)
1354                 #find_package(zlib) # we want to find before finding things that depend on it like png
1355
1356
1357                 find_package(png)
1358                 if(NOT PNG_FOUND)
1359                         message(WARNING "Using HARDCODED libpng locations")
1360                         set(PNG_PNG_INCLUDE_DIR ${LIBDIR}/png/include)
1361                         set(PNG_LIBRARIES libpng)
1362                         set(PNG "${LIBDIR}/png")
1363                         set(PNG_INCLUDE_DIRS "${PNG}/include")
1364                         set(PNG_LIBPATH ${PNG}/lib) # not cmake defined
1365                 endif()
1366
1367                 set(JPEG_NAMES ${JPEG_NAMES} libjpeg)
1368                 find_package(jpeg REQUIRED)
1369
1370                 set(PTHREADS_INCLUDE_DIRS ${LIBDIR}/pthreads/include)
1371                 set(PTHREADS_LIBRARIES ${LIBDIR}/pthreads/lib/pthreadVC2.lib)
1372
1373                 set(FREETYPE ${LIBDIR}/freetype)
1374                 set(FREETYPE_INCLUDE_DIRS
1375                         ${LIBDIR}/freetype/include
1376                         ${LIBDIR}/freetype/include/freetype2
1377                 )
1378                 set(FREETYPE_LIBRARY ${LIBDIR}/freetype/lib/freetype2ST.lib)
1379                 find_package(freetype REQUIRED)
1380
1381                 if(WITH_FFTW3)
1382                         set(FFTW3 ${LIBDIR}/fftw3)
1383                         set(FFTW3_LIBRARIES libfftw)
1384                         set(FFTW3_INCLUDE_DIRS ${FFTW3}/include)
1385                         set(FFTW3_LIBPATH ${FFTW3}/lib)
1386                 endif()
1387
1388                 if(WITH_OPENCOLLADA)
1389                         set(OPENCOLLADA ${LIBDIR}/opencollada)
1390
1391                         set(OPENCOLLADA_INCLUDE_DIRS
1392                                 ${OPENCOLLADA}/include/opencollada/COLLADAStreamWriter
1393                                 ${OPENCOLLADA}/include/opencollada/COLLADABaseUtils
1394                                 ${OPENCOLLADA}/include/opencollada/COLLADAFramework
1395                                 ${OPENCOLLADA}/include/opencollada/COLLADASaxFrameworkLoader
1396                                 ${OPENCOLLADA}/include/opencollada/GeneratedSaxParser
1397                         )
1398
1399                         set(OPENCOLLADA_LIBRARIES
1400                                 ${OPENCOLLADA}/lib/opencollada/OpenCOLLADASaxFrameworkLoader.lib
1401                                 ${OPENCOLLADA}/lib/opencollada/OpenCOLLADAFramework.lib
1402                                 ${OPENCOLLADA}/lib/opencollada/OpenCOLLADABaseUtils.lib
1403                                 ${OPENCOLLADA}/lib/opencollada/OpenCOLLADAStreamWriter.lib
1404                                 ${OPENCOLLADA}/lib/opencollada/MathMLSolver.lib
1405                                 ${OPENCOLLADA}/lib/opencollada/GeneratedSaxParser.lib
1406                                 ${OPENCOLLADA}/lib/opencollada/xml.lib
1407                                 ${OPENCOLLADA}/lib/opencollada/buffer.lib
1408                                 ${OPENCOLLADA}/lib/opencollada/ftoa.lib
1409                         )
1410
1411                         if(NOT WITH_LLVM)
1412                                 list(APPEND OPENCOLLADA_LIBRARIES ${OPENCOLLADA}/lib/opencollada/UTF.lib)
1413                         endif()
1414
1415                         set(PCRE_LIBRARIES
1416                                 ${OPENCOLLADA}/lib/opencollada/pcre.lib
1417                         )
1418                 endif()
1419
1420                 if(WITH_CODEC_FFMPEG)
1421                         set(FFMPEG_INCLUDE_DIRS
1422                                 ${LIBDIR}/ffmpeg/include
1423                                 ${LIBDIR}/ffmpeg/include/msvc
1424                         )
1425                         find_package(FFMPEG)
1426                         if(NOT FFMPEG_FOUND)
1427                                 message(WARNING "Using HARDCODED ffmpeg locations")
1428                                 set(FFMPEG_LIBRARY_VERSION 55)
1429                                 set(FFMPEG_LIBRARY_VERSION_AVU 52)
1430                                 set(FFMPEG_LIBRARIES
1431                                         ${LIBDIR}/ffmpeg/lib/avcodec-${FFMPEG_LIBRARY_VERSION}.lib
1432                                         ${LIBDIR}/ffmpeg/lib/avformat-${FFMPEG_LIBRARY_VERSION}.lib
1433                                         ${LIBDIR}/ffmpeg/lib/avdevice-${FFMPEG_LIBRARY_VERSION}.lib
1434                                         ${LIBDIR}/ffmpeg/lib/avutil-${FFMPEG_LIBRARY_VERSION_AVU}.lib
1435                                         ${LIBDIR}/ffmpeg/lib/swscale-2.lib
1436                                         )
1437                         endif()
1438                 endif()
1439
1440                 if(WITH_IMAGE_OPENEXR)
1441                         set(OPENEXR_ROOT_DIR ${LIBDIR}/openexr)
1442                         set(OPENEXR_VERSION "2.1")
1443                         find_package(OPENEXR REQUIRED)
1444                         if(NOT OPENEXR_FOUND)
1445                                 message(WARNING "Using HARDCODED OpenEXR locations")
1446                                 set(OPENEXR ${LIBDIR}/openexr)
1447                                 set(OPENEXR_INCLUDE_DIR ${OPENEXR}/include)
1448                                 set(OPENEXR_INCLUDE_DIRS ${OPENEXR}/include/OpenEXR)
1449                                 set(OPENEXR_LIBPATH ${OPENEXR}/lib)
1450                                 set(OPENEXR_LIBRARIES
1451                                         ${OPENEXR_LIBPATH}/Iex-2_2.lib
1452                                         ${OPENEXR_LIBPATH}/Half.lib
1453                                         ${OPENEXR_LIBPATH}/IlmImf-2_2.lib
1454                                         ${OPENEXR_LIBPATH}/Imath-2_2.lib
1455                                         ${OPENEXR_LIBPATH}/IlmThread-2_2.lib
1456                                 )
1457                         endif()
1458                 endif()
1459
1460                 if(WITH_IMAGE_TIFF)
1461                 # Try to find tiff first then complain and set static and maybe wrong paths
1462                 find_package(TIFF)
1463                 if(NOT TIFF_FOUND)
1464                         message(WARNING "Using HARDCODED libtiff locations")
1465                         set(TIFF_LIBRARY ${LIBDIR}/tiff/lib/libtiff.lib)
1466                         set(TIFF_INCLUDE_DIR ${LIBDIR}/tiff/include)
1467                 endif()
1468                 endif()
1469
1470                 if(WITH_JACK)
1471                         set(JACK_INCLUDE_DIRS
1472                                 ${LIBDIR}/jack/include/jack
1473                                 ${LIBDIR}/jack/include
1474                         )
1475                         set(JACK_LIBRARIES optimized ${LIBDIR}/jack/lib/libjack.lib debug ${LIBDIR}/jack/lib/libjack_d.lib)
1476                 endif()
1477
1478                 if(WITH_PYTHON)
1479                         set(PYTHON_VERSION 3.5) # CACHE STRING)
1480
1481                         string(REPLACE "." "" _PYTHON_VERSION_NO_DOTS ${PYTHON_VERSION})
1482                         # Use shared libs for vc2008 and vc2010 until we actually have vc2010 libs
1483                         set(PYTHON_LIBRARY ${LIBDIR}/python/lib/python${_PYTHON_VERSION_NO_DOTS}.lib)
1484                         unset(_PYTHON_VERSION_NO_DOTS)
1485
1486                         # Shared includes for both vc2008 and vc2010
1487                         set(PYTHON_INCLUDE_DIR ${LIBDIR}/python/include/python${PYTHON_VERSION})
1488
1489                         # uncached vars
1490                         set(PYTHON_INCLUDE_DIRS "${PYTHON_INCLUDE_DIR}")
1491                         set(PYTHON_LIBRARIES  "${PYTHON_LIBRARY}")
1492                 endif()
1493
1494                 if(WITH_BOOST)
1495                         if(WITH_CYCLES_OSL)
1496                                 set(boost_extra_libs wave)
1497                         endif()
1498                         if(WITH_INTERNATIONAL)
1499                                 list(APPEND boost_extra_libs locale)
1500                         endif()
1501                         set(Boost_USE_STATIC_RUNTIME ON) # prefix lib
1502                         set(Boost_USE_MULTITHREADED ON) # suffix -mt
1503                         set(Boost_USE_STATIC_LIBS ON) # suffix -s
1504                         find_package(Boost COMPONENTS date_time filesystem thread regex system ${boost_extra_libs})
1505                         if(NOT Boost_FOUND)
1506                                 message(WARNING "USING HARDCODED boost locations")
1507                                 set(BOOST ${LIBDIR}/boost)
1508                                 set(BOOST_INCLUDE_DIR ${BOOST}/include)
1509                                 if(MSVC12)
1510                                         set(BOOST_LIBPATH ${BOOST}/lib)
1511                                         set(BOOST_POSTFIX "vc120-mt-s-1_60.lib")
1512                                         set(BOOST_DEBUG_POSTFIX "vc120-mt-sgd-1_60.lib")
1513                                 else()
1514                                         set(BOOST_LIBPATH ${BOOST}/lib)
1515                                         set(BOOST_POSTFIX "vc140-mt-s-1_60.lib")
1516                                         set(BOOST_DEBUG_POSTFIX "vc140-mt-sgd-1_60.lib")
1517                                 endif()
1518                                 set(BOOST_LIBRARIES
1519                                         optimized libboost_date_time-${BOOST_POSTFIX} optimized libboost_filesystem-${BOOST_POSTFIX}
1520                                         optimized libboost_regex-${BOOST_POSTFIX}
1521                                         optimized libboost_system-${BOOST_POSTFIX} optimized libboost_thread-${BOOST_POSTFIX}
1522                                         debug libboost_date_time-${BOOST_DEBUG_POSTFIX} debug libboost_filesystem-${BOOST_DEBUG_POSTFIX}
1523                                         debug libboost_regex-${BOOST_DEBUG_POSTFIX}
1524                                         debug libboost_system-${BOOST_DEBUG_POSTFIX} debug libboost_thread-${BOOST_DEBUG_POSTFIX})
1525                                 if(WITH_CYCLES_OSL)
1526                                         set(BOOST_LIBRARIES ${BOOST_LIBRARIES}
1527                                                 optimized libboost_wave-${BOOST_POSTFIX}
1528                                                 debug libboost_wave-${BOOST_DEBUG_POSTFIX})
1529                                 endif()
1530                                 if(WITH_INTERNATIONAL)
1531                                         set(BOOST_LIBRARIES ${BOOST_LIBRARIES}
1532                                                 optimized libboost_locale-${BOOST_POSTFIX}
1533                                                 debug libboost_locale-${BOOST_DEBUG_POSTFIX})
1534                                 endif()
1535                         else() # we found boost using find_package
1536                                 set(BOOST_INCLUDE_DIR ${Boost_INCLUDE_DIRS})
1537                                 set(BOOST_LIBRARIES ${Boost_LIBRARIES})
1538                                 set(BOOST_LIBPATH ${Boost_LIBRARY_DIRS})
1539                         endif()
1540                         set(BOOST_DEFINITIONS "-DBOOST_ALL_NO_LIB")
1541                 endif()
1542                         
1543                 if(WITH_OPENIMAGEIO)
1544                         find_package(OpenImageIO)
1545                         set(OPENIMAGEIO ${LIBDIR}/openimageio)
1546                         set(OPENIMAGEIO_INCLUDE_DIRS ${OPENIMAGEIO}/include)
1547                         set(OIIO_OPTIMIZED optimized OpenImageIO optimized OpenImageIO_Util)
1548                         set(OIIO_DEBUG debug OpenImageIO_d debug OpenImageIO_Util_d)
1549                         set(OPENIMAGEIO_LIBRARIES ${OIIO_OPTIMIZED} ${OIIO_DEBUG})
1550                         set(OPENIMAGEIO_LIBPATH ${OPENIMAGEIO}/lib)
1551                         set(OPENIMAGEIO_DEFINITIONS "-DUSE_TBB=0")
1552                         set(OPENCOLORIO_DEFINITIONS "-DOCIO_STATIC_BUILD")
1553                         set(OPENIMAGEIO_IDIFF "${OPENIMAGEIO}/bin/idiff.exe")
1554                         add_definitions(-DOIIO_STATIC_BUILD)
1555                 endif()
1556
1557                 if(WITH_LLVM)
1558                         set(LLVM_ROOT_DIR ${LIBDIR}/llvm CACHE PATH     "Path to the LLVM installation")
1559                         file(GLOB LLVM_LIBRARY_OPTIMIZED ${LLVM_ROOT_DIR}/lib/*.lib)
1560
1561                         if(EXISTS ${LLVM_ROOT_DIR}/debug/lib)
1562                                 foreach(LLVM_OPTIMIZED_LIB ${LLVM_LIBRARY_OPTIMIZED})
1563                                         get_filename_component(LIBNAME ${LLVM_OPTIMIZED_LIB} ABSOLUTE)
1564                                         list(APPEND LLVM_LIBS optimized ${LIBNAME})
1565                                 endforeach(LLVM_OPTIMIZED_LIB)
1566                         
1567                                 file(GLOB LLVM_LIBRARY_DEBUG ${LLVM_ROOT_DIR}/debug/lib/*.lib)
1568
1569                                 foreach(LLVM_DEBUG_LIB ${LLVM_LIBRARY_DEBUG})
1570                                         get_filename_component(LIBNAME ${LLVM_DEBUG_LIB} ABSOLUTE)
1571                                         list(APPEND LLVM_LIBS debug ${LIBNAME})
1572                                 endforeach(LLVM_DEBUG_LIB)
1573
1574                                 set(LLVM_LIBRARY ${LLVM_LIBS})
1575                         else()
1576                                 message(WARNING "LLVM debug libs not present on this system. Using release libs for debug builds.")
1577                                 set(LLVM_LIBRARY ${LLVM_LIBRARY_OPTIMIZED})
1578                         endif()
1579                         
1580                 endif()
1581         
1582                 if(WITH_OPENCOLORIO)
1583                         set(OPENCOLORIO ${LIBDIR}/opencolorio)
1584                         set(OPENCOLORIO_INCLUDE_DIRS ${OPENCOLORIO}/include)
1585                         set(OPENCOLORIO_LIBRARIES OpenColorIO)
1586                         set(OPENCOLORIO_LIBPATH ${LIBDIR}/opencolorio/lib)
1587                         set(OPENCOLORIO_DEFINITIONS)
1588                 endif()
1589
1590                 if(WITH_OPENVDB)
1591                         set(OPENVDB ${LIBDIR}/openvdb)
1592                         set(OPENVDB_INCLUDE_DIRS ${OPENVDB}/include)
1593                         set(OPENVDB_LIBRARIES openvdb ${TBB_LIBRARIES})
1594                         set(OPENVDB_LIBPATH ${LIBDIR}/openvdb/lib)
1595                         set(OPENVDB_DEFINITIONS)
1596                 endif()
1597
1598                 if(WITH_MOD_CLOTH_ELTOPO)
1599                         set(LAPACK ${LIBDIR}/lapack)
1600                         # set(LAPACK_INCLUDE_DIR ${LAPACK}/include)
1601                         set(LAPACK_LIBPATH ${LAPACK}/lib)
1602                         set(LAPACK_LIBRARIES
1603                                 ${LIBDIR}/lapack/lib/libf2c.lib
1604                                 ${LIBDIR}/lapack/lib/clapack_nowrap.lib
1605                                 ${LIBDIR}/lapack/lib/BLAS_nowrap.lib
1606                         )
1607                 endif()
1608
1609                 if(WITH_OPENSUBDIV)
1610                         set(OPENSUBDIV_INCLUDE_DIR ${LIBDIR}/opensubdiv/include)
1611                         set(OPENSUBDIV_LIBPATH ${LIBDIR}/opensubdiv/lib)
1612                         set(OPENSUBDIV_LIBRARIES ${OPENSUBDIV_LIBPATH}/osdCPU.lib ${OPENSUBDIV_LIBPATH}/osdGPU.lib)
1613                         find_package(OpenSubdiv)
1614                 endif()
1615
1616                 if(WITH_SDL)
1617                         set(SDL ${LIBDIR}/sdl)
1618                         set(SDL_INCLUDE_DIR ${SDL}/include)
1619                         set(SDL_LIBPATH ${SDL}/lib)
1620                         # MinGW TODO: Update MinGW to SDL2
1621                         if(NOT CMAKE_COMPILER_IS_GNUCC)
1622                                 set(SDL_LIBRARY SDL2)
1623                         else()
1624                                 set(SDL_LIBRARY SDL)
1625                         endif()
1626                 endif()
1627
1628                 # Audio IO
1629                 if(WITH_SYSTEM_AUDASPACE)
1630                         set(AUDASPACE_INCLUDE_DIRS ${LIBDIR}/audaspace/include/audaspace)
1631                         set(AUDASPACE_LIBRARIES ${LIBDIR}/audaspace/lib/audaspace.lib)
1632                         set(AUDASPACE_C_INCLUDE_DIRS ${LIBDIR}/audaspace/include/audaspace)
1633                         set(AUDASPACE_C_LIBRARIES ${LIBDIR}/audaspace/lib/audaspace-c.lib)
1634                         set(AUDASPACE_PY_INCLUDE_DIRS ${LIBDIR}/audaspace/include/audaspace)
1635                         set(AUDASPACE_PY_LIBRARIES ${LIBDIR}/audaspace/lib/audaspace-py.lib)
1636                 endif()
1637
1638                 # used in many places so include globally, like OpenGL
1639                 blender_include_dirs_sys("${PTHREADS_INCLUDE_DIRS}")
1640
1641         elseif(CMAKE_COMPILER_IS_GNUCC)
1642                 # keep GCC specific stuff here
1643                 include(CheckCSourceCompiles)
1644                 # Setup 64bit and 64bit windows systems
1645                 CHECK_C_SOURCE_COMPILES("
1646                         #ifndef __MINGW64__
1647                         #error
1648                         #endif
1649                         int main(void) { return 0; }
1650                         " 
1651                         WITH_MINGW64)
1652                 
1653                 if(WITH_MINGW64)
1654                         message(STATUS "Compiling for 64 bit with MinGW-w64.")
1655                         set(LIBDIR ${CMAKE_SOURCE_DIR}/../lib/mingw64)
1656                 else()
1657                         message(STATUS "Compiling for 32 bit with MinGW-w32.")
1658                         set(LIBDIR ${CMAKE_SOURCE_DIR}/../lib/mingw32)
1659                         
1660                         if(WITH_RAYOPTIMIZATION)
1661                                 message(WARNING "MinGW-w32 is known to be unstable with 'WITH_RAYOPTIMIZATION' option enabled.")
1662                         endif()
1663                 endif()
1664                 
1665                 list(APPEND PLATFORM_LINKLIBS -lshell32 -lshfolder -lgdi32 -lmsvcrt -lwinmm -lmingw32 -lm -lws2_32 -lz -lstdc++ -lole32 -luuid -lwsock32 -lpsapi -ldbghelp)
1666
1667                 if(WITH_INPUT_IME)
1668                         list(APPEND PLATFORM_LINKLIBS -limm32)
1669                 endif()
1670
1671                 set(PLATFORM_CFLAGS "-pipe -funsigned-char -fno-strict-aliasing")
1672
1673                 if(WITH_MINGW64)
1674                         set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fpermissive")
1675                         list(APPEND PLATFORM_LINKLIBS -lpthread)
1676                         
1677                         add_definitions(-DFREE_WINDOWS64 -DMS_WIN64)
1678                 endif()
1679
1680                 add_definitions(-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE)
1681
1682                 add_definitions(-DFREE_WINDOWS)
1683
1684                 set(PNG "${LIBDIR}/png")
1685                 set(PNG_INCLUDE_DIRS "${PNG}/include")
1686                 set(PNG_LIBPATH ${PNG}/lib) # not cmake defined
1687
1688                 if(WITH_MINGW64)
1689                         set(JPEG_LIBRARIES jpeg)
1690                 else()
1691                         set(JPEG_LIBRARIES libjpeg)
1692                 endif()
1693                 set(PNG_LIBRARIES png)
1694
1695                 set(ZLIB ${LIBDIR}/zlib)
1696                 set(ZLIB_INCLUDE_DIRS ${ZLIB}/include)
1697                 set(ZLIB_LIBPATH ${ZLIB}/lib)
1698                 set(ZLIB_LIBRARIES z)
1699
1700                 set(JPEG "${LIBDIR}/jpeg")
1701                 set(JPEG_INCLUDE_DIR "${JPEG}/include")
1702                 set(JPEG_LIBPATH ${JPEG}/lib) # not cmake defined
1703                 
1704                 # comes with own pthread library
1705                 if(NOT WITH_MINGW64)
1706                         set(PTHREADS ${LIBDIR}/pthreads)
1707                         #set(PTHREADS_INCLUDE_DIRS ${PTHREADS}/include)
1708                         set(PTHREADS_LIBPATH ${PTHREADS}/lib)
1709                         set(PTHREADS_LIBRARIES pthreadGC2)
1710                 endif()
1711                 
1712                 set(FREETYPE ${LIBDIR}/freetype)
1713                 set(FREETYPE_INCLUDE_DIRS ${FREETYPE}/include ${FREETYPE}/include/freetype2)
1714                 set(FREETYPE_LIBPATH ${FREETYPE}/lib)
1715                 set(FREETYPE_LIBRARY freetype)
1716
1717                 if(WITH_FFTW3)
1718                         set(FFTW3 ${LIBDIR}/fftw3)
1719                         set(FFTW3_LIBRARIES fftw3)
1720                         set(FFTW3_INCLUDE_DIRS ${FFTW3}/include)
1721                         set(FFTW3_LIBPATH ${FFTW3}/lib)
1722                 endif()
1723
1724                 if(WITH_OPENCOLLADA)
1725                         set(OPENCOLLADA ${LIBDIR}/opencollada)
1726                         set(OPENCOLLADA_INCLUDE_DIRS
1727                                 ${OPENCOLLADA}/include/opencollada/COLLADAStreamWriter
1728                                 ${OPENCOLLADA}/include/opencollada/COLLADABaseUtils
1729                                 ${OPENCOLLADA}/include/opencollada/COLLADAFramework
1730                                 ${OPENCOLLADA}/include/opencollada/COLLADASaxFrameworkLoader
1731                                 ${OPENCOLLADA}/include/opencollada/GeneratedSaxParser
1732                         )
1733                         set(OPENCOLLADA_LIBPATH ${OPENCOLLADA}/lib/opencollada)
1734                         set(OPENCOLLADA_LIBRARIES OpenCOLLADAStreamWriter OpenCOLLADASaxFrameworkLoader OpenCOLLADAFramework OpenCOLLADABaseUtils GeneratedSaxParser UTF MathMLSolver buffer ftoa xml)
1735                         set(PCRE_LIBRARIES pcre)
1736                 endif()
1737
1738                 if(WITH_CODEC_FFMPEG)
1739                         set(FFMPEG ${LIBDIR}/ffmpeg)
1740                         set(FFMPEG_INCLUDE_DIRS ${FFMPEG}/include)
1741                         if(WITH_MINGW64)
1742                                 set(FFMPEG_LIBRARIES avcodec.dll avformat.dll avdevice.dll avutil.dll swscale.dll swresample.dll)
1743                         else()
1744                                 set(FFMPEG_LIBRARIES avcodec-55 avformat-55 avdevice-55 avutil-52 swscale-2)
1745                         endif()
1746                         set(FFMPEG_LIBPATH ${FFMPEG}/lib)
1747                 endif()
1748
1749                 if(WITH_IMAGE_OPENEXR)
1750                         set(OPENEXR ${LIBDIR}/openexr)
1751                         set(OPENEXR_INCLUDE_DIR ${OPENEXR}/include)
1752                         set(OPENEXR_INCLUDE_DIRS ${OPENEXR}/include/OpenEXR)
1753                         set(OPENEXR_LIBRARIES Half IlmImf Imath IlmThread Iex)
1754                         set(OPENEXR_LIBPATH ${OPENEXR}/lib)
1755                 endif()
1756
1757                 if(WITH_IMAGE_TIFF)
1758                         set(TIFF ${LIBDIR}/tiff)
1759                         set(TIFF_LIBRARY tiff)
1760                         set(TIFF_INCLUDE_DIR ${TIFF}/include)
1761                         set(TIFF_LIBPATH ${TIFF}/lib)
1762                 endif()
1763
1764                 if(WITH_JACK)
1765                         set(JACK ${LIBDIR}/jack)
1766                         set(JACK_INCLUDE_DIRS ${JACK}/include/jack ${JACK}/include)
1767                         set(JACK_LIBRARIES jack)
1768                         set(JACK_LIBPATH ${JACK}/lib)
1769
1770                         # TODO, gives linking errors, force off
1771                         set(WITH_JACK OFF)
1772                 endif()
1773
1774                 if(WITH_PYTHON)
1775                         # normally cached but not since we include them with blender
1776                         set(PYTHON_VERSION 3.5) #  CACHE STRING)
1777                         string(REPLACE "." "" _PYTHON_VERSION_NO_DOTS ${PYTHON_VERSION})
1778                         set(PYTHON_INCLUDE_DIR "${LIBDIR}/python/include/python${PYTHON_VERSION}")  # CACHE PATH)
1779                         set(PYTHON_LIBRARY "${LIBDIR}/python/lib/python${_PYTHON_VERSION_NO_DOTS}mw.lib")  # CACHE FILEPATH)
1780                         unset(_PYTHON_VERSION_NO_DOTS)
1781
1782                         # uncached vars
1783                         set(PYTHON_INCLUDE_DIRS "${PYTHON_INCLUDE_DIR}")
1784                         set(PYTHON_LIBRARIES  "${PYTHON_LIBRARY}")
1785                 endif()
1786
1787                 if(WITH_BOOST)
1788                         set(BOOST ${LIBDIR}/boost)
1789                         set(BOOST_INCLUDE_DIR ${BOOST}/include)
1790                         if(WITH_MINGW64)
1791                                 set(BOOST_POSTFIX "mgw47-mt-s-1_49")
1792                                 set(BOOST_DEBUG_POSTFIX "mgw47-mt-sd-1_49")
1793                         else()
1794                                 set(BOOST_POSTFIX "mgw46-mt-s-1_49")
1795                                 set(BOOST_DEBUG_POSTFIX "mgw46-mt-sd-1_49")
1796                         endif()
1797                         set(BOOST_LIBRARIES
1798                                 optimized boost_date_time-${BOOST_POSTFIX} boost_filesystem-${BOOST_POSTFIX}
1799                                 boost_regex-${BOOST_POSTFIX}
1800                                 boost_system-${BOOST_POSTFIX} boost_thread-${BOOST_POSTFIX}
1801                                 debug boost_date_time-${BOOST_DEBUG_POSTFIX} boost_filesystem-${BOOST_DEBUG_POSTFIX}
1802                                 boost_regex-${BOOST_DEBUG_POSTFIX}
1803                                 boost_system-${BOOST_DEBUG_POSTFIX} boost_thread-${BOOST_DEBUG_POSTFIX})
1804                         if(WITH_INTERNATIONAL)
1805                                 set(BOOST_LIBRARIES ${BOOST_LIBRARIES}
1806                                         optimized boost_locale-${BOOST_POSTFIX}
1807                                         debug boost_locale-${BOOST_DEBUG_POSTFIX}) 
1808                         endif()
1809                         if(WITH_CYCLES_OSL)
1810                                 set(BOOST_LIBRARIES ${BOOST_LIBRARIES}
1811                                         optimized boost_wave-${BOOST_POSTFIX}
1812                                         debug boost_wave-${BOOST_DEBUG_POSTFIX}) 
1813                         endif()
1814                         set(BOOST_LIBPATH ${BOOST}/lib)
1815                         set(BOOST_DEFINITIONS "-DBOOST_ALL_NO_LIB -DBOOST_THREAD_USE_LIB ")
1816                 endif()
1817                         
1818                 if(WITH_OPENIMAGEIO)
1819                         set(OPENIMAGEIO ${LIBDIR}/openimageio)
1820                         set(OPENIMAGEIO_INCLUDE_DIRS ${OPENIMAGEIO}/include)
1821                         set(OPENIMAGEIO_LIBRARIES OpenImageIO)
1822                         set(OPENIMAGEIO_LIBPATH ${OPENIMAGEIO}/lib)
1823                         set(OPENIMAGEIO_DEFINITIONS "")
1824                         set(OPENIMAGEIO_IDIFF "${OPENIMAGEIO}/bin/idiff.exe")
1825                 endif()
1826                 
1827                 if(WITH_LLVM)
1828                         set(LLVM_ROOT_DIR ${LIBDIR}/llvm CACHE PATH     "Path to the LLVM installation")
1829                         set(LLVM_LIBPATH ${LLVM_ROOT_DIR}/lib)
1830                         # Explicitly set llvm lib order.
1831                         #---- WARNING ON GCC ORDER OF LIBS IS IMPORTANT, DO NOT CHANGE! ---------
1832                         set(LLVM_LIBRARY LLVMSelectionDAG LLVMCodeGen LLVMScalarOpts LLVMAnalysis LLVMArchive
1833                                 LLVMAsmParser LLVMAsmPrinter
1834                                 LLVMBitReader LLVMBitWriter
1835                                 LLVMDebugInfo LLVMExecutionEngine
1836                                 LLVMInstCombine LLVMInstrumentation
1837                                 LLVMInterpreter LLVMJIT
1838                                 LLVMLinker LLVMMC
1839                                 LLVMMCDisassembler LLVMMCJIT
1840                                 LLVMMCParser LLVMObject
1841                                 LLVMRuntimeDyld 
1842                                 LLVMSupport
1843                                 LLVMTableGen LLVMTarget
1844                                 LLVMTransformUtils LLVMVectorize
1845                                 LLVMX86AsmParser LLVMX86AsmPrinter
1846                                 LLVMX86CodeGen LLVMX86Desc
1847                                 LLVMX86Disassembler LLVMX86Info
1848                                 LLVMX86Utils LLVMipa
1849                                 LLVMipo LLVMCore)
1850                         # imagehelp is needed by LLVM 3.1 on MinGW, check lib\Support\Windows\Signals.inc
1851                         list(APPEND PLATFORM_LINKLIBS -limagehlp)
1852                 endif()
1853                 
1854                 if(WITH_OPENCOLORIO)
1855                         set(OPENCOLORIO ${LIBDIR}/opencolorio)
1856                         set(OPENCOLORIO_INCLUDE_DIRS ${OPENCOLORIO}/include)
1857                         set(OPENCOLORIO_LIBRARIES OpenColorIO)
1858                         set(OPENCOLORIO_LIBPATH ${OPENCOLORIO}/lib)
1859                         set(OPENCOLORIO_DEFINITIONS)
1860                 endif()
1861
1862                 if(WITH_SDL)
1863                         set(SDL ${LIBDIR}/sdl)
1864                         set(SDL_INCLUDE_DIR ${SDL}/include)
1865                         set(SDL_LIBRARY SDL)
1866                         set(SDL_LIBPATH ${SDL}/lib)
1867                 endif()
1868
1869                 if(WITH_OPENVDB)
1870                         set(OPENVDB ${LIBDIR}/openvdb)
1871                         set(OPENVDB_INCLUDE_DIRS ${OPENVDB}/include)
1872                         set(OPENVDB_LIBRARIES openvdb ${TBB_LIBRARIES})
1873                         set(OPENVDB_LIBPATH ${LIBDIR}/openvdb/lib)
1874                         set(OPENVDB_DEFINITIONS)
1875                 endif()
1876
1877                 set(PLATFORM_LINKFLAGS "-Xlinker --stack=2097152")
1878
1879                 ## DISABLE - causes linking errors 
1880                 ## for re-distribution, so users dont need mingw installed
1881                 # set(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} -static-libgcc -static-libstdc++")
1882
1883         endif()
1884         
1885         # Things common to both mingw and MSVC  should go here
1886
1887         set(WINTAB_INC ${LIBDIR}/wintab/include)
1888
1889         if(WITH_OPENAL)
1890                 set(OPENAL ${LIBDIR}/openal)
1891                 set(OPENALDIR ${LIBDIR}/openal)
1892                 set(OPENAL_INCLUDE_DIR ${OPENAL}/include)
1893                 if(MSVC12)
1894                         set(OPENAL_LIBRARY openal32)
1895                 else()
1896                         set(OPENAL_LIBRARY wrap_oal)
1897                 endif()
1898                 set(OPENAL_LIBPATH ${OPENAL}/lib)
1899         endif()
1900
1901         if(WITH_CODEC_SNDFILE)
1902                 set(SNDFILE ${LIBDIR}/sndfile)
1903                 set(SNDFILE_INCLUDE_DIRS ${SNDFILE}/include)
1904                 set(SNDFILE_LIBRARIES libsndfile-1)
1905                 set(SNDFILE_LIBPATH ${SNDFILE}/lib) # TODO, deprecate
1906         endif()
1907
1908         if(WITH_RAYOPTIMIZATION AND SUPPORT_SSE_BUILD)
1909                 add_definitions(-D__SSE__ -D__MMX__)
1910         endif()
1911
1912         if(WITH_CYCLES_OSL)
1913                 set(CYCLES_OSL ${LIBDIR}/osl CACHE PATH "Path to OpenShadingLanguage installation")
1914         
1915                 find_library(OSL_LIB_EXEC NAMES oslexec PATHS ${CYCLES_OSL}/lib)
1916                 find_library(OSL_LIB_COMP NAMES oslcomp PATHS ${CYCLES_OSL}/lib)
1917                 find_library(OSL_LIB_QUERY NAMES oslquery PATHS ${CYCLES_OSL}/lib)
1918                 find_library(OSL_LIB_EXEC_DEBUG NAMES oslexec_d PATHS ${CYCLES_OSL}/lib)
1919                 find_library(OSL_LIB_COMP_DEBUG NAMES oslcomp_d PATHS ${CYCLES_OSL}/lib)
1920                 find_library(OSL_LIB_QUERY_DEBUG NAMES oslquery_d PATHS ${CYCLES_OSL}/lib)
1921                 list(APPEND OSL_LIBRARIES optimized ${OSL_LIB_COMP} optimized ${OSL_LIB_EXEC} optimized ${OSL_LIB_QUERY} debug ${OSL_LIB_EXEC_DEBUG} debug ${OSL_LIB_COMP_DEBUG} debug ${OSL_LIB_QUERY_DEBUG})
1922                 find_path(OSL_INCLUDE_DIR OSL/oslclosure.h PATHS ${CYCLES_OSL}/include)
1923                 find_program(OSL_COMPILER NAMES oslc PATHS ${CYCLES_OSL}/bin)
1924         
1925                 if(OSL_INCLUDE_DIR AND OSL_LIBRARIES AND OSL_COMPILER)
1926                         set(OSL_FOUND TRUE)
1927                 else()
1928                         message(STATUS "OSL not found")
1929                         set(WITH_CYCLES_OSL OFF)
1930                 endif()
1931         endif()
1932
1933 elseif(APPLE)
1934
1935         if(${CMAKE_OSX_DEPLOYMENT_TARGET} STREQUAL "10.5" OR ${CMAKE_OSX_DEPLOYMENT_TARGET} STRGREATER "10.5")
1936                 set(WITH_LIBS10.5 ON CACHE BOOL "Use 10.5 libs" FORCE) # valid also for 10.6/7/8/9
1937         endif()
1938
1939         if(WITH_LIBS10.5)
1940                 set(LIBDIR ${CMAKE_SOURCE_DIR}/../lib/darwin-9.x.universal)
1941         else()
1942                 if(CMAKE_OSX_ARCHITECTURES MATCHES i386)
1943                         set(LIBDIR ${CMAKE_SOURCE_DIR}/../lib/darwin-8.x.i386)
1944                 else()
1945                         set(LIBDIR ${CMAKE_SOURCE_DIR}/../lib/darwin-8.0.0-powerpc)
1946                 endif()
1947         endif()
1948
1949
1950         if(WITH_OPENAL)
1951                 find_package(OpenAL)
1952                 if(OPENAL_FOUND)
1953                         set(WITH_OPENAL ON)
1954                         set(OPENAL_INCLUDE_DIR "${LIBDIR}/openal/include")
1955                 else()
1956                         set(WITH_OPENAL OFF)
1957                 endif()
1958         endif()
1959
1960         if(WITH_OPENSUBDIV)
1961                 set(OPENSUBDIV ${LIBDIR}/opensubdiv)
1962                 set(OPENSUBDIV_LIBPATH ${OPENSUBDIV}/lib)
1963                 find_library(OSL_LIB_UTIL NAMES osdutil PATHS ${OPENSUBDIV_LIBPATH})
1964                 find_library(OSL_LIB_CPU NAMES osdCPU PATHS ${OPENSUBDIV_LIBPATH})
1965                 find_library(OSL_LIB_GPU NAMES osdGPU PATHS ${OPENSUBDIV_LIBPATH})
1966                 set(OPENSUBDIV_INCLUDE_DIR ${OPENSUBDIV}/include)
1967                 set(OPENSUBDIV_INCLUDE_DIRS ${OPENSUBDIV_INCLUDE_DIR})
1968                 list(APPEND OPENSUBDIV_LIBRARIES ${OSL_LIB_UTIL} ${OSL_LIB_CPU} ${OSL_LIB_GPU})
1969         endif()
1970
1971         if(WITH_JACK)
1972                 find_library(JACK_FRAMEWORK
1973                         NAMES jackmp
1974                 )
1975                 set(JACK_INCLUDE_DIRS ${JACK_FRAMEWORK}/headers)
1976                 if(NOT JACK_FRAMEWORK)
1977                         set(WITH_JACK OFF)
1978                 endif()
1979         endif()
1980
1981         if(WITH_CODEC_SNDFILE)
1982                 set(SNDFILE ${LIBDIR}/sndfile)
1983                 set(SNDFILE_INCLUDE_DIRS ${SNDFILE}/include)
1984                 set(SNDFILE_LIBRARIES sndfile FLAC ogg vorbis vorbisenc)
1985                 set(SNDFILE_LIBPATH ${SNDFILE}/lib ${FFMPEG}/lib)  # TODO, deprecate
1986         endif()
1987
1988         if(WITH_PYTHON)
1989                 # we use precompiled libraries for py 3.5 and up by default
1990                 set(PYTHON_VERSION 3.5)
1991                 if(NOT WITH_PYTHON_MODULE AND NOT WITH_PYTHON_FRAMEWORK)
1992                         # normally cached but not since we include them with blender
1993                         set(PYTHON_INCLUDE_DIR "${LIBDIR}/python/include/python${PYTHON_VERSION}m")
1994                         # set(PYTHON_EXECUTABLE "${LIBDIR}/python/bin/python${PYTHON_VERSION}") # not used yet
1995                         set(PYTHON_LIBRARY python${PYTHON_VERSION}m)
1996                         set(PYTHON_LIBPATH "${LIBDIR}/python/lib/python${PYTHON_VERSION}")
1997                         # set(PYTHON_LINKFLAGS "-u _PyMac_Error")  # won't  build with this enabled
1998                 else()
1999                         # module must be compiled against Python framework
2000                         set(PYTHON_INCLUDE_DIR "/Library/Frameworks/Python.framework/Versions/${PYTHON_VERSION}/include/python${PYTHON_VERSION}m")
2001                         set(PYTHON_EXECUTABLE "/Library/Frameworks/Python.framework/Versions/${PYTHON_VERSION}/bin/python${PYTHON_VERSION}")
2002                         #set(PYTHON_LIBRARY python${PYTHON_VERSION})
2003                         set(PYTHON_LIBPATH "/Library/Frameworks/Python.framework/Versions/${PYTHON_VERSION}/lib/python${PYTHON_VERSION}/config-${PYTHON_VERSION}m")
2004                         #set(PYTHON_LINKFLAGS "-u _PyMac_Error -framework Python")  # won't  build with this enabled
2005                 endif()
2006                 
2007                 # uncached vars
2008                 set(PYTHON_INCLUDE_DIRS "${PYTHON_INCLUDE_DIR}")
2009                 set(PYTHON_LIBRARIES  "${PYTHON_LIBRARY}")
2010         endif()
2011
2012         if(WITH_FFTW3)
2013                 set(FFTW3 ${LIBDIR}/fftw3)
2014                 set(FFTW3_INCLUDE_DIRS ${FFTW3}/include)
2015                 set(FFTW3_LIBRARIES fftw3)
2016                 set(FFTW3_LIBPATH ${FFTW3}/lib)
2017         endif()
2018
2019         set(PNG_LIBRARIES png)
2020         set(JPEG_LIBRARIES jpeg)
2021
2022         set(ZLIB /usr)
2023         set(ZLIB_INCLUDE_DIRS "${ZLIB}/include")
2024         set(ZLIB_LIBRARIES z bz2)
2025
2026         set(FREETYPE ${LIBDIR}/freetype)
2027         set(FREETYPE_INCLUDE_DIRS ${FREETYPE}/include ${FREETYPE}/include/freetype2)
2028         set(FREETYPE_LIBPATH ${FREETYPE}/lib)
2029         set(FREETYPE_LIBRARY freetype)
2030
2031         if(WITH_IMAGE_OPENEXR)
2032                 set(OPENEXR ${LIBDIR}/openexr)
2033                 set(OPENEXR_INCLUDE_DIR ${OPENEXR}/include)
2034                 set(OPENEXR_INCLUDE_DIRS ${OPENEXR}/include/OpenEXR)
2035                 set(OPENEXR_LIBRARIES Iex Half IlmImf Imath IlmThread)
2036                 set(OPENEXR_LIBPATH ${OPENEXR}/lib)
2037         endif()
2038
2039         if(WITH_CODEC_FFMPEG)
2040                 set(FFMPEG ${LIBDIR}/ffmpeg)
2041                 set(FFMPEG_INCLUDE_DIRS ${FFMPEG}/include)
2042                 set(FFMPEG_LIBRARIES avcodec avdevice avformat avutil mp3lame swscale x264 xvidcore theora theoradec theoraenc vorbis vorbisenc vorbisfile ogg)
2043                 set(FFMPEG_LIBPATH ${FFMPEG}/lib)
2044         endif()
2045
2046         find_library(SYSTEMSTUBS_LIBRARY
2047                 NAMES
2048                 SystemStubs
2049                 PATHS
2050         )
2051         mark_as_advanced(SYSTEMSTUBS_LIBRARY)
2052         if(SYSTEMSTUBS_LIBRARY)
2053                 list(APPEND PLATFORM_LINKLIBS stdc++ SystemStubs)
2054         else()
2055                 list(APPEND PLATFORM_LINKLIBS stdc++)
2056         endif()
2057
2058         set(PLATFORM_CFLAGS "-pipe -funsigned-char")
2059         set(PLATFORM_LINKFLAGS "-fexceptions -framework CoreServices -framework Foundation -framework IOKit -framework AppKit -framework Cocoa -framework Carbon -framework AudioUnit -framework AudioToolbox -framework CoreAudio")
2060         if(WITH_CODEC_QUICKTIME)
2061                 set(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} -framework QTKit")
2062                 if(CMAKE_OSX_ARCHITECTURES MATCHES i386)
2063                         set(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} -framework QuickTime")
2064                         # libSDL still needs 32bit carbon quicktime
2065                 endif()
2066         endif()
2067
2068         # XXX - SOME MAC DEV PLEASE TEST WITH THE SDK INSTALLED!
2069         # ALSO SHOULD BE MOVED INTO OWN MODULE WHEN FUNCTIONAL
2070         if(WITH_INPUT_NDOF)
2071                 # This thread it *should* work and check the framework - campbell
2072                 # http://www.cmake.org/pipermail/cmake/2005-December/007740.html
2073                 find_library(3DCONNEXION_CLIENT_FRAMEWORK
2074                         NAMES 3DconnexionClient
2075                 )
2076                 if(NOT 3DCONNEXION_CLIENT_FRAMEWORK)
2077                         set(WITH_INPUT_NDOF OFF)
2078                 endif()
2079
2080                 if(WITH_INPUT_NDOF)
2081                         set(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} -F/Library/Frameworks -weak_framework 3DconnexionClient")
2082                         set(NDOF_INCLUDE_DIRS /Library/Frameworks/3DconnexionClient.framework/Headers )
2083                 endif()
2084         endif()
2085
2086         if(WITH_JACK)
2087                 set(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} -F/Library/Frameworks -weak_framework jackmp")
2088         endif()
2089         
2090         if(WITH_PYTHON_MODULE OR WITH_PYTHON_FRAMEWORK)
2091                 set(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} /Library/Frameworks/Python.framework/Versions/${PYTHON_VERSION}/Python")# force cmake to link right framework
2092         endif()
2093         
2094         if(WITH_OPENCOLLADA)
2095                 set(OPENCOLLADA ${LIBDIR}/opencollada)
2096
2097                 set(OPENCOLLADA_INCLUDE_DIRS
2098                         ${LIBDIR}/opencollada/include/COLLADAStreamWriter
2099                         ${LIBDIR}/opencollada/include/COLLADABaseUtils
2100                         ${LIBDIR}/opencollada/include/COLLADAFramework
2101                         ${LIBDIR}/opencollada/include/COLLADASaxFrameworkLoader
2102                         ${LIBDIR}/opencollada/include/GeneratedSaxParser
2103                 )
2104
2105                 set(OPENCOLLADA_LIBPATH ${OPENCOLLADA}/lib)
2106                 set(OPENCOLLADA_LIBRARIES "OpenCOLLADASaxFrameworkLoader -lOpenCOLLADAFramework -lOpenCOLLADABaseUtils -lOpenCOLLADAStreamWriter -lMathMLSolver -lGeneratedSaxParser -lxml2 -lbuffer -lftoa")
2107                 # Use UTF functions from collada if LLVM is not enabled
2108                 if(NOT WITH_LLVM)
2109                         set(OPENCOLLADA_LIBRARIES "${OPENCOLLADA_LIBRARIES} -lUTF")
2110                 endif()
2111                 # pcre is bundled with openCollada
2112                 #set(PCRE ${LIBDIR}/pcre)
2113                 #set(PCRE_LIBPATH ${PCRE}/lib)
2114                 set(PCRE_LIBRARIES pcre)
2115                 #libxml2 is used
2116                 #set(EXPAT ${LIBDIR}/expat)
2117                 #set(EXPAT_LIBPATH ${EXPAT}/lib)
2118                 set(EXPAT_LIB)
2119         endif()
2120
2121         if(WITH_SDL)
2122                 set(SDL ${LIBDIR}/sdl)
2123                 set(SDL_INCLUDE_DIR ${SDL}/include)
2124                 set(SDL_LIBRARY SDL2)
2125                 set(SDL_LIBPATH ${SDL}/lib)
2126                 set(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} -lazy_framework ForceFeedback")
2127         endif()
2128
2129         set(PNG "${LIBDIR}/png")
2130         set(PNG_INCLUDE_DIRS "${PNG}/include")
2131         set(PNG_LIBPATH ${PNG}/lib)
2132
2133         set(JPEG "${LIBDIR}/jpeg")
2134         set(JPEG_INCLUDE_DIR "${JPEG}/include")
2135         set(JPEG_LIBPATH ${JPEG}/lib)
2136
2137         if(WITH_IMAGE_TIFF)
2138                 set(TIFF ${LIBDIR}/tiff)
2139                 set(TIFF_INCLUDE_DIR ${TIFF}/include)
2140                 set(TIFF_LIBRARY tiff)
2141                 set(TIFF_LIBPATH ${TIFF}/lib)
2142         endif()
2143
2144         if(WITH_INPUT_NDOF)
2145                 # linker needs "-weak_framework 3DconnexionClient"
2146         endif()
2147
2148         if(WITH_BOOST)
2149                 set(BOOST ${LIBDIR}/boost)
2150                 set(BOOST_INCLUDE_DIR ${BOOST}/include)
2151                 set(BOOST_LIBRARIES boost_date_time-mt boost_filesystem-mt boost_regex-mt boost_system-mt boost_thread-mt boost_wave-mt)
2152                 if(WITH_INTERNATIONAL)
2153                         list(APPEND BOOST_LIBRARIES boost_locale-mt)
2154                 endif()
2155                 if(WITH_CYCLES_NETWORK)
2156                         list(APPEND BOOST_LIBRARIES boost_serialization-mt)
2157                 endif()
2158                 set(BOOST_LIBPATH ${BOOST}/lib)
2159                 set(BOOST_DEFINITIONS)
2160         endif()
2161         
2162         if(WITH_INTERNATIONAL OR WITH_CODEC_FFMPEG)
2163                 set(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} -liconv") # boost_locale and ffmpeg needs it !
2164         endif()
2165
2166         if(WITH_OPENIMAGEIO)
2167                 set(OPENIMAGEIO ${LIBDIR}/openimageio)
2168                 set(OPENIMAGEIO_INCLUDE_DIRS ${OPENIMAGEIO}/include)
2169                 set(OPENIMAGEIO_LIBRARIES ${OPENIMAGEIO}/lib/libOpenImageIO.a ${PNG_LIBRARIES} ${JPEG_LIBRARIES} ${TIFF_LIBRARY} ${OPENEXR_LIBRARIES} ${ZLIB_LIBRARIES})
2170                 set(OPENIMAGEIO_LIBPATH ${OPENIMAGEIO}/lib ${JPEG_LIBPATH} ${PNG_LIBPATH} ${TIFF_LIBPATH} ${OPENEXR_LIBPATH} ${ZLIB_LIBPATH})
2171                 set(OPENIMAGEIO_DEFINITIONS "-DOIIO_STATIC_BUILD")
2172                 set(OPENIMAGEIO_IDIFF "${LIBDIR}/openimageio/bin/idiff")
2173         endif()
2174
2175         if(WITH_OPENCOLORIO)
2176                 set(OPENCOLORIO ${LIBDIR}/opencolorio)
2177                 set(OPENCOLORIO_INCLUDE_DIRS ${OPENCOLORIO}/include)
2178                 set(OPENCOLORIO_LIBRARIES OpenColorIO tinyxml yaml-cpp)
2179                 set(OPENCOLORIO_LIBPATH ${OPENCOLORIO}/lib)
2180         endif()
2181
2182         if(WITH_OPENVDB)
2183                 set(OPENVDB ${LIBDIR}/openvdb)
2184                 set(OPENVDB_INCLUDE_DIRS ${OPENVDB}/include)
2185                 set(OPENVDB_LIBRARIES openvdb ${TBB_LIBRARIES})
2186                 set(OPENVDB_LIBPATH ${LIBDIR}/openvdb/lib)
2187                 set(OPENVDB_DEFINITIONS)
2188         endif()
2189
2190         if(WITH_LLVM)
2191                 set(LLVM_ROOT_DIR ${LIBDIR}/llvm CACHE PATH     "Path to the LLVM installation")
2192                 set(LLVM_VERSION "3.4" CACHE STRING     "Version of LLVM to use")
2193                 if(EXISTS "${LLVM_ROOT_DIR}/bin/llvm-config")
2194                         set(LLVM_CONFIG "${LLVM_ROOT_DIR}/bin/llvm-config")
2195                 else()
2196                         set(LLVM_CONFIG llvm-config)
2197                 endif()
2198                 execute_process(COMMAND ${LLVM_CONFIG} --version
2199                                 OUTPUT_VARIABLE LLVM_VERSION
2200                                 OUTPUT_STRIP_TRAILING_WHITESPACE)
2201                 execute_process(COMMAND ${LLVM_CONFIG} --prefix
2202                                 OUTPUT_VARIABLE LLVM_ROOT_DIR
2203                                 OUTPUT_STRIP_TRAILING_WHITESPACE)
2204                 execute_process(COMMAND ${LLVM_CONFIG} --libdir
2205                                 OUTPUT_VARIABLE LLVM_LIBPATH
2206                                 OUTPUT_STRIP_TRAILING_WHITESPACE)
2207                 find_library(LLVM_LIBRARY
2208                              NAMES LLVMAnalysis # first of a whole bunch of libs to get
2209                              PATHS ${LLVM_LIBPATH})
2210
2211                 if(LLVM_LIBRARY AND LLVM_ROOT_DIR AND LLVM_LIBPATH)
2212                         if(LLVM_STATIC)
2213                                 # if static LLVM libraries were requested, use llvm-config to generate
2214                                 # the list of what libraries we need, and substitute that in the right
2215                                 # way for LLVM_LIBRARY.
2216                                 execute_process(COMMAND ${LLVM_CONFIG} --libfiles
2217                                                 OUTPUT_VARIABLE LLVM_LIBRARY
2218                                                 OUTPUT_STRIP_TRAILING_WHITESPACE)
2219                                 string(REPLACE " " ";" LLVM_LIBRARY ${LLVM_LIBRARY})
2220                         else()
2221                                 set(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} -lLLVM-3.4")
2222                         endif()
2223                 else()
2224                         message(FATAL_ERROR "LLVM not found.")
2225                 endif()
2226         endif()
2227
2228         if(WITH_CYCLES_OSL)
2229                 set(CYCLES_OSL ${LIBDIR}/osl CACHE PATH "Path to OpenShadingLanguage installation")
2230         
2231                 find_library(OSL_LIB_EXEC NAMES oslexec PATHS ${CYCLES_OSL}/lib)
2232                 find_library(OSL_LIB_COMP NAMES oslcomp PATHS ${CYCLES_OSL}/lib)
2233                 find_library(OSL_LIB_QUERY NAMES oslquery PATHS ${CYCLES_OSL}/lib)
2234                 # WARNING! depends on correct order of OSL libs linking
2235                 list(APPEND OSL_LIBRARIES ${OSL_LIB_COMP} -force_load ${OSL_LIB_EXEC} ${OSL_LIB_QUERY})
2236                 find_path(OSL_INCLUDE_DIR OSL/oslclosure.h PATHS ${CYCLES_OSL}/include)
2237                 find_program(OSL_COMPILER NAMES oslc PATHS ${CYCLES_OSL}/bin)
2238         
2239                 if(OSL_INCLUDE_DIR AND OSL_LIBRARIES AND OSL_COMPILER)
2240                         set(OSL_FOUND TRUE)
2241                 else()
2242                         message(STATUS "OSL not found")
2243                         set(WITH_CYCLES_OSL OFF)
2244                 endif()
2245         endif()
2246         
2247         if(WITH_OPENMP)
2248                 execute_process(COMMAND ${CMAKE_C_COMPILER} --version OUTPUT_VARIABLE COMPILER_VENDOR)
2249                 string(SUBSTRING "${COMPILER_VENDOR}" 0 5 VENDOR_NAME) # truncate output
2250                 if(${VENDOR_NAME} MATCHES "Apple") # Apple does not support OpenMP reliable with gcc and not with clang
2251                         set(WITH_OPENMP OFF)
2252                 else() # vanilla gcc or clang_omp support OpenMP
2253                         message(STATUS "Using special OpenMP enabled compiler !") # letting find_package(OpenMP) module work for gcc
2254                         if(CMAKE_C_COMPILER_ID MATCHES "Clang") # clang-omp in darwin libs
2255                                 set(OPENMP_FOUND ON)
2256                                 set(OpenMP_C_FLAGS "-fopenmp" CACHE STRING "C compiler flags for OpenMP parallization" FORCE)
2257                                 set(OpenMP_CXX_FLAGS "-fopenmp" CACHE STRING "C++ compiler flags for OpenMP parallization" FORCE)
2258                                 include_directories(${LIBDIR}/openmp/include)
2259                                 link_directories(${LIBDIR}/openmp/lib)
2260                                 # This is a workaround for our helperbinaries ( datatoc, masgfmt, ... ),
2261                                 # They are linked also to omp lib, so we need it in builddir for runtime exexcution, TODO: remove all unneeded dependencies from these
2262                                 execute_process(COMMAND ditto -arch ${CMAKE_OSX_ARCHITECTURES} ${LIBDIR}/openmp/lib/libiomp5.dylib ${CMAKE_BINARY_DIR}/Resources/lib/libiomp5.dylib) # for intermediate binaries, in respect to lib ID
2263                         endif()
2264                 endif()
2265         endif()
2266
2267         set(EXETYPE MACOSX_BUNDLE)
2268
2269         set(CMAKE_C_FLAGS_DEBUG "-fno-strict-aliasing -g")
2270         set(CMAKE_CXX_FLAGS_DEBUG "-fno-strict-aliasing -g")
2271         if(CMAKE_OSX_ARCHITECTURES MATCHES "x86_64" OR CMAKE_OSX_ARCHITECTURES MATCHES "i386")
2272                 set(CMAKE_CXX_FLAGS_RELEASE "-O2 -mdynamic-no-pic -msse -msse2 -msse3 -mssse3")
2273                 set(CMAKE_C_FLAGS_RELEASE "-O2 -mdynamic-no-pic  -msse -msse2 -msse3 -mssse3")
2274                 if(NOT CMAKE_C_COMPILER_ID MATCHES "Clang")
2275                         set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -ftree-vectorize  -fvariable-expansion-in-unroller")
2276                         set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -ftree-vectorize  -fvariable-expansion-in-unroller")
2277                 endif()
2278         else()
2279                 set(CMAKE_C_FLAGS_RELEASE "-mdynamic-no-pic -fno-strict-aliasing")
2280                 set(CMAKE_CXX_FLAGS_RELEASE "-mdynamic-no-pic -fno-strict-aliasing")
2281         endif()
2282
2283         if(${XCODE_VERSION} VERSION_EQUAL 5 OR ${XCODE_VERSION} VERSION_GREATER 5)
2284                 # Xcode 5 is always using CLANG, which has too low template depth of 128 for libmv
2285                 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -ftemplate-depth=1024")
2286         endif()
2287         # Get rid of eventually clashes, we export some symbols explicite as local
2288         set(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} -Xlinker -unexported_symbols_list -Xlinker ${CMAKE_SOURCE_DIR}/source/creator/osx_locals.map")
2289 endif()
2290
2291 #-----------------------------------------------------------------------------
2292 # Common.
2293
2294 if(APPLE OR WIN32)
2295         if(NOT EXISTS "${LIBDIR}/")
2296                 message(FATAL_ERROR "Apple and Windows require pre-compiled libs at: '${LIBDIR}'")
2297         endif()
2298 endif()
2299
2300 if(NOT WITH_FFTW3 AND WITH_MOD_OCEANSIM)
2301         message(FATAL_ERROR "WITH_MOD_OCEANSIM requires WITH_FFTW3 to be ON")
2302 endif()
2303
2304 if(WITH_CYCLES)
2305         if(NOT WITH_OPENIMAGEIO)
2306                 message(FATAL_ERROR "Cycles requires WITH_OPENIMAGEIO, the library may not have been found. Configure OIIO or disable WITH_CYCLES")
2307         endif()
2308         if(NOT WITH_BOOST)
2309                 message(FATAL_ERROR "Cycles requires WITH_BOOST, the library may not have been found. Configure BOOST or disable WITH_CYCLES")
2310         endif()
2311
2312         if(WITH_CYCLES_OSL)
2313                 if(NOT WITH_LLVM)
2314                         message(FATAL_ERROR "Cycles OSL requires WITH_LLVM, the library may not have been found. Configure LLVM or disable WITH_CYCLES_OSL")
2315                 endif()
2316         endif()
2317 endif()
2318
2319 if(WITH_INTERNATIONAL)
2320         if(NOT WITH_BOOST)
2321                 message(FATAL_ERROR "Internationalization requires WITH_BOOST, the library may not have been found. Configure BOOST or disable WITH_INTERNATIONAL")
2322         endif()
2323 endif()
2324
2325 # See TEST_SSE_SUPPORT() for how this is defined.
2326
2327 if(WITH_RAYOPTIMIZATION)
2328         if(SUPPORT_SSE_BUILD)
2329                 set(PLATFORM_CFLAGS " ${COMPILER_SSE_FLAG} ${PLATFORM_CFLAGS}")
2330                 add_definitions(-D__SSE__ -D__MMX__)
2331         endif()
2332         if(SUPPORT_SSE2_BUILD)
2333                 set(PLATFORM_CFLAGS " ${COMPILER_SSE2_FLAG} ${PLATFORM_CFLAGS}")
2334                 add_definitions(-D__SSE2__)
2335                 if(NOT SUPPORT_SSE_BUILD) # dont double up
2336                         add_definitions(-D__MMX__)
2337                 endif()
2338         endif()
2339 endif()
2340
2341
2342 # set the endian define
2343 if(MSVC)
2344         # for some reason this fails on msvc
2345         add_definitions(-D__LITTLE_ENDIAN__)
2346         
2347 # OSX-Note: as we do crosscompiling with specific set architecture,
2348 # endianess-detection and autosetting is counterproductive
2349 # so we just set endianess according CMAKE_OSX_ARCHITECTURES
2350
2351 elseif(CMAKE_OSX_ARCHITECTURES MATCHES i386 OR CMAKE_OSX_ARCHITECTURES MATCHES x86_64)
2352         add_definitions(-D__LITTLE_ENDIAN__)
2353 elseif(CMAKE_OSX_ARCHITECTURES MATCHES ppc OR CMAKE_OSX_ARCHITECTURES MATCHES ppc64)            
2354         add_definitions(-D__BIG_ENDIAN__)
2355         
2356 else()
2357         include(TestBigEndian)
2358         test_big_endian(_SYSTEM_BIG_ENDIAN)
2359         if(_SYSTEM_BIG_ENDIAN)
2360                 add_definitions(-D__BIG_ENDIAN__)
2361         else()
2362                 add_definitions(-D__LITTLE_ENDIAN__)
2363         endif()
2364         unset(_SYSTEM_BIG_ENDIAN)
2365 endif()
2366
2367
2368 if(WITH_IMAGE_OPENJPEG)
2369         if(WITH_SYSTEM_OPENJPEG)
2370                 # dealt with above
2371                 set(OPENJPEG_DEFINES "")
2372         else()
2373                 set(OPENJPEG_INCLUDE_DIRS "${CMAKE_SOURCE_DIR}/extern/libopenjpeg")
2374                 set(OPENJPEG_DEFINES "-DOPJ_STATIC")
2375         endif()
2376         # Special handling of Windows platform where openjpeg is always static.
2377         if(WIN32)
2378                 set(OPENJPEG_DEFINES "-DOPJ_STATIC")
2379         endif()
2380 endif()
2381
2382 if(WITH_IMAGE_REDCODE)
2383         set(REDCODE ${CMAKE_SOURCE_DIR}/extern)
2384         set(REDCODE_INC ${REDCODE})
2385 endif()
2386
2387 if(NOT WITH_SYSTEM_EIGEN3)
2388         set(EIGEN3_INCLUDE_DIRS ${CMAKE_SOURCE_DIR}/extern/Eigen3)
2389 endif()
2390
2391 #-----------------------------------------------------------------------------
2392 # Configure OpenGL.
2393
2394 find_package(OpenGL)
2395 blender_include_dirs_sys("${OPENGL_INCLUDE_DIR}")
2396
2397 if(WITH_GLU)
2398         list(APPEND BLENDER_GL_LIBRARIES "${OPENGL_glu_LIBRARY}")
2399         list(APPEND GL_DEFINITIONS -DWITH_GLU)
2400 endif()
2401
2402 if(WITH_SYSTEM_GLES)
2403         find_package_wrapper(OpenGLES)
2404 endif()
2405
2406 if(WITH_GL_PROFILE_COMPAT OR WITH_GL_PROFILE_CORE)
2407         list(APPEND BLENDER_GL_LIBRARIES "${OPENGL_gl_LIBRARY}")
2408
2409 elseif(WITH_GL_PROFILE_ES20)
2410         if(WITH_SYSTEM_GLES)
2411                 if(NOT OPENGLES_LIBRARY)
2412                         message(FATAL_ERROR "Unable to find OpenGL ES libraries.  Install them or disable WITH_SYSTEM_GLES.")
2413                 endif()
2414
2415                 list(APPEND BLENDER_GL_LIBRARIES OPENGLES_LIBRARY)
2416
2417         else()
2418                 set(OPENGLES_LIBRARY "" CACHE FILEPATH "OpenGL ES 2.0 library file")
2419                 mark_as_advanced(OPENGLES_LIBRARY)
2420
2421                 list(APPEND BLENDER_GL_LIBRARIES "${OPENGLES_LIBRARY}")
2422
2423                 if(NOT OPENGLES_LIBRARY)
2424                         message(FATAL_ERROR "To compile WITH_GL_EGL you need to set OPENGLES_LIBRARY to the file path of an OpenGL ES 2.0 library.")
2425                 endif()
2426
2427         endif()
2428
2429         if(WIN32)
2430                 # Setup paths to files needed to install and redistribute Windows Blender with OpenGL ES
2431
2432                 set(OPENGLES_DLL "" CACHE FILEPATH "OpenGL ES 2.0 redistributable DLL file")
2433                 mark_as_advanced(OPENGLES_DLL)
2434
2435                 if(NOT OPENGLES_DLL)
2436                         message(FATAL_ERROR "To compile WITH_GL_PROFILE_ES20 you need to set OPENGLES_DLL to the file path of an OpenGL ES 2.0 runtime dynamic link library (DLL).")
2437                 endif()
2438
2439                 if(WITH_GL_ANGLE)
2440                         list(APPEND GL_DEFINITIONS -DWITH_ANGLE)
2441
2442                         set(D3DCOMPILER_DLL "" CACHE FILEPATH "Direct3D Compiler redistributable DLL file (needed by ANGLE)")
2443
2444                         get_filename_component(D3DCOMPILER_FILENAME "${D3DCOMPILER_DLL}" NAME)
2445                         list(APPEND GL_DEFINITIONS "-DD3DCOMPILER=\"\\\"${D3DCOMPILER_FILENAME}\\\"\"")
2446
2447                         mark_as_advanced(D3DCOMPILER_DLL)
2448
2449                         if(D3DCOMPILER_DLL STREQUAL "")
2450                                 message(FATAL_ERROR "To compile WITH_GL_ANGLE you need to set D3DCOMPILER_DLL to the file path of a copy of the DirectX redistributable DLL file: D3DCompiler_46.dll")
2451                         endif()
2452
2453                 endif()
2454
2455         endif()
2456
2457 endif()
2458
2459 if(WITH_GL_EGL)
2460         list(APPEND GL_DEFINITIONS -DWITH_GL_EGL)
2461
2462         if(WITH_SYSTEM_GLES)
2463                 if(NOT OPENGLES_EGL_LIBRARY)
2464                         message(FATAL_ERROR "Unable to find OpenGL ES libraries.  Install them or disable WITH_SYSTEM_GLES.")
2465                 endif()
2466
2467                 list(APPEND BLENDER_GL_LIBRARIES OPENGLES_EGL_LIBRARY)
2468
2469         else()
2470                 set(OPENGLES_EGL_LIBRARY "" CACHE FILEPATH "EGL library file")
2471                 mark_as_advanced(OPENGLES_EGL_LIBRARY)
2472
2473                 list(APPEND BLENDER_GL_LIBRARIES "${OPENGLES_LIBRARY}" "${OPENGLES_EGL_LIBRARY}")
2474
2475                 if(NOT OPENGLES_EGL_LIBRARY)
2476                         message(FATAL_ERROR "To compile WITH_GL_EGL you need to set OPENGLES_EGL_LIBRARY to the file path of an EGL library.")
2477                 endif()
2478
2479         endif()
2480
2481         if(WIN32)
2482                 # Setup paths to files needed to install and redistribute Windows Blender with OpenGL ES
2483
2484                 set(OPENGLES_EGL_DLL "" CACHE FILEPATH "EGL redistributable DLL file")
2485                 mark_as_advanced(OPENGLES_EGL_DLL)
2486
2487                 if(NOT OPENGLES_EGL_DLL)
2488                         message(FATAL_ERROR "To compile WITH_GL_EGL you need to set OPENGLES_EGL_DLL to the file path of an EGL runtime dynamic link library (DLL).")
2489                 endif()
2490
2491         endif()
2492
2493 endif()
2494
2495 if(WITH_GL_PROFILE_COMPAT)
2496         list(APPEND GL_DEFINITIONS -DWITH_GL_PROFILE_COMPAT)
2497 endif()
2498
2499 if(WITH_GL_PROFILE_CORE)
2500         list(APPEND GL_DEFINITIONS -DWITH_GL_PROFILE_CORE)
2501 endif()
2502
2503 if(WITH_GL_PROFILE_ES20)
2504         list(APPEND GL_DEFINITIONS -DWITH_GL_PROFILE_ES20)
2505 endif()
2506
2507 if(WITH_GL_EGL)
2508         list(APPEND GL_DEFINITIONS -DWITH_EGL)
2509 endif()
2510
2511 #-----------------------------------------------------------------------------
2512 # Configure OpenMP.
2513 if(WITH_OPENMP)
2514         find_package(OpenMP)
2515         if(OPENMP_FOUND)
2516                 if(NOT WITH_OPENMP_STATIC)
2517                         set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
2518                         set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
2519                 else()
2520                         # Typically avoid adding flags as defines but we can't
2521                         # pass OpenMP flags to the linker for static builds, meaning
2522                         # we can't add any OpenMP related flags to CFLAGS variables
2523                         # since they're passed to the linker as well.
2524                         add_definitions("${OpenMP_C_FLAGS}")
2525
2526                         find_library_static(OpenMP_LIBRARIES gomp ${CMAKE_CXX_IMPLICIT_LINK_DIRECTORIES})
2527                 endif()
2528         else()
2529                 set(WITH_OPENMP OFF)
2530         endif()
2531
2532         mark_as_advanced(
2533                 OpenMP_C_FLAGS
2534                 OpenMP_CXX_FLAGS
2535         )
2536 endif()
2537
2538 #-----------------------------------------------------------------------------
2539 # Configure GLEW
2540
2541 if(WITH_GLEW_MX)
2542         list(APPEND GL_DEFINITIONS -DWITH_GLEW_MX)
2543 endif()
2544
2545 if(WITH_SYSTEM_GLEW)
2546         find_package(GLEW)
2547
2548         # Note: There is an assumption here that the system GLEW is not a static library.
2549
2550         if(NOT GLEW_FOUND)
2551                 message(FATAL_ERROR "GLEW is required to build Blender. Install it or disable WITH_SYSTEM_GLEW.")
2552         endif()
2553
2554         if(WITH_GLEW_MX)
2555                 set(BLENDER_GLEW_LIBRARIES ${GLEW_MX_LIBRARY})
2556         else()
2557                 set(BLENDER_GLEW_LIBRARIES ${GLEW_LIBRARY})
2558         endif()
2559 else()
2560         if(WITH_GLEW_ES)
2561                 set(GLEW_INCLUDE_PATH "${CMAKE_SOURCE_DIR}/extern/glew-es/include")
2562
2563                 list(APPEND GL_DEFINITIONS -DGLEW_STATIC -DWITH_GLEW_ES)
2564
2565                 # These definitions remove APIs from glew.h, making GLEW smaller, and catching unguarded API usage
2566                 if(NOT WITH_GL_PROFILE_ES20)
2567                         # No ES functions are needed
2568                         list(APPEND GL_DEFINITIONS -DGLEW_NO_ES)
2569                 elseif(NOT (WITH_GL_PROFILE_CORE OR WITH_GL_PROFILE_COMPAT))
2570                         # ES is enabled, but the other functions are all disabled
2571                         list(APPEND GL_DEFINITIONS -DGLEW_ES_ONLY)
2572                 endif()
2573
2574                 if(WITH_GL_PROFILE_ES20)
2575                         if(WITH_GL_EGL)
2576                                 list(APPEND GL_DEFINITIONS -DGLEW_USE_LIB_ES20)
2577                         endif()
2578
2579                         # ToDo: This is an experiment to eliminate ES 1 symbols,
2580                         # GLEW doesn't really properly provide this level of control
2581                         # (for example, without modification it eliminates too many symbols)
2582                         # so there are lots of modifications to GLEW to make this work,
2583                         # and no attempt to make it work beyond Blender at this point.
2584                         list(APPEND GL_DEFINITIONS -DGL_ES_VERSION_1_0=0 -DGL_ES_VERSION_CL_1_1=0 -DGL_ES_VERSION_CM_1_1=0)
2585                 endif()
2586
2587                 if(WITH_GL_EGL)
2588                         list(APPEND GL_DEFINITIONS -DGLEW_INC_EGL)
2589                 endif()
2590
2591                 set(BLENDER_GLEW_LIBRARIES extern_glew_es bf_intern_glew_mx)
2592
2593         else()
2594                 set(GLEW_INCLUDE_PATH "${CMAKE_SOURCE_DIR}/extern/glew/include")
2595
2596                 list(APPEND GL_DEFINITIONS -DGLEW_STATIC)
2597
2598                 # This won't affect the non-experimental glew library, 
2599                 # but is used for conditional compilation elsewhere.
2600                 list(APPEND GL_DEFINITIONS -DGLEW_NO_ES)
2601
2602                 set(BLENDER_GLEW_LIBRARIES extern_glew)
2603
2604         endif()
2605
2606 endif()
2607
2608 if(NOT WITH_GLU)
2609         list(APPEND GL_DEFINITIONS -DGLEW_NO_GLU)
2610 endif()
2611
2612 #-----------------------------------------------------------------------------
2613 # Configure Bullet
2614
2615 if(WITH_BULLET AND WITH_SYSTEM_BULLET)
2616         find_package(Bullet)
2617         if(NOT BULLET_FOUND)
2618                 set(WITH_BULLET OFF)
2619         endif()
2620 else()
2621         set(BULLET_INCLUDE_DIRS "${CMAKE_SOURCE_DIR}/extern/bullet2/src")
2622         # set(BULLET_LIBRARIES "")
2623 endif()
2624
2625 #-----------------------------------------------------------------------------
2626 # Configure Python.
2627
2628 if(WITH_PYTHON_MODULE)
2629         add_definitions(-DPy_ENABLE_SHARED)
2630 endif()
2631
2632 #-----------------------------------------------------------------------------
2633 # Configure GLog/GFlags
2634
2635 if(WITH_LIBMV OR WITH_GTESTS OR (WITH_CYCLES AND WITH_CYCLES_LOGGING))
2636         set(GLOG_DEFINES
2637                 -DGOOGLE_GLOG_DLL_DECL=
2638         )
2639
2640         set(GFLAGS_DEFINES
2641                 -DGFLAGS_DLL_DEFINE_FLAG=
2642                 -DGFLAGS_DLL_DECLARE_FLAG=
2643                 -DGFLAGS_DLL_DECL=
2644         )
2645 endif()
2646
2647 #-----------------------------------------------------------------------------
2648 # Configure Ceres
2649
2650 if(WITH_LIBMV)
2651         set(CERES_DEFINES)
2652
2653         if(SHARED_PTR_FOUND)
2654                 if(SHARED_PTR_TR1_MEMORY_HEADER)
2655                         list(APPEND CERES_DEFINES -DCERES_TR1_MEMORY_HEADER)
2656                 endif()
2657                 if(SHARED_PTR_TR1_NAMESPACE)
2658                         list(APPEND CERES_DEFINES -DCERES_TR1_SHARED_PTR)
2659                 endif()
2660         else()
2661                 message(FATAL_ERROR "Ceres: Unable to find shared_ptr.")
2662         endif()
2663
2664         if(HAVE_STD_UNORDERED_MAP_HEADER)
2665                 if(HAVE_UNORDERED_MAP_IN_STD_NAMESPACE)
2666                         list(APPEND CERES_DEFINES -DCERES_STD_UNORDERED_MAP)
2667                 else()
2668                         if(HAVE_UNORDERED_MAP_IN_TR1_NAMESPACE)
2669                                 list(APPEND CERES_DEFINES -DCERES_STD_UNORDERED_MAP_IN_TR1_NAMESPACE)
2670                         else()
2671                                 list(APPEND CERES_DEFINES -DCERES_NO_UNORDERED_MAP)
2672                                 message(STATUS "Ceres: Replacing unordered_map/set with map/set (warning: slower!)")
2673                         endif()
2674                 endif()
2675         else()
2676                 if(HAVE_UNORDERED_MAP_IN_TR1_NAMESPACE)
2677                         list(APPEND CERES_DEFINES -DCERES_TR1_UNORDERED_MAP)
2678                 else()
2679                         list(APPEND CERES_DEFINES -DCERES_NO_UNORDERED_MAP)
2680                         message(STATUS "Ceres: Replacing unordered_map/set with map/set (warning: slower!)")
2681                 endif()
2682         endif()
2683 endif()
2684
2685 #-----------------------------------------------------------------------------
2686 # Extra compile flags
2687
2688 if(CMAKE_COMPILER_IS_GNUCC)
2689
2690         ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_ALL -Wall)
2691         ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_CAST_ALIGN -Wcast-align)
2692         ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_ERROR_IMPLICIT_FUNCTION_DECLARATION -Werror=implicit-function-declaration)
2693         ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_ERROR_RETURN_TYPE  -Werror=return-type)
2694         ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_ERROR_VLA -Werror=vla)
2695         # system headers sometimes do this, disable for now, was: -Werror=strict-prototypes
2696         ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_STRICT_PROTOTYPES  -Wstrict-prototypes)
2697         ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_MISSING_PROTOTYPES -Wmissing-prototypes)
2698         ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_NO_CHAR_SUBSCRIPTS -Wno-char-subscripts)
2699         ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_NO_UNKNOWN_PRAGMAS -Wno-unknown-pragmas)
2700         ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_POINTER_ARITH -Wpointer-arith)
2701         ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_UNUSED_PARAMETER -Wunused-parameter)
2702         ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_WRITE_STRINGS -Wwrite-strings)
2703         ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_LOGICAL_OP -Wlogical-op)
2704         ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_UNDEF -Wundef)
2705         ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_INIT_SELF -Winit-self)  # needs -Wuninitialized
2706         ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_NO_NULL -Wnonnull)  # C only
2707         ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_MISSING_INCLUDE_DIRS -Wmissing-include-dirs)
2708         ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_NO_DIV_BY_ZERO -Wno-div-by-zero)
2709         ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_TYPE_LIMITS -Wtype-limits)
2710         ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_FORMAT_SIGN -Wformat-signedness)
2711
2712         # gcc 4.2 gives annoying warnings on every file with this
2713         if(NOT "${CMAKE_C_COMPILER_VERSION}" VERSION_LESS "4.3")
2714                 ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_UNINITIALIZED -Wuninitialized)
2715         endif()
2716
2717         # versions before gcc4.6 give many BLI_math warnings
2718         if(NOT "${CMAKE_C_COMPILER_VERSION}" VERSION_LESS "4.6")
2719                 ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_REDUNDANT_DECLS       -Wredundant-decls)
2720                 ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_REDUNDANT_DECLS -Wredundant-decls)
2721         endif()
2722
2723         # versions before gcc4.8 include global name-space.
2724         if(NOT "${CMAKE_C_COMPILER_VERSION}" VERSION_LESS "4.8")
2725                 ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_SHADOW -Wshadow)
2726         endif()
2727
2728         # disable because it gives warnings for printf() & friends.
2729         # ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_DOUBLE_PROMOTION -Wdouble-promotion -Wno-error=double-promotion)
2730
2731         if(NOT APPLE)
2732                 ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_NO_ERROR_UNUSED_BUT_SET_VARIABLE -Wno-error=unused-but-set-variable)
2733         endif()
2734
2735         ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_ALL -Wall)
2736         ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_NO_INVALID_OFFSETOF -Wno-invalid-offsetof)
2737         ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_NO_SIGN_COMPARE -Wno-sign-compare)
2738         ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_LOGICAL_OP -Wlogical-op)
2739         ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_INIT_SELF -Winit-self)  # needs -Wuninitialized
2740         ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_MISSING_INCLUDE_DIRS -Wmissing-include-dirs)
2741         ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_NO_DIV_BY_ZERO -Wno-div-by-zero)
2742         ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_TYPE_LIMITS -Wtype-limits)
2743         ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_ERROR_RETURN_TYPE  -Werror=return-type)
2744         ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_ERROR_IMPLICIT_FUNCTION_DECLARATION -Werror=implicit-function-declaration)
2745         ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_NO_CHAR_SUBSCRIPTS -Wno-char-subscripts)
2746         ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_NO_UNKNOWN_PRAGMAS -Wno-unknown-pragmas)
2747         ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_POINTER_ARITH -Wpointer-arith)
2748         ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_UNUSED_PARAMETER -Wunused-parameter)
2749         ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_WRITE_STRINGS -Wwrite-strings)
2750         ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_UNDEF -Wundef)
2751         ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_FORMAT_SIGN -Wformat-signedness)
2752
2753         # gcc 4.2 gives annoying warnings on every file with this
2754         if(NOT "${CMAKE_C_COMPILER_VERSION}" VERSION_LESS "4.3")
2755                 ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_UNINITIALIZED -Wuninitialized)
2756         endif()
2757
2758         # causes too many warnings
2759         if(NOT APPLE)
2760                 ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_UNDEF -Wundef)
2761                 ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_MISSING_DECLARATIONS -Wmissing-declarations)
2762         endif()
2763
2764         # flags to undo strict flags
2765         ADD_CHECK_C_COMPILER_FLAG(CC_REMOVE_STRICT_FLAGS C_WARN_NO_DEPRECATED_DECLARATIONS -Wno-deprecated-declarations)
2766         ADD_CHECK_C_COMPILER_FLAG(CC_REMOVE_STRICT_FLAGS C_WARN_NO_UNUSED_PARAMETER        -Wno-unused-parameter)
2767
2768         if(NOT APPLE)
2769                 ADD_CHECK_C_COMPILER_FLAG(CC_REMOVE_STRICT_FLAGS C_WARN_NO_ERROR_UNUSED_BUT_SET_VARIABLE -Wno-error=unused-but-set-variable)
2770         endif()
2771
2772 elseif(CMAKE_C_COMPILER_ID MATCHES "Clang")
2773
2774         if(APPLE AND WITH_OPENMP) # we need the Intel omp lib linked here to not fail all tests due presence of -fopenmp !
2775                 set(CMAKE_REQUIRED_FLAGS "-L${LIBDIR}/openmp/lib -liomp5") # these are only used for the checks
2776         endif()
2777
2778         # strange, clang complains these are not supported, but then yses them.
2779         ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_ALL -Wall)
2780         ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_ERROR_IMPLICIT_FUNCTION_DECLARATION -Werror=implicit-function-declaration)
2781         ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_ERROR_RETURN_TYPE  -Werror=return-type)
2782         ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_NO_AUTOLOGICAL_COMPARE -Wno-tautological-compare)
2783         ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_NO_UNKNOWN_PRAGMAS -Wno-unknown-pragmas)
2784         ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_NO_CHAR_SUBSCRIPTS -Wno-char-subscripts)
2785         ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_STRICT_PROTOTYPES  -Wstrict-prototypes)
2786         ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_MISSING_PROTOTYPES -Wmissing-prototypes)
2787         ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_UNUSED_PARAMETER -Wunused-parameter)
2788
2789         ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_ALL -Wall)
2790         ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_NO_AUTOLOGICAL_COMPARE -Wno-tautological-compare)
2791         ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_NO_UNKNOWN_PRAGMAS     -Wno-unknown-pragmas)
2792         ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_NO_CHAR_SUBSCRIPTS     -Wno-char-subscripts)
2793         ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_NO_OVERLOADED_VIRTUAL  -Wno-overloaded-virtual)  # we get a lot of these, if its a problem a dev needs to look into it.
2794         ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_NO_SIGN_COMPARE        -Wno-sign-compare)
2795         ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_NO_INVALID_OFFSETOF    -Wno-invalid-offsetof)
2796
2797         # gives too many unfixable warnings
2798         # ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_UNUSED_MACROS      -Wunused-macros)
2799         # ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_UNUSED_MACROS          -Wunused-macros)
2800
2801         # flags to undo strict flags
2802         ADD_CHECK_C_COMPILER_FLAG(CC_REMOVE_STRICT_FLAGS C_WARN_NO_UNUSED_PARAMETER -Wno-unused-parameter)
2803         ADD_CHECK_C_COMPILER_FLAG(CC_REMOVE_STRICT_FLAGS C_WARN_NO_UNUSED_MACROS    -Wno-unused-macros)
2804
2805         ADD_CHECK_C_COMPILER_FLAG(CC_REMOVE_STRICT_FLAGS C_WARN_NO_MISSING_VARIABLE_DECLARATIONS -Wno-missing-variable-declarations)
2806         ADD_CHECK_C_COMPILER_FLAG(CC_REMOVE_STRICT_FLAGS C_WARN_NO_INCOMPAT_PTR_DISCARD_QUAL -Wno-incompatible-pointer-types-discards-qualifiers)
2807         ADD_CHECK_C_COMPILER_FLAG(CC_REMOVE_STRICT_FLAGS C_WARN_NO_UNUSED_FUNCTION -Wno-unused-function)
2808         ADD_CHECK_C_COMPILER_FLAG(CC_REMOVE_STRICT_FLAGS C_WARN_NO_INT_TO_VOID_POINTER_CAST -Wno-int-to-void-pointer-cast)
2809         ADD_CHECK_C_COMPILER_FLAG(CC_REMOVE_STRICT_FLAGS C_WARN_NO_MISSING_PROTOTYPES -Wno-missing-prototypes)
2810         ADD_CHECK_C_COMPILER_FLAG(CC_REMOVE_STRICT_FLAGS C_WARN_NO_DUPLICATE_ENUM -Wno-duplicate-enum)
2811         ADD_CHECK_C_COMPILER_FLAG(CC_REMOVE_STRICT_FLAGS C_WARN_NO_UNDEF -Wno-undef)
2812         ADD_CHECK_C_COMPILER_FLAG(CC_REMOVE_STRICT_FLAGS C_WARN_NO_MISSING_NORETURN -Wno-missing-noreturn)
2813
2814         ADD_CHECK_CXX_COMPILER_FLAG(CC_REMOVE_STRICT_FLAGS CXX_WARN_NO_UNUSED_PRIVATE_FIELD -Wno-unused-private-field)
2815         ADD_CHECK_CXX_COMPILER_FLAG(CC_REMOVE_STRICT_FLAGS CXX_WARN_NO_CXX11_NARROWING -Wno-c++11-narrowing)
2816         ADD_CHECK_CXX_COMPILER_FLAG(CC_REMOVE_STRICT_FLAGS CXX_WARN_NO_NON_VIRTUAL_DTOR -Wno-non-virtual-dtor)
2817         ADD_CHECK_CXX_COMPILER_FLAG(CC_REMOVE_STRICT_FLAGS CXX_WARN_NO_UNUSED_MACROS -Wno-unused-macros)
2818         ADD_CHECK_CXX_COMPILER_FLAG(CC_REMOVE_STRICT_FLAGS CXX_WARN_NO_REORDER -Wno-reorder)
2819
2820 elseif(CMAKE_C_COMPILER_ID MATCHES "Intel")
2821
2822         ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_ALL -Wall)
2823         ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_POINTER_ARITH -Wpointer-arith)
2824         ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_NO_UNKNOWN_PRAGMAS -Wno-unknown-pragmas)
2825
2826         ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_ALL -Wall)
2827         ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_NO_INVALID_OFFSETOF -Wno-invalid-offsetof)
2828         ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_NO_SIGN_COMPARE -Wno-sign-compare)
2829
2830         # disable numbered, false positives
2831         set(C_WARNINGS "${C_WARNINGS} -wd188,186,144,913,556")
2832         set(CXX_WARNINGS "${CXX_WARNINGS} -wd188,186,144,913,556")
2833 elseif(CMAKE_C_COMPILER_ID MATCHES "MSVC")
2834         # most msvc warnings are C & C++
2835         set(_WARNINGS
2836                 # warning level:
2837                 "/W3"
2838                 "/w34062"  # switch statement contains 'default' but no 'case' labels
2839                 # disable:
2840                 "/wd4018"  # signed/unsigned mismatch
2841                 "/wd4146"  # unary minus operator applied to unsigned type, result still unsigned
2842                 "/wd4065"  # switch statement contains 'default' but no 'case' labels
2843                 "/wd4127"  # conditional expression is constant
2844                 "/wd4181"  # qualifier applied to reference type; ignored
2845                 "/wd4200"  # zero-sized array in struct/union
2846                 "/wd4244"  # conversion from 'type1' to 'type2', possible loss of data
2847                 "/wd4267"  # conversion from 'size_t' to 'type', possible loss of data
2848                 "/wd4305"  # truncation from 'type1' to 'type2'
2849                 "/wd4800"  # forcing value to bool 'true' or 'false'
2850                 # errors:
2851                 "/we4013"  # 'function' undefined; assuming extern returning int
2852                 "/we4431"  # missing type specifier - int assumed
2853         )
2854
2855         string(REPLACE ";" " " _WARNINGS "${_WARNINGS}")
2856         set(C_WARNINGS "${_WARNINGS}")
2857         set(CXX_WARNINGS "${_WARNINGS}")
2858         unset(_WARNINGS)
2859 endif()
2860
2861 # ensure python header is found since detection can fail, this could happen
2862 # with _any_ library but since we used a fixed python version this tends to
2863 # be most problematic.
2864 if(WITH_PYTHON)
2865         if(NOT EXISTS "${PYTHON_INCLUDE_DIR}/Python.h")
2866                 message(FATAL_ERROR "Missing: \"${PYTHON_INCLUDE_DIR}/Python.h\",\n"
2867                                                         "Set the cache entry 'PYTHON_INCLUDE_DIR' to point "
2868                                                         "to a valid python include path. Containing "
2869                                                         "Python.h for python version \"${PYTHON_VERSION}\"")
2870         endif()
2871
2872         if(WIN32)
2873                 # pass, we have this in an archive to extract
2874         elseif(WITH_PYTHON_INSTALL AND WITH_PYTHON_INSTALL_NUMPY)
2875                 find_python_package(numpy)
2876         endif()
2877
2878         if(WIN32 OR APPLE)
2879                 # pass, we have this in lib/python/site-packages
2880         elseif(WITH_PYTHON_INSTALL_REQUESTS)
2881                 find_python_package(requests)
2882         endif()
2883 endif()
2884
2885 if(WITH_CPP11)
2886         if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_C_COMPILER_ID MATCHES "Clang")
2887                 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
2888         elseif(MSVC12)
2889                 # Nothing special is needed, C++11 features are available by default.
2890         else()
2891                 message(FATAL_ERROR "Compiler ${CMAKE_C_COMPILER_ID} is not supported for C++11 build yet")
2892         endif()
2893 endif()
2894
2895 # Visual Studio has all standards it supports available by default
2896 if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_C_COMPILER_ID MATCHES "Clang" OR CMAKE_C_COMPILER_ID MATCHES "Intel")
2897         # Use C99 + GNU extensions, works with GCC, Clang, ICC
2898         set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu99")
2899 endif()
2900
2901 # Include warnings first, so its possible to disable them with user defined flags
2902 # eg: -Wno-uninitialized
2903 set(CMAKE_C_FLAGS "${C_WARNINGS} ${CMAKE_C_FLAGS} ${PLATFORM_CFLAGS}")
2904 set(CMAKE_CXX_FLAGS "${CXX_WARNINGS} ${CMAKE_CXX_FLAGS} ${PLATFORM_CFLAGS}")
2905
2906 # defined above, platform spesific but shared names
2907 mark_as_advanced(
2908         CYCLES_OSL
2909         OSL_LIB_EXEC
2910         OSL_COMPILER
2911         OSL_LIB_COMP
2912         OSL_LIB_QUERY
2913         OSL_INCLUDE_DIR
2914 )
2915
2916 mark_as_advanced(
2917         LLVM_CONFIG
2918         LLVM_ROOT_DIR
2919         LLVM_LIBRARY
2920         LLVM_VERSION
2921 )
2922
2923 #-------------------------------------------------------------------------------
2924 # Global Defines
2925
2926 # better not set includes here but this debugging option is off by default.
2927 if(WITH_CXX_GUARDEDALLOC)
2928         include_directories(${CMAKE_SOURCE_DIR}/intern/guardedalloc)
2929         add_definitions(-DWITH_CXX_GUARDEDALLOC)
2930 endif()
2931
2932 if(WITH_ASSERT_ABORT)
2933         add_definitions(-DWITH_ASSERT_ABORT)
2934 endif()
2935
2936 # message(STATUS "Using CFLAGS: ${CMAKE_C_FLAGS}")
2937 # message(STATUS "Using CXXFLAGS: ${CMAKE_CXX_FLAGS}")
2938
2939 #-----------------------------------------------------------------------------
2940 # Libraries
2941
2942 if(WITH_GTESTS)
2943         include(GTestTesting)
2944 endif()
2945
2946 if(WITH_BLENDER OR WITH_PLAYER)
2947         add_subdirectory(intern)
2948         add_subdirectory(extern)
2949
2950         # source after intern and extern to gather all
2951         # internal and external library information first, for test linking
2952         add_subdirectory(source)
2953 elseif(WITH_CYCLES_STANDALONE)
2954         add_subdirectory(intern/cycles)
2955         add_subdirectory(extern/clew)
2956         if(WITH_CUDA_DYNLOAD)
2957                 add_subdirectory(extern/cuew)
2958         endif()
2959         if(NOT WITH_SYSTEM_GLEW)
2960                 add_subdirectory(extern/glew)
2961         endif()
2962 endif()
2963
2964 #-----------------------------------------------------------------------------
2965 # Blender Application
2966 if(WITH_BLENDER)
2967         add_subdirectory(source/creator)
2968 endif()
2969
2970
2971 #-----------------------------------------------------------------------------
2972 # Blender Player
2973 if(WITH_PLAYER)
2974         add_subdirectory(source/blenderplayer)
2975 endif()
2976
2977
2978 #-----------------------------------------------------------------------------
2979 # Testing
2980 add_subdirectory(tests)
2981
2982
2983 #-----------------------------------------------------------------------------
2984 # CPack for generating packages
2985 include(build_files/cmake/packaging.cmake)
2986
2987
2988 #-----------------------------------------------------------------------------
2989 # Print Final Configuration
2990
2991 if(FIRST_RUN)
2992
2993         set(_config_msg "\nBlender Configuration\n=====================")
2994
2995         function(info_cfg_option
2996                 _setting
2997                 )
2998
2999                 set(_msg "  - ${_setting}")
3000                 string(LENGTH "${_msg}" _len)
3001                 while("32" GREATER "${_len}")
3002                         set(_msg "${_msg} ")
3003                          math(EXPR _len "${_len} + 1")
3004                 endwhile()
3005
3006                 set(_config_msg "${_config_msg}\n${_msg}${${_setting}}" PARENT_SCOPE)
3007         endfunction()
3008
3009         function(info_cfg_text
3010                 _text
3011                 )
3012
3013                 set(_config_msg "${_config_msg}\n\n  ${_text}" PARENT_SCOPE)
3014         endfunction()
3015
3016         message(STATUS "C Compiler:   \"${CMAKE_C_COMPILER_ID}\"")
3017         message(STATUS "C++ Compiler: \"${CMAKE_CXX_COMPILER_ID}\"")
3018
3019         info_cfg_text("Build Options:")
3020         info_cfg_option(WITH_GAMEENGINE)
3021         info_cfg_option(WITH_PLAYER)
3022         info_cfg_option(WITH_BULLET)
3023         info_cfg_option(WITH_IK_SOLVER)
3024         info_cfg_option(WITH_IK_ITASC)
3025         info_cfg_option(WITH_OPENCOLLADA)
3026         info_cfg_option(WITH_FFTW3)
3027         info_cfg_option(WITH_INTERNATIONAL)
3028         info_cfg_option(WITH_INPUT_NDOF)
3029         info_cfg_option(WITH_CYCLES)
3030         info_cfg_option(WITH_FREESTYLE)
3031         info_cfg_option(WITH_OPENCOLORIO)
3032         info_cfg_option(WITH_OPENVDB)
3033
3034         info_cfg_text("Compiler Options:")
3035         info_cfg_option(WITH_BUILDINFO)
3036         info_cfg_option(WITH_OPENMP)
3037         info_cfg_option(WITH_RAYOPTIMIZATION)
3038
3039         info_cfg_text("System Options:")
3040         info_cfg_option(WITH_INSTALL_PORTABLE)
3041         info_cfg_option(WITH_X11_XF86VMODE)
3042         info_cfg_option(WITH_X11_XINPUT)
3043         info_cfg_option(WITH_MEM_JEMALLOC)
3044         info_cfg_option(WITH_MEM_VALGRIND)
3045         info_cfg_option(WITH_SYSTEM_GLEW)
3046         info_cfg_option(WITH_SYSTEM_OPENJPEG)
3047
3048         info_cfg_text("Image Formats:")
3049         info_cfg_option(WITH_OPENIMAGEIO)
3050         info_cfg_option(WITH_IMAGE_CINEON)
3051         info_cfg_option(WITH_IMAGE_DDS)
3052         info_cfg_option(WITH_IMAGE_HDR)
3053         info_cfg_option(WITH_IMAGE_OPENEXR)
3054         info_cfg_option(WITH_IMAGE_OPENJPEG)
3055         info_cfg_option(WITH_IMAGE_REDCODE)
3056         info_cfg_option(WITH_IMAGE_TIFF)
3057
3058         info_cfg_text("Audio:")
3059         info_cfg_option(WITH_OPENAL)
3060         info_cfg_option(WITH_SDL)
3061         info_cfg_option(WITH_SDL_DYNLOAD)
3062         info_cfg_option(WITH_JACK)
3063         info_cfg_option(WITH_JACK_DYNLOAD)
3064         info_cfg_option(WITH_CODEC_AVI)
3065         info_cfg_option(WITH_CODEC_FFMPEG)
3066         info_cfg_option(WITH_CODEC_SNDFILE)
3067
3068         info_cfg_text("Compression:")
3069         info_cfg_option(WITH_LZMA)
3070         info_cfg_option(WITH_LZO)
3071
3072         info_cfg_text("Python:")
3073         info_cfg_option(WITH_PYTHON_INSTALL)
3074         info_cfg_option(WITH_PYTHON_INSTALL_NUMPY)
3075         info_cfg_option(WITH_PYTHON_MODULE)
3076         info_cfg_option(WITH_PYTHON_SAFETY)
3077         if(APPLE)
3078                 info_cfg_option(WITH_PYTHON_FRAMEWORK)
3079         endif()
3080
3081         info_cfg_text("Modifiers:")
3082         info_cfg_option(WITH_MOD_BOOLEAN)
3083         info_cfg_option(WITH_MOD_REMESH)
3084         info_cfg_option(WITH_MOD_FLUID)
3085         info_cfg_option(WITH_MOD_OCEANSIM)
3086
3087         info_cfg_text("OpenGL:")
3088         info_cfg_option(WITH_GLEW_ES)
3089         info_cfg_option(WITH_GLU)
3090         info_cfg_option(WITH_GL_EGL)
3091         info_cfg_option(WITH_GL_PROFILE_COMPAT)
3092         info_cfg_option(WITH_GL_PROFILE_CORE)
3093         info_cfg_option(WITH_GL_PROFILE_ES20)
3094         if(WIN32)
3095                 info_cfg_option(WITH_GL_ANGLE)
3096         endif()
3097
3098         info_cfg_text("")
3099
3100         message("${_config_msg}")
3101 endif()
3102
3103 if(0)
3104         print_all_vars()
3105 endif()
3106