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