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