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