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