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