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