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