Merging r40572 through r40597 from trunk into soc-2011-tomato
[blender.git] / CMakeLists.txt
1 # -*- mode: cmake; indent-tabs-mode: t; -*-
2 # $Id$
3 # ***** BEGIN GPL LICENSE BLOCK *****
4 #
5 # This program is free software; you can redistribute it and/or
6 # modify it under the terms of the GNU General Public License
7 # as published by the Free Software Foundation; either version 2
8 # of the License, or (at your option) any later version.
9 #
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 # GNU General Public License for more details.
14 #
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write to the Free Software Foundation,
17 # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 #
19 # The Original Code is Copyright (C) 2006, Blender Foundation
20 # All rights reserved.
21 #
22 # The Original Code is: all of this file.
23 #
24 # Contributor(s): Jacques Beaurain.
25 #
26 # ***** END GPL LICENSE BLOCK *****
27
28 #-----------------------------------------------------------------------------
29 # We don't allow in-source builds. This causes no end of troubles because 
30 # all out-of-source builds will use the CMakeCache.txt file there and even 
31 # build the libs and objects in it.
32
33 if(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR})
34         if(NOT DEFINED WITH_IN_SOURCE_BUILD)
35                 message(FATAL_ERROR
36                         "CMake generation for blender is not allowed within the source directory!"
37                         "\n Remove the CMakeCache.txt file and try again from another folder, e.g.:"
38                         "\n "
39                         "\n rm CMakeCache.txt"
40                         "\n cd .."
41                         "\n mkdir cmake-make"
42                         "\n cd cmake-make"
43                         "\n cmake ../blender"
44                         "\n "
45                         "\n Alternately define WITH_IN_SOURCE_BUILD to force this option (not recommended!)"
46                 )
47         endif()
48 endif()
49
50 cmake_minimum_required(VERSION 2.8)
51
52 if(NOT EXECUTABLE_OUTPUT_PATH)
53         set(FIRST_RUN "TRUE")
54 endif()
55
56 # this starts out unset
57 list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/build_files/cmake/Modules")
58
59 # avoid having empty buildtype
60 set(CMAKE_BUILD_TYPE_INIT "Release")
61
62 # quiet output for Makefiles, 'make -s' helps too
63 # set_property(GLOBAL PROPERTY RULE_MESSAGES OFF)
64
65 #-----------------------------------------------------------------------------
66 # Set policy
67
68 # see "cmake --help-policy CMP0003"
69 # So library linking is more sane
70 cmake_policy(SET CMP0003 NEW)
71
72 # So BUILDINFO and BLENDERPATH strings are automatically quoted
73 cmake_policy(SET CMP0005 NEW)
74
75 # So syntax problems are errors
76 cmake_policy(SET CMP0010 NEW)
77
78 # Input directories must have CMakeLists.txt
79 cmake_policy(SET CMP0014 NEW)
80
81 #-----------------------------------------------------------------------------
82 # Load some macros.
83 include(build_files/cmake/macros.cmake)
84
85
86 #-----------------------------------------------------------------------------
87 # Initialize project.
88
89 blender_project_hack_pre()
90
91 project(Blender)
92
93 blender_project_hack_post()
94
95 enable_testing()
96
97 #-----------------------------------------------------------------------------
98 # Redirect output files
99
100 set(EXECUTABLE_OUTPUT_PATH ${CMAKE_BINARY_DIR}/bin CACHE INTERNAL "" FORCE )
101 set(LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR}/lib CACHE INTERNAL "" FORCE )
102
103 #-----------------------------------------------------------------------------
104 # Set default config options
105
106 get_blender_version()
107
108
109 # Blender internal features
110 option(WITH_BLENDER "Build blender (disable to build only the blender player)" ON)
111 mark_as_advanced(WITH_BLENDER)
112
113 option(WITH_INTERNATIONAL "Enable I18N (International fonts and text)" ON)
114
115 option(WITH_PYTHON        "Enable Embedded Python API  (only disable for development)" ON)
116 option(WITH_PYTHON_SECURITY "Disables execution of scripts within blend files by default (recommend to leave off)" OFF)
117 mark_as_advanced(WITH_PYTHON)  # dont want people disabling this unless they really know what they are doing.
118 mark_as_advanced(WITH_PYTHON_SECURITY)  # some distrobutions see this as a security issue, rather than have them patch it, make a build option.
119
120 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)
121 option(WITH_PYTHON_MODULE "Enable building as a python module (experemental, only enable for development)" OFF)
122 option(WITH_BUILDINFO     "Include extra build details (only disable for development & faster builds)" ON)
123 option(WITH_IK_ITASC      "Enable ITASC IK solver (only disable for development & for incompatible C++ compilers)" ON)
124 option(WITH_FFTW3         "Enable FFTW3 support (Used for smoke and audio effects)" OFF)
125 option(WITH_BULLET        "Enable Bullet (Physics Engine)" ON)
126 option(WITH_GAMEENGINE    "Enable Game Engine" ON)
127 option(WITH_PLAYER        "Build Player" OFF)
128
129 # GHOST Windowing Library Options
130 option(WITH_GHOST_DEBUG   "Enable debugging output for the GHOST library" OFF)
131 mark_as_advanced(WITH_GHOST_DEBUG)
132
133 option(WITH_GHOST_SDL    "Enable building blender against SDL for windowing rather then the native APIs" OFF)
134 mark_as_advanced(WITH_GHOST_SDL)
135
136 # Misc...
137 option(WITH_HEADLESS      "Build without graphical support (renderfarm, server mode only)" OFF)
138 mark_as_advanced(WITH_HEADLESS)
139
140 option(WITH_AUDASPACE    "Build with blenders audio library (only disable if you know what you're doing!)" ON)
141 mark_as_advanced(WITH_AUDASPACE)
142
143
144 # (unix defaults to OpenMP On)
145 if(UNIX AND NOT APPLE)
146         option(WITH_OPENMP        "Enable OpenMP (has to be supported by the compiler)" ON)
147 else()
148         option(WITH_OPENMP        "Enable OpenMP (has to be supported by the compiler)" OFF)
149 endif()
150
151 if(UNIX AND NOT APPLE)
152         option(WITH_X11_XINPUT "Enable X11 Xinput (tablet support)"     ON)
153         option(WITH_BUILTIN_GLEW "Use GLEW OpenGL wrapper library bundled with blender" ON)
154 else()
155         # not an option for other OS's
156         set(WITH_BUILTIN_GLEW ON)
157 endif()
158
159 # Modifiers
160 option(WITH_MOD_FLUID           "Enable Elbeem Modifier (Fluid Simulation)" ON)
161 option(WITH_MOD_SMOKE           "Enable Smoke Modifier (Smoke Simulation)" ON)
162 option(WITH_MOD_DECIMATE        "Enable Decimate Modifier" ON)
163 option(WITH_MOD_BOOLEAN         "Enable Boolean Modifier" ON)
164 option(WITH_MOD_CLOTH_ELTOPO    "Enable Experemental cloth solver" OFF)
165 mark_as_advanced(WITH_MOD_CLOTH_ELTOPO)
166
167 # Image format support
168 option(WITH_IMAGE_OPENEXR       "Enable OpenEXR Support (http://www.openexr.com)" ON)
169 option(WITH_IMAGE_OPENJPEG      "Enable OpenJpeg Support (http://www.openjpeg.org)" ON)
170 option(WITH_IMAGE_TIFF          "Enable LibTIFF Support" ON)
171 option(WITH_IMAGE_DDS           "Enable DDS Image Support" ON)
172 option(WITH_IMAGE_CINEON        "Enable CINEON and DPX Image Support" ON)
173 option(WITH_IMAGE_HDR           "Enable HDR Image Support" ON)
174 option(WITH_IMAGE_REDCODE       "Enable RedCode Image Support" OFF)
175 option(WITH_IMAGE_FRAMESERVER   "Enable image FrameServer Support for rendering" ON)
176
177 # Audio/Video format support
178 option(WITH_CODEC_FFMPEG        "Enable FFMPeg Support (http://ffmpeg.org)" OFF)
179 option(WITH_CODEC_SNDFILE       "Enable libsndfile Support (http://www.mega-nerd.com/libsndfile)" OFF)
180 if(APPLE OR (WIN32 AND NOT UNIX))
181         option(WITH_CODEC_QUICKTIME     "Enable Quicktime Support" OFF)
182 endif()
183
184 # 3D format support
185 # disable opencollada on non-apple unix because opencollada has no package for debian
186 option(WITH_OPENCOLLADA         "Enable OpenCollada Support (http://www.opencollada.org)"       OFF)
187
188 # Sound output
189 option(WITH_SDL           "Enable SDL for sound and joystick support" ON)
190 option(WITH_OPENAL        "Enable OpenAL Support (http://www.openal.org)" ON)
191 option(WITH_JACK          "Enable Jack Support (http://www.jackaudio.org)" OFF)
192 option(WITH_SAMPLERATE    "Enable samplerate conversion" ON)
193
194 # Compression
195 option(WITH_LZO           "Enable fast LZO compression (used for pointcache)" ON)
196 option(WITH_LZMA          "Enable best LZMA compression, (used for pointcache)" ON)
197
198 # Tracking
199 option(WITH_LIBMV         "Enable libmv structure from motion library" ON)
200
201 # Misc
202 option(WITH_INPUT_NDOF "Enable NDOF input devices (SpaceNavigator and friends)" ON)
203 option(WITH_RAYOPTIMIZATION     "Enable use of SIMD (SSE) optimizations for the raytracer" ON) 
204 if(UNIX AND NOT APPLE)
205         option(WITH_INSTALL_PORTABLE "Install redistributeable runtime, otherwise install into CMAKE_INSTALL_PREFIX" ON)
206 endif()
207 option(WITH_PYTHON_INSTALL       "Copy system python into the blender install folder" ON)
208
209 # disable for now, but plan to support on all platforms eventually
210 option(WITH_MEM_JEMALLOC   "Enable malloc replacement (http://www.canonware.com/jemalloc)" OFF)
211 mark_as_advanced(WITH_MEM_JEMALLOC)
212
213 # Debug
214 option(WITH_CXX_GUARDEDALLOC "Enable GuardedAlloc for C++ memory allocation tracking (only enable for development)" OFF)
215 mark_as_advanced(WITH_CXX_GUARDEDALLOC)
216
217 option(WITH_ASSERT_ABORT "Call abort() when raising an assertion through BLI_assert()" OFF)
218 mark_as_advanced(WITH_ASSERT_ABORT)
219
220 if(APPLE)
221         if(NOT CMAKE_OSX_ARCHITECTURES)
222                 set(CMAKE_OSX_ARCHITECTURES x86_64 CACHE STRING
223                 "Choose the architecture you want to build Blender for: i386, x86_64 or ppc"
224                 FORCE)
225         endif()
226         if(NOT CMAKE_OSX_DEPLOYMENT_TARGET)
227                 set(CMAKE_OSX_DEPLOYMENT_TARGET 10.5 CACHE STRING
228                 "Choose the minimum OSX version required: 10.4 or 10.5"
229                 FORCE)
230         endif()
231         option(WITH_COCOA         "Use Cocoa framework instead of deprecated Carbon" ON)
232         option(USE_QTKIT          "Use QtKit instead of Carbon quicktime (needed for having partial quicktime for 64bit)" OFF)
233         option(WITH_LIBS10.5  "Use 10.5 libs (needed for 64bit builds)" OFF)
234 endif()
235
236 #-----------------------------------------------------------------------------
237 # Check for conflicting/unsupported configurations
238
239 if(NOT WITH_BLENDER AND NOT WITH_PLAYER)
240         message(FATAL_ERROR "At least one of WITH_BLENDER or WITH_PLAYER must be enabled, nothing to do!")
241 endif()
242
243 if(NOT WITH_GAMEENGINE AND WITH_PLAYER)
244         message(FATAL_ERROR "WITH_PLAYER requires WITH_GAMEENGINE")
245 endif()
246
247 if(NOT WITH_AUDASPACE AND (WITH_OPENAL OR WITH_SDL OR WITH_JACK))
248         message(FATAL_ERROR "WITH_OPENAL/WITH_SDL/WITH_JACK/WITH_CODEC_FFMPEG require WITH_AUDASPACE")
249 endif()
250
251 if(NOT WITH_SDL AND WITH_GHOST_SDL)
252         message(FATAL_ERROR "WITH_GHOST_SDL requires WITH_SDL to be ON")
253 endif()
254
255 if(NOT WITH_IMAGE_OPENJPEG AND WITH_IMAGE_REDCODE)
256         message(FATAL_ERROR "WITH_IMAGE_REDCODE requires WITH_IMAGE_OPENJPEG")
257 endif()
258
259 # python module, needs some different options
260 if(WITH_PYTHON_MODULE AND WITH_PLAYER)
261         message(FATAL_ERROR "WITH_PYTHON_MODULE requires WITH_PLAYER to be OFF")
262 endif()
263
264 if(WITH_PYTHON_MODULE AND WITH_PYTHON_INSTALL)
265         message(FATAL_ERROR "WITH_PYTHON_MODULE requires WITH_PYTHON_INSTALL to be OFF")
266 endif()
267
268 if(WITH_CODEC_QUICKTIME AND MINGW)
269         message(FATAL_ERROR "MINGW requires WITH_CODEC_QUICKTIME to be OFF "
270                                                 "because it is currently unsupported, remove this "
271                                                 "line if youre a developer who wants to add support.")
272 endif()
273
274 # may as well build python module without a UI
275 if(WITH_PYTHON_MODULE)
276         set(WITH_HEADLESS ON)
277 endif()
278
279 TEST_SSE_SUPPORT()
280
281 # don't store paths to libs for portable distrobution
282 if(WITH_INSTALL_PORTABLE)
283         set(CMAKE_SKIP_BUILD_RPATH TRUE)
284 endif()
285
286 #-----------------------------------------------------------------------------
287 # Initialize un-cached vars, avoid unused warning
288
289 # linux only, not cached
290 set(WITH_BINRELOC OFF)
291
292 # MAXOSX only, set to avoid uninitialized 
293 set(EXETYPE)
294
295 # C/C++ flags
296 set(PLATFORM_CFLAGS)
297
298 # these are added to later on.
299 set(C_WARNINGS)
300 set(CXX_WARNINGS)
301
302 # libraries to link the binary with passed to target_link_libraries()
303 # known as LLIBS to scons
304 set(PLATFORM_LINKLIBS)
305
306 # Added to linker flags in setup_liblinks
307 # - CMAKE_EXE_LINKER_FLAGS
308 # - CMAKE_EXE_LINKER_FLAGS_DEBUG
309 set(PLATFORM_LINKFLAGS)
310 set(PLATFORM_LINKFLAGS_DEBUG)
311
312
313 # disabled for now, not supported
314 # option(WITH_WEBPLUGIN     "Enable Web Plugin (Unix only)" OFF)
315
316 # For alternate Python locations the commandline can be used to override detected/default cache settings, e.g:
317 # On Unix: 
318 #   cmake ../blender \
319 #         -D PYTHON_VERSION=3.2 \
320 #         -D PYTHON_INCLUDE_DIR=/opt/py32/include/python3.2d \
321 #         -D PYTHON_LIBRARY=/opt/py32/lib/libpython3.2d.so
322 #
323 # On Macs: 
324 #   cmake ../blender \
325 #         -D PYTHON_INCLUDE_DIR=/System/Library/Frameworks/Python.framework/Versions/3.2/include/python3.2 \
326 #         -D PYTHON_LIBPATH=/System/Library/Frameworks/Python.framework/Versions/3.2/lib/python3.2/config \
327 #         -G Xcode
328 #
329 # When changing any of this remember to update the notes in doc/build_systems/cmake.txt
330
331 #-----------------------------------------------------------------------------
332 #Platform specifics
333
334 if(UNIX AND NOT APPLE)
335         
336         # needed for ubuntu 11.04
337         if(EXISTS "/usr/lib/x86_64-linux-gnu")
338                 set(CMAKE_LIBRARY_PATH "/usr/lib/x86_64-linux-gnu;${CMAKE_LIBRARY_PATH}")
339         endif()
340
341         find_package(JPEG REQUIRED)
342         find_package(PNG REQUIRED)
343         find_package(ZLIB REQUIRED)
344         find_package(Freetype REQUIRED)
345
346         if(WITH_PYTHON)
347                 # No way to set py32. remove for now.
348                 # find_package(PythonLibs)
349
350                 # Use our own instead, since wothout py is such a rare case,
351                 # require this package
352                 find_package(PythonLibsUnix REQUIRED)
353         endif()
354
355
356         if(WITH_IMAGE_OPENEXR)
357                 find_package(OpenEXR)  # our own module
358                 if(NOT OPENEXR_FOUND)
359                         set(WITH_IMAGE_OPENEXR OFF)
360                 endif()
361         endif()
362
363         if(WITH_IMAGE_OPENJPEG)
364                 find_package(OpenJPEG)
365                 if(NOT OPENJPEG_FOUND)
366                         set(WITH_IMAGE_OPENJPEG OFF)
367                 endif()
368         endif()
369
370         if(WITH_IMAGE_TIFF)
371                 find_package(TIFF)
372                 if(NOT TIFF_FOUND)
373                         set(WITH_IMAGE_TIFF OFF)
374                 endif()
375         endif()
376
377         # Audio IO
378         if(WITH_OPENAL)
379                 find_package(OpenAL)
380                 if(NOT OPENAL_FOUND)
381                         set(WITH_OPENAL OFF)
382                 endif()
383         endif()
384
385         if(WITH_SDL)
386                 find_package(SDL)
387                 mark_as_advanced(SDLMAIN_LIBRARY)
388                 mark_as_advanced(SDL_INCLUDE_DIR)
389                 mark_as_advanced(SDL_LIBRARY)
390                 mark_as_advanced(SDL_LIBRARY_TEMP)
391                 # unset(SDLMAIN_LIBRARY CACHE)
392                 if(NOT SDL_FOUND)
393                         set(WITH_SDL OFF)
394                 endif()
395         endif()
396
397         if(WITH_JACK)
398                 find_package(Jack)
399                 if(NOT JACK_FOUND)
400                         set(WITH_JACK OFF)
401                 endif()
402         endif()
403
404         # Codecs
405         if(WITH_CODEC_SNDFILE)
406                 find_package(SndFile)
407                 if(NOT SNDFILE_FOUND)
408                         set(WITH_CODEC_SNDFILE OFF)
409                 endif()
410         endif()
411
412         if(WITH_CODEC_FFMPEG)
413                 set(FFMPEG /usr CACHE PATH "FFMPEG Directory")
414                 mark_as_advanced(FFMPEG)
415                 set(FFMPEG_INCLUDE_DIRS ${FFMPEG}/include)
416                 set(FFMPEG_LIBRARIES avformat avcodec avutil avdevice swscale CACHE STRING "FFMPEG Libraries")
417                 mark_as_advanced(FFMPEG_LIBRARIES)
418                 set(FFMPEG_LIBPATH ${FFMPEG}/lib)
419                 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D__STDC_CONSTANT_MACROS")
420         endif()
421
422         if(WITH_INTERNATIONAL)
423                 find_library(INTL_LIBRARY
424                         NAMES intl
425                         PATHS
426                         /sw/lib
427                 )
428
429                 find_library(ICONV_LIBRARY
430                         NAMES iconv
431                         PATHS
432                         /sw/lib
433                 )
434                 mark_as_advanced(ICONV_LIBRARY)
435                 mark_as_advanced(INTL_LIBRARY)
436
437                 if(INTL_LIBRARY AND ICONV_LIBRARY)
438                         set(GETTEXT_LIB ${INTL_LIBRARY} ${ICONV_LIBRARY})
439                 endif()
440         endif()
441
442         if(WITH_FFTW3)
443                 find_package(Fftw3)
444                 if(NOT FFTW3_FOUND)
445                         set(WITH_FFTW3 OFF)
446                 endif()
447         endif()
448
449         if(WITH_SAMPLERATE)
450                 find_package(Samplerate)
451                 if(NOT SAMPLERATE_FOUND)
452                         set(WITH_SAMPLERATE OFF)
453                 endif()
454         endif()
455
456         if(WITH_OPENCOLLADA)
457                 find_package(OpenCOLLADA)
458                 if(OPENCOLLADA_FOUND)
459                         find_package(XML2)
460                         find_package(PCRE)
461                 else()
462                         set(WITH_OPENCOLLADA OFF)
463                 endif()
464         endif()
465
466         if(WITH_MEM_JEMALLOC)
467                 find_package(JeMalloc)
468                 if(NOT JEMALLOC_FOUND)
469                         set(WITH_MEM_JEMALLOC OFF)
470                 endif()
471         endif()
472
473         if (WITH_INPUT_NDOF)
474                 find_package(Spacenav)
475                 if(NOT SPACENAV_FOUND)
476                         set(WITH_INPUT_NDOF OFF)
477                 endif()
478
479                 # use generic names within blenders buildsystem.
480                 if(SPACENAV_FOUND)
481                         set(NDOF_INCLUDE_DIRS ${SPACENAV_INCLUDE_DIRS})
482                         set(NDOF_LIBRARIES ${SPACENAV_LIBRARIES})
483                 endif()
484         endif()
485
486         # OpenSuse needs lutil, ArchLinux not, for now keep, can avoid by using --as-needed
487         set(PLATFORM_LINKLIBS "-lutil -lc -lm -lpthread -lstdc++")
488
489         if((NOT WITH_HEADLESS) AND (NOT WITH_GHOST_SDL))
490                 find_package(X11 REQUIRED)
491                 find_path(X11_XF86keysym_INCLUDE_PATH X11/XF86keysym.h ${X11_INC_SEARCH_PATH})
492                 mark_as_advanced(X11_XF86keysym_INCLUDE_PATH)
493
494                 list(APPEND PLATFORM_LINKLIBS ${X11_X11_LIB})
495
496                 if(WITH_X11_XINPUT)
497                         list(APPEND PLATFORM_LINKLIBS ${X11_Xinput_LIB})
498                 endif()
499         endif()
500
501         if(CMAKE_SYSTEM_NAME MATCHES "Linux")
502                 if(NOT WITH_PYTHON_MODULE)
503                         # BSD's dont use libdl.so
504                         list(APPEND PLATFORM_LINKLIBS -ldl)
505                         # binreloc is linux only
506                         set(BINRELOC_INCLUDE_DIRS ${CMAKE_SOURCE_DIR}/extern/binreloc/include)
507                         set(WITH_BINRELOC ON)
508                 endif()
509         endif()
510
511         set(PLATFORM_LINKFLAGS "-pthread")
512
513         set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE")
514         set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE")
515
516         # GNU Compiler
517         if(CMAKE_COMPILER_IS_GNUCC)
518                 set(PLATFORM_CFLAGS "-pipe -fPIC -funsigned-char -fno-strict-aliasing")
519         # CLang is the same as GCC for now.
520         elseif(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
521                 set(PLATFORM_CFLAGS "-pipe -fPIC -funsigned-char -fno-strict-aliasing")
522         # Intel C++ Compiler
523         elseif(CMAKE_C_COMPILER_ID MATCHES "Intel")
524                 # think these next two are broken
525                 find_program(XIAR xiar) 
526                 if(XIAR) 
527                         set(CMAKE_AR "${XIAR}")
528                 endif() 
529                 mark_as_advanced(XIAR)
530
531                 find_program(XILD xild) 
532                 if(XILD) 
533                         set(CMAKE_LINKER "${XILD}")
534                 endif() 
535                 mark_as_advanced(XILD)
536
537                 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fp-model precise -prec_div -parallel")
538                 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fp-model precise -prec_div -parallel")
539
540                 # set(PLATFORM_CFLAGS "${PLATFORM_CFLAGS} -diag-enable sc3")
541                 set(PLATFORM_CFLAGS "-pipe -fPIC -funsigned-char -fno-strict-aliasing")
542                 set(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} -static-intel")
543         endif()
544
545 elseif(WIN32)
546
547         # this file is included anyway when building under Windows with cl.exe
548         #  include(${CMAKE_ROOT}/Modules/Platform/Windows-cl.cmake)
549
550         set(LIBDIR ${CMAKE_SOURCE_DIR}/../lib/windows)
551
552         # Setup 64bit and 64bit windows systems
553         if(CMAKE_CL_64)
554                 message("64 bit compiler detected.")
555                 set(LIBDIR ${CMAKE_SOURCE_DIR}/../lib/win64)
556         endif()
557         
558         add_definitions(-DWIN32)
559
560         if(WITH_INTERNATIONAL)
561                 set(ICONV ${LIBDIR}/iconv)
562                 set(ICONV_INCLUDE_DIRS ${ICONV}/include)
563                 set(ICONV_LIBRARIES iconv)
564                 set(ICONV_LIBPATH ${ICONV}/lib)
565         endif()
566
567         if(WITH_SAMPLERATE)
568                 set(SAMPLERATE ${LIBDIR}/samplerate)
569                 set(SAMPLERATE_INCLUDE_DIRS ${SAMPLERATE}/include)
570                 set(SAMPLERATE_LIBRARIES libsamplerate)
571                 set(SAMPLERATE_LIBPATH ${SAMPLERATE}/lib)
572         endif()
573
574         set(PNG "${LIBDIR}/png")
575         set(PNG_INCLUDE_DIR "${PNG}/include")
576         set(PNG_LIBPATH ${PNG}/lib) # not cmake defined
577
578         set(JPEG "${LIBDIR}/jpeg")
579         set(JPEG_INCLUDE_DIR "${JPEG}/include")
580         set(JPEG_LIBPATH ${JPEG}/lib) # not cmake defined
581
582         set(WINTAB_INC ${LIBDIR}/wintab/include) 
583
584         if(WITH_OPENAL)
585                 set(OPENAL ${LIBDIR}/openal)
586                 set(OPENAL_INCLUDE_DIR ${OPENAL}/include)
587                 set(OPENAL_LIBRARY wrap_oal)
588                 set(OPENAL_LIBPATH ${OPENAL}/lib)
589         endif()
590
591         if(WITH_CODEC_SNDFILE)
592                 set(SNDFILE ${LIBDIR}/sndfile)
593                 set(SNDFILE_INCLUDE_DIRS ${SNDFILE}/include)
594                 set(SNDFILE_LIBRARIES libsndfile-1)
595                 set(SNDFILE_LIBPATH ${SNDFILE}/lib) # TODO, deprecate
596         endif()
597
598         if(WITH_SDL)
599                 set(SDL ${LIBDIR}/sdl)
600                 set(SDL_INCLUDE_DIR ${SDL}/include)
601                 set(SDL_LIBRARY SDL)
602                 set(SDL_LIBPATH ${SDL}/lib)
603         endif()
604
605         if(WITH_CODEC_QUICKTIME)
606                 set(QUICKTIME ${LIBDIR}/QTDevWin)
607                 set(QUICKTIME_INCLUDE_DIRS ${QUICKTIME}/CIncludes)
608                 set(QUICKTIME_LIBRARIES qtmlClient)
609                 set(QUICKTIME_LIBPATH ${QUICKTIME}/Libraries)
610         endif()
611
612         if(WITH_RAYOPTIMIZATION AND SUPPORT_SSE_BUILD)
613                 add_definitions(-D__SSE__ -D__MMX__)
614         endif()
615
616         if(MSVC)
617                 if(CMAKE_CL_64)
618                         set(PLATFORM_LINKLIBS ws2_32 vfw32 winmm kernel32 user32 gdi32 comdlg32 advapi32 shfolder shell32 ole32 oleaut32 uuid)
619                 else()
620                         set(PLATFORM_LINKLIBS ws2_32 vfw32 winmm kernel32 user32 gdi32 comdlg32 advapi32 shfolder shell32 ole32 oleaut32 uuid)
621                 endif()
622
623                 add_definitions(/D_CRT_NONSTDC_NO_DEPRECATE /D_CRT_SECURE_NO_DEPRECATE /D_SCL_SECURE_NO_DEPRECATE /D_CONSOLE /D_LIB)
624
625                 set(CMAKE_CXX_FLAGS "/nologo /J /W0 /Gd /wd4018 /wd4244 /wd4305 /wd4800 /wd4065 /wd4267 /we4013" CACHE STRING "MSVC MT C++ flags " FORCE)
626                 set(CMAKE_C_FLAGS   "/nologo /J /W0 /Gd /wd4018 /wd4244 /wd4305 /wd4800 /wd4065 /wd4267 /we4013 /EHsc" CACHE STRING "MSVC MT C++ flags " FORCE)
627
628                 if(CMAKE_CL_64)
629                         set(CMAKE_CXX_FLAGS_DEBUG "/D_DEBUG /Od /Gm /EHsc /RTC1 /MTd /W3 /nologo /Zi /J" CACHE STRING "MSVC MT flags " FORCE)
630                 else()
631                         set(CMAKE_CXX_FLAGS_DEBUG "/D_DEBUG /Od /Gm /EHsc /RTC1 /MTd /W3 /nologo /ZI /J" CACHE STRING "MSVC MT flags " FORCE)
632                 endif()
633                 set(CMAKE_CXX_FLAGS_RELEASE "/O2 /Ob2 /DNDEBUG /EHsc /MT /W3 /nologo /J" CACHE STRING "MSVC MT flags " FORCE)
634                 set(CMAKE_CXX_FLAGS_MINSIZEREL "/O1 /Ob1 /DNDEBUG /EHsc /MT /W3 /nologo /J" CACHE STRING "MSVC MT flags " FORCE)
635                 set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "/O2 /Ob1 /DNDEBUG /EHsc /MT /W3 /nologo /Zi /J" CACHE STRING "MSVC MT flags " FORCE)
636                 if(CMAKE_CL_64)
637                         set(CMAKE_C_FLAGS_DEBUG "/D_DEBUG /Od /Gm /EHsc /RTC1 /MTd /W3 /nologo /Zi /J" CACHE STRING "MSVC MT flags " FORCE)
638                 else()
639                         set(CMAKE_C_FLAGS_DEBUG "/D_DEBUG /Od /Gm /EHsc /RTC1 /MTd /W3 /nologo /ZI /J" CACHE STRING "MSVC MT flags " FORCE)
640                 endif()
641                 set(CMAKE_C_FLAGS_RELEASE "/O2 /Ob2 /DNDEBUG /EHsc /MT /W3 /nologo /J" CACHE STRING "MSVC MT flags " FORCE)
642                 set(CMAKE_C_FLAGS_MINSIZEREL "/O1 /Ob1 /DNDEBUG /EHsc /MT /W3 /nologo /J" CACHE STRING "MSVC MT flags " FORCE)
643                 set(CMAKE_C_FLAGS_RELWITHDEBINFO "/O2 /Ob1 /DNDEBUG /EHsc /MT /W3 /nologo /Zi /J" CACHE STRING "MSVC MT flags " FORCE)
644
645                 if(WITH_INTERNATIONAL)
646                         set(GETTEXT ${LIBDIR}/gettext)
647                         set(GETTEXT_INC ${GETTEXT}/include)
648                         set(GETTEXT_LIBPATH ${GETTEXT}/lib)
649                         set(GETTEXT_LIB gnu_gettext)
650                 endif()
651
652                 if(CMAKE_CL_64)
653                         set(PNG_LIBRARIES libpng)
654                 else()
655                         set(PNG_LIBRARIES libpng_st)
656                 endif()
657                 set(JPEG_LIBRARIES libjpeg)
658
659                 set(ZLIB_INCLUDE_DIRS ${LIBDIR}/zlib/include)
660                 if(CMAKE_CL_64)
661                         set(ZLIB_LIBRARIES ${LIBDIR}/zlib/lib/libz.lib)
662                 else()
663                         set(ZLIB_LIBRARIES ${LIBDIR}/zlib/lib/zlib.lib)
664                 endif()
665
666                 set(PTHREADS_INCLUDE_DIRS ${LIBDIR}/pthreads/include)
667                 set(PTHREADS_LIBRARIES ${LIBDIR}/pthreads/lib/pthreadVC2.lib)
668
669                 set(FREETYPE ${LIBDIR}/freetype)
670                 set(FREETYPE_INCLUDE_DIRS
671                         ${LIBDIR}/freetype/include
672                         ${LIBDIR}/freetype/include/freetype2
673                 )
674                 set(FREETYPE_LIBRARY ${LIBDIR}/freetype/lib/freetype2ST.lib)
675
676                 if(WITH_FFTW3)
677                         set(FFTW3 ${LIBDIR}/fftw3)
678                         set(FFTW3_LIBRARIES libfftw)
679                         set(FFTW3_INCLUDE_DIRS ${FFTW3}/include)
680                         set(FFTW3_LIBPATH ${FFTW3}/lib)
681                 endif()
682
683                 if(WITH_OPENCOLLADA)
684
685                         set(OPENCOLLADA_INCLUDE_DIRS
686                                 ${LIBDIR}/opencollada/include/COLLADAStreamWriter/include
687                                 ${LIBDIR}/opencollada/include/COLLADABaseUtils/include
688                                 ${LIBDIR}/opencollada/include/COLLADAFramework/include
689                                 ${LIBDIR}/opencollada/include/COLLADASaxFrameworkLoader/include
690                                 ${LIBDIR}/opencollada/include/GeneratedSaxParser/include                        
691                         )
692
693                         set(OPENCOLLADA_LIBRARIES
694                                 ${LIBDIR}/opencollada/lib/OpenCOLLADASaxFrameworkLoader.lib
695                                 ${LIBDIR}/opencollada/lib/OpenCOLLADAFramework.lib
696                                 ${LIBDIR}/opencollada/lib/OpenCOLLADABaseUtils.lib
697                                 ${LIBDIR}/opencollada/lib/OpenCOLLADAStreamWriter.lib
698                                 ${LIBDIR}/opencollada/lib/MathMLSolver.lib
699                                 ${LIBDIR}/opencollada/lib/GeneratedSaxParser.lib
700                                 ${LIBDIR}/opencollada/lib/xml2.lib
701                                 ${LIBDIR}/opencollada/lib/buffer.lib
702                                 ${LIBDIR}/opencollada/lib/ftoa.lib
703                                 ${LIBDIR}/opencollada/lib/UTF.lib
704                         )
705                         set(PCRE_LIBRARIES
706                                 ${LIBDIR}/opencollada/lib/pcre.lib
707                         )
708                 endif()
709
710                 if(WITH_CODEC_FFMPEG)
711                         set(FFMPEG_INCLUDE_DIRS
712                                 ${LIBDIR}/ffmpeg/include
713                                 ${LIBDIR}/ffmpeg/include/msvc
714                         )
715                         set(FFMPEG_LIBRARIES
716                                 ${LIBDIR}/ffmpeg/lib/avcodec-53.lib
717                                 ${LIBDIR}/ffmpeg/lib/avformat-53.lib
718                                 ${LIBDIR}/ffmpeg/lib/avdevice-53.lib
719                                 ${LIBDIR}/ffmpeg/lib/avutil-51.lib
720                                 ${LIBDIR}/ffmpeg/lib/swscale-2.lib
721                         )
722                 endif()
723
724                 if(WITH_IMAGE_OPENEXR)
725                         if(MSVC90)
726                                 set(MSVC_LIB _vs2008)
727                                 set(MSVC_INC)
728                         elseif(MSVC10)
729                                 set(MSVC_LIB _vs2010)
730                                 set(MSVC_INC _vs2010)
731                         else()
732                                 set(MSVC_LIB msvc)
733                                 set(MSVC_INC)
734                         endif()
735                         set(OPENEXR ${LIBDIR}/openexr)
736                         set(OPENEXR_LIBPATH ${OPENEXR}/lib${MSVC_LIB})
737                         set(OPENEXR_LIBRARIES
738                                 ${OPENEXR_LIBPATH}/Iex.lib
739                                 ${OPENEXR_LIBPATH}/Half.lib
740                                 ${OPENEXR_LIBPATH}/IlmImf.lib
741                                 ${OPENEXR_LIBPATH}/Imath.lib
742                                 ${OPENEXR_LIBPATH}/IlmThread.lib
743                         )
744                         set(OPENEXR_INCUDE ${OPENEXR}/include${MSVC_INC})
745                         set(OPENEXR_INCLUDE_DIRS
746                                 ${OPENEXR_INCUDE}
747                                 ${OPENEXR_INCUDE}/IlmImf
748                                 ${OPENEXR_INCUDE}/Iex
749                                 ${OPENEXR_INCUDE}/Imath
750                         )
751                         unset(OPENEXR_INCUDE)
752                         unset(OPENEXR_LIBPATH)
753                 endif()
754
755                 if(WITH_IMAGE_TIFF)
756                         set(TIFF_LIBRARY ${LIBDIR}/tiff/lib/libtiff.lib)
757                         set(TIFF_INCLUDE_DIR ${LIBDIR}/tiff/include)
758                 endif()
759
760                 if(WITH_JACK)
761                         set(JACK_INCLUDE_DIRS
762                                 ${LIBDIR}/jack/include/jack
763                                 ${LIBDIR}/jack/include
764                         )
765                         set(JACK_LIBRARIES ${LIBDIR}/jack/lib/libjack.lib)
766                 endif()
767
768                 if(WITH_PYTHON)
769                         # normally cached but not since we include them with blender
770                         set(PYTHON_VERSION 3.2) # CACHE STRING)
771                         set(PYTHON_INCLUDE_DIR "${LIBDIR}/python/include/python${PYTHON_VERSION}") # CACHE PATH)
772                         set(PYTHON_LIBRARY "${LIBDIR}/python/lib/python32.lib") #CACHE FILEPATH)
773
774                         # uncached vars
775                         set(PYTHON_INCLUDE_DIRS "${PYTHON_INCLUDE_DIR}")
776                         set(PYTHON_LIBRARIES  "${PYTHON_LIBRARY}")
777                 endif()
778
779                 set(PLATFORM_LINKFLAGS "/SUBSYSTEM:CONSOLE /STACK:2097152 /INCREMENTAL:NO /NODEFAULTLIB:msvcrt.lib /NODEFAULTLIB:msvcmrt.lib /NODEFAULTLIB:msvcurt.lib /NODEFAULTLIB:msvcrtd.lib")
780
781                 # MSVC only, Mingw doesnt need
782                 if(CMAKE_CL_64)
783                         set(PLATFORM_LINKFLAGS "/MACHINE:X64 /OPT:NOREF ${PLATFORM_LINKFLAGS}")
784                 else()
785                         set(PLATFORM_LINKFLAGS "/MACHINE:IX86 /LARGEADDRESSAWARE ${PLATFORM_LINKFLAGS}")
786                 endif()
787
788                 set(PLATFORM_LINKFLAGS_DEBUG "/NODEFAULTLIB:libcmt.lib /NODEFAULTLIB:libc.lib")
789
790         else()
791                 # keep GCC spesific stuff here
792                 if(CMAKE_COMPILER_IS_GNUCC)
793                         set(PLATFORM_LINKLIBS "-lshell32 -lshfolder -lgdi32 -lmsvcrt -lwinmm -lmingw32 -lm -lws2_32 -lz -lstdc++ -lole32 -luuid -lwsock32")
794                         set(PLATFORM_CFLAGS "-pipe -funsigned-char -fno-strict-aliasing")
795
796                         add_definitions(-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE)
797                 endif()
798
799                 add_definitions(-DFREE_WINDOWS)
800
801                 set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -D_DEBUG")
802                 set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -D_DEBUG")
803
804                 if(WITH_INTERNATIONAL)
805                         set(GETTEXT ${LIBDIR}/gcc/gettext)
806                         set(GETTEXT_INC ${GETTEXT}/include)
807                         set(GETTEXT_LIBPATH ${GETTEXT}/lib)
808                         set(GETTEXT_LIB intl)
809                 endif()
810
811                 set(JPEG_LIBRARIES libjpeg)
812                 set(PNG_LIBRARIES png)
813
814                 set(ZLIB ${LIBDIR}/zlib)
815                 set(ZLIB_INCLUDE_DIRS ${ZLIB}/include)
816                 set(ZLIB_LIBPATH ${ZLIB}/lib)
817                 set(ZLIB_LIBRARIES z)
818
819                 set(PTHREADS ${LIBDIR}/pthreads)
820                 set(PTHREADS_INCLUDE_DIRS ${PTHREADS}/include)
821                 set(PTHREADS_LIBPATH ${PTHREADS}/lib)
822                 set(PTHREADS_LIBRARIES pthreadGC2)
823                 
824                 set(FREETYPE ${LIBDIR}/gcc/freetype)
825                 set(FREETYPE_INCLUDE_DIRS ${FREETYPE}/include ${FREETYPE}/include/freetype2)
826                 set(FREETYPE_LIBPATH ${FREETYPE}/lib)
827                 set(FREETYPE_LIBRARY freetype)
828
829                 if(WITH_FFTW3)
830                         set(FFTW3 ${LIBDIR}/gcc/fftw3)
831                         set(FFTW3_LIBRARIES fftw3)
832                         set(FFTW3_INCLUDE_DIRS ${FFTW3}/include)
833                         set(FFTW3_LIBPATH ${FFTW3}/lib)
834                 endif()
835
836                 if(WITH_OPENCOLLADA)
837                         set(OPENCOLLADA ${LIBDIR}/gcc/opencollada)
838                         set(OPENCOLLADA_INCLUDE_DIRS
839                                 ${LIBDIR}/gcc/opencollada/include/COLLADAStreamWriter/include
840                                 ${LIBDIR}/gcc/opencollada/include/COLLADABaseUtils/include
841                                 ${LIBDIR}/gcc/opencollada/include/COLLADAFramework/include
842                                 ${LIBDIR}/gcc/opencollada/include/COLLADASaxFrameworkLoader/include
843                                 ${LIBDIR}/gcc/opencollada/include/GeneratedSaxParser/include                    
844                         )
845                         set(OPENCOLLADA_LIBPATH ${OPENCOLLADA}/lib ${OPENCOLLADA}/lib)
846                         set(OPENCOLLADA_LIBRARIES OpenCOLLADAStreamWriter OpenCOLLADASaxFrameworkLoader OpenCOLLADAFramework OpenCOLLADABaseUtils GeneratedSaxParser UTF MathMLSolver expat pcre buffer ftoa)
847                         set(PCRE_LIBRARIES pcre)
848                 endif()
849                 
850                 if(WITH_CODEC_FFMPEG)
851                         set(FFMPEG ${LIBDIR}/ffmpeg)
852                         set(FFMPEG_INCLUDE_DIRS ${FFMPEG}/include ${FFMPEG}/include)
853                         set(FFMPEG_LIBRARIES avcodec-53 avformat-53 avdevice-53 avutil-51 swscale-2)
854                         set(FFMPEG_LIBPATH ${FFMPEG}/lib)
855                 endif()
856
857                 if(WITH_IMAGE_OPENEXR)
858                         set(OPENEXR ${LIBDIR}/gcc/openexr)
859                         set(OPENEXR_INCLUDE_DIRS ${OPENEXR}/include/OpenEXR)
860                         set(OPENEXR_LIBRARIES Half IlmImf Imath IlmThread Iex)
861                         set(OPENEXR_LIBPATH ${OPENEXR}/lib)
862                 endif()
863
864                 if(WITH_IMAGE_TIFF)
865                         set(TIFF ${LIBDIR}/gcc/tiff)
866                         set(TIFF_LIBRARY tiff)
867                         set(TIFF_INCLUDE_DIR ${TIFF}/include)
868                         set(TIFF_LIBPATH ${TIFF}/lib)
869                 endif()
870
871                 if(WITH_JACK)
872                         set(JACK ${LIBDIR}/jack)
873                         set(JACK_INCLUDE_DIRS ${JACK}/include/jack ${JACK}/include)
874                         set(JACK_LIBRARIES jack)
875                         set(JACK_LIBPATH ${JACK}/lib)
876                         
877                         # TODO, gives linking errors, force off
878                         set(WITH_JACK OFF)
879                 endif()
880
881                 if(WITH_PYTHON)
882                         # normally cached but not since we include them with blender
883                         set(PYTHON_VERSION 3.2) #  CACHE STRING)
884                         set(PYTHON_INCLUDE_DIR "${LIBDIR}/python/include/python${PYTHON_VERSION}")  # CACHE PATH)
885                         set(PYTHON_LIBRARY "${LIBDIR}/python/lib/python32mw.lib")  # CACHE FILEPATH)
886
887                         # uncached vars
888                         set(PYTHON_INCLUDE_DIRS "${PYTHON_INCLUDE_DIR}")
889                         set(PYTHON_LIBRARIES  "${PYTHON_LIBRARY}")
890                 endif()
891
892                 set(PLATFORM_LINKFLAGS "--stack,2097152")
893
894         endif()
895
896         # used in many places so include globally, like OpenGL
897         blender_include_dirs("${PTHREADS_INCLUDE_DIRS}")
898
899 elseif(APPLE)
900
901         if (${CMAKE_OSX_DEPLOYMENT_TARGET} STREQUAL "10.5")
902                 set(WITH_LIBS10.5 ON CACHE BOOL "Use 10.5 libs" FORCE)
903         endif()
904
905         if(WITH_LIBS10.5)
906                 set(LIBDIR ${CMAKE_SOURCE_DIR}/../lib/darwin-9.x.universal)
907         else()
908                 if(CMAKE_OSX_ARCHITECTURES MATCHES i386)
909                         set(LIBDIR ${CMAKE_SOURCE_DIR}/../lib/darwin-8.x.i386)
910                 else()
911                         set(LIBDIR ${CMAKE_SOURCE_DIR}/../lib/darwin-8.0.0-powerpc)
912                 endif()
913         endif()
914         
915
916         if(WITH_OPENAL)
917                 find_package(OpenAL)
918                 if(OPENAL_FOUND)
919                         set(WITH_OPENAL ON)
920                         set(OPENAL_INCLUDE_DIR "${LIBDIR}/openal/include")
921                 else()
922                         set(WITH_OPENAL OFF)
923                 endif()
924         endif()
925
926         if(WITH_JACK)
927                 set(JACK /usr)
928                 set(JACK_INCLUDE_DIRS ${JACK}/include/jack)
929                 set(JACK_LIBRARIES jack)
930                 set(JACK_LIBPATH ${JACK}/lib)
931         endif()
932
933         if(WITH_CODEC_SNDFILE)
934                 set(SNDFILE ${LIBDIR}/sndfile)
935                 set(SNDFILE_INCLUDE_DIRS ${SNDFILE}/include)
936                 set(SNDFILE_LIBRARIES sndfile FLAC ogg vorbis vorbisenc)
937                 set(SNDFILE_LIBPATH ${SNDFILE}/lib ${FFMPEG}/lib)  # TODO, deprecate
938         endif()
939
940         if(WITH_PYTHON)
941                 # we use precompiled libraries for py 3.2 and up by default
942
943                 # normally cached but not since we include them with blender
944                 set(PYTHON_VERSION 3.2)
945                 set(PYTHON_INCLUDE_DIR "${LIBDIR}/python/include/python${PYTHON_VERSION}")
946                 # set(PYTHON_BINARY "${LIBDIR}/python/bin/python${PYTHON_VERSION}") # not used yet
947                 set(PYTHON_LIBRARY python${PYTHON_VERSION})
948                 set(PYTHON_LIBPATH "${LIBDIR}/python/lib/python${PYTHON_VERSION}")
949                 # set(PYTHON_LINKFLAGS "-u _PyMac_Error")  # won't  build with this enabled
950
951                 # uncached vars
952                 set(PYTHON_INCLUDE_DIRS "${PYTHON_INCLUDE_DIR}")
953                 set(PYTHON_LIBRARIES  "${PYTHON_LIBRARY}")
954         endif()
955
956         if(WITH_INTERNATIONAL)
957                 set(GETTEXT ${LIBDIR}/gettext)
958                 set(GETTEXT_INC "${GETTEXT}/include")
959                 set(GETTEXT_LIB intl iconv)
960                 set(GETTEXT_LIBPATH ${GETTEXT}/lib)
961         endif()
962
963         if(WITH_FFTW3)
964                 set(FFTW3 ${LIBDIR}/fftw3)
965                 set(FFTW3_INCLUDE_DIRS ${FFTW3}/include)
966                 set(FFTW3_LIBRARIES fftw3)
967                 set(FFTW3_LIBPATH ${FFTW3}/lib)
968         endif()
969
970         set(PNG_LIBRARIES png)
971         set(JPEG_LIBRARIES jpeg)
972
973         set(ZLIB /usr)
974         set(ZLIB_INCLUDE_DIRS "${ZLIB}/include")
975         set(ZLIB_LIBRARIES z bz2)
976
977         set(FREETYPE ${LIBDIR}/freetype)
978         set(FREETYPE_INCLUDE_DIRS ${FREETYPE}/include ${FREETYPE}/include/freetype2)
979         set(FREETYPE_LIBPATH ${FREETYPE}/lib)
980         set(FREETYPE_LIBRARY freetype)
981
982         if(WITH_IMAGE_OPENEXR)
983                 set(OPENEXR ${LIBDIR}/openexr)
984                 set(OPENEXR_INCLUDE_DIRS ${OPENEXR}/include/OpenEXR)
985                 set(OPENEXR_LIBRARIES Iex Half IlmImf Imath IlmThread)
986                 set(OPENEXR_LIBPATH ${OPENEXR}/lib)
987         endif()
988
989         if(WITH_CODEC_FFMPEG)
990                 set(FFMPEG ${LIBDIR}/ffmpeg)
991                 set(FFMPEG_INCLUDE_DIRS ${FFMPEG}/include)
992                 set(FFMPEG_LIBRARIES avcodec avdevice avformat avutil mp3lame swscale x264 xvidcore theora theoradec theoraenc vorbis vorbisenc vorbisfile ogg)
993                 set(FFMPEG_LIBPATH ${FFMPEG}/lib)
994                 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D__STDC_CONSTANT_MACROS")
995         endif()
996
997         if(WITH_SAMPLERATE)
998                 set(SAMPLERATE ${LIBDIR}/samplerate)
999                 set(SAMPLERATE_INCLUDE_DIRS ${SAMPLERATE}/include)
1000                 set(SAMPLERATE_LIBRARIES samplerate)
1001                 set(SAMPLERATE_LIBPATH ${SAMPLERATE}/lib)
1002         endif()
1003
1004         find_library(SYSTEMSTUBS_LIBRARY 
1005                 NAMES 
1006                 SystemStubs 
1007                 PATHS
1008         )
1009         mark_as_advanced(SYSTEMSTUBS_LIBRARY)
1010         if(SYSTEMSTUBS_LIBRARY)
1011                 set(PLATFORM_LINKLIBS stdc++ SystemStubs)
1012         else()
1013                 set(PLATFORM_LINKLIBS stdc++)
1014         endif()
1015
1016         if(WITH_COCOA)
1017                 set(PLATFORM_CFLAGS "-pipe -funsigned-char -DGHOST_COCOA")
1018                 set(PLATFORM_LINKFLAGS "-fexceptions -framework CoreServices -framework Foundation -framework IOKit -framework AppKit -framework Cocoa -framework Carbon -framework AudioUnit -framework AudioToolbox -framework CoreAudio")
1019                 if(USE_QTKIT)
1020                         set(PLATFORM_CFLAGS "${PLATFORM_CFLAGS} -DUSE_QTKIT")
1021                         set(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} -framework QTKit")
1022                         if(CMAKE_OSX_ARCHITECTURES MATCHES i386)
1023                                 set(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} -framework QuickTime")
1024                                 #libSDL still needs 32bit carbon quicktime 
1025                         endif()
1026                 elseif(WITH_CODEC_QUICKTIME)
1027                         set(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} -framework QuickTime")
1028                 endif()
1029
1030                 # XXX - SOME MAC DEV PLEASE TEST WITH THE SDK INSTALLED! 
1031                 # ALSO SHOULD BE MOVED INTO OWN MODULE WHEN FUNCTIONAL
1032                 if(WITH_INPUT_NDOF)
1033                         # This thread it *should* work and check the framework - campbell
1034                         # http://www.cmake.org/pipermail/cmake/2005-December/007740.html
1035                         find_library(3D_CONNEXION_CLIENT_LIBRARY
1036                                 NAMES 3DconnexionClient
1037                         )
1038                         if(NOT 3D_CONNEXION_CLIENT_LIBRARY)
1039                                 set(WITH_INPUT_NDOF OFF)
1040                         endif()
1041
1042                         if(WITH_INPUT_NDOF)
1043                                 set(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} -weak_framework 3DconnexionClient")
1044                         endif()
1045                 endif()
1046
1047         else()
1048                 set(PLATFORM_CFLAGS "-pipe -funsigned-char")
1049                 set(PLATFORM_LINKFLAGS "-fexceptions -framework CoreServices -framework Foundation -framework IOKit -framework AppKit -framework Carbon -framework AGL -framework AudioUnit -framework AudioToolbox -framework CoreAudio -framework QuickTime")
1050                 set(WITH_INPUT_NDOF OFF)  # unsupported
1051         endif()
1052
1053         if(WITH_OPENCOLLADA)
1054                 set(OPENCOLLADA ${LIBDIR}/opencollada)
1055
1056                 set(OPENCOLLADA_INCLUDE_DIRS
1057                         ${LIBDIR}/opencollada/include/COLLADAStreamWriter
1058                         ${LIBDIR}/opencollada/include/COLLADABaseUtils
1059                         ${LIBDIR}/opencollada/include/COLLADAFramework
1060                         ${LIBDIR}/opencollada/include/COLLADASaxFrameworkLoader
1061                         ${LIBDIR}/opencollada/include/GeneratedSaxParser
1062                 )
1063
1064                 set(OPENCOLLADA_LIBPATH ${OPENCOLLADA}/lib)
1065                 set(OPENCOLLADA_LIBRARIES "OpenCOLLADASaxFrameworkLoader -lOpenCOLLADAFramework -lOpenCOLLADABaseUtils -lOpenCOLLADAStreamWriter -lMathMLSolver -lGeneratedSaxParser -lUTF -lxml2 -lbuffer -lftoa" )
1066                 #pcre is bundled with openCollada
1067                 #set(PCRE ${LIBDIR}/pcre)
1068                 #set(PCRE_LIBPATH ${PCRE}/lib)
1069                 set(PCRE_LIBRARIES pcre)
1070                 #libxml2 is used
1071                 #set(EXPAT ${LIBDIR}/expat)
1072                 #set(EXPAT_LIBPATH ${EXPAT}/lib)
1073                 set(EXPAT_LIB)
1074         endif()
1075
1076         if(WITH_SDL)
1077                 set(SDL ${LIBDIR}/sdl)
1078                 set(SDL_INCLUDE_DIR ${SDL}/include)
1079                 set(SDL_LIBRARY SDL)
1080                 set(SDL_LIBPATH ${SDL}/lib)
1081         endif()
1082
1083         set(PNG "${LIBDIR}/png")
1084         set(PNG_INCLUDE_DIR "${PNG}/include")
1085         set(PNG_LIBPATH ${PNG}/lib)
1086
1087         set(JPEG "${LIBDIR}/jpeg")
1088         set(JPEG_INCLUDE_DIR "${JPEG}/include")
1089         set(JPEG_LIBPATH ${JPEG}/lib)
1090
1091         if(WITH_IMAGE_TIFF)
1092                 set(TIFF ${LIBDIR}/tiff)
1093                 set(TIFF_INCLUDE_DIR ${TIFF}/include)
1094                 set(TIFF_LIBRARY tiff)
1095                 set(TIFF_LIBPATH ${TIFF}/lib)
1096         endif()
1097
1098         if (WITH_INPUT_NDOF)
1099                 # linker needs "-weak_framework 3DconnexionClient"
1100         endif()
1101
1102         set(EXETYPE MACOSX_BUNDLE)
1103
1104         set(CMAKE_C_FLAGS_DEBUG "-fno-strict-aliasing -g")
1105         set(CMAKE_CXX_FLAGS_DEBUG "-fno-strict-aliasing -g")
1106         if(CMAKE_OSX_ARCHITECTURES MATCHES "i386")
1107                 set(CMAKE_CXX_FLAGS_RELEASE "-O3 -mdynamic-no-pic -ftree-vectorize -msse -msse2 -fvariable-expansion-in-unroller")
1108                 set(CMAKE_C_FLAGS_RELEASE "-O3 -mdynamic-no-pic -ftree-vectorize -msse -msse2 -fvariable-expansion-in-unroller")
1109         elseif(CMAKE_OSX_ARCHITECTURES MATCHES "x86_64")
1110                 set(CMAKE_CXX_FLAGS_RELEASE "-O3 -mdynamic-no-pic -ftree-vectorize -msse -msse2 -msse3 -mssse3 -fvariable-expansion-in-unroller")
1111                 set(CMAKE_C_FLAGS_RELEASE "-O3 -mdynamic-no-pic -ftree-vectorize -msse -msse2 -msse3 -mssse3 -fvariable-expansion-in-unroller")
1112         else()
1113                 set(CMAKE_C_FLAGS_RELEASE "-mdynamic-no-pic -fno-strict-aliasing")
1114                 set(CMAKE_CXX_FLAGS_RELEASE "-mdynamic-no-pic -fno-strict-aliasing")
1115         endif()
1116 endif()
1117
1118 #-----------------------------------------------------------------------------
1119 # Common.
1120
1121 if(APPLE OR WIN32)
1122         if(NOT EXISTS "${LIBDIR}/")
1123                 message(FATAL_ERROR "Apple and Windows require pre-compiled libs at: '${LIBDIR}'")
1124         endif()
1125 endif()
1126
1127 # See TEST_SSE_SUPPORT() for how this is defined.
1128
1129 if(WITH_RAYOPTIMIZATION)
1130         if(CMAKE_COMPILER_IS_GNUCC)
1131                 set(_sse "-msse")
1132                 set(_sse2 "-msse2")
1133         elseif(MSVC)
1134                 set(_sse "/arch:SSE")
1135                 set(_sse2 "/arch:SSE2")
1136         else()
1137                 message(WARNING "SSE flags for this compiler not known")
1138                 set(_sse)
1139                 set(_sse2)
1140         endif()
1141
1142         if(SUPPORT_SSE_BUILD)
1143                 set(PLATFORM_CFLAGS " ${_sse} ${PLATFORM_CFLAGS}")
1144                 add_definitions(-D__SSE__ -D__MMX__)
1145         endif()
1146         if(SUPPORT_SSE2_BUILD)
1147                 set(PLATFORM_CFLAGS " ${_sse2} ${PLATFORM_CFLAGS}")
1148                 add_definitions(-D__SSE2__)
1149                 if(NOT SUPPORT_SSE_BUILD) # dont double up
1150                         add_definitions(-D__MMX__)
1151                 endif()
1152         endif()
1153         unset(_sse)
1154         unset(_sse2)
1155 endif()
1156
1157
1158 # set the endian define
1159 if(MSVC)
1160         # for some reason this fails on msvc
1161         add_definitions(-D__LITTLE_ENDIAN__)
1162 else()
1163         include(TestBigEndian)
1164         test_big_endian(_SYSTEM_BIG_ENDIAN)
1165         if(_SYSTEM_BIG_ENDIAN)
1166                 add_definitions(-D__BIG_ENDIAN__)
1167         else()
1168                 add_definitions(-D__LITTLE_ENDIAN__)
1169         endif()
1170         unset(_SYSTEM_BIG_ENDIAN)
1171 endif()
1172
1173
1174 if(WITH_IMAGE_OPENJPEG)
1175         if(UNIX AND NOT APPLE)
1176                 # dealt with above
1177         else()
1178                 set(OPENJPEG_INCLUDE_DIRS "${CMAKE_SOURCE_DIR}/extern/libopenjpeg")
1179         endif()
1180 endif()
1181
1182 if(WITH_IMAGE_REDCODE)
1183         set(REDCODE ${CMAKE_SOURCE_DIR}/extern)
1184         set(REDCODE_INC ${REDCODE})
1185 endif()
1186
1187 #-----------------------------------------------------------------------------
1188 # Blender WebPlugin
1189
1190 if(WITH_WEBPLUGIN) 
1191         set(GECKO_DIR "${CMAKE_SOURCE_DIR}/../gecko-sdk/" CACHE PATH "Gecko SDK path")
1192         set(WEBPLUGIN_SANDBOX_MODE "apparmor" CACHE STRING "WEB Plugin sandbox mode, can be apparmor, privsep, none")
1193
1194         set(WITH_PLAYER ON)
1195 endif()
1196
1197
1198 #-----------------------------------------------------------------------------
1199 # Configure OpenGL.
1200 find_package(OpenGL)
1201 blender_include_dirs_sys("${OPENGL_INCLUDE_DIR}")
1202 # unset(OPENGL_LIBRARIES CACHE) # not compat with older cmake 
1203 # unset(OPENGL_xmesa_INCLUDE_DIR CACHE) # not compat with older cmake 
1204
1205 #-----------------------------------------------------------------------------
1206 # Configure OpenMP.
1207 if(WITH_OPENMP)
1208         find_package(OpenMP)    
1209         if(OPENMP_FOUND)
1210                 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
1211                 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
1212
1213                 if(APPLE AND ${CMAKE_GENERATOR} MATCHES "Xcode")
1214                         set(CMAKE_XCODE_ATTRIBUTE_ENABLE_OPENMP_SUPPORT "YES")
1215                 endif()
1216         else()
1217                 set(WITH_OPENMP OFF)
1218         endif()
1219
1220         mark_as_advanced(OpenMP_C_FLAGS)
1221         mark_as_advanced(OpenMP_CXX_FLAGS)
1222 endif() 
1223
1224 #-----------------------------------------------------------------------------
1225 # Configure GLEW
1226
1227 if(WITH_BUILTIN_GLEW)
1228         # set(GLEW_LIBRARY "")  # unused
1229         set(GLEW_INCLUDE_PATH "${CMAKE_SOURCE_DIR}/extern/glew/include")
1230 else()
1231         find_package(GLEW)
1232
1233         if(NOT GLEW_FOUND)
1234                 message(FATAL_ERROR "GLEW is required to build blender, install it or use WITH_BUILTIN_GLEW")
1235         endif()
1236
1237         mark_as_advanced(GLEW_LIBRARY)
1238         mark_as_advanced(GLEW_INCLUDE_PATH)
1239 endif()
1240
1241 #-----------------------------------------------------------------------------
1242 # Configure Python.
1243
1244 if(WITH_PYTHON_MODULE)
1245         add_definitions(-DPy_ENABLE_SHARED)
1246 endif() 
1247
1248 #-----------------------------------------------------------------------------
1249 # Extra compile flags
1250
1251 if((NOT WIN32) AND (NOT MSVC))
1252         # used for internal debug checks
1253         set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DDEBUG")
1254         set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DDEBUG")
1255         
1256         # assert() checks for this.
1257         set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -DNDEBUG")
1258         set(CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS_MINSIZEREL} -DNDEBUG")
1259         set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -DNDEBUG")
1260
1261         set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -DNDEBUG")
1262         set(CMAKE_C_FLAGS_MINSIZEREL "${CMAKE_C_FLAGS_MINSIZEREL} -DNDEBUG")
1263         set(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO} -DNDEBUG")
1264 endif()
1265
1266 if(CMAKE_COMPILER_IS_GNUCC)
1267
1268         ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_ALL -Wall)
1269         ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_CAST_ALIGN -Wcast-align)
1270         ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_ERROR_DECLARATION_AFTER_STATEMENT -Werror=declaration-after-statement)
1271         ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_ERROR_IMPLICIT_FUNCTION_DECLARATION -Werror=implicit-function-declaration)
1272         ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_ERROR_RETURN_TYPE -Werror=return-type)
1273         # system headers sometimes do this, disable for now, was: -Werror=strict-prototypes
1274         ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_STRICT_PROTOTYPES -Wstrict-prototypes)
1275         ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_NO_CHAR_SUBSCRIPTS -Wno-char-subscripts)
1276         ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_NO_UNKNOWN_PRAGMAS -Wno-unknown-pragmas)
1277         ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_POINTER_ARITH -Wpointer-arith)
1278         ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_UNUSED_PARAMETER -Wunused-parameter)
1279         ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_WRITE_STRINGS -Wwrite-strings)
1280
1281         # # this causes too many warnings, disable
1282         # ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_UNDEFINED -Wundef)
1283
1284         # disable because it gives warnings for printf() & friends.
1285         # ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_DOUBLE_PROMOTION -Wdouble-promotion -Wno-error=double-promotion)
1286         ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_NO_ERROR_UNUSED_BUT_SET_VARIABLE -Wno-error=unused-but-set-variable)
1287
1288         ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_ALL -Wall)
1289         ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_NO_INVALID_OFFSETOF -Wno-invalid-offsetof)
1290         ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_NO_SIGN_COMPARE -Wno-sign-compare)
1291
1292         # # this causes too many warnings, disable
1293         # ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_UNDEFINED -Wundef)
1294
1295 elseif(CMAKE_C_COMPILER_ID MATCHES "Intel")
1296
1297         ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_ALL -Wall)
1298         ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_POINTER_ARITH -Wpointer-arith)
1299         ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_NO_UNKNOWN_PRAGMAS -Wno-unknown-pragmas)
1300
1301         ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_ALL -Wall)
1302         ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_NO_INVALID_OFFSETOF -Wno-invalid-offsetof)
1303         ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_NO_SIGN_COMPARE -Wno-sign-compare)
1304
1305 endif()
1306
1307 # MSVC2010 fails to links C++ libs right
1308 if(MSVC10)
1309         if(WITH_IMAGE_OPENEXR)
1310                 message(WARNING "MSVC 2010 does not support OpenEXR, disabling WITH_IMAGE_OPENEXR. To enable support use Use MSVC 2008")
1311                 set(WITH_IMAGE_OPENEXR OFF)
1312         endif()
1313         if(WITH_OPENCOLLADA)
1314                 message(WARNING "MSVC 2010 does not support OpenCollada, disabling WITH_OPENCOLLADA. To enable support use Use MSVC 2008")
1315                 set(WITH_OPENCOLLADA OFF)
1316         endif()
1317 endif()
1318
1319 if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
1320         if(WITH_IK_ITASC OR WITH_MOD_FLUID)
1321                 message(WARNING "Using Clang as CXX compiler: disabling WITH_IK_ITASC and WITH_MOD_FLUID, these features will be missing.")
1322                 set(WITH_IK_ITASC OFF)
1323                 set(WITH_MOD_FLUID OFF)
1324         endif()
1325 endif()
1326
1327
1328 # ensure python header is found since detection can fail, this could happen
1329 # with _any_ library but since we used a fixed python version this tends to
1330 # be most problematic.
1331 if(WITH_PYTHON)
1332         if(NOT EXISTS "${PYTHON_INCLUDE_DIR}/Python.h")
1333                 message(FATAL_ERROR "Missing: \"${PYTHON_INCLUDE_DIR}/Python.h\",\n"
1334                                                         "Set the cache entry 'PYTHON_INCLUDE_DIR' to point "
1335                                                         "to a valid python include path. Containing "
1336                                                         "Python.h for python version \"${PYTHON_VERSION}\"")
1337         endif()
1338 endif()
1339
1340
1341 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${PLATFORM_CFLAGS} ${C_WARNINGS}")
1342 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${PLATFORM_CFLAGS} ${CXX_WARNINGS}")
1343
1344 #-------------------------------------------------------------------------------
1345 # Global Defines
1346
1347 # better not set includes here but this debugging option is off by default.
1348 if(WITH_CXX_GUARDEDALLOC)
1349         include_directories(${CMAKE_SOURCE_DIR}/intern/guardedalloc)
1350 endif()
1351
1352 if(WITH_ASSERT_ABORT)
1353         add_definitions(-DWITH_ASSERT_ABORT)
1354 endif()
1355
1356 # message(STATUS "Using CFLAGS: ${CMAKE_C_FLAGS}")
1357 # message(STATUS "Using CXXFLAGS: ${CMAKE_CXX_FLAGS}")
1358
1359 #-----------------------------------------------------------------------------
1360 # Libraries
1361
1362 add_subdirectory(source)
1363 add_subdirectory(intern)
1364 add_subdirectory(extern)
1365
1366
1367 #-----------------------------------------------------------------------------
1368 # Blender Application
1369 if(WITH_BLENDER)
1370         add_subdirectory(source/creator)
1371 endif()
1372
1373
1374 #-----------------------------------------------------------------------------
1375 # Blender Player
1376 if(WITH_PLAYER)
1377         add_subdirectory(source/blenderplayer)
1378 endif()
1379
1380 #-----------------------------------------------------------------------------
1381 # CPack for generating packages
1382 include(build_files/cmake/packaging.cmake)
1383
1384
1385 #-----------------------------------------------------------------------------
1386 # Print Final Configuration
1387
1388 if(FIRST_RUN)
1389         set(_config_msg "\n* Blender Configuration *")
1390         macro(info_cfg_option
1391                 _setting)
1392                 set(_msg "   * ${_setting}")
1393                 string(LENGTH "${_msg}" _len)
1394                 while("28" GREATER "${_len}")
1395                         set(_msg "${_msg} ")
1396                          math(EXPR _len "${_len} + 1")
1397                 endwhile()
1398
1399                 set(_config_msg "${_config_msg}\n${_msg}${${_setting}}")
1400         endmacro()
1401
1402         macro(info_cfg_text
1403                 _text)
1404                 set(_config_msg "${_config_msg}\n\n  ${_text}")
1405                 
1406                 
1407         endmacro()
1408
1409         info_cfg_text("Build Options:")
1410         info_cfg_option(WITH_GAMEENGINE)
1411         info_cfg_option(WITH_PLAYER)
1412         info_cfg_option(WITH_BULLET)
1413         info_cfg_option(WITH_IK_ITASC)
1414         info_cfg_option(WITH_OPENCOLLADA)
1415         info_cfg_option(WITH_FFTW3)
1416         info_cfg_option(WITH_INTERNATIONAL)
1417         info_cfg_option(WITH_INPUT_NDOF)
1418
1419         info_cfg_text("Compiler Options:")
1420         info_cfg_option(WITH_BUILDINFO)
1421         info_cfg_option(WITH_OPENMP)
1422         info_cfg_option(WITH_RAYOPTIMIZATION)
1423
1424         info_cfg_text("System Options:")
1425         info_cfg_option(WITH_INSTALL_PORTABLE)
1426         info_cfg_option(WITH_X11_XINPUT)
1427         info_cfg_option(WITH_BUILTIN_GLEW)
1428
1429         info_cfg_text("Image Formats:")
1430         info_cfg_option(WITH_IMAGE_CINEON)
1431         info_cfg_option(WITH_IMAGE_DDS)
1432         info_cfg_option(WITH_IMAGE_HDR)
1433         info_cfg_option(WITH_IMAGE_OPENEXR)
1434         info_cfg_option(WITH_IMAGE_OPENJPEG)
1435         info_cfg_option(WITH_IMAGE_REDCODE)
1436         info_cfg_option(WITH_IMAGE_TIFF)
1437
1438         info_cfg_text("Audio:")
1439         info_cfg_option(WITH_OPENAL)
1440         info_cfg_option(WITH_SDL)
1441         info_cfg_option(WITH_JACK)
1442         info_cfg_option(WITH_CODEC_FFMPEG)
1443         info_cfg_option(WITH_CODEC_SNDFILE)
1444         info_cfg_option(WITH_SAMPLERATE)
1445
1446         info_cfg_text("Compression:")
1447         info_cfg_option(WITH_LZMA)
1448         info_cfg_option(WITH_LZO)
1449
1450         info_cfg_text("Python:")
1451         info_cfg_option(WITH_PYTHON_INSTALL)
1452         info_cfg_option(WITH_PYTHON_MODULE)
1453         info_cfg_option(WITH_PYTHON_SAFETY)
1454
1455         info_cfg_text("Modifiers:")
1456         info_cfg_option(WITH_MOD_BOOLEAN)
1457         info_cfg_option(WITH_MOD_DECIMATE)
1458         info_cfg_option(WITH_MOD_FLUID)
1459
1460         info_cfg_text("")
1461
1462         message("${_config_msg}")
1463 endif()