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