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