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