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