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