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