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