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