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