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