Fix #35587: Cycles: image movie to single image crashing
[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 endif()
53
54 # this starts out unset
55 list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/build_files/cmake/Modules")
56
57 # avoid having empty buildtype
58 set(CMAKE_BUILD_TYPE_INIT "Release")
59
60 # quiet output for Makefiles, 'make -s' helps too
61 # set_property(GLOBAL PROPERTY RULE_MESSAGES OFF)
62
63 # global compile definitions since add_definitions() adds for all.
64 set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS_DEBUG           DEBUG _DEBUG)
65 set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS_RELEASE         NDEBUG)
66 set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS_MINSIZEREL      NDEBUG)
67 set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS_RELWITHDEBINFO  NDEBUG)
68
69
70 #-----------------------------------------------------------------------------
71 # Set policy
72
73 # see "cmake --help-policy CMP0003"
74 # So library linking is more sane
75 cmake_policy(SET CMP0003 NEW)
76
77 # So BUILDINFO and BLENDERPATH strings are automatically quoted
78 cmake_policy(SET CMP0005 NEW)
79
80 # So syntax problems are errors
81 cmake_policy(SET CMP0010 NEW)
82
83 # Input directories must have CMakeLists.txt
84 cmake_policy(SET CMP0014 NEW)
85
86 #-----------------------------------------------------------------------------
87 # Load some macros.
88 include(build_files/cmake/macros.cmake)
89
90
91 #-----------------------------------------------------------------------------
92 # Initialize project.
93
94 blender_project_hack_pre()
95
96 project(Blender)
97
98 blender_project_hack_post()
99
100 enable_testing()
101
102 #-----------------------------------------------------------------------------
103 # Redirect output files
104
105 set(EXECUTABLE_OUTPUT_PATH ${CMAKE_BINARY_DIR}/bin CACHE INTERNAL "" FORCE)
106 set(LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR}/lib CACHE INTERNAL "" FORCE)
107
108 #-----------------------------------------------------------------------------
109 # Set default config options
110
111 get_blender_version()
112
113
114 # Blender internal features
115 option(WITH_BLENDER "Build blender (disable to build only the blender player)" ON)
116 mark_as_advanced(WITH_BLENDER)
117
118 option(WITH_INTERNATIONAL "Enable I18N (International fonts and text)" ON)
119
120 option(WITH_PYTHON        "Enable Embedded Python API  (only disable for development)" ON)
121 option(WITH_PYTHON_SECURITY "Disables execution of scripts within blend files by default (recommend to leave off)" OFF)
122 mark_as_advanced(WITH_PYTHON)  # dont want people disabling this unless they really know what they are doing.
123 mark_as_advanced(WITH_PYTHON_SECURITY)  # some distributions see this as a security issue, rather than have them patch it, make a build option.
124
125 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)
126 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)" OFF)
127 if(APPLE)
128         option(WITH_PYTHON_FRAMEWORK "Enable building using the Python available in the framework (OSX only)" OFF)
129 endif()
130
131 option(WITH_BUILDINFO     "Include extra build details (only disable for development & faster builds)" ON)
132 option(WITH_IK_ITASC      "Enable ITASC IK solver (only disable for development & for incompatible C++ compilers)" ON)
133 option(WITH_IK_SOLVER     "Enable Legacy IK solver (only disable for development)" ON)
134 option(WITH_FFTW3         "Enable FFTW3 support (Used for smoke and audio effects)" ON)
135 option(WITH_BULLET        "Enable Bullet (Physics Engine)" ON)
136 option(WITH_SYSTEM_BULLET "Use the systems bullet library (currently unsupported due to missing features in upstream!)" )
137 mark_as_advanced(WITH_SYSTEM_BULLET)
138 option(WITH_GAMEENGINE    "Enable Game Engine" ON)
139 option(WITH_PLAYER        "Build Player" OFF)
140 option(WITH_OPENCOLORIO   "Enable OpenColorIO color management" ON)
141 option(WITH_COMPOSITOR    "Enable the tile based nodal compositor" ON)
142
143 # GHOST Windowing Library Options
144 option(WITH_GHOST_DEBUG   "Enable debugging output for the GHOST library" OFF)
145 mark_as_advanced(WITH_GHOST_DEBUG)
146
147 option(WITH_GHOST_SDL    "Enable building blender against SDL for windowing rather then the native APIs" OFF)
148 mark_as_advanced(WITH_GHOST_SDL)
149
150 # Misc...
151 option(WITH_HEADLESS      "Build without graphical support (renderfarm, server mode only)" OFF)
152 mark_as_advanced(WITH_HEADLESS)
153
154 option(WITH_AUDASPACE    "Build with blenders audio library (only disable if you know what you're doing!)" ON)
155 mark_as_advanced(WITH_AUDASPACE)
156
157 option(WITH_BOOL_COMPAT "Continue defining \"TRUE\" and \"FALSE\" until these can be replaced with \"true\" and \"false\" from stdbool.h" ON)
158 mark_as_advanced(WITH_BOOL_COMPAT)
159
160 # (unix defaults to OpenMP On)
161 if((UNIX AND NOT APPLE) OR (MINGW))
162         set(PLATFORM_DEFAULT ON)
163 else()
164         set(PLATFORM_DEFAULT OFF)
165 endif()
166 option(WITH_OPENMP        "Enable OpenMP (has to be supported by the compiler)" ${PLATFORM_DEFAULT})
167 unset(PLATFORM_DEFAULT)
168
169
170 if(UNIX AND NOT APPLE)
171         option(WITH_X11_XINPUT "Enable X11 Xinput (tablet support and unicode input)"   ON)
172         option(WITH_X11_XF86VMODE "Enable X11 video mode switching"     ON)
173         option(WITH_SYSTEM_GLEW "Use GLEW OpenGL wrapper library provided by the operating system" ON)
174
175         # freebsd doesn't seems to support XDND
176         if(NOT ${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD")
177                 option(WITH_GHOST_XDND   "Enable drag'n'drop support on Linux using XDND protocol" ON)
178         endif()
179 else()
180         # not an option for other OS's
181         set(WITH_SYSTEM_GLEW OFF)
182 endif()
183
184
185 # (unix defaults to System OpenJPEG On)
186 if(UNIX AND NOT APPLE)
187         set(PLATFORM_DEFAULT ON)
188 else()
189         set(PLATFORM_DEFAULT OFF)
190 endif()
191 option(WITH_SYSTEM_OPENJPEG "Use the operating systems OpenJPEG library" ${PLATFORM_DEFAULT})
192 unset(PLATFORM_DEFAULT)
193
194
195 # Modifiers
196 option(WITH_MOD_FLUID           "Enable Elbeem Modifier (Fluid Simulation)" ON)
197 option(WITH_MOD_SMOKE           "Enable Smoke Modifier (Smoke Simulation)" ON)
198 option(WITH_MOD_BOOLEAN         "Enable Boolean Modifier" ON)
199 option(WITH_MOD_REMESH          "Enable Remesh Modifier" ON)
200 # option(WITH_MOD_CLOTH_ELTOPO    "Enable Experimental cloth solver" OFF)  # this is now only available in a branch
201 # mark_as_advanced(WITH_MOD_CLOTH_ELTOPO)
202 option(WITH_MOD_OCEANSIM        "Enable Ocean Modifier" OFF)
203
204 # Image format support
205 option(WITH_IMAGE_OPENEXR       "Enable OpenEXR Support (http://www.openexr.com)" ON)
206 option(WITH_IMAGE_OPENJPEG      "Enable OpenJpeg Support (http://www.openjpeg.org)" ON)
207 option(WITH_IMAGE_TIFF          "Enable LibTIFF Support" ON)
208 option(WITH_IMAGE_DDS           "Enable DDS Image Support" ON)
209 option(WITH_IMAGE_CINEON        "Enable CINEON and DPX Image Support" ON)
210 option(WITH_IMAGE_HDR           "Enable HDR Image Support" ON)
211 option(WITH_IMAGE_REDCODE       "Enable RedCode Image Support" OFF)
212 option(WITH_IMAGE_FRAMESERVER   "Enable image FrameServer Support for rendering" ON)
213
214 # Audio/Video format support
215 option(WITH_CODEC_AVI           "Enable Blenders own AVI file support (raw/jpeg)" ON)
216 option(WITH_CODEC_FFMPEG        "Enable FFMPeg Support (http://ffmpeg.org)" OFF)
217
218 option(WITH_CODEC_SNDFILE       "Enable libsndfile Support (http://www.mega-nerd.com/libsndfile)" OFF)
219 if(APPLE OR (WIN32 AND NOT UNIX))
220         option(WITH_CODEC_QUICKTIME     "Enable Quicktime Support" OFF)
221 endif()
222
223 # 3D format support
224 # disable opencollada on non-apple unix because opencollada has no package for debian
225 option(WITH_OPENCOLLADA         "Enable OpenCollada Support (http://www.opencollada.org)"       OFF)
226
227 # Sound output
228 option(WITH_SDL           "Enable SDL for sound and joystick support" ON)
229 option(WITH_OPENAL        "Enable OpenAL Support (http://www.openal.org)" ON)
230 option(WITH_JACK          "Enable Jack Support (http://www.jackaudio.org)" OFF)
231 if(UNIX AND NOT APPLE)
232         option(WITH_JACK_DYNLOAD  "Enable runtime dynamic Jack libraries loading" OFF)
233 endif()
234
235 # Compression
236 option(WITH_LZO           "Enable fast LZO compression (used for pointcache)" ON)
237 option(WITH_LZMA          "Enable best LZMA compression, (used for pointcache)" ON)
238
239 # Camera/motion tracking
240 option(WITH_LIBMV         "Enable libmv structure from motion library" ON)
241
242 # Freestyle
243 option(WITH_FREESTYLE     "Enable Freestyle (advanced edges rendering)" ON)
244
245 # Misc
246 option(WITH_INPUT_NDOF "Enable NDOF input devices (SpaceNavigator and friends)" ON)
247 option(WITH_RAYOPTIMIZATION     "Enable use of SIMD (SSE) optimizations for the raytracer" ON)
248 if(UNIX AND NOT APPLE)
249         option(WITH_INSTALL_PORTABLE "Install redistributeable runtime, otherwise install into CMAKE_INSTALL_PREFIX" ON)
250         option(WITH_STATIC_LIBS "Try to link with static libraries, as much as possible, to make blender more portable across distributions" OFF)
251         if(WITH_STATIC_LIBS)
252                 option(WITH_BOOST_ICU "Boost uses ICU library (required for linking with static Boost built with libicu)." OFF)
253                 mark_as_advanced(WITH_BOOST_ICU)
254         endif()
255 endif()
256 option(WITH_PYTHON_INSTALL       "Copy system python into the blender install folder" ON)
257 option(WITH_PYTHON_INSTALL_NUMPY "Copy system numpy into the blender install folder"  ON)
258 set(PYTHON_NUMPY_PATH            "" CACHE PATH "Python to python site-packages or dist-packages containing 'numpy' module")
259 mark_as_advanced(PYTHON_NUMPY_PATH)
260
261 # Cycles
262 option(WITH_CYCLES                                      "Enable cycles Render Engine" ON)
263 option(WITH_CYCLES_TEST                         "Build cycles test application" OFF)
264 option(WITH_CYCLES_OSL                          "Build Cycles with OSL support" OFF)
265 option(WITH_CYCLES_CUDA_BINARIES        "Build cycles CUDA binaries" OFF)
266 set(CYCLES_CUDA_BINARIES_ARCH sm_20 sm_21 sm_30 CACHE STRING "CUDA architectures to build binaries for")
267 mark_as_advanced(CYCLES_CUDA_BINARIES_ARCH)
268 unset(PLATFORM_DEFAULT)
269
270 # LLVM
271 option(WITH_LLVM                                        "Use LLVM" OFF)
272 option(LLVM_STATIC                                      "Link with LLVM static libraries" ON)
273 mark_as_advanced(LLVM_STATIC)
274
275 # disable for now, but plan to support on all platforms eventually
276 option(WITH_MEM_JEMALLOC   "Enable malloc replacement (http://www.canonware.com/jemalloc)" OFF)
277 mark_as_advanced(WITH_MEM_JEMALLOC)
278
279 # Debug
280 option(WITH_CXX_GUARDEDALLOC "Enable GuardedAlloc for C++ memory allocation tracking (only enable for development)" OFF)
281 mark_as_advanced(WITH_CXX_GUARDEDALLOC)
282
283 option(WITH_GUARDEDALLOC "Enable GuardedAlloc (DISABLE AT OWN RISK!)" ON)
284 mark_as_advanced(WITH_GUARDEDALLOC)
285
286 option(WITH_ASSERT_ABORT "Call abort() when raising an assertion through BLI_assert()" OFF)
287 mark_as_advanced(WITH_ASSERT_ABORT)
288
289 option(WITH_BOOST                                       "Enable features depending no boost" ON)
290
291 if(CMAKE_COMPILER_IS_GNUCC)
292         option(WITH_GCC_MUDFLAP                 "Enable mudflap" OFF)
293         mark_as_advanced(WITH_GCC_MUDFLAP)
294 endif()
295
296 if(APPLE)
297         cmake_minimum_required(VERSION 2.8.8)
298         cmake_policy(VERSION 2.8.8)
299
300         if(NOT CMAKE_OSX_ARCHITECTURES)
301                 set(CMAKE_OSX_ARCHITECTURES x86_64 CACHE STRING
302                 "Choose the architecture you want to build Blender for: i386, x86_64 or ppc"
303                 FORCE)
304         endif()
305         
306         execute_process(COMMAND uname -r OUTPUT_VARIABLE MAC_SYS) # check for actual system-version
307         if(${MAC_SYS} MATCHES 12)
308                 set(OSX_SYSTEM 10.8)
309         elseif(${MAC_SYS} MATCHES 11)
310                 set(OSX_SYSTEM 10.7)
311         elseif(${MAC_SYS} MATCHES 10)
312                 set(OSX_SYSTEM 10.6)
313         elseif(${MAC_SYS} MATCHES 9)
314                 set(OSX_SYSTEM 10.5)
315         else()
316                 set(OSX_SYSTEM unsupported)
317         endif()
318         message(STATUS "Detected system-version: " ${OSX_SYSTEM})
319
320         if(${CMAKE_GENERATOR} MATCHES "Xcode")
321         
322                 ##### cmake incompatibility with xcode  4.3 and higher #####
323                 if(${XCODE_VERSION} MATCHES '') # cmake fails due looking for xcode in the wrong path, thus will be empty var
324                         message(FATAL_ERROR "Xcode 4.3 and higher must be used with cmake 2.8-8 or higher")
325                 endif()
326                 ### end cmake incompatibility with xcode 4.3 and higher ###
327                 
328                 if(${XCODE_VERSION} VERSION_EQUAL 4 OR ${XCODE_VERSION} VERSION_GREATER 4 AND ${XCODE_VERSION} VERSION_LESS 4.3)
329                         # Xcode 4 defaults to the Apple LLVM Compiler.
330                         # Override the default compiler selection because Blender only compiles with gcc up to xcode 4.2
331                         set(CMAKE_XCODE_ATTRIBUTE_GCC_VERSION "com.apple.compilers.llvmgcc42")
332                         message(STATUS "Setting compiler to: " ${CMAKE_XCODE_ATTRIBUTE_GCC_VERSION})
333                 endif()
334         else() # unix makefile generator does not fill XCODE_VERSION var, so we get it with a command
335                 execute_process(COMMAND xcodebuild -version OUTPUT_VARIABLE XCODE_VERS_BUILD_NR)
336                 string(SUBSTRING "${XCODE_VERS_BUILD_NR}" 6 3 XCODE_VERSION) # truncate away build-nr
337                 unset(XCODE_VERS_BUILD_NR)
338         endif()
339         
340         message(STATUS "Detected Xcode-version: " ${XCODE_VERSION})
341
342         if(${XCODE_VERSION} VERSION_LESS 4.3)
343                 set(CMAKE_OSX_SYSROOT /Developer/SDKs/MacOSX${OSX_SYSTEM}.sdk CACHE PATH "" FORCE)  # use guaranteed existing sdk
344         else()
345                 # note: i don't use xcode-select path on purpose, cause also /Applications/Xcode.app would be allowed
346                 # absolute pathes are more foolproof here !
347                 set(OSX_SYSROOT_PREFIX /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform)
348                 set(OSX_DEVELOPER_PREFIX /Developer/SDKs/MacOSX${OSX_SYSTEM}.sdk) # use guaranteed existing sdk
349                 set(CMAKE_OSX_SYSROOT ${OSX_SYSROOT_PREFIX}/${OSX_DEVELOPER_PREFIX} CACHE PATH "" FORCE)
350         endif()
351         
352         if(NOT CMAKE_OSX_DEPLOYMENT_TARGET)
353                         set(CMAKE_OSX_DEPLOYMENT_TARGET "10.5" CACHE STRING "" FORCE) # 10.5 is our min. target, if you use higher sdk, weak linking happens
354         endif()
355         
356         if(NOT ${CMAKE_GENERATOR} MATCHES "Xcode")
357                 # force CMAKE_OSX_DEPLOYMENT_TARGET for makefiles, will not work else ( cmake bug ? )
358                 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mmacosx-version-min=${CMAKE_OSX_DEPLOYMENT_TARGET}")
359                 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mmacosx-version-min=${CMAKE_OSX_DEPLOYMENT_TARGET}")
360                 add_definitions("-DMACOSX_DEPLOYMENT_TARGET=${CMAKE_OSX_DEPLOYMENT_TARGET}")
361         endif()
362
363         option(WITH_COCOA         "Use Cocoa framework instead of deprecated Carbon" ON)
364         option(USE_QTKIT          "Use QtKit instead of Carbon quicktime (needed for having partial quicktime for 64bit)" OFF)
365         option(WITH_LIBS10.5  "Use 10.5 libs (needed for 64bit builds)" OFF)
366         if(CMAKE_OSX_ARCHITECTURES MATCHES x86_64)
367                 set(USE_QTKIT ON CACHE BOOL "ON" FORCE) # no Quicktime in 64bit
368         endif()
369 endif()
370
371
372 #-----------------------------------------------------------------------------
373 # Check for conflicting/unsupported configurations
374
375 if(NOT WITH_BLENDER AND NOT WITH_PLAYER AND NOT WITH_CYCLES_TEST)
376         message(FATAL_ERROR "At least one of WITH_BLENDER or WITH_PLAYER must be enabled, nothing to do!")
377 endif()
378
379 if(NOT WITH_GAMEENGINE AND WITH_PLAYER)
380         message(FATAL_ERROR "WITH_PLAYER requires WITH_GAMEENGINE")
381 endif()
382
383 if(NOT WITH_AUDASPACE)
384         if(WITH_OPENAL)
385                 message(FATAL_ERROR "WITH_OPENAL requires WITH_AUDASPACE")
386         endif()
387         if(WITH_JACK)
388                 message(FATAL_ERROR "WITH_JACK requires WITH_AUDASPACE")
389         endif()
390         if(WITH_GAMEENGINE)
391                 message(FATAL_ERROR "WITH_GAMEENGINE requires WITH_AUDASPACE")
392         endif()
393 endif()
394
395 if(NOT WITH_SDL AND WITH_GHOST_SDL)
396         message(FATAL_ERROR "WITH_GHOST_SDL requires WITH_SDL")
397 endif()
398
399 if(WITH_IMAGE_REDCODE AND ((NOT WITH_IMAGE_OPENJPEG) OR (NOT WITH_CODEC_FFMPEG)))
400         message(FATAL_ERROR "WITH_IMAGE_REDCODE requires WITH_IMAGE_OPENJPEG and WITH_CODEC_FFMPEG")
401 endif()
402
403 # python module, needs some different options
404 if(WITH_PYTHON_MODULE AND WITH_PLAYER)
405         message(FATAL_ERROR "WITH_PYTHON_MODULE requires WITH_PLAYER to be OFF")
406 endif()
407
408 if(WITH_PYTHON_MODULE AND WITH_PYTHON_INSTALL)
409         message(FATAL_ERROR "WITH_PYTHON_MODULE requires WITH_PYTHON_INSTALL to be OFF")
410 endif()
411
412
413 # may as well build python module without a UI
414 if(WITH_PYTHON_MODULE)
415         set(WITH_HEADLESS ON)
416 endif()
417
418 # enable boost for cycles, booleans, audaspace or i18n
419 # otherwise if the user disabled
420 if(NOT WITH_BOOST)
421         # Explicitly disabled. so disable all deps.
422         macro(set_and_warn
423                 _setting _val)
424                 if(${${_setting}})
425                         message(STATUS "'WITH_BOOST' is disabled: forceing 'set(${_setting} ${_val})'")
426                 endif()
427                 set(${_setting} ${_val})
428         endmacro()
429
430         set_and_warn(WITH_CYCLES         OFF)
431         set_and_warn(WITH_MOD_BOOLEAN    OFF)
432         set_and_warn(WITH_AUDASPACE      OFF)
433         set_and_warn(WITH_INTERNATIONAL  OFF)
434
435         set_and_warn(WITH_OPENAL         OFF)  # depends on AUDASPACE
436         set_and_warn(WITH_GAMEENGINE     OFF)  # depends on AUDASPACE
437 elseif(WITH_CYCLES OR WITH_MOD_BOOLEAN OR WITH_AUDASPACE OR WITH_INTERNATIONAL)
438         # Keep enabled
439 else()
440         # Enabled but we don't need it
441         set(WITH_BOOST OFF)
442 endif()
443
444 # auto enable openimageio for cycles
445 if(WITH_CYCLES)
446         set(WITH_OPENIMAGEIO ON)
447 endif()
448
449 # auto enable openimageio linking dependencies
450 if(WITH_OPENIMAGEIO)
451         set(WITH_IMAGE_OPENEXR ON)
452         set(WITH_IMAGE_TIFF ON)
453 endif()
454
455 # auto enable llvm for cycles_osl
456 if(WITH_CYCLES_OSL)
457         set(WITH_LLVM ON CACHE BOOL "ON" FORCE)
458 endif()
459
460 # don't store paths to libs for portable distribution
461 if(WITH_INSTALL_PORTABLE)
462         set(CMAKE_SKIP_BUILD_RPATH TRUE)
463 endif()
464
465 if(WITH_GHOST_SDL OR WITH_HEADLESS)
466         set(WITH_GHOST_XDND OFF)
467         set(WITH_X11_XF86VMODE OFF)
468         set(WITH_X11_XINPUT OFF)
469 endif()
470
471 if(MINGW)
472         if(WITH_CODEC_QUICKTIME)
473                 message(FATAL_ERROR "MINGW requires WITH_CODEC_QUICKTIME to be OFF "
474                                     "because it is currently unsupported, remove this "
475                                     "line if youre a developer who wants to add support.")
476         endif()
477 endif()
478
479 TEST_SSE_SUPPORT(COMPILER_SSE_FLAG COMPILER_SSE2_FLAG)
480
481 TEST_STDBOOL_SUPPORT()
482 if(HAVE_STDBOOL_H)
483         add_definitions(-DHAVE_STDBOOL_H)
484 endif()
485 if(WITH_BOOL_COMPAT)
486         add_definitions(-DWITH_BOOL_COMPAT)
487 endif()
488
489 #-----------------------------------------------------------------------------
490 # Check for valid directories
491 # ... svn extern paths can be missing because of svn-git.
492
493 if(WITH_INTERNATIONAL)
494         if(NOT EXISTS "${CMAKE_SOURCE_DIR}/release/datafiles/locale")
495                 message(WARNING "Translation path '${CMAKE_SOURCE_DIR}/release/datafiles/locale' is missing, "
496                                                 "This is an 'svn external', which are known not to work with bridges to other version "
497                                                 "control systems, disabling 'WITH_INTERNATIONAL'.")
498                 set(WITH_INTERNATIONAL OFF)
499         endif()
500 endif()
501
502 if(WITH_PYTHON)
503         if(NOT EXISTS "${CMAKE_SOURCE_DIR}/release/scripts/addons")
504                 message(WARNING "Addons path '${CMAKE_SOURCE_DIR}/release/scripts/addons' is missing, "
505                                                 "This is an 'svn external', which are known not to work with bridges to other version "
506                                                 "control systems: * CONTINUING WITHOUT ADDONS *")
507         endif()
508 endif()
509
510 #-----------------------------------------------------------------------------
511 # Initialize un-cached vars, avoid unused warning
512
513 # linux only, not cached
514 set(WITH_BINRELOC OFF)
515
516 # MAXOSX only, set to avoid uninitialized
517 set(EXETYPE "")
518
519 # C/C++ flags
520 set(PLATFORM_CFLAGS)
521
522 # these are added to later on.
523 set(C_WARNINGS)
524 set(CXX_WARNINGS)
525
526 # for gcc -Wno-blah-blah
527 set(CC_REMOVE_STRICT_FLAGS)
528
529 # libraries to link the binary with passed to target_link_libraries()
530 # known as LLIBS to scons
531 set(PLATFORM_LINKLIBS "")
532
533 # Added to linker flags in setup_liblinks
534 # - CMAKE_EXE_LINKER_FLAGS
535 # - CMAKE_EXE_LINKER_FLAGS_DEBUG
536 set(PLATFORM_LINKFLAGS "")
537 set(PLATFORM_LINKFLAGS_DEBUG "")
538
539
540 # disabled for now, not supported
541 # option(WITH_WEBPLUGIN     "Enable Web Plugin (Unix only)" OFF)
542
543 # For alternate Python locations the commandline can be used to override detected/default cache settings, e.g:
544 # On Unix:
545 #   cmake ../blender \
546 #         -D PYTHON_VERSION=3.3 \
547 #         -D PYTHON_INCLUDE_DIR=/opt/py33/include/python3.3d \
548 #         -D PYTHON_LIBRARY=/opt/py33/lib/libpython3.3d.so
549 #
550 # On Macs:
551 #   cmake ../blender \
552 #         -D PYTHON_INCLUDE_DIR=/System/Library/Frameworks/Python.framework/Versions/3.3/include/python3.3 \
553 #         -D PYTHON_LIBPATH=/System/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/config \
554 #         -G Xcode
555 #
556 # When changing any of this remember to update the notes in doc/build_systems/cmake.txt
557
558 #-----------------------------------------------------------------------------
559 #Platform specifics
560
561 if(UNIX AND NOT APPLE)
562         macro(find_package_wrapper)
563                 string(TOUPPER ${ARGV0} _NAME_UPPER)
564                 if(${WITH_STATIC_LIBS})
565                         set(_cmake_find_library_suffixes_back ${CMAKE_FIND_LIBRARY_SUFFIXES})
566                         set(CMAKE_FIND_LIBRARY_SUFFIXES .a ${CMAKE_FIND_LIBRARY_SUFFIXES})
567                 endif()
568                 find_package(${ARGV})
569                 if(${WITH_STATIC_LIBS})
570                         set(CMAKE_FIND_LIBRARY_SUFFIXES ${_cmake_find_library_suffixes_back})
571                         unset(_cmake_find_library_suffixes_back)
572                 endif()
573         endmacro()
574
575         find_package_wrapper(JPEG REQUIRED)
576         find_package_wrapper(PNG REQUIRED)
577         find_package_wrapper(ZLIB REQUIRED)
578         find_package_wrapper(Freetype REQUIRED)
579
580         if(WITH_PYTHON)
581                 # No way to set py33. remove for now.
582                 # find_package(PythonLibs)
583
584                 # Use our own instead, since wothout py is such a rare case,
585                 # require this package
586                 # XXX Linking errors with debian static python :/
587 #               find_package_wrapper(PythonLibsUnix REQUIRED)
588                 find_package(PythonLibsUnix REQUIRED)
589         endif()
590
591         if(WITH_IMAGE_OPENEXR)
592                 find_package_wrapper(OpenEXR)  # our own module
593                 if(NOT OPENEXR_FOUND)
594                         set(WITH_IMAGE_OPENEXR OFF)
595                 endif()
596         endif()
597
598         if(WITH_IMAGE_OPENJPEG)
599                 find_package_wrapper(OpenJPEG)
600                 if(NOT OPENJPEG_FOUND)
601                         set(WITH_IMAGE_OPENJPEG OFF)
602                 endif()
603         endif()
604
605         if(WITH_IMAGE_TIFF)
606                 # XXX Linking errors with debian static tiff :/
607 #               find_package_wrapper(TIFF)
608                 find_package(TIFF)
609                 if(NOT TIFF_FOUND)
610                         set(WITH_IMAGE_TIFF OFF)
611                 endif()
612         endif()
613
614         # Audio IO
615         if(WITH_OPENAL)
616                 find_package_wrapper(OpenAL)
617                 if(NOT OPENAL_FOUND)
618                         set(WITH_OPENAL OFF)
619                 endif()
620         endif()
621
622         if(WITH_SDL)
623                 find_package_wrapper(SDL)
624                 mark_as_advanced(
625                         SDLMAIN_LIBRARY
626                         SDL_INCLUDE_DIR
627                         SDL_LIBRARY
628                         SDL_LIBRARY_TEMP
629                 )
630                 # unset(SDLMAIN_LIBRARY CACHE)
631                 if(NOT SDL_FOUND)
632                         set(WITH_SDL OFF)
633                 endif()
634         endif()
635
636         if(WITH_JACK)
637                 find_package_wrapper(Jack)
638                 if(NOT JACK_FOUND)
639                         set(WITH_JACK OFF)
640                 endif()
641         endif()
642
643         # Codecs
644         if(WITH_CODEC_SNDFILE)
645                 find_package_wrapper(SndFile)
646                 if(NOT SNDFILE_FOUND)
647                         set(WITH_CODEC_SNDFILE OFF)
648                 endif()
649         endif()
650
651         if(WITH_CODEC_FFMPEG)
652                 set(FFMPEG /usr CACHE PATH "FFMPEG Directory")
653                 set(FFMPEG_LIBRARIES avformat avcodec avutil avdevice swscale CACHE STRING "FFMPEG Libraries")
654
655                 mark_as_advanced(FFMPEG)
656
657                 # lame, but until we have proper find module for ffmpeg
658                 set(FFMPEG_INCLUDE_DIRS ${FFMPEG}/include)
659                 if(EXISTS "${FFMPEG}/include/ffmpeg/")
660                         list(APPEND FFMPEG_INCLUDE_DIRS "${FFMPEG}/include/ffmpeg")
661                 endif()
662                 # end lameness
663
664                 mark_as_advanced(FFMPEG_LIBRARIES)
665                 set(FFMPEG_LIBPATH ${FFMPEG}/lib)
666                 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D__STDC_CONSTANT_MACROS")
667         endif()
668
669         if(WITH_FFTW3)
670                 find_package_wrapper(Fftw3)
671                 if(NOT FFTW3_FOUND)
672                         set(WITH_FFTW3 OFF)
673                 endif()
674         endif()
675
676         if(WITH_OPENCOLLADA)
677                 find_package_wrapper(OpenCOLLADA)
678                 if(OPENCOLLADA_FOUND)
679                         find_package_wrapper(XML2)
680                         find_package_wrapper(PCRE)
681                 else()
682                         set(WITH_OPENCOLLADA OFF)
683                 endif()
684         endif()
685
686         if(WITH_MEM_JEMALLOC)
687                 find_package_wrapper(JeMalloc)
688                 if(NOT JEMALLOC_FOUND)
689                         set(WITH_MEM_JEMALLOC OFF)
690                 endif()
691         endif()
692
693         if(WITH_INPUT_NDOF)
694                 find_package_wrapper(Spacenav)
695                 if(NOT SPACENAV_FOUND)
696                         set(WITH_INPUT_NDOF OFF)
697                 endif()
698
699                 # use generic names within blenders buildsystem.
700                 if(SPACENAV_FOUND)
701                         set(NDOF_INCLUDE_DIRS ${SPACENAV_INCLUDE_DIRS})
702                         set(NDOF_LIBRARIES ${SPACENAV_LIBRARIES})
703                 endif()
704         endif()
705
706         if(WITH_BOOST)
707                 # uses in build instructions to override include and library variables
708                 if(NOT BOOST_CUSTOM)
709                         if(${WITH_STATIC_LIBS})
710                                 set(Boost_USE_STATIC_LIBS ON)
711                         endif()
712                         set(Boost_USE_MULTITHREADED ON)
713                         set(__boost_packages filesystem regex system thread date_time)
714                         if(WITH_INTERNATIONAL)
715                                 list(APPEND __boost_packages locale)
716                         endif()
717                         find_package(Boost 1.48 COMPONENTS ${__boost_packages})
718                         unset(__boost_packages)
719                         if(Boost_USE_STATIC_LIBS AND WITH_BOOST_ICU)
720                                 find_package(IcuLinux)
721                         endif()
722                         mark_as_advanced(Boost_DIR)  # why doesnt boost do this?
723                 endif()
724
725                 set(BOOST_INCLUDE_DIR ${Boost_INCLUDE_DIRS})
726                 set(BOOST_LIBRARIES ${Boost_LIBRARIES})
727                 set(BOOST_LIBPATH ${Boost_LIBRARY_DIRS})
728                 set(BOOST_DEFINITIONS "-DBOOST_ALL_NO_LIB")
729         endif()
730
731         if(WITH_OPENIMAGEIO)
732                 find_package_wrapper(OpenImageIO)
733
734                 set(OPENIMAGEIO_LIBRARIES ${OPENIMAGEIO_LIBRARIES} ${PNG_LIBRARIES} ${JPEG_LIBRARIES} ${ZLIB_LIBRARIES} ${BOOST_LIBRARIES})
735                 set(OPENIMAGEIO_LIBPATH)  # TODO, remove and reference the absolute path everywhere
736                 set(OPENIMAGEIO_DEFINITIONS "")
737
738                 if(WITH_IMAGE_TIFF)
739                         list(APPEND OPENIMAGEIO_LIBRARIES "${TIFF_LIBRARY}")
740                 endif()
741                 if(WITH_IMAGE_OPENEXR)
742                         list(APPEND OPENIMAGEIO_LIBRARIES "${OPENEXR_LIBRARIES}")
743                 endif()
744
745                 if(NOT OPENIMAGEIO_FOUND)
746                         set(WITH_OPENIMAGEIO OFF)
747                         message(STATUS "OpenImageIO not found, disabling WITH_CYCLES")
748                 endif()
749         endif()
750
751         if(WITH_OPENCOLORIO)
752                 find_package_wrapper(OpenColorIO)
753
754                 set(OPENCOLORIO_LIBRARIES ${OPENCOLORIO_LIBRARIES})
755                 set(OPENCOLORIO_LIBPATH)  # TODO, remove and reference the absolute path everywhere
756                 set(OPENCOLORIO_DEFINITIONS)
757
758                 if(NOT OPENCOLORIO_FOUND)
759                         set(WITH_OPENCOLORIO OFF)
760                         message(STATUS "OpenColorIO not found")
761                 endif()
762         endif()
763
764         # XXX Maybe most of this section should go into an llvm module?
765         if(WITH_LLVM)
766                 # Set llvm version if not specified
767                 if(NOT LLVM_VERSION)
768                         set(LLVM_VERSION "3.0")
769                 endif()
770
771                 if(LLVM_DIRECTORY)
772                         FIND_PROGRAM(LLVM_CONFIG llvm-config-${LLVM_VERSION} HINTS ${LLVM_DIRECTORY}/bin NO_CMAKE_PATH)
773                         if(NOT LLVM_CONFIG)
774                                 FIND_PROGRAM(LLVM_CONFIG llvm-config HINTS ${LLVM_DIRECTORY}/bin NO_CMAKE_PATH)
775                         endif()
776                 else()
777                         FIND_PROGRAM(LLVM_CONFIG llvm-config-${LLVM_VERSION})
778                         if(NOT LLVM_CONFIG)
779                                 FIND_PROGRAM(LLVM_CONFIG llvm-config)
780                         endif()
781                 endif()
782                 execute_process(COMMAND ${LLVM_CONFIG} --version
783                                 OUTPUT_VARIABLE LLVM_VERSION
784                                 OUTPUT_STRIP_TRAILING_WHITESPACE)
785                 execute_process(COMMAND ${LLVM_CONFIG} --prefix
786                                 OUTPUT_VARIABLE LLVM_DIRECTORY
787                                 OUTPUT_STRIP_TRAILING_WHITESPACE)
788                 execute_process(COMMAND ${LLVM_CONFIG} --libdir
789                                 OUTPUT_VARIABLE LLVM_LIB_DIR
790                                 OUTPUT_STRIP_TRAILING_WHITESPACE)
791
792                 if(LLVM_STATIC)
793                         find_library(LLVM_LIBRARY
794                                      NAMES LLVMAnalysis # first of a whole bunch of libs to get
795                                      PATHS ${LLVM_LIB_DIR})
796                 else()
797                         find_library(LLVM_LIBRARY
798                                      NAMES LLVM-${LLVM_VERSION}
799                                      PATHS ${LLVM_LIB_DIR})
800                 endif()
801
802                 message(STATUS "LLVM version  = ${LLVM_VERSION}")
803                 message(STATUS "LLVM dir      = ${LLVM_DIRECTORY}")
804                 message(STATUS "LLVM lib dir  = ${LLVM_LIB_DIR}")
805                 set(LLVM_VERSION ${LLVM_VERSION} CACHE STRING "Version of LLVM to use")
806                 set(LLVM_DIRECTORY ${LLVM_DIRECTORY} CACHE PATH "Path to the LLVM installation")
807
808                 if(LLVM_LIBRARY AND LLVM_DIRECTORY AND LLVM_LIB_DIR)
809                         if(LLVM_STATIC)
810                                 # if static LLVM libraries were requested, use llvm-config to generate
811                                 # the list of what libraries we need, and substitute that in the right
812                                 # way for LLVM_LIBRARY.
813                                 execute_process(COMMAND ${LLVM_CONFIG} --libfiles
814                                                 OUTPUT_VARIABLE LLVM_LIBRARY
815                                                 OUTPUT_STRIP_TRAILING_WHITESPACE)
816                                 string(REPLACE " " ";" LLVM_LIBRARY ${LLVM_LIBRARY})
817                         endif()
818                 else()
819                         message(FATAL_ERROR "LLVM not found.")
820                 endif()
821
822                 # Fix for conflict with Mesa llvmpipe
823                 set(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} -Wl,--version-script=${CMAKE_SOURCE_DIR}/source/creator/blender.map")
824         endif()
825
826         if(WITH_CYCLES_OSL)
827                 set(CYCLES_OSL ${LIBDIR}/osl CACHE PATH "Path to OpenShadingLanguage installation")
828         
829                 message(STATUS "CYCLES_OSL = ${CYCLES_OSL}")
830         
831                 find_library(OSL_LIB_EXEC NAMES oslexec PATHS ${CYCLES_OSL}/lib)
832                 find_library(OSL_LIB_COMP NAMES oslcomp PATHS ${CYCLES_OSL}/lib)
833                 find_library(OSL_LIB_QUERY NAMES oslquery PATHS ${CYCLES_OSL}/lib)
834                 # Note: --whole-archive is needed to force loading of all symbols in liboslexec,
835                 # otherwise LLVM is missing the osl_allocate_closure_component function
836                 list(APPEND OSL_LIBRARIES ${OSL_LIB_COMP} -Wl,--whole-archive ${OSL_LIB_EXEC} -Wl,--no-whole-archive ${OSL_LIB_QUERY})
837                 find_path(OSL_INCLUDES OSL/oslclosure.h PATHS ${CYCLES_OSL}/include)
838                 find_program(OSL_COMPILER NAMES oslc PATHS ${CYCLES_OSL}/bin)
839         
840                 if(OSL_INCLUDES AND OSL_LIBRARIES AND OSL_COMPILER)
841                         set(OSL_FOUND TRUE)
842                         message(STATUS "OSL includes = ${OSL_INCLUDES}")
843                         message(STATUS "OSL library = ${OSL_LIBRARIES}")
844                         message(STATUS "OSL compiler = ${OSL_COMPILER}")
845                 else()
846                         message(STATUS "OSL not found")
847                 endif()
848         endif()
849
850         # OpenSuse needs lutil, ArchLinux not, for now keep, can avoid by using --as-needed
851         set(PLATFORM_LINKLIBS "-lutil -lc -lm -lpthread -lstdc++")
852
853         if((NOT WITH_HEADLESS) AND (NOT WITH_GHOST_SDL))
854                 find_package(X11 REQUIRED)
855                 find_path(X11_XF86keysym_INCLUDE_PATH X11/XF86keysym.h ${X11_INC_SEARCH_PATH})
856                 mark_as_advanced(X11_XF86keysym_INCLUDE_PATH)
857
858                 set(PLATFORM_LINKLIBS "${PLATFORM_LINKLIBS} ${X11_X11_LIB}")
859
860                 if(WITH_X11_XINPUT)
861                         if(X11_Xinput_LIB)
862                                 set(PLATFORM_LINKLIBS "${PLATFORM_LINKLIBS} ${X11_Xinput_LIB}")
863                         else()
864                                 set(WITH_X11_XINPUT OFF)
865                         endif()
866                 endif()
867
868                 if(WITH_X11_XF86VMODE)
869                         # XXX, why dont cmake make this available?
870                         FIND_LIBRARY(X11_Xxf86vmode_LIB Xxf86vm   ${X11_LIB_SEARCH_PATH})
871                         mark_as_advanced(X11_Xxf86vmode_LIB)
872                         if(X11_Xxf86vmode_LIB)
873                                 set(PLATFORM_LINKLIBS "${PLATFORM_LINKLIBS} ${X11_Xxf86vmode_LIB}")
874                         else()
875                                 set(WITH_X11_XF86VMODE OFF)
876                         endif()
877                 endif()
878         endif()
879
880         if(CMAKE_SYSTEM_NAME MATCHES "Linux")
881                 if(NOT WITH_PYTHON_MODULE)
882                         # BSD's dont use libdl.so
883                 set(PLATFORM_LINKLIBS "${PLATFORM_LINKLIBS} -ldl")
884                         # binreloc is linux only
885                         set(BINRELOC_INCLUDE_DIRS ${CMAKE_SOURCE_DIR}/extern/binreloc/include)
886                         set(WITH_BINRELOC ON)
887                 endif()
888         endif()
889
890         set(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} -pthread")
891
892         # lfs on glibc, all compilers should use
893         add_definitions(-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE)
894
895         # GNU Compiler
896         if(CMAKE_COMPILER_IS_GNUCC)
897                 set(PLATFORM_CFLAGS "-pipe -fPIC -funsigned-char -fno-strict-aliasing")
898         # CLang is the same as GCC for now.
899         elseif(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
900                 set(PLATFORM_CFLAGS "-pipe -fPIC -funsigned-char -fno-strict-aliasing")
901         # Solaris CC
902         elseif(CMAKE_CXX_COMPILER_ID MATCHES "SunPro")
903                 set(PLATFORM_CFLAGS "-pipe -features=extensions -fPIC -D__FUNCTION__=__func__")
904                 
905         # Intel C++ Compiler
906         elseif(CMAKE_C_COMPILER_ID MATCHES "Intel")
907                 # think these next two are broken
908                 find_program(XIAR xiar)
909                 if(XIAR)
910                         set(CMAKE_AR "${XIAR}")
911                 endif()
912                 mark_as_advanced(XIAR)
913
914                 find_program(XILD xild)
915                 if(XILD)
916                         set(CMAKE_LINKER "${XILD}")
917                 endif()
918                 mark_as_advanced(XILD)
919
920                 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fp-model precise -prec_div -parallel")
921                 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fp-model precise -prec_div -parallel")
922
923                 # set(PLATFORM_CFLAGS "${PLATFORM_CFLAGS} -diag-enable sc3")
924                 set(PLATFORM_CFLAGS "-pipe -fPIC -funsigned-char -fno-strict-aliasing")
925                 set(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} -static-intel")
926         endif()
927
928 elseif(WIN32)
929
930         # this file is included anyway when building under Windows with cl.exe
931         #  include(${CMAKE_ROOT}/Modules/Platform/Windows-cl.cmake)
932
933         if(CMAKE_COMPILER_IS_GNUCC)
934                 set(LIBDIR ${CMAKE_SOURCE_DIR}/../lib/mingw32)
935                 include(CheckCSourceCompiles)
936                 # Setup 64bit and 64bit windows systems
937                 CHECK_C_SOURCE_COMPILES("
938                         #ifndef __MINGW64__
939                         #error
940                         #endif
941                         main(){}
942                         " 
943                         WITH_MINGW64)
944                 
945                 if(WITH_MINGW64)
946                         message(STATUS "Compiling for 64 bit with MinGW-w64.")
947                         set(LIBDIR ${CMAKE_SOURCE_DIR}/../lib/mingw64)
948                 endif()
949         else()
950                 # Setup 64bit and 64bit windows systems
951                 if(CMAKE_CL_64)
952                         message(STATUS "64 bit compiler detected.")
953                         if(MSVC11)
954                                 message(STATUS "Visual C++ 2012 detected.")
955                                 set(LIBDIR ${CMAKE_SOURCE_DIR}/../lib/win64_vc11)
956                         else()
957                                 set(LIBDIR ${CMAKE_SOURCE_DIR}/../lib/win64)
958                         endif()
959                 else()
960                 # Setup 32bit windows systems
961                         if(MSVC11)
962                                 message(STATUS "Visual C++ 2012 detected.")
963                                 set(LIBDIR ${CMAKE_SOURCE_DIR}/../lib/windows_vc11)
964                         else()
965                                 set(LIBDIR ${CMAKE_SOURCE_DIR}/../lib/windows)
966                         endif()
967                 endif()
968         endif()
969                 
970         add_definitions(-DWIN32)
971
972         set(JPEG "${LIBDIR}/jpeg")
973         set(JPEG_INCLUDE_DIR "${JPEG}/include")
974         set(JPEG_LIBPATH ${JPEG}/lib) # not cmake defined
975
976         set(WINTAB_INC ${LIBDIR}/wintab/include)
977
978         if(WITH_OPENAL)
979                 set(OPENAL ${LIBDIR}/openal)
980                 set(OPENAL_INCLUDE_DIR ${OPENAL}/include)
981                 if(MSVC11)
982                         set(OPENAL_LIBRARY openal32)
983                 else()
984                         set(OPENAL_LIBRARY wrap_oal)
985                 endif()
986                 set(OPENAL_LIBPATH ${OPENAL}/lib)
987         endif()
988
989         if(WITH_CODEC_SNDFILE)
990                 set(SNDFILE ${LIBDIR}/sndfile)
991                 set(SNDFILE_INCLUDE_DIRS ${SNDFILE}/include)
992                 set(SNDFILE_LIBRARIES libsndfile-1)
993                 set(SNDFILE_LIBPATH ${SNDFILE}/lib) # TODO, deprecate
994         endif()
995
996         if(WITH_SDL)
997                 set(SDL ${LIBDIR}/sdl)
998                 set(SDL_INCLUDE_DIR ${SDL}/include)
999                 set(SDL_LIBRARY SDL)
1000                 set(SDL_LIBPATH ${SDL}/lib)
1001         endif()
1002
1003         if(WITH_CODEC_QUICKTIME)
1004                 set(QUICKTIME ${LIBDIR}/QTDevWin)
1005                 set(QUICKTIME_INCLUDE_DIRS ${QUICKTIME}/CIncludes)
1006                 set(QUICKTIME_LIBRARIES qtmlClient)
1007                 set(QUICKTIME_LIBPATH ${QUICKTIME}/Libraries)
1008         endif()
1009
1010         if(WITH_RAYOPTIMIZATION AND SUPPORT_SSE_BUILD)
1011                 add_definitions(-D__SSE__ -D__MMX__)
1012         endif()
1013
1014         if(WITH_CYCLES_OSL)
1015                 set(CYCLES_OSL ${LIBDIR}/osl CACHE PATH "Path to OpenShadingLanguage installation")
1016         
1017                 find_library(OSL_LIB_EXEC NAMES oslexec PATHS ${CYCLES_OSL}/lib)
1018                 find_library(OSL_LIB_COMP NAMES oslcomp PATHS ${CYCLES_OSL}/lib)
1019                 find_library(OSL_LIB_QUERY NAMES oslquery PATHS ${CYCLES_OSL}/lib)
1020                 list(APPEND OSL_LIBRARIES ${OSL_LIB_COMP} ${OSL_LIB_EXEC} ${OSL_LIB_QUERY})
1021                 find_path(OSL_INCLUDES OSL/oslclosure.h PATHS ${CYCLES_OSL}/include)
1022                 find_program(OSL_COMPILER NAMES oslc PATHS ${CYCLES_OSL}/bin)
1023         
1024                 if(OSL_INCLUDES AND OSL_LIBRARIES AND OSL_COMPILER)
1025                         set(OSL_FOUND TRUE)
1026                 else()
1027                         message(STATUS "OSL not found")
1028                 endif()
1029         endif()
1030
1031         if(MSVC)
1032                 set(PLATFORM_LINKLIBS ws2_32 vfw32 winmm kernel32 user32 gdi32 comdlg32 advapi32 shfolder shell32 ole32 oleaut32 uuid psapi)
1033
1034                 # MSVC11 SDL is not hard linked to dxguid.lib
1035                 if(MSVC11 AND WITH_SDL)
1036                         set(PLATFORM_LINKLIBS ${PLATFORM_LINKLIBS} dxguid)
1037                 endif()
1038
1039                 add_definitions(/D_CRT_NONSTDC_NO_DEPRECATE /D_CRT_SECURE_NO_DEPRECATE /D_SCL_SECURE_NO_DEPRECATE /D_CONSOLE /D_LIB)
1040
1041                 # MSVC11 needs _ALLOW_KEYWORD_MACROS to build
1042                 if(MSVC11)
1043                         add_definitions(/D_ALLOW_KEYWORD_MACROS)
1044                 endif()
1045
1046                 set(CMAKE_CXX_FLAGS "/nologo /J /Gd /EHsc" CACHE STRING "MSVC MT C++ flags " FORCE)
1047                 set(CMAKE_C_FLAGS   "/nologo /J /Gd"       CACHE STRING "MSVC MT C++ flags " FORCE)
1048
1049                 if(CMAKE_CL_64)
1050                         set(CMAKE_CXX_FLAGS_DEBUG "/Od /Gm /RTC1 /MTd /Zi" CACHE STRING "MSVC MT flags " FORCE)
1051                 else()
1052                         set(CMAKE_CXX_FLAGS_DEBUG "/Od /Gm /RTC1 /MTd /ZI" CACHE STRING "MSVC MT flags " FORCE)
1053                 endif()
1054                 set(CMAKE_CXX_FLAGS_RELEASE "/O2 /Ob2 /MT" CACHE STRING "MSVC MT flags " FORCE)
1055                 set(CMAKE_CXX_FLAGS_MINSIZEREL "/O1 /Ob1 /MT" CACHE STRING "MSVC MT flags " FORCE)
1056                 set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "/O2 /Ob1 /MT /Zi" CACHE STRING "MSVC MT flags " FORCE)
1057                 if(CMAKE_CL_64)
1058                         set(CMAKE_C_FLAGS_DEBUG "/Od /Gm /RTC1 /MTd /Zi" CACHE STRING "MSVC MT flags " FORCE)
1059                 else()
1060                         set(CMAKE_C_FLAGS_DEBUG "/Od /Gm /RTC1 /MTd /ZI" CACHE STRING "MSVC MT flags " FORCE)
1061                 endif()
1062                 set(CMAKE_C_FLAGS_RELEASE "/O2 /Ob2 /MT" CACHE STRING "MSVC MT flags " FORCE)
1063                 set(CMAKE_C_FLAGS_MINSIZEREL "/O1 /Ob1 /MT" CACHE STRING "MSVC MT flags " FORCE)
1064                 set(CMAKE_C_FLAGS_RELWITHDEBINFO "/O2 /Ob1 /MT /Zi" CACHE STRING "MSVC MT flags " FORCE)
1065
1066                 # most msvc warnings are C & C++
1067                 set(_WARNINGS "/W3 /wd4018 /wd4244 /wd4305 /wd4800 /wd4181 /wd4065 /wd4267 /we4013 /wd4200")
1068                 set(C_WARNINGS "${_WARNINGS}")
1069                 set(CXX_WARNINGS "${_WARNINGS}")
1070                 unset(_WARNINGS)
1071
1072                 if(WITH_MOD_CLOTH_ELTOPO)
1073                         set(LAPACK ${LIBDIR}/lapack)
1074                         # set(LAPACK_INCLUDE_DIR ${LAPACK}/include)
1075                         set(LAPACK_LIBPATH ${LAPACK}/lib)
1076                         set(LAPACK_LIBRARIES
1077                                 ${LIBDIR}/lapack/lib/libf2c.lib
1078                                 ${LIBDIR}/lapack/lib/clapack_nowrap.lib
1079                                 ${LIBDIR}/lapack/lib/BLAS_nowrap.lib
1080                         )
1081                 endif()
1082
1083                 set(PNG_LIBRARIES libpng)
1084                 set(JPEG_LIBRARIES libjpeg)
1085                 
1086                 set(PNG "${LIBDIR}/png")
1087                 set(PNG_INCLUDE_DIR "${PNG}/include")
1088                 set(PNG_LIBPATH ${PNG}/lib) # not cmake defined
1089
1090                 set(ZLIB_INCLUDE_DIRS ${LIBDIR}/zlib/include)
1091                 set(ZLIB_LIBRARIES ${LIBDIR}/zlib/lib/libz_st.lib)
1092
1093                 set(PTHREADS_INCLUDE_DIRS ${LIBDIR}/pthreads/include)
1094                 set(PTHREADS_LIBRARIES ${LIBDIR}/pthreads/lib/pthreadVC2.lib)
1095
1096                 set(FREETYPE ${LIBDIR}/freetype)
1097                 set(FREETYPE_INCLUDE_DIRS
1098                         ${LIBDIR}/freetype/include
1099                         ${LIBDIR}/freetype/include/freetype2
1100                 )
1101                 set(FREETYPE_LIBRARY ${LIBDIR}/freetype/lib/freetype2ST.lib)
1102
1103                 if(WITH_FFTW3)
1104                         set(FFTW3 ${LIBDIR}/fftw3)
1105                         set(FFTW3_LIBRARIES libfftw)
1106                         set(FFTW3_INCLUDE_DIRS ${FFTW3}/include)
1107                         set(FFTW3_LIBPATH ${FFTW3}/lib)
1108                 endif()
1109
1110                 if(WITH_OPENCOLLADA)
1111                         set(OPENCOLLADA ${LIBDIR}/opencollada)
1112
1113                         set(OPENCOLLADA_INCLUDE_DIRS
1114                                 ${OPENCOLLADA}/include/opencollada/COLLADAStreamWriter
1115                                 ${OPENCOLLADA}/include/opencollada/COLLADABaseUtils
1116                                 ${OPENCOLLADA}/include/opencollada/COLLADAFramework
1117                                 ${OPENCOLLADA}/include/opencollada/COLLADASaxFrameworkLoader
1118                                 ${OPENCOLLADA}/include/opencollada/GeneratedSaxParser
1119                         )
1120                         set_lib_path(OPENCOLLADA_LIBPATH "opencollada")
1121
1122                         set(OPENCOLLADA_LIBRARIES
1123                                 ${OPENCOLLADA_LIBPATH}/lib/opencollada/OpenCOLLADASaxFrameworkLoader.lib
1124                                 ${OPENCOLLADA_LIBPATH}/lib/opencollada/OpenCOLLADAFramework.lib
1125                                 ${OPENCOLLADA_LIBPATH}/lib/opencollada/OpenCOLLADABaseUtils.lib
1126                                 ${OPENCOLLADA_LIBPATH}/lib/opencollada/OpenCOLLADAStreamWriter.lib
1127                                 ${OPENCOLLADA_LIBPATH}/lib/opencollada/MathMLSolver.lib
1128                                 ${OPENCOLLADA_LIBPATH}/lib/opencollada/GeneratedSaxParser.lib
1129                                 ${OPENCOLLADA_LIBPATH}/lib/opencollada/xml.lib
1130                                 ${OPENCOLLADA_LIBPATH}/lib/opencollada/buffer.lib
1131                                 ${OPENCOLLADA_LIBPATH}/lib/opencollada/ftoa.lib
1132                                 ${OPENCOLLADA_LIBPATH}/lib/opencollada/UTF.lib
1133                         )
1134                         set(PCRE_LIBRARIES
1135                                 ${OPENCOLLADA_LIBPATH}/lib/opencollada/pcre.lib
1136                         )
1137                         
1138                         unset(OPENCOLLADA_LIBPATH)
1139                         
1140                 endif()
1141
1142                 if(WITH_CODEC_FFMPEG)
1143                         set(FFMPEG_INCLUDE_DIRS
1144                                 ${LIBDIR}/ffmpeg/include
1145                                 ${LIBDIR}/ffmpeg/include/msvc
1146                         )
1147                         # MSVC11 FFMPEG libs are newer
1148                         if(MSVC11)
1149                                 set(FFMPEG_LIBRARIES
1150                                         ${LIBDIR}/ffmpeg/lib/avcodec-54.lib
1151                                         ${LIBDIR}/ffmpeg/lib/avformat-54.lib
1152                                         ${LIBDIR}/ffmpeg/lib/avdevice-54.lib
1153                                         ${LIBDIR}/ffmpeg/lib/avutil-52.lib
1154                                         ${LIBDIR}/ffmpeg/lib/swscale-2.lib
1155                                 )
1156                         else()
1157                                 set(FFMPEG_LIBRARIES
1158                                         ${LIBDIR}/ffmpeg/lib/avcodec-53.lib
1159                                         ${LIBDIR}/ffmpeg/lib/avformat-53.lib
1160                                         ${LIBDIR}/ffmpeg/lib/avdevice-53.lib
1161                                         ${LIBDIR}/ffmpeg/lib/avutil-51.lib
1162                                         ${LIBDIR}/ffmpeg/lib/swscale-2.lib
1163                                 )
1164                         endif()
1165                 endif()
1166
1167                 if(WITH_IMAGE_OPENEXR)
1168                         set_lib_path(OPENEXR "openexr")
1169                         set(OPENEXR_INCLUDE_DIR ${OPENEXR}/include)
1170                         set(OPENEXR_INCLUDE_DIRS ${OPENEXR}/include/OpenEXR)
1171                         set(OPENEXR_LIBPATH ${OPENEXR}/lib)
1172                         set(OPENEXR_LIBRARIES
1173                                 ${OPENEXR_LIBPATH}/Iex.lib
1174                                 ${OPENEXR_LIBPATH}/Half.lib
1175                                 ${OPENEXR_LIBPATH}/IlmImf.lib
1176                                 ${OPENEXR_LIBPATH}/Imath.lib
1177                                 ${OPENEXR_LIBPATH}/IlmThread.lib
1178                         )
1179                 endif()
1180
1181                 if(WITH_IMAGE_TIFF)
1182                         set(TIFF_LIBRARY ${LIBDIR}/tiff/lib/libtiff.lib)
1183                         set(TIFF_INCLUDE_DIR ${LIBDIR}/tiff/include)
1184                 endif()
1185
1186                 if(WITH_JACK)
1187                         set(JACK_INCLUDE_DIRS
1188                                 ${LIBDIR}/jack/include/jack
1189                                 ${LIBDIR}/jack/include
1190                         )
1191                         set(JACK_LIBRARIES ${LIBDIR}/jack/lib/libjack.lib)
1192                 endif()
1193
1194                 if(WITH_PYTHON)
1195                         # normally cached but not since we include them with blender
1196                         if(MSVC10)
1197                                 set(PYTHON_VERSION 3.3) # CACHE STRING)
1198                         else()
1199                                 set(PYTHON_VERSION 3.3) # CACHE STRING)
1200                         endif()
1201
1202                         set_lib_path(PYTHON "python")
1203                         string(REPLACE "." "" _PYTHON_VERSION_NO_DOTS ${PYTHON_VERSION})
1204                         # Use shared libs for vc2008 and vc2010 until we actually have vc2010 libs
1205                         set(PYTHON_LIBRARY ${LIBDIR}/python/lib/python${_PYTHON_VERSION_NO_DOTS}.lib)
1206                         # set(PYTHON_LIBRARY ${PYTHON}/lib/python${_PYTHON_VERSION_NO_DOTS}.lib) #CACHE FILEPATH
1207                         unset(_PYTHON_VERSION_NO_DOTS)
1208
1209                         # Shared includes for both vc2008 and vc2010
1210                         set(PYTHON_INCLUDE_DIR ${LIBDIR}/python/include/python${PYTHON_VERSION})
1211
1212                         # uncached vars
1213                         set(PYTHON_INCLUDE_DIRS "${PYTHON_INCLUDE_DIR}")
1214                         set(PYTHON_LIBRARIES  "${PYTHON_LIBRARY}")
1215                 endif()
1216
1217                 if(WITH_BOOST)
1218                         set(BOOST ${LIBDIR}/boost)
1219                         set(BOOST_INCLUDE_DIR ${BOOST}/include)
1220                         if(MSVC11)
1221                                 set(BOOST_LIBPATH ${BOOST}/lib)
1222                                 set(BOOST_POSTFIX "vc110-mt-s-1_53.lib")
1223                                 set(BOOST_DEBUG_POSTFIX "vc110-mt-sgd-1_53.lib")
1224                         elseif(MSVC10)
1225                                 set(BOOST_LIBPATH ${BOOST}/vc2010/lib)
1226                                 set(BOOST_POSTFIX "vc100-mt-s-1_49.lib")
1227                                 set(BOOST_DEBUG_POSTFIX "vc100-mt-sgd-1_49.lib")
1228                         else()
1229                                 set(BOOST_LIBPATH ${BOOST}/lib)
1230                                 set(BOOST_POSTFIX "vc90-mt-s-1_49.lib")
1231                                 set(BOOST_DEBUG_POSTFIX "vc90-mt-sgd-1_49.lib")
1232                         endif()
1233                         set(BOOST_LIBRARIES
1234                                 optimized libboost_date_time-${BOOST_POSTFIX} optimized libboost_filesystem-${BOOST_POSTFIX}
1235                                 optimized libboost_regex-${BOOST_POSTFIX}
1236                                 optimized libboost_system-${BOOST_POSTFIX} optimized libboost_thread-${BOOST_POSTFIX}
1237                                 debug libboost_date_time-${BOOST_DEBUG_POSTFIX} debug libboost_filesystem-${BOOST_DEBUG_POSTFIX}
1238                                 debug libboost_regex-${BOOST_DEBUG_POSTFIX}
1239                                 debug libboost_system-${BOOST_DEBUG_POSTFIX} debug libboost_thread-${BOOST_DEBUG_POSTFIX})
1240                         if(WITH_CYCLES_OSL)
1241                                 set(BOOST_LIBRARIES ${BOOST_LIBRARIES}
1242                                         optimized libboost_wave-${BOOST_POSTFIX}
1243                                         debug libboost_wave-${BOOST_DEBUG_POSTFIX})
1244                         endif()
1245                         if(WITH_INTERNATIONAL)
1246                                 set(BOOST_LIBRARIES ${BOOST_LIBRARIES}
1247                                         optimized libboost_locale-${BOOST_POSTFIX}
1248                                         debug libboost_locale-${BOOST_DEBUG_POSTFIX})
1249                         endif()
1250                         set(BOOST_DEFINITIONS "-DBOOST_ALL_NO_LIB")
1251                 endif()
1252                         
1253                 if(WITH_OPENIMAGEIO)
1254                         set(OPENIMAGEIO ${LIBDIR}/openimageio)
1255                         set(OPENIMAGEIO_INCLUDE_DIRS ${OPENIMAGEIO}/include)
1256                         set(OPENIMAGEIO_LIBRARIES optimized OpenImageIO debug OpenImageIO_d)
1257                         set(OPENIMAGEIO_LIBPATH ${OPENIMAGEIO}/lib)
1258                         set(OPENIMAGEIO_DEFINITIONS "-DUSE_TBB=0")
1259                 endif()
1260
1261                 if(WITH_LLVM)
1262                         set(LLVM_DIRECTORY ${LIBDIR}/llvm CACHE PATH    "Path to the LLVM installation")
1263                         file(GLOB LLVM_LIBRARY ${LLVM_DIRECTORY}/lib/*.lib)
1264                 endif()
1265         
1266                 if(WITH_OPENCOLORIO)
1267                         set(OPENCOLORIO ${LIBDIR}/opencolorio)
1268                         set(OPENCOLORIO_INCLUDE_DIRS ${OPENCOLORIO}/include)
1269                         set(OPENCOLORIO_LIBRARIES OpenColorIO)
1270                         set(OPENCOLORIO_LIBPATH ${LIBDIR}/opencolorio/lib)
1271                         set(OPENCOLORIO_DEFINITIONS)
1272                 endif()
1273
1274                 set(PLATFORM_LINKFLAGS "/SUBSYSTEM:CONSOLE /STACK:2097152 /INCREMENTAL:NO /NODEFAULTLIB:msvcrt.lib /NODEFAULTLIB:msvcmrt.lib /NODEFAULTLIB:msvcurt.lib /NODEFAULTLIB:msvcrtd.lib")
1275
1276                 # MSVC only, Mingw doesnt need
1277                 if(CMAKE_CL_64)
1278                         set(PLATFORM_LINKFLAGS "/MACHINE:X64 /OPT:NOREF ${PLATFORM_LINKFLAGS}")
1279                 else()
1280                         set(PLATFORM_LINKFLAGS "/MACHINE:IX86 /LARGEADDRESSAWARE ${PLATFORM_LINKFLAGS}")
1281                 endif()
1282
1283                 set(PLATFORM_LINKFLAGS_DEBUG "/NODEFAULTLIB:libcmt.lib /NODEFAULTLIB:libc.lib")
1284
1285                 # used in many places so include globally, like OpenGL
1286                 blender_include_dirs_sys("${PTHREADS_INCLUDE_DIRS}")
1287
1288         elseif(CMAKE_COMPILER_IS_GNUCC)
1289         # keep GCC specific stuff here
1290                 set(PLATFORM_LINKLIBS "-lshell32 -lshfolder -lgdi32 -lmsvcrt -lwinmm -lmingw32 -lm -lws2_32 -lz -lstdc++ -lole32 -luuid -lwsock32 -lpsapi")
1291                 set(PLATFORM_CFLAGS "-pipe -funsigned-char -fno-strict-aliasing")
1292
1293                 if(WITH_MINGW64)
1294                         set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fpermissive")
1295                         set(PLATFORM_LINKLIBS "${PLATFORM_LINKLIBS} -lpthread")
1296                         
1297                         add_definitions(-DFREE_WINDOWS64 -DMS_WIN64)
1298                         # Turn off OpenMP since it causes crashes on render for subsurfed/multiresolution meshes
1299                         set(WITH_OPENMP OFF)
1300                 endif()
1301
1302                 add_definitions(-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE)
1303
1304                 add_definitions(-DFREE_WINDOWS)
1305
1306                 set(PNG "${LIBDIR}/png")
1307                 set(PNG_INCLUDE_DIR "${PNG}/include")
1308                 set(PNG_LIBPATH ${PNG}/lib) # not cmake defined
1309
1310                 if(WITH_MINGW64)
1311                         set(JPEG_LIBRARIES jpeg)
1312                 else()
1313                         set(JPEG_LIBRARIES libjpeg)
1314                 endif()
1315                 set(PNG_LIBRARIES png)
1316
1317                 set(ZLIB ${LIBDIR}/zlib)
1318                 set(ZLIB_INCLUDE_DIRS ${ZLIB}/include)
1319                 set(ZLIB_LIBPATH ${ZLIB}/lib)
1320                 set(ZLIB_LIBRARIES z)
1321
1322                 # comes with own pthread library
1323                 if(NOT WITH_MINGW64)
1324                         set(PTHREADS ${LIBDIR}/pthreads)
1325                         #set(PTHREADS_INCLUDE_DIRS ${PTHREADS}/include)
1326                         set(PTHREADS_LIBPATH ${PTHREADS}/lib)
1327                         set(PTHREADS_LIBRARIES pthreadGC2)
1328                 endif()
1329                 
1330                 set(FREETYPE ${LIBDIR}/freetype)
1331                 set(FREETYPE_INCLUDE_DIRS ${FREETYPE}/include ${FREETYPE}/include/freetype2)
1332                 set(FREETYPE_LIBPATH ${FREETYPE}/lib)
1333                 set(FREETYPE_LIBRARY freetype)
1334
1335                 if(WITH_FFTW3)
1336                         set(FFTW3 ${LIBDIR}/fftw3)
1337                         set(FFTW3_LIBRARIES fftw3)
1338                         set(FFTW3_INCLUDE_DIRS ${FFTW3}/include)
1339                         set(FFTW3_LIBPATH ${FFTW3}/lib)
1340                 endif()
1341
1342                 if(WITH_OPENCOLLADA)
1343                         set(OPENCOLLADA ${LIBDIR}/opencollada)
1344                         set(OPENCOLLADA_INCLUDE_DIRS
1345                                 ${OPENCOLLADA}/include/opencollada/COLLADAStreamWriter
1346                                 ${OPENCOLLADA}/include/opencollada/COLLADABaseUtils
1347                                 ${OPENCOLLADA}/include/opencollada/COLLADAFramework
1348                                 ${OPENCOLLADA}/include/opencollada/COLLADASaxFrameworkLoader
1349                                 ${OPENCOLLADA}/include/opencollada/GeneratedSaxParser
1350                         )
1351                         set(OPENCOLLADA_LIBPATH ${OPENCOLLADA}/lib/opencollada)
1352                         set(OPENCOLLADA_LIBRARIES OpenCOLLADAStreamWriter OpenCOLLADASaxFrameworkLoader OpenCOLLADAFramework OpenCOLLADABaseUtils GeneratedSaxParser UTF MathMLSolver buffer ftoa xml)
1353                         set(PCRE_LIBRARIES pcre)
1354                 endif()
1355
1356                 if(WITH_CODEC_FFMPEG)
1357                         set(FFMPEG ${LIBDIR}/ffmpeg)
1358                         set(FFMPEG_INCLUDE_DIRS ${FFMPEG}/include)
1359                         if(WITH_MINGW64)
1360                                 set(FFMPEG_LIBRARIES avcodec.dll avformat.dll avdevice.dll avutil.dll swscale.dll swresample.dll)
1361                         else()
1362                                 set(FFMPEG_LIBRARIES avcodec-53 avformat-53 avdevice-53 avutil-51 swscale-2)
1363                         endif()
1364                         set(FFMPEG_LIBPATH ${FFMPEG}/lib)
1365                 endif()
1366
1367                 if(WITH_IMAGE_OPENEXR)
1368                         set(OPENEXR ${LIBDIR}/openexr)
1369                         set(OPENEXR_INCLUDE_DIR ${OPENEXR}/include)
1370                         set(OPENEXR_INCLUDE_DIRS ${OPENEXR}/include/OpenEXR)
1371                         set(OPENEXR_LIBRARIES Half IlmImf Imath IlmThread Iex)
1372                         set(OPENEXR_LIBPATH ${OPENEXR}/lib)
1373                 endif()
1374
1375                 if(WITH_IMAGE_TIFF)
1376                         set(TIFF ${LIBDIR}/tiff)
1377                         set(TIFF_LIBRARY tiff)
1378                         set(TIFF_INCLUDE_DIR ${TIFF}/include)
1379                         set(TIFF_LIBPATH ${TIFF}/lib)
1380                 endif()
1381
1382                 if(WITH_JACK)
1383                         set(JACK ${LIBDIR}/jack)
1384                         set(JACK_INCLUDE_DIRS ${JACK}/include/jack ${JACK}/include)
1385                         set(JACK_LIBRARIES jack)
1386                         set(JACK_LIBPATH ${JACK}/lib)
1387
1388                         # TODO, gives linking errors, force off
1389                         set(WITH_JACK OFF)
1390                 endif()
1391
1392                 if(WITH_PYTHON)
1393                         # normally cached but not since we include them with blender
1394                         set(PYTHON_VERSION 3.3) #  CACHE STRING)
1395                         set(PYTHON_INCLUDE_DIR "${LIBDIR}/python/include/python${PYTHON_VERSION}")  # CACHE PATH)
1396                         set(PYTHON_LIBRARY "${LIBDIR}/python/lib/python33mw.lib")  # CACHE FILEPATH)
1397
1398                         # uncached vars
1399                         set(PYTHON_INCLUDE_DIRS "${PYTHON_INCLUDE_DIR}")
1400                         set(PYTHON_LIBRARIES  "${PYTHON_LIBRARY}")
1401                 endif()
1402
1403                 if(WITH_BOOST)
1404                         set(BOOST ${LIBDIR}/boost)
1405                         set(BOOST_INCLUDE_DIR ${BOOST}/include)
1406                         if(WITH_MINGW64)
1407                                 set(BOOST_POSTFIX "mgw47-mt-s-1_49")
1408                                 set(BOOST_DEBUG_POSTFIX "mgw47-mt-sd-1_49")
1409                         else()
1410                                 set(BOOST_POSTFIX "mgw46-mt-s-1_49")
1411                                 set(BOOST_DEBUG_POSTFIX "mgw46-mt-sd-1_49")
1412                         endif()
1413                         set(BOOST_LIBRARIES
1414                                 optimized boost_date_time-${BOOST_POSTFIX} boost_filesystem-${BOOST_POSTFIX}
1415                                 boost_regex-${BOOST_POSTFIX}
1416                                 boost_system-${BOOST_POSTFIX} boost_thread-${BOOST_POSTFIX}
1417                                 debug boost_date_time-${BOOST_DEBUG_POSTFIX} boost_filesystem-${BOOST_DEBUG_POSTFIX}
1418                                 boost_regex-${BOOST_DEBUG_POSTFIX}
1419                                 boost_system-${BOOST_DEBUG_POSTFIX} boost_thread-${BOOST_DEBUG_POSTFIX})
1420                         if(WITH_INTERNATIONAL)
1421                                 set(BOOST_LIBRARIES ${BOOST_LIBRARIES}
1422                                         optimized boost_locale-${BOOST_POSTFIX}
1423                                         debug boost_locale-${BOOST_DEBUG_POSTFIX}) 
1424                         endif()
1425                         if(WITH_CYCLES_OSL)
1426                                 set(BOOST_LIBRARIES ${BOOST_LIBRARIES}
1427                                         optimized boost_wave-${BOOST_POSTFIX}
1428                                         debug boost_wave-${BOOST_DEBUG_POSTFIX}) 
1429                         endif()
1430                         set(BOOST_LIBPATH ${BOOST}/lib)
1431                         set(BOOST_DEFINITIONS "-DBOOST_ALL_NO_LIB -DBOOST_THREAD_USE_LIB ")
1432                 endif()
1433                         
1434                 if(WITH_OPENIMAGEIO)
1435                         set(OPENIMAGEIO ${LIBDIR}/openimageio)
1436                         set(OPENIMAGEIO_INCLUDE_DIRS ${OPENIMAGEIO}/include)
1437                         set(OPENIMAGEIO_LIBRARIES OpenImageIO)
1438                         set(OPENIMAGEIO_LIBPATH ${OPENIMAGEIO}/lib)
1439                         set(OPENIMAGEIO_DEFINITIONS "")
1440                 endif()
1441                 
1442                 if(WITH_LLVM)
1443                         set(LLVM_DIRECTORY ${LIBDIR}/llvm CACHE PATH    "Path to the LLVM installation")
1444                         set(LLVM_LIB_DIR ${LLVM_DIRECTORY}/lib)
1445                         # Explicitly set llvm lib order.
1446                         #---- WARNING ON GCC ORDER OF LIBS IS IMPORTANT, DO NOT CHANGE! ---------
1447                         set(LLVM_LIBRARY LLVMSelectionDAG LLVMCodeGen LLVMScalarOpts LLVMAnalysis LLVMArchive
1448                                 LLVMAsmParser LLVMAsmPrinter
1449                                 LLVMBitReader LLVMBitWriter
1450                                 LLVMDebugInfo LLVMExecutionEngine
1451                                 LLVMInstCombine LLVMInstrumentation
1452                                 LLVMInterpreter LLVMJIT
1453                                 LLVMLinker LLVMMC
1454                                 LLVMMCDisassembler LLVMMCJIT
1455                                 LLVMMCParser LLVMObject
1456                                 LLVMRuntimeDyld 
1457                                 LLVMSupport
1458                                 LLVMTableGen LLVMTarget
1459                                 LLVMTransformUtils LLVMVectorize
1460                                 LLVMX86AsmParser LLVMX86AsmPrinter
1461                                 LLVMX86CodeGen LLVMX86Desc
1462                                 LLVMX86Disassembler LLVMX86Info
1463                                 LLVMX86Utils LLVMipa
1464                                 LLVMipo LLVMCore)
1465                         # imagehelp is needed by LLVM 3.1 on MinGW, check lib\Support\Windows\Signals.inc
1466                         set(PLATFORM_LINKLIBS "${PLATFORM_LINKLIBS} -limagehlp")
1467                 endif()
1468                 
1469                 if(WITH_OPENCOLORIO)
1470                         set(OPENCOLORIO ${LIBDIR}/opencolorio)
1471                         set(OPENCOLORIO_INCLUDE_DIRS ${OPENCOLORIO}/include)
1472                         set(OPENCOLORIO_LIBRARIES OpenColorIO)
1473                         set(OPENCOLORIO_LIBPATH ${OPENCOLORIO}/lib)
1474                         set(OPENCOLORIO_DEFINITIONS)
1475                 endif()
1476
1477                 set(PLATFORM_LINKFLAGS "-Xlinker --stack=2097152")
1478
1479                 ## DISABLE - causes linking errors 
1480                 ## for re-distribution, so users dont need mingw installed
1481                 # set(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} -static-libgcc -static-libstdc++")
1482
1483         endif()
1484
1485 elseif(APPLE)
1486
1487         if(${CMAKE_OSX_DEPLOYMENT_TARGET} STREQUAL "10.5" OR ${CMAKE_OSX_DEPLOYMENT_TARGET} STRGREATER "10.5")
1488                 set(WITH_LIBS10.5 ON CACHE BOOL "Use 10.5 libs" FORCE) # valid also for 10.6/10.7
1489         endif()
1490
1491         if(WITH_LIBS10.5)
1492                 set(LIBDIR ${CMAKE_SOURCE_DIR}/../lib/darwin-9.x.universal)
1493         else()
1494                 if(CMAKE_OSX_ARCHITECTURES MATCHES i386)
1495                         set(LIBDIR ${CMAKE_SOURCE_DIR}/../lib/darwin-8.x.i386)
1496                 else()
1497                         set(LIBDIR ${CMAKE_SOURCE_DIR}/../lib/darwin-8.0.0-powerpc)
1498                 endif()
1499         endif()
1500
1501
1502         if(WITH_OPENAL)
1503                 find_package(OpenAL)
1504                 if(OPENAL_FOUND)
1505                         set(WITH_OPENAL ON)
1506                         set(OPENAL_INCLUDE_DIR "${LIBDIR}/openal/include")
1507                 else()
1508                         set(WITH_OPENAL OFF)
1509                 endif()
1510         endif()
1511
1512         if(WITH_JACK)
1513                 find_library(JACK_FRAMEWORK
1514                         NAMES jackmp
1515                 )
1516                 set(JACK_INCLUDE_DIRS ${JACK_FRAMEWORK}/headers)
1517                 if(NOT JACK_FRAMEWORK)
1518                         set(WITH_JACK OFF)
1519                 endif()
1520         endif()
1521
1522         if(WITH_CODEC_SNDFILE)
1523                 set(SNDFILE ${LIBDIR}/sndfile)
1524                 set(SNDFILE_INCLUDE_DIRS ${SNDFILE}/include)
1525                 set(SNDFILE_LIBRARIES sndfile FLAC ogg vorbis vorbisenc)
1526                 set(SNDFILE_LIBPATH ${SNDFILE}/lib ${FFMPEG}/lib)  # TODO, deprecate
1527         endif()
1528
1529         if(WITH_PYTHON)
1530                 # we use precompiled libraries for py 3.3 and up by default
1531                 set(PYTHON_VERSION 3.3)
1532                 if(NOT WITH_PYTHON_MODULE AND NOT WITH_PYTHON_FRAMEWORK)
1533                         # normally cached but not since we include them with blender
1534                         set(PYTHON_INCLUDE_DIR "${LIBDIR}/python/include/python${PYTHON_VERSION}m")
1535                         # set(PYTHON_BINARY "${LIBDIR}/python/bin/python${PYTHON_VERSION}") # not used yet
1536                         set(PYTHON_LIBRARY python${PYTHON_VERSION}m)
1537                         set(PYTHON_LIBPATH "${LIBDIR}/python/lib/python${PYTHON_VERSION}")
1538                         # set(PYTHON_LINKFLAGS "-u _PyMac_Error")  # won't  build with this enabled
1539                 else()
1540                         # module must be compiled against Python framework
1541                         set(PYTHON_INCLUDE_DIR "/Library/Frameworks/Python.framework/Versions/${PYTHON_VERSION}/include/python${PYTHON_VERSION}m")
1542                         set(PYTHON_BINARY "/Library/Frameworks/Python.framework/Versions/${PYTHON_VERSION}/bin/python${PYTHON_VERSION}")
1543                         #set(PYTHON_LIBRARY python${PYTHON_VERSION})
1544                         set(PYTHON_LIBPATH "/Library/Frameworks/Python.framework/Versions/${PYTHON_VERSION}/lib/python${PYTHON_VERSION}/config-${PYTHON_VERSION}m")
1545                         #set(PYTHON_LINKFLAGS "-u _PyMac_Error -framework Python")  # won't  build with this enabled
1546                 endif()
1547                 
1548                 # uncached vars
1549                 set(PYTHON_INCLUDE_DIRS "${PYTHON_INCLUDE_DIR}")
1550                 set(PYTHON_LIBRARIES  "${PYTHON_LIBRARY}")
1551         endif()
1552
1553         if(WITH_FFTW3)
1554                 set(FFTW3 ${LIBDIR}/fftw3)
1555                 set(FFTW3_INCLUDE_DIRS ${FFTW3}/include)
1556                 set(FFTW3_LIBRARIES fftw3)
1557                 set(FFTW3_LIBPATH ${FFTW3}/lib)
1558         endif()
1559
1560         set(PNG_LIBRARIES png)
1561         set(JPEG_LIBRARIES jpeg)
1562
1563         set(ZLIB /usr)
1564         set(ZLIB_INCLUDE_DIRS "${ZLIB}/include")
1565         set(ZLIB_LIBRARIES z bz2)
1566
1567         set(FREETYPE ${LIBDIR}/freetype)
1568         set(FREETYPE_INCLUDE_DIRS ${FREETYPE}/include ${FREETYPE}/include/freetype2)
1569         set(FREETYPE_LIBPATH ${FREETYPE}/lib)
1570         set(FREETYPE_LIBRARY freetype)
1571
1572         if(WITH_IMAGE_OPENEXR)
1573                 set(OPENEXR ${LIBDIR}/openexr)
1574                 set(OPENEXR_INCLUDE_DIR ${OPENEXR}/include)
1575                 set(OPENEXR_INCLUDE_DIRS ${OPENEXR}/include/OpenEXR)
1576                 set(OPENEXR_LIBRARIES Iex Half IlmImf Imath IlmThread)
1577                 set(OPENEXR_LIBPATH ${OPENEXR}/lib)
1578         endif()
1579
1580         if(WITH_CODEC_FFMPEG)
1581                 set(FFMPEG ${LIBDIR}/ffmpeg)
1582                 set(FFMPEG_INCLUDE_DIRS ${FFMPEG}/include)
1583                 set(FFMPEG_LIBRARIES avcodec avdevice avformat avutil mp3lame swscale x264 xvidcore theora theoradec theoraenc vorbis vorbisenc vorbisfile ogg)
1584                 set(FFMPEG_LIBPATH ${FFMPEG}/lib)
1585                 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D__STDC_CONSTANT_MACROS")
1586         endif()
1587
1588         find_library(SYSTEMSTUBS_LIBRARY
1589                 NAMES
1590                 SystemStubs
1591                 PATHS
1592         )
1593         mark_as_advanced(SYSTEMSTUBS_LIBRARY)
1594         if(SYSTEMSTUBS_LIBRARY)
1595                 set(PLATFORM_LINKLIBS stdc++ SystemStubs)
1596         else()
1597                 set(PLATFORM_LINKLIBS stdc++)
1598         endif()
1599
1600         if(WITH_COCOA)
1601                 set(PLATFORM_CFLAGS "-pipe -funsigned-char -DGHOST_COCOA")
1602                 set(PLATFORM_LINKFLAGS "-fexceptions -framework CoreServices -framework Foundation -framework IOKit -framework AppKit -framework Cocoa -framework Carbon -framework AudioUnit -framework AudioToolbox -framework CoreAudio")
1603                 if(USE_QTKIT)
1604                         set(PLATFORM_CFLAGS "${PLATFORM_CFLAGS} -DUSE_QTKIT")
1605                         set(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} -framework QTKit")
1606                         if(CMAKE_OSX_ARCHITECTURES MATCHES i386)
1607                                 set(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} -framework QuickTime")
1608                                 # libSDL still needs 32bit carbon quicktime
1609                         endif()
1610                 elseif(WITH_CODEC_QUICKTIME)
1611                         set(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} -framework QuickTime")
1612                 endif()
1613
1614                 # XXX - SOME MAC DEV PLEASE TEST WITH THE SDK INSTALLED!
1615                 # ALSO SHOULD BE MOVED INTO OWN MODULE WHEN FUNCTIONAL
1616                 if(WITH_INPUT_NDOF)
1617                         # This thread it *should* work and check the framework - campbell
1618                         # http://www.cmake.org/pipermail/cmake/2005-December/007740.html
1619                         find_library(3DCONNEXION_CLIENT_FRAMEWORK
1620                                 NAMES 3DconnexionClient
1621                         )
1622                         if(NOT 3DCONNEXION_CLIENT_FRAMEWORK)
1623                                 set(WITH_INPUT_NDOF OFF)
1624                         endif()
1625
1626                         if(WITH_INPUT_NDOF)
1627                                 set(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} -F/Library/Frameworks -weak_framework 3DconnexionClient")
1628                                 set(NDOF_INCLUDE_DIRS /Library/Frameworks/3DconnexionClient.framework/Headers )
1629                         endif()
1630                 endif()
1631
1632         if(WITH_JACK)
1633                 set(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} -weak_framework jackmp")
1634         endif()
1635
1636         else()
1637                 set(PLATFORM_CFLAGS "-pipe -funsigned-char")
1638                 set(PLATFORM_LINKFLAGS "-fexceptions -framework CoreServices -framework Foundation -framework IOKit -framework AppKit -framework Carbon -framework AGL -framework AudioUnit -framework AudioToolbox -framework CoreAudio -framework QuickTime")
1639                 set(WITH_INPUT_NDOF OFF)  # unsupported
1640         endif()
1641         
1642         if(WITH_PYTHON_MODULE OR WITH_PYTHON_FRAMEWORK)
1643                 set(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} /Library/Frameworks/Python.framework/Versions/${PYTHON_VERSION}/Python")# force cmake to link right framework
1644         endif()
1645         
1646         if(WITH_OPENCOLLADA)
1647                 set(OPENCOLLADA ${LIBDIR}/opencollada)
1648
1649                 set(OPENCOLLADA_INCLUDE_DIRS
1650                         ${LIBDIR}/opencollada/include/COLLADAStreamWriter
1651                         ${LIBDIR}/opencollada/include/COLLADABaseUtils
1652                         ${LIBDIR}/opencollada/include/COLLADAFramework
1653                         ${LIBDIR}/opencollada/include/COLLADASaxFrameworkLoader
1654                         ${LIBDIR}/opencollada/include/GeneratedSaxParser
1655                 )
1656
1657                 set(OPENCOLLADA_LIBPATH ${OPENCOLLADA}/lib)
1658                 set(OPENCOLLADA_LIBRARIES "OpenCOLLADASaxFrameworkLoader -lOpenCOLLADAFramework -lOpenCOLLADABaseUtils -lOpenCOLLADAStreamWriter -lMathMLSolver -lGeneratedSaxParser -lUTF -lxml2 -lbuffer -lftoa")
1659                 # pcre is bundled with openCollada
1660                 #set(PCRE ${LIBDIR}/pcre)
1661                 #set(PCRE_LIBPATH ${PCRE}/lib)
1662                 set(PCRE_LIBRARIES pcre)
1663                 #libxml2 is used
1664                 #set(EXPAT ${LIBDIR}/expat)
1665                 #set(EXPAT_LIBPATH ${EXPAT}/lib)
1666                 set(EXPAT_LIB)
1667         endif()
1668
1669         if(WITH_SDL)
1670                 set(SDL ${LIBDIR}/sdl)
1671                 set(SDL_INCLUDE_DIR ${SDL}/include)
1672                 set(SDL_LIBRARY SDL)
1673                 set(SDL_LIBPATH ${SDL}/lib)
1674         endif()
1675
1676         set(PNG "${LIBDIR}/png")
1677         set(PNG_INCLUDE_DIR "${PNG}/include")
1678         set(PNG_LIBPATH ${PNG}/lib)
1679
1680         set(JPEG "${LIBDIR}/jpeg")
1681         set(JPEG_INCLUDE_DIR "${JPEG}/include")
1682         set(JPEG_LIBPATH ${JPEG}/lib)
1683
1684         if(WITH_IMAGE_TIFF)
1685                 set(TIFF ${LIBDIR}/tiff)
1686                 set(TIFF_INCLUDE_DIR ${TIFF}/include)
1687                 set(TIFF_LIBRARY tiff)
1688                 set(TIFF_LIBPATH ${TIFF}/lib)
1689         endif()
1690
1691         if(WITH_INPUT_NDOF)
1692                 # linker needs "-weak_framework 3DconnexionClient"
1693         endif()
1694
1695         if(WITH_BOOST)
1696                 set(BOOST ${LIBDIR}/boost)
1697                 set(BOOST_INCLUDE_DIR ${BOOST}/include)
1698                 set(BOOST_LIBRARIES boost_date_time-mt boost_filesystem-mt boost_regex-mt boost_system-mt boost_thread-mt boost_wave-mt)
1699                 if(WITH_INTERNATIONAL)
1700                         list(APPEND BOOST_LIBRARIES boost_locale-mt)
1701                         set(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} -liconv") # boost_locale needs it !
1702                 endif()
1703                 set(BOOST_LIBPATH ${BOOST}/lib)
1704                 set(BOOST_DEFINITIONS)
1705         endif()
1706
1707         if(WITH_OPENIMAGEIO)
1708                 set(OPENIMAGEIO ${LIBDIR}/openimageio)
1709                 set(OPENIMAGEIO_INCLUDE_DIRS ${OPENIMAGEIO}/include)
1710                 set(OPENIMAGEIO_LIBRARIES ${OPENIMAGEIO}/lib/libOpenImageIO.a ${PNG_LIBRARIES} ${JPEG_LIBRARIES} ${TIFF_LIBRARY} ${OPENEXR_LIBRARIES} ${ZLIB_LIBRARIES})
1711                 set(OPENIMAGEIO_LIBPATH ${OPENIMAGEIO}/lib ${JPEG_LIBPATH} ${PNG_LIBPATH} ${TIFF_LIBPATH} ${OPENEXR_LIBPATH} ${ZLIB_LIBPATH})
1712                 set(OPENIMAGEIO_DEFINITIONS "-DOIIO_STATIC_BUILD")
1713         endif()
1714
1715         if(WITH_OPENCOLORIO)
1716                 set(OPENCOLORIO ${LIBDIR}/opencolorio)
1717                 set(OPENCOLORIO_INCLUDE_DIRS ${OPENCOLORIO}/include)
1718                 set(OPENCOLORIO_LIBRARIES OpenColorIO tinyxml yaml-cpp)
1719                 set(OPENCOLORIO_LIBPATH ${OPENCOLORIO}/lib)
1720                 set(OPENCOLORIO_DEFINITIONS "-DOCIO_STATIC_BUILD")
1721         endif()
1722
1723         if(WITH_LLVM)
1724                 set(LLVM_DIRECTORY ${LIBDIR}/llvm CACHE PATH    "Path to the LLVM installation")
1725                 set(LLVM_VERSION "3.1" CACHE STRING     "Version of LLVM to use")
1726                 if(EXISTS "${LLVM_DIRECTORY}/bin/llvm-config")
1727                         set(LLVM_CONFIG "${LLVM_DIRECTORY}/bin/llvm-config")
1728                 else()
1729                         set(LLVM_CONFIG llvm-config)
1730                 endif()
1731                 execute_process(COMMAND ${LLVM_CONFIG} --version
1732                                 OUTPUT_VARIABLE LLVM_VERSION
1733                                 OUTPUT_STRIP_TRAILING_WHITESPACE)
1734                 execute_process(COMMAND ${LLVM_CONFIG} --prefix
1735                                 OUTPUT_VARIABLE LLVM_DIRECTORY
1736                                 OUTPUT_STRIP_TRAILING_WHITESPACE)
1737                 execute_process(COMMAND ${LLVM_CONFIG} --libdir
1738                                 OUTPUT_VARIABLE LLVM_LIB_DIR
1739                                 OUTPUT_STRIP_TRAILING_WHITESPACE)
1740                 find_library(LLVM_LIBRARY
1741                              NAMES LLVMAnalysis # first of a whole bunch of libs to get
1742                              PATHS ${LLVM_LIB_DIR})
1743
1744                 if(LLVM_LIBRARY AND LLVM_DIRECTORY AND LLVM_LIB_DIR)
1745                         if(LLVM_STATIC)
1746                                 # if static LLVM libraries were requested, use llvm-config to generate
1747                                 # the list of what libraries we need, and substitute that in the right
1748                                 # way for LLVM_LIBRARY.
1749                                 execute_process(COMMAND ${LLVM_CONFIG} --libfiles
1750                                                 OUTPUT_VARIABLE LLVM_LIBRARY
1751                                                 OUTPUT_STRIP_TRAILING_WHITESPACE)
1752                                 string(REPLACE " " ";" LLVM_LIBRARY ${LLVM_LIBRARY})
1753                         endif()
1754                 else()
1755                         message(FATAL_ERROR "LLVM not found.")
1756                 endif()
1757         endif()
1758
1759         if(WITH_CYCLES_OSL)
1760                 set(CYCLES_OSL ${LIBDIR}/osl CACHE PATH "Path to OpenShadingLanguage installation")
1761         
1762                 find_library(OSL_LIB_EXEC NAMES oslexec PATHS ${CYCLES_OSL}/lib)
1763                 find_library(OSL_LIB_COMP NAMES oslcomp PATHS ${CYCLES_OSL}/lib)
1764                 find_library(OSL_LIB_QUERY NAMES oslquery PATHS ${CYCLES_OSL}/lib)
1765                 # WARNING! depends on correct order of OSL libs linking
1766                 list(APPEND OSL_LIBRARIES ${OSL_LIB_COMP} -force_load ${OSL_LIB_EXEC} ${OSL_LIB_QUERY})
1767                 find_path(OSL_INCLUDES OSL/oslclosure.h PATHS ${CYCLES_OSL}/include)
1768                 find_program(OSL_COMPILER NAMES oslc PATHS ${CYCLES_OSL}/bin)
1769         
1770                 if(OSL_INCLUDES AND OSL_LIBRARIES AND OSL_COMPILER)
1771                         set(OSL_FOUND TRUE)
1772                 else()
1773                         message(STATUS "OSL not found")
1774                 endif()
1775         endif()
1776
1777         set(EXETYPE MACOSX_BUNDLE)
1778
1779         set(CMAKE_C_FLAGS_DEBUG "-fno-strict-aliasing -g")
1780         set(CMAKE_CXX_FLAGS_DEBUG "-fno-strict-aliasing -g")
1781         if(CMAKE_OSX_ARCHITECTURES MATCHES "x86_64" OR CMAKE_OSX_ARCHITECTURES MATCHES "i386")
1782                 set(CMAKE_CXX_FLAGS_RELEASE "-O2 -mdynamic-no-pic -msse -msse2 -msse3 -mssse3")
1783                 set(CMAKE_C_FLAGS_RELEASE "-O2 -mdynamic-no-pic  -msse -msse2 -msse3 -mssse3")
1784                 if(NOT CMAKE_CXX_COMPILER_ID MATCHES "Clang")
1785                         set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -ftree-vectorize  -fvariable-expansion-in-unroller")
1786                         set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -ftree-vectorize  -fvariable-expansion-in-unroller")
1787                 endif()
1788         else()
1789                 set(CMAKE_C_FLAGS_RELEASE "-mdynamic-no-pic -fno-strict-aliasing")
1790                 set(CMAKE_CXX_FLAGS_RELEASE "-mdynamic-no-pic -fno-strict-aliasing")
1791         endif()
1792 endif()
1793
1794 #-----------------------------------------------------------------------------
1795 # Common.
1796
1797 if(APPLE OR WIN32)
1798         if(NOT EXISTS "${LIBDIR}/")
1799                 message(FATAL_ERROR "Apple and Windows require pre-compiled libs at: '${LIBDIR}'")
1800         endif()
1801 endif()
1802
1803 if(NOT WITH_FFTW3 AND WITH_MOD_OCEANSIM)
1804         message(FATAL_ERROR "WITH_MOD_OCEANSIM requires WITH_FFTW3 to be ON")
1805 endif()
1806
1807 if(WITH_CYCLES)
1808         if(NOT WITH_OPENIMAGEIO)
1809                 message(FATAL_ERROR "Cycles reqires WITH_OPENIMAGEIO, the library may not have been found. Configure OIIO or disable WITH_CYCLES")
1810         endif()
1811         if(NOT WITH_BOOST)
1812                 message(FATAL_ERROR "Cycles reqires WITH_BOOST, the library may not have been found. Configure BOOST or disable WITH_CYCLES")
1813         endif()
1814
1815         if(WITH_CYCLES_OSL)
1816                 if(NOT WITH_LLVM)
1817                         message(FATAL_ERROR "Cycles OSL reqires WITH_LLVM, the library may not have been found. Configure LLVM or disable WITH_CYCLES_OSL")
1818                 endif()
1819         endif()
1820 endif()
1821
1822 if(WITH_INTERNATIONAL)
1823         if(NOT WITH_BOOST)
1824                 message(FATAL_ERROR "Internationalization reqires WITH_BOOST, the library may not have been found. Configure BOOST or disable WITH_INTERNATIONAL")
1825         endif()
1826 endif()
1827
1828 # See TEST_SSE_SUPPORT() for how this is defined.
1829
1830 if(WITH_RAYOPTIMIZATION)
1831         if(SUPPORT_SSE_BUILD)
1832                 set(PLATFORM_CFLAGS " ${COMPILER_SSE_FLAG} ${PLATFORM_CFLAGS}")
1833                 add_definitions(-D__SSE__ -D__MMX__)
1834         endif()
1835         if(SUPPORT_SSE2_BUILD)
1836                 set(PLATFORM_CFLAGS " ${COMPILER_SSE2_FLAG} ${PLATFORM_CFLAGS}")
1837                 add_definitions(-D__SSE2__)
1838                 if(NOT SUPPORT_SSE_BUILD) # dont double up
1839                         add_definitions(-D__MMX__)
1840                 endif()
1841         endif()
1842 endif()
1843
1844
1845 # set the endian define
1846 if(MSVC)
1847         # for some reason this fails on msvc
1848         add_definitions(-D__LITTLE_ENDIAN__)
1849         
1850 # OSX-Note: as we do crosscompiling with specific set architecture,
1851 # endianess-detection and autosetting is counterproductive
1852 # so we just set endianess according CMAKE_OSX_ARCHITECTURES
1853
1854 elseif(CMAKE_OSX_ARCHITECTURES MATCHES i386 OR CMAKE_OSX_ARCHITECTURES MATCHES x86_64)
1855         add_definitions(-D__LITTLE_ENDIAN__)
1856 elseif(CMAKE_OSX_ARCHITECTURES MATCHES ppc OR CMAKE_OSX_ARCHITECTURES MATCHES ppc64)            
1857         add_definitions(-D__BIG_ENDIAN__)
1858         
1859 else()
1860         include(TestBigEndian)
1861         test_big_endian(_SYSTEM_BIG_ENDIAN)
1862         if(_SYSTEM_BIG_ENDIAN)
1863                 add_definitions(-D__BIG_ENDIAN__)
1864         else()
1865                 add_definitions(-D__LITTLE_ENDIAN__)
1866         endif()
1867         unset(_SYSTEM_BIG_ENDIAN)
1868 endif()
1869
1870
1871 if(WITH_IMAGE_OPENJPEG)
1872         if(WITH_SYSTEM_OPENJPEG)
1873                 # dealt with above
1874         else()
1875                 set(OPENJPEG_INCLUDE_DIRS "${CMAKE_SOURCE_DIR}/extern/libopenjpeg")
1876                 add_definitions(-DOPJ_STATIC)
1877         endif()
1878 endif()
1879
1880 if(WITH_IMAGE_REDCODE)
1881         set(REDCODE ${CMAKE_SOURCE_DIR}/extern)
1882         set(REDCODE_INC ${REDCODE})
1883 endif()
1884
1885 #-----------------------------------------------------------------------------
1886 # Blender WebPlugin
1887
1888 if(WITH_WEBPLUGIN)
1889         set(GECKO_DIR "${CMAKE_SOURCE_DIR}/../gecko-sdk/" CACHE PATH "Gecko SDK path")
1890         set(WEBPLUGIN_SANDBOX_MODE "apparmor" CACHE STRING "WEB Plugin sandbox mode, can be apparmor, privsep, none")
1891
1892         set(WITH_PLAYER ON)
1893 endif()
1894
1895
1896 #-----------------------------------------------------------------------------
1897 # Configure OpenGL.
1898 find_package(OpenGL)
1899 blender_include_dirs_sys("${OPENGL_INCLUDE_DIR}")
1900 # unset(OPENGL_LIBRARIES CACHE) # not compat with older cmake
1901 # unset(OPENGL_xmesa_INCLUDE_DIR CACHE) # not compat with older cmake
1902
1903 #-----------------------------------------------------------------------------
1904 # Configure OpenMP.
1905 if(WITH_OPENMP)
1906         find_package(OpenMP)
1907         if(OPENMP_FOUND)
1908                 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
1909                 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
1910
1911                 if(APPLE AND ${CMAKE_GENERATOR} MATCHES "Xcode")
1912                         set(CMAKE_XCODE_ATTRIBUTE_ENABLE_OPENMP_SUPPORT "YES")
1913                 endif()
1914         else()
1915                 set(WITH_OPENMP OFF)
1916         endif()
1917
1918         mark_as_advanced(
1919                 OpenMP_C_FLAGS
1920                 OpenMP_CXX_FLAGS
1921         )
1922 endif()
1923
1924 #-----------------------------------------------------------------------------
1925 # Configure GLEW
1926
1927 if(WITH_SYSTEM_GLEW)
1928         find_package(GLEW)
1929
1930         if(NOT GLEW_FOUND)
1931                 message(FATAL_ERROR "GLEW is required to build blender, install it or disable WITH_SYSTEM_GLEW")
1932         endif()
1933
1934         mark_as_advanced(
1935                 GLEW_LIBRARY
1936                 GLEW_INCLUDE_PATH
1937         )
1938 else()
1939         # set(GLEW_LIBRARY "")  # unused
1940         set(GLEW_INCLUDE_PATH "${CMAKE_SOURCE_DIR}/extern/glew/include")
1941 endif()
1942
1943
1944 #-----------------------------------------------------------------------------
1945 # Configure Bullet
1946
1947 if(WITH_BULLET AND WITH_SYSTEM_BULLET)
1948         find_package(Bullet)
1949         if(NOT BULLET_FOUND)
1950                 set(WITH_BULLET OFF)
1951         endif()
1952 else()
1953         set(BULLET_INCLUDE_DIRS "${CMAKE_SOURCE_DIR}/extern/bullet2/src")
1954         # set(BULLET_LIBRARIES "")
1955 endif()
1956
1957 #-----------------------------------------------------------------------------
1958 # Configure Python.
1959
1960 if(WITH_PYTHON_MODULE)
1961         add_definitions(-DPy_ENABLE_SHARED)
1962 endif()
1963
1964 #-----------------------------------------------------------------------------
1965 # Extra compile flags
1966
1967 if(CMAKE_COMPILER_IS_GNUCC)
1968
1969         ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_ALL -Wall)
1970         ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_CAST_ALIGN -Wcast-align)
1971         ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_ERROR_DECLARATION_AFTER_STATEMENT -Werror=declaration-after-statement)
1972         ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_ERROR_IMPLICIT_FUNCTION_DECLARATION -Werror=implicit-function-declaration)
1973         ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_ERROR_RETURN_TYPE  -Werror=return-type)
1974         # system headers sometimes do this, disable for now, was: -Werror=strict-prototypes
1975         ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_STRICT_PROTOTYPES  -Wstrict-prototypes)
1976         ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_MISSING_PROTOTYPES -Wmissing-prototypes)
1977         ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_NO_CHAR_SUBSCRIPTS -Wno-char-subscripts)
1978         ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_NO_UNKNOWN_PRAGMAS -Wno-unknown-pragmas)
1979         ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_POINTER_ARITH -Wpointer-arith)
1980         ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_UNUSED_PARAMETER -Wunused-parameter)
1981         ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_WRITE_STRINGS -Wwrite-strings)
1982         ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_LOGICAL_OP -Wlogical-op)
1983         ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_UNDEF -Wundef)
1984         ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_INIT_SELF -Winit-self)  # needs -Wuninitialized
1985         ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_NO_NULL -Wnonnull)  # C only
1986         ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_MISSING_INCLUDE_DIRS -Wmissing-include-dirs)
1987         ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_NO_DIV_BY_ZERO -Wno-div-by-zero)
1988
1989         # gcc 4.2 gives annoying warnings on every file with this
1990         if(NOT "${CMAKE_C_COMPILER_VERSION}" VERSION_LESS "4.3")
1991                 ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_UNINITIALIZED -Wuninitialized)
1992         endif()
1993
1994         # versions before gcc4.6 give many BLI_math warnings
1995         if(NOT "${CMAKE_C_COMPILER_VERSION}" VERSION_LESS "4.6")
1996                 ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_REDUNDANT_DECLS       -Wredundant-decls)
1997                 ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_REDUNDANT_DECLS -Wredundant-decls)
1998         endif()
1999
2000         # disable because it gives warnings for printf() & friends.
2001         # ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_DOUBLE_PROMOTION -Wdouble-promotion -Wno-error=double-promotion)
2002
2003         if(NOT APPLE)
2004                 ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_NO_ERROR_UNUSED_BUT_SET_VARIABLE -Wno-error=unused-but-set-variable)
2005         endif()
2006
2007         ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_ALL -Wall)
2008         ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_NO_INVALID_OFFSETOF -Wno-invalid-offsetof)
2009         ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_NO_SIGN_COMPARE -Wno-sign-compare)
2010         ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_LOGICAL_OP -Wlogical-op)
2011         ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_INIT_SELF -Winit-self)  # needs -Wuninitialized
2012         ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_MISSING_INCLUDE_DIRS -Wmissing-include-dirs)
2013         ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_NO_DIV_BY_ZERO -Wno-div-by-zero)
2014
2015         # gcc 4.2 gives annoying warnings on every file with this
2016         if(NOT "${CMAKE_C_COMPILER_VERSION}" VERSION_LESS "4.3")
2017                 ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_UNINITIALIZED -Wuninitialized)
2018         endif()
2019
2020         # causes too many warnings
2021         if(NOT APPLE)
2022                 ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_UNDEF -Wundef)
2023                 ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_MISSING_DECLARATIONS -Wmissing-declarations)
2024         endif()
2025
2026         # flags to undo strict flags
2027         ADD_CHECK_C_COMPILER_FLAG(CC_REMOVE_STRICT_FLAGS C_WARN_NO_DEPRECATED_DECLARATIONS -Wno-deprecated-declarations)
2028         ADD_CHECK_C_COMPILER_FLAG(CC_REMOVE_STRICT_FLAGS C_WARN_NO_UNUSED_PARAMETER        -Wno-unused-parameter)
2029
2030         if(NOT APPLE)
2031                 ADD_CHECK_C_COMPILER_FLAG(CC_REMOVE_STRICT_FLAGS C_WARN_NO_ERROR_UNUSED_BUT_SET_VARIABLE -Wno-error=unused-but-set-variable)
2032         endif()
2033
2034 elseif(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
2035
2036         # strange, clang complains these are not supported, but then yses them.
2037         ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_ALL -Wall)
2038         ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_ERROR_DECLARATION_AFTER_STATEMENT -Werror=declaration-after-statement)
2039         ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_ERROR_IMPLICIT_FUNCTION_DECLARATION -Werror=implicit-function-declaration)
2040         ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_ERROR_RETURN_TYPE  -Werror=return-type)
2041         ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_NO_AUTOLOGICAL_COMPARE -Wno-tautological-compare)
2042         ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_NO_UNKNOWN_PRAGMAS -Wno-unknown-pragmas)
2043         ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_NO_CHAR_SUBSCRIPTS -Wno-char-subscripts)
2044         ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_STRICT_PROTOTYPES  -Wstrict-prototypes)
2045         ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_MISSING_PROTOTYPES -Wmissing-prototypes)
2046         ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_UNUSED_PARAMETER -Wunused-parameter)
2047
2048         ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_ALL -Wall)
2049         ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_NO_AUTOLOGICAL_COMPARE -Wno-tautological-compare)
2050         ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_NO_UNKNOWN_PRAGMAS     -Wno-unknown-pragmas)
2051         ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_NO_CHAR_SUBSCRIPTS     -Wno-char-subscripts)
2052         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.
2053         ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_NO_SIGN_COMPARE        -Wno-sign-compare)
2054         ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_NO_INVALID_OFFSETOF    -Wno-invalid-offsetof)
2055
2056         # gives too many unfixable warnings
2057         # ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_UNUSED_MACROS      -Wunused-macros)
2058         # ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_UNUSED_MACROS          -Wunused-macros)
2059
2060         # flags to undo strict flags
2061         ADD_CHECK_C_COMPILER_FLAG(CC_REMOVE_STRICT_FLAGS C_WARN_NO_UNUSED_PARAMETER -Wno-unused-parameter)
2062         ADD_CHECK_C_COMPILER_FLAG(CC_REMOVE_STRICT_FLAGS C_WARN_NO_UNUSED_MACROS    -Wno-unused-macros)
2063
2064 elseif(CMAKE_C_COMPILER_ID MATCHES "Intel")
2065
2066         ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_ALL -Wall)
2067         ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_POINTER_ARITH -Wpointer-arith)
2068         ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_NO_UNKNOWN_PRAGMAS -Wno-unknown-pragmas)
2069
2070         ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_ALL -Wall)
2071         ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_NO_INVALID_OFFSETOF -Wno-invalid-offsetof)
2072         ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_NO_SIGN_COMPARE -Wno-sign-compare)
2073
2074         # disable numbered, false positives
2075         set(C_WARNINGS "${C_WARNINGS} -wd188,186,144,913,556")
2076         set(CXX_WARNINGS "${CXX_WARNINGS} -wd188,186,144,913,556")
2077
2078 endif()
2079
2080 # MSVC2010 fails to links C++ libs right
2081 if(MSVC10)
2082         if(WITH_OPENCOLLADA)
2083                 message(WARNING "MSVC 2010 does not support OpenCollada, disabling WITH_OPENCOLLADA. To enable support use Use MSVC 2008")
2084         endif()
2085 endif()
2086
2087 # ensure python header is found since detection can fail, this could happen
2088 # with _any_ library but since we used a fixed python version this tends to
2089 # be most problematic.
2090 if(WITH_PYTHON)
2091         if(NOT EXISTS "${PYTHON_INCLUDE_DIR}/Python.h")
2092                 message(FATAL_ERROR "Missing: \"${PYTHON_INCLUDE_DIR}/Python.h\",\n"
2093                                                         "Set the cache entry 'PYTHON_INCLUDE_DIR' to point "
2094                                                         "to a valid python include path. Containing "
2095                                                         "Python.h for python version \"${PYTHON_VERSION}\"")
2096         endif()
2097
2098         if(WITH_PYTHON_INSTALL AND WITH_PYTHON_INSTALL_NUMPY)
2099                 # set but invalid
2100                 # -- disabled until we make numpy bundled with blender - campbell
2101                 if((NOT ${PYTHON_NUMPY_PATH} STREQUAL "") AND (NOT ${PYTHON_NUMPY_PATH} MATCHES NOTFOUND))
2102 #                       if(NOT EXISTS "${PYTHON_NUMPY_PATH}/numpy")
2103 #                               message(WARNING "PYTHON_NUMPY_PATH is invalid, numpy not found in '${PYTHON_NUMPY_PATH}' "
2104 #                                               "WITH_PYTHON_INSTALL_NUMPY option will be ignored when installing python")
2105 #                               set(WITH_PYTHON_INSTALL_NUMPY OFF)
2106 #                       endif()
2107                 # not set, so initialize
2108                 else()
2109                         string(REPLACE "." ";" _PY_VER_SPLIT "${PYTHON_VERSION}")
2110                         list(GET _PY_VER_SPLIT 0 _PY_VER_MAJOR)
2111
2112                         # re-cache
2113                         unset(PYTHON_NUMPY_PATH CACHE)
2114                         find_path(PYTHON_NUMPY_PATH
2115                           NAMES
2116                             numpy
2117                           HINTS
2118                             "${PYTHON_LIBPATH}/python${PYTHON_VERSION}/"
2119                             "${PYTHON_LIBPATH}/python${_PY_VER_MAJOR}/"
2120                           PATH_SUFFIXES
2121                             site-packages
2122                             dist-packages
2123                            NO_DEFAULT_PATH
2124                         )
2125
2126                         if(NOT EXISTS "${PYTHON_NUMPY_PATH}")
2127                                 message(WARNING "'numpy' path could not be found in:\n"
2128                                                 "'${PYTHON_LIBPATH}/python${PYTHON_VERSION}/site-packages/numpy', "
2129                                                 "'${PYTHON_LIBPATH}/python${_PY_VER_MAJOR}/site-packages/numpy', "
2130                                                 "'${PYTHON_LIBPATH}/python${PYTHON_VERSION}/dist-packages/numpy', "
2131                                                 "'${PYTHON_LIBPATH}/python${_PY_VER_MAJOR}/dist-packages/numpy', "
2132                                                 "WITH_PYTHON_INSTALL_NUMPY option will be ignored when installing python")
2133                                 set(WITH_PYTHON_INSTALL_NUMPY OFF)
2134                         else()
2135                                 message(STATUS "numpy found at '${PYTHON_NUMPY_PATH}'")
2136                         endif()
2137
2138                         unset(_PY_VER_SPLIT)
2139                         unset(_PY_VER_MAJOR)
2140                 endif()
2141         endif()
2142 endif()
2143
2144 if(WITH_GCC_MUDFLAP)
2145         set(PLATFORM_CFLAGS "${PLATFORM_CFLAGS} -fmudflapth -funwind-tables")
2146         set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -lpthread -lmudflapth -rdynamic")
2147         ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS     C_WARN_NO_ERROR_MUDFLAP   -Wno-error=mudflap)
2148         ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_NO_ERROR_MUDFLAP -Wno-error=mudflap)
2149 endif()
2150
2151 # Include warnings first, so its possible to disable them with user defined flags
2152 # eg: -Wno-uninitialized
2153 set(CMAKE_C_FLAGS "${C_WARNINGS} ${CMAKE_C_FLAGS} ${PLATFORM_CFLAGS}")
2154 set(CMAKE_CXX_FLAGS "${CXX_WARNINGS} ${CMAKE_CXX_FLAGS} ${PLATFORM_CFLAGS}")
2155
2156 #-------------------------------------------------------------------------------
2157 # Global Defines
2158
2159 # better not set includes here but this debugging option is off by default.
2160 if(WITH_CXX_GUARDEDALLOC)
2161         include_directories(${CMAKE_SOURCE_DIR}/intern/guardedalloc)
2162         add_definitions(-DWITH_CXX_GUARDEDALLOC)
2163 endif()
2164
2165 if(WITH_ASSERT_ABORT)
2166         add_definitions(-DWITH_ASSERT_ABORT)
2167 endif()
2168
2169 # message(STATUS "Using CFLAGS: ${CMAKE_C_FLAGS}")
2170 # message(STATUS "Using CXXFLAGS: ${CMAKE_CXX_FLAGS}")
2171
2172 #-----------------------------------------------------------------------------
2173 # Libraries
2174
2175 add_subdirectory(source)
2176 add_subdirectory(intern)
2177 add_subdirectory(extern)
2178
2179
2180 #-----------------------------------------------------------------------------
2181 # Blender Application
2182 if(WITH_BLENDER)
2183         add_subdirectory(source/creator)
2184 endif()
2185
2186
2187 #-----------------------------------------------------------------------------
2188 # Blender Player
2189 if(WITH_PLAYER)
2190         add_subdirectory(source/blenderplayer)
2191 endif()
2192
2193 #-----------------------------------------------------------------------------
2194 # CPack for generating packages
2195 include(build_files/cmake/packaging.cmake)
2196
2197
2198 #-----------------------------------------------------------------------------
2199 # Print Final Configuration
2200
2201 if(FIRST_RUN)
2202         set(_config_msg "\n* Blender Configuration *")
2203         macro(info_cfg_option
2204                 _setting)
2205                 set(_msg "   * ${_setting}")
2206                 string(LENGTH "${_msg}" _len)
2207                 while("32" GREATER "${_len}")
2208                         set(_msg "${_msg} ")
2209                          math(EXPR _len "${_len} + 1")
2210                 endwhile()
2211
2212                 set(_config_msg "${_config_msg}\n${_msg}${${_setting}}")
2213         endmacro()
2214
2215         macro(info_cfg_text
2216                 _text)
2217                 set(_config_msg "${_config_msg}\n\n  ${_text}")
2218
2219
2220         endmacro()
2221
2222         info_cfg_text("Build Options:")
2223         info_cfg_option(WITH_GAMEENGINE)
2224         info_cfg_option(WITH_PLAYER)
2225         info_cfg_option(WITH_BULLET)
2226         info_cfg_option(WITH_IK_SOLVER)
2227         info_cfg_option(WITH_IK_ITASC)
2228         info_cfg_option(WITH_OPENCOLLADA)
2229         info_cfg_option(WITH_FFTW3)
2230         info_cfg_option(WITH_INTERNATIONAL)
2231         info_cfg_option(WITH_INPUT_NDOF)
2232         info_cfg_option(WITH_CYCLES)
2233         info_cfg_option(WITH_FREESTYLE)
2234         info_cfg_option(WITH_OPENCOLORIO)
2235
2236         info_cfg_text("Compiler Options:")
2237         info_cfg_option(WITH_BUILDINFO)
2238         info_cfg_option(WITH_OPENMP)
2239         info_cfg_option(WITH_RAYOPTIMIZATION)
2240
2241         info_cfg_text("System Options:")
2242         info_cfg_option(WITH_INSTALL_PORTABLE)
2243         info_cfg_option(WITH_X11_XF86VMODE)
2244         info_cfg_option(WITH_X11_XINPUT)
2245         info_cfg_option(WITH_MEM_JEMALLOC)
2246         info_cfg_option(WITH_SYSTEM_GLEW)
2247         info_cfg_option(WITH_SYSTEM_OPENJPEG)
2248
2249         info_cfg_text("Image Formats:")
2250         info_cfg_option(WITH_IMAGE_CINEON)
2251         info_cfg_option(WITH_IMAGE_DDS)
2252         info_cfg_option(WITH_IMAGE_HDR)
2253         info_cfg_option(WITH_IMAGE_OPENEXR)
2254         info_cfg_option(WITH_IMAGE_OPENJPEG)
2255         info_cfg_option(WITH_IMAGE_REDCODE)
2256         info_cfg_option(WITH_IMAGE_TIFF)
2257
2258         info_cfg_text("Audio:")
2259         info_cfg_option(WITH_OPENAL)
2260         info_cfg_option(WITH_SDL)
2261         info_cfg_option(WITH_JACK)
2262         info_cfg_option(WITH_JACK_DYNLOAD)
2263         info_cfg_option(WITH_CODEC_AVI)
2264         info_cfg_option(WITH_CODEC_FFMPEG)
2265         info_cfg_option(WITH_CODEC_SNDFILE)
2266
2267         info_cfg_text("Compression:")
2268         info_cfg_option(WITH_LZMA)
2269         info_cfg_option(WITH_LZO)
2270
2271         info_cfg_text("Python:")
2272         info_cfg_option(WITH_PYTHON_INSTALL)
2273         info_cfg_option(WITH_PYTHON_INSTALL_NUMPY)
2274         info_cfg_option(WITH_PYTHON_MODULE)
2275         info_cfg_option(WITH_PYTHON_SAFETY)
2276         if(APPLE)
2277                 info_cfg_option(WITH_PYTHON_FRAMEWORK)
2278         endif()
2279
2280         info_cfg_text("Modifiers:")
2281         info_cfg_option(WITH_MOD_BOOLEAN)
2282         info_cfg_option(WITH_MOD_REMESH)
2283         info_cfg_option(WITH_MOD_FLUID)
2284         info_cfg_option(WITH_MOD_OCEANSIM)
2285
2286         # debug
2287         message(STATUS "HAVE_STDBOOL_H = ${HAVE_STDBOOL_H}")
2288
2289         info_cfg_text("")
2290
2291         message("${_config_msg}")
2292 endif()