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