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