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