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