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