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