svn merge ^/trunk/blender -r49520:49531
[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_lib_path(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
916                         set(OPENCOLLADA_INCLUDE_DIRS
917                                 ${LIBDIR}/opencollada/include/COLLADAStreamWriter/include
918                                 ${LIBDIR}/opencollada/include/COLLADABaseUtils/include
919                                 ${LIBDIR}/opencollada/include/COLLADAFramework/include
920                                 ${LIBDIR}/opencollada/include/COLLADASaxFrameworkLoader/include
921                                 ${LIBDIR}/opencollada/include/GeneratedSaxParser/include
922                         )
923                         
924                         set_lib_path(OPENCOLLADA_LIBPATH "opencollada/lib")
925
926                         set(OPENCOLLADA_LIBRARIES
927                                 ${OPENCOLLADA_LIBPATH}/OpenCOLLADASaxFrameworkLoader.lib
928                                 ${OPENCOLLADA_LIBPATH}/OpenCOLLADAFramework.lib
929                                 ${OPENCOLLADA_LIBPATH}/OpenCOLLADABaseUtils.lib
930                                 ${OPENCOLLADA_LIBPATH}/OpenCOLLADAStreamWriter.lib
931                                 ${OPENCOLLADA_LIBPATH}/MathMLSolver.lib
932                                 ${OPENCOLLADA_LIBPATH}/GeneratedSaxParser.lib
933                                 ${OPENCOLLADA_LIBPATH}/xml2.lib
934                                 ${OPENCOLLADA_LIBPATH}/buffer.lib
935                                 ${OPENCOLLADA_LIBPATH}/ftoa.lib
936                                 ${OPENCOLLADA_LIBPATH}/UTF.lib
937                         )
938                         set(PCRE_LIBRARIES
939                                 ${OPENCOLLADA_LIBPATH}/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_lib_path(OPENEXR_LIBPATH "openexr/lib")
963                         set(OPENEXR_LIBRARIES
964                                 ${OPENEXR_LIBPATH}/Iex.lib
965                                 ${OPENEXR_LIBPATH}/Half.lib
966                                 ${OPENEXR_LIBPATH}/IlmImf.lib
967                                 ${OPENEXR_LIBPATH}/Imath.lib
968                                 ${OPENEXR_LIBPATH}/IlmThread.lib
969                         )
970                         set_lib_path(OPENEXR_INCUDE "openexr/include")
971                         set(OPENEXR_INCLUDE_DIRS
972                                 ${OPENEXR_INCUDE}
973                                 ${OPENEXR_INCUDE}/IlmImf
974                                 ${OPENEXR_INCUDE}/Iex
975                                 ${OPENEXR_INCUDE}/Imath
976                         )
977                         unset(OPENEXR_INCUDE)
978                         unset(OPENEXR_LIBPATH)
979                 endif()
980
981                 if(WITH_IMAGE_TIFF)
982                         set(TIFF_LIBRARY ${LIBDIR}/tiff/lib/libtiff.lib)
983                         set(TIFF_INCLUDE_DIR ${LIBDIR}/tiff/include)
984                 endif()
985
986                 if(WITH_JACK)
987                         set(JACK_INCLUDE_DIRS
988                                 ${LIBDIR}/jack/include/jack
989                                 ${LIBDIR}/jack/include
990                         )
991                         set(JACK_LIBRARIES ${LIBDIR}/jack/lib/libjack.lib)
992                 endif()
993
994                 if(WITH_PYTHON)
995                         # normally cached but not since we include them with blender
996                         set(PYTHON_VERSION 3.2) # CACHE STRING)
997                         set_lib_path(PYTHON_INCLUDE_DIR "python/include/python${PYTHON_VERSION}")
998                         set_lib_path(PYTHON_LIBRARY "python/lib/python32.lib") #CACHE FILEPATH)
999                         
1000                         # uncached vars
1001                         set(PYTHON_INCLUDE_DIRS "${PYTHON_INCLUDE_DIR}")
1002                         set(PYTHON_LIBRARIES  "${PYTHON_LIBRARY}")
1003                 endif()
1004
1005                 if(WITH_BOOST)
1006                         set(BOOST ${LIBDIR}/boost)
1007                         set(BOOST_INCLUDE_DIR ${BOOST}/include)
1008                         if(MSVC10)
1009                                 set(BOOST_LIBPATH ${BOOST}/lib/vc_10)
1010                                 set(BOOST_POSTFIX "vc100-mt-s-1_49.lib")
1011                                 set(BOOST_DEBUG_POSTFIX "vc100-mt-sgd-1_49.lib")
1012                         else()
1013                                 set(BOOST_LIBPATH ${BOOST}/lib)
1014                                 set(BOOST_POSTFIX "vc90-mt-s-1_49.lib")
1015                                 set(BOOST_DEBUG_POSTFIX "vc90-mt-sgd-1_49.lib")                                 
1016                         endif()
1017                         set(BOOST_LIBRARIES
1018                                 optimized libboost_date_time-${BOOST_POSTFIX} optimized libboost_filesystem-${BOOST_POSTFIX}
1019                                 optimized libboost_regex-${BOOST_POSTFIX} optimized libboost_system-${BOOST_POSTFIX} optimized libboost_thread-${BOOST_POSTFIX}
1020                                 debug libboost_date_time-${BOOST_DEBUG_POSTFIX} debug libboost_filesystem-${BOOST_DEBUG_POSTFIX}
1021                                 debug libboost_regex-${BOOST_DEBUG_POSTFIX} debug libboost_system-${BOOST_DEBUG_POSTFIX} debug libboost_thread-${BOOST_DEBUG_POSTFIX})
1022                         set(BOOST_DEFINITIONS "-DBOOST_ALL_NO_LIB")
1023                 endif()
1024                         
1025                 if(WITH_OPENIMAGEIO)
1026                         set(OPENIMAGEIO ${LIBDIR}/openimageio)
1027                         set(OPENIMAGEIO_INCLUDE_DIRS ${OPENIMAGEIO}/include)
1028                         set(OPENIMAGEIO_LIBRARIES OpenImageIO)
1029                         set_lib_path(OPENIMAGEIO_LIBPATH "openimageio/lib")
1030                         set(OPENIMAGEIO_DEFINITIONS)
1031                 endif()
1032
1033                 if(WITH_OPENCOLORIO)
1034                         set(OPENCOLORIO ${LIBDIR}/opencolorio)
1035                         set(OPENCOLORIO_INCLUDE_DIRS ${OPENCOLORIO}/include)
1036                         set(OPENCOLORIO_LIBRARIES OpenColorIO)
1037                         set_lib_path(OPENCOLORIO_LIBPATH "opencolorio/lib")
1038                         set(OPENCOLORIO_DEFINITIONS)
1039                 endif()
1040
1041                 set(PLATFORM_LINKFLAGS "/SUBSYSTEM:CONSOLE /STACK:2097152 /INCREMENTAL:NO /NODEFAULTLIB:msvcrt.lib /NODEFAULTLIB:msvcmrt.lib /NODEFAULTLIB:msvcurt.lib /NODEFAULTLIB:msvcrtd.lib")
1042
1043                 # MSVC only, Mingw doesnt need
1044                 if(CMAKE_CL_64)
1045                         set(PLATFORM_LINKFLAGS "/MACHINE:X64 /OPT:NOREF ${PLATFORM_LINKFLAGS}")
1046                 else()
1047                         set(PLATFORM_LINKFLAGS "/MACHINE:IX86 /LARGEADDRESSAWARE ${PLATFORM_LINKFLAGS}")
1048                 endif()
1049
1050                 set(PLATFORM_LINKFLAGS_DEBUG "/NODEFAULTLIB:libcmt.lib /NODEFAULTLIB:libc.lib")
1051
1052                 # used in many places so include globally, like OpenGL
1053                 blender_include_dirs("${PTHREADS_INCLUDE_DIRS}")
1054
1055         elseif(CMAKE_COMPILER_IS_GNUCC)
1056         # keep GCC specific stuff here          
1057                 set(PLATFORM_LINKLIBS "-lshell32 -lshfolder -lgdi32 -lmsvcrt -lwinmm -lmingw32 -lm -lws2_32 -lz -lstdc++ -lole32 -luuid -lwsock32 -lpsapi")
1058                 set(PLATFORM_CFLAGS "-pipe -funsigned-char -fno-strict-aliasing")
1059
1060                 if(WITH_MINGW64)
1061                         #We need to take care though not to have these on debug builds because they may play funky with gdb
1062                         if(CMAKE_BUILD_TYPE MATCHES "Release")
1063                                 set(PLATFORM_CFLAGS "${PLATFORM_CFLAGS} -mmmx -ftree-vectorize")
1064                         endif()
1065                         set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fpermissive")
1066                         set(PLATFORM_LINKLIBS "${PLATFORM_LINKLIBS} -lpthread")
1067                         
1068                         add_definitions(-DFREE_WINDOWS64 -DMS_WIN64)
1069                 endif()
1070
1071                 add_definitions(-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE)
1072
1073
1074                 add_definitions(-DFREE_WINDOWS)
1075
1076                 if(WITH_INTERNATIONAL)
1077                         set(GETTEXT ${LIBDIR}/gettext)
1078                         set(GETTEXT_INCLUDE_DIRS ${GETTEXT}/include)
1079                         set(GETTEXT_LIBPATH ${GETTEXT}/lib)
1080                         set(GETTEXT_LIBRARIES intl)
1081                 endif()
1082                 
1083                 set(PNG "${LIBDIR}/png")
1084                 set(PNG_INCLUDE_DIR "${PNG}/include")
1085                 set(PNG_LIBPATH ${PNG}/lib) # not cmake defined
1086
1087                 if(WITH_MINGW64)
1088                         set(JPEG_LIBRARIES jpeg)
1089                 else()
1090                         set(JPEG_LIBRARIES libjpeg)
1091                 endif()
1092                 set(PNG_LIBRARIES png)
1093
1094                 set(ZLIB ${LIBDIR}/zlib)
1095                 set(ZLIB_INCLUDE_DIRS ${ZLIB}/include)
1096                 set(ZLIB_LIBPATH ${ZLIB}/lib)
1097                 set(ZLIB_LIBRARIES z)
1098
1099                 #comes with own pthread library
1100                 if(NOT WITH_MINGW64)
1101                         set(PTHREADS ${LIBDIR}/pthreads)
1102                         set(PTHREADS_INCLUDE_DIRS ${PTHREADS}/include)
1103                         set(PTHREADS_LIBPATH ${PTHREADS}/lib)
1104                         set(PTHREADS_LIBRARIES pthreadGC2)
1105                 endif()
1106                 
1107                 set(FREETYPE ${LIBDIR}/freetype)
1108                 set(FREETYPE_INCLUDE_DIRS ${FREETYPE}/include ${FREETYPE}/include/freetype2)
1109                 set(FREETYPE_LIBPATH ${FREETYPE}/lib)
1110                 set(FREETYPE_LIBRARY freetype)
1111
1112                 if(WITH_FFTW3)
1113                         set(FFTW3 ${LIBDIR}/fftw3)
1114                         set(FFTW3_LIBRARIES fftw3)
1115                         set(FFTW3_INCLUDE_DIRS ${FFTW3}/include)
1116                         set(FFTW3_LIBPATH ${FFTW3}/lib)
1117                 endif()
1118
1119                 if(WITH_OPENCOLLADA)
1120                         set(OPENCOLLADA ${LIBDIR}/opencollada)
1121                         set(OPENCOLLADA_INCLUDE_DIRS
1122                                 ${LIBDIR}/opencollada/include/COLLADAStreamWriter/include
1123                                 ${LIBDIR}/opencollada/include/COLLADABaseUtils/include
1124                                 ${LIBDIR}/opencollada/include/COLLADAFramework/include
1125                                 ${LIBDIR}/opencollada/include/COLLADASaxFrameworkLoader/include
1126                                 ${LIBDIR}/opencollada/include/GeneratedSaxParser/include
1127                         )
1128                         set(OPENCOLLADA_LIBPATH ${OPENCOLLADA}/lib ${OPENCOLLADA}/lib)
1129                         if(WITH_MINGW64)
1130                                 set(OPENCOLLADA_LIBRARIES OpenCOLLADAStreamWriter OpenCOLLADASaxFrameworkLoader OpenCOLLADAFramework OpenCOLLADABaseUtils GeneratedSaxParser UTF MathMLSolver pcre buffer ftoa xml)
1131                         else()
1132                                 set(OPENCOLLADA_LIBRARIES OpenCOLLADAStreamWriter OpenCOLLADASaxFrameworkLoader OpenCOLLADAFramework OpenCOLLADABaseUtils GeneratedSaxParser UTF MathMLSolver expat pcre buffer ftoa)
1133                         endif()
1134                         set(PCRE_LIBRARIES pcre)
1135                 endif()
1136
1137                 if(WITH_CODEC_FFMPEG)
1138                         set(FFMPEG ${LIBDIR}/ffmpeg)
1139                         set(FFMPEG_INCLUDE_DIRS ${FFMPEG}/include)
1140                         if(WITH_MINGW64)
1141                                 set(FFMPEG_LIBRARIES avcodec.dll avformat.dll avdevice.dll avutil.dll swscale.dll swresample.dll)
1142                         else()
1143                                 set(FFMPEG_LIBRARIES avcodec-53 avformat-53 avdevice-53 avutil-51 swscale-2)
1144                         endif()
1145                         set(FFMPEG_LIBPATH ${FFMPEG}/lib)
1146                 endif()
1147
1148                 if(WITH_IMAGE_OPENEXR)
1149                         if(MSVC10)
1150                                 set(OPENEXR ${LIBDIR}/openexr)
1151                                 set(OPENEXR_INCLUDE_DIRS ${OPENEXR}/include/vc_10)
1152                                 set(OPENEXR_LIBRARIES Half IlmImf Imath IlmThread Iex)
1153                                 set(OPENEXR_LIBPATH ${OPENEXR}/lib/vc_10)
1154                         else()
1155                                 set(OPENEXR ${LIBDIR}/openexr)
1156                                 set(OPENEXR_INCLUDE_DIRS ${OPENEXR}/include)
1157                                 set(OPENEXR_LIBRARIES Half IlmImf Imath IlmThread Iex)
1158                                 set(OPENEXR_LIBPATH ${OPENEXR}/lib)
1159                         endif()
1160                 endif()
1161
1162                 if(WITH_IMAGE_TIFF)
1163                         set(TIFF ${LIBDIR}/tiff)
1164                         set(TIFF_LIBRARY tiff)
1165                         set(TIFF_INCLUDE_DIR ${TIFF}/include)
1166                         set(TIFF_LIBPATH ${TIFF}/lib)
1167                 endif()
1168
1169                 if(WITH_JACK)
1170                         set(JACK ${LIBDIR}/jack)
1171                         set(JACK_INCLUDE_DIRS ${JACK}/include/jack ${JACK}/include)
1172                         set(JACK_LIBRARIES jack)
1173                         set(JACK_LIBPATH ${JACK}/lib)
1174
1175                         # TODO, gives linking errors, force off
1176                         set(WITH_JACK OFF)
1177                 endif()
1178
1179                 if(WITH_PYTHON)
1180                         # normally cached but not since we include them with blender
1181                         set(PYTHON_VERSION 3.2) #  CACHE STRING)
1182                         set(PYTHON_INCLUDE_DIR "${LIBDIR}/python/include/python${PYTHON_VERSION}")  # CACHE PATH)
1183                         set(PYTHON_LIBRARY "${LIBDIR}/python/lib/python32mw.lib")  # CACHE FILEPATH)
1184
1185                         # uncached vars
1186                         set(PYTHON_INCLUDE_DIRS "${PYTHON_INCLUDE_DIR}")
1187                         set(PYTHON_LIBRARIES  "${PYTHON_LIBRARY}")
1188                 endif()
1189
1190                 if(WITH_BOOST)
1191                         set(BOOST ${LIBDIR}/boost)
1192                         set(BOOST_INCLUDE_DIR ${BOOST}/include)
1193                         if(WITH_MINGW64)
1194                                 set(BOOST_POSTFIX "mgw47-mt-s-1_49")
1195                                 set(BOOST_DEBUG_POSTFIX "mgw47-mt-sd-1_49")
1196                         else()
1197                                 set(BOOST_POSTFIX "mgw46-mt-s-1_47")
1198                                 set(BOOST_DEBUG_POSTFIX "mgw46-mt-sd-1_47")
1199                         endif()         
1200                         set(BOOST_LIBRARIES
1201                                 optimized boost_date_time-${BOOST_POSTFIX} boost_filesystem-${BOOST_POSTFIX}
1202                                 boost_regex-${BOOST_POSTFIX} boost_system-${BOOST_POSTFIX} boost_thread-${BOOST_POSTFIX}
1203                                 debug boost_date_time-${BOOST_DEBUG_POSTFIX} boost_filesystem-${BOOST_DEBUG_POSTFIX}
1204                                 boost_regex-${BOOST_DEBUG_POSTFIX} boost_system-${BOOST_DEBUG_POSTFIX} boost_thread-${BOOST_DEBUG_POSTFIX})
1205                         set(BOOST_LIBPATH ${BOOST}/lib)
1206                         set(BOOST_DEFINITIONS "-DBOOST_ALL_NO_LIB -DBOOST_THREAD_USE_LIB ")
1207                 endif()
1208                         
1209                 if(WITH_OPENIMAGEIO)
1210                         set(OPENIMAGEIO ${LIBDIR}/openimageio)
1211                         set(OPENIMAGEIO_INCLUDE_DIRS ${OPENIMAGEIO}/include)
1212                         set(OPENIMAGEIO_LIBRARIES OpenImageIO)
1213                         set(OPENIMAGEIO_LIBPATH ${OPENIMAGEIO}/lib)
1214                         set(OPENIMAGEIO_DEFINITIONS)
1215                 endif()
1216                 
1217                 if(WITH_OPENCOLORIO)
1218                         set(OPENCOLORIO ${LIBDIR}/opencolorio)
1219                         set(OPENCOLORIO_INCLUDE_DIRS ${OPENCOLORIO}/include)
1220                         set(OPENCOLORIO_LIBRARIES OpenColorIO)
1221                         set(OPENCOLORIO_LIBPATH ${OPENCOLORIO}/lib)
1222                         set(OPENCOLORIO_DEFINITIONS)
1223                 endif()
1224
1225                 set(PLATFORM_LINKFLAGS "-Xlinker --stack=2097152")
1226
1227                 ## DISABLE - causes linking errors 
1228                 ## for re-distrobution, so users dont need mingw installed
1229                 # set(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} -static-libgcc -static-libstdc++")
1230
1231         endif()
1232
1233 elseif(APPLE)
1234
1235         if(${CMAKE_OSX_DEPLOYMENT_TARGET} STREQUAL "10.5" OR ${CMAKE_OSX_DEPLOYMENT_TARGET} STRGREATER "10.5")
1236                 set(WITH_LIBS10.5 ON CACHE BOOL "Use 10.5 libs" FORCE) # valid also for 10.6/10.7
1237         endif()
1238
1239         if(${XCODE_VERSION} VERSION_LESS 4.3)
1240                 set(CMAKE_OSX_SYSROOT /Developer/SDKs/MacOSX${OSX_SYSTEM}.sdk CACHE PATH "" FORCE)  # use guaranteed existing sdk
1241         else()
1242                 # note: i don't use xcode-select path on purpose, cause also /Applications/Xcode.app would be allowed
1243                 # absolute pathes are more foolproof here !
1244                 set(OSX_SYSROOT_PREFIX /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform)
1245                 set(OSX_DEVELOPER_PREFIX /Developer/SDKs/MacOSX${OSX_SYSTEM}.sdk) # use guaranteed existing sdk
1246                 set(CMAKE_OSX_SYSROOT ${OSX_SYSROOT_PREFIX}/${OSX_DEVELOPER_PREFIX} CACHE PATH "" FORCE)
1247         endif() 
1248         
1249         if(WITH_LIBS10.5)
1250                 set(LIBDIR ${CMAKE_SOURCE_DIR}/../lib/darwin-9.x.universal)
1251         else()
1252                 if(CMAKE_OSX_ARCHITECTURES MATCHES i386)
1253                         set(LIBDIR ${CMAKE_SOURCE_DIR}/../lib/darwin-8.x.i386)
1254                 else()
1255                         set(LIBDIR ${CMAKE_SOURCE_DIR}/../lib/darwin-8.0.0-powerpc)
1256                 endif()
1257         endif()
1258
1259
1260         if(WITH_OPENAL)
1261                 find_package(OpenAL)
1262                 if(OPENAL_FOUND)
1263                         set(WITH_OPENAL ON)
1264                         set(OPENAL_INCLUDE_DIR "${LIBDIR}/openal/include")
1265                 else()
1266                         set(WITH_OPENAL OFF)
1267                 endif()
1268         endif()
1269
1270         if(WITH_JACK)
1271                 set(JACK /usr)
1272                 set(JACK_INCLUDE_DIRS ${JACK}/include/jack)
1273                 set(JACK_LIBRARIES jack)
1274                 set(JACK_LIBPATH ${JACK}/lib)
1275         endif()
1276
1277         if(WITH_CODEC_SNDFILE)
1278                 set(SNDFILE ${LIBDIR}/sndfile)
1279                 set(SNDFILE_INCLUDE_DIRS ${SNDFILE}/include)
1280                 set(SNDFILE_LIBRARIES sndfile FLAC ogg vorbis vorbisenc)
1281                 set(SNDFILE_LIBPATH ${SNDFILE}/lib ${FFMPEG}/lib)  # TODO, deprecate
1282         endif()
1283
1284         if(WITH_PYTHON)
1285                 if(NOT WITH_PYTHON_MODULE)
1286                         # we use precompiled libraries for py 3.2 and up by default
1287
1288                         # normally cached but not since we include them with blender
1289                         set(PYTHON_VERSION 3.2)
1290                         set(PYTHON_INCLUDE_DIR "${LIBDIR}/python/include/python${PYTHON_VERSION}")
1291                         # set(PYTHON_BINARY "${LIBDIR}/python/bin/python${PYTHON_VERSION}") # not used yet
1292                         set(PYTHON_LIBRARY python${PYTHON_VERSION})
1293                         set(PYTHON_LIBPATH "${LIBDIR}/python/lib/python${PYTHON_VERSION}")
1294                         # set(PYTHON_LINKFLAGS "-u _PyMac_Error")  # won't  build with this enabled
1295                 else()
1296                         # module must be compiled against Python framework
1297
1298                         # normally cached but not since we include them with blender
1299                         set(PYTHON_VERSION 3.2)
1300                         set(PYTHON_INCLUDE_DIR "/Library/Frameworks/Python.framework/Versions/${PYTHON_VERSION}/include/python${PYTHON_VERSION}m")
1301                         set(PYTHON_BINARY "/Library/Frameworks/Python.framework/Versions/${PYTHON_VERSION}/bin/python${PYTHON_VERSION}")
1302                         #set(PYTHON_LIBRARY python${PYTHON_VERSION})
1303                         set(PYTHON_LIBPATH "/Library/Frameworks/Python.framework/Versions/${PYTHON_VERSION}/lib/python${PYTHON_VERSION}/config-3.2m")
1304                         #set(PYTHON_LINKFLAGS "-u _PyMac_Error -framework Python")  # won't  build with this enabled
1305                 endif()
1306                 
1307                 # uncached vars
1308                 set(PYTHON_INCLUDE_DIRS "${PYTHON_INCLUDE_DIR}")
1309                 set(PYTHON_LIBRARIES  "${PYTHON_LIBRARY}")
1310         endif()
1311
1312         if(WITH_INTERNATIONAL)
1313                 set(GETTEXT ${LIBDIR}/gettext)
1314                 set(GETTEXT_INCLUDE_DIRS "${GETTEXT}/include")
1315                 set(GETTEXT_LIBRARIES intl iconv)
1316                 set(GETTEXT_LIBPATH ${GETTEXT}/lib)
1317         endif()
1318
1319         if(WITH_FFTW3)
1320                 set(FFTW3 ${LIBDIR}/fftw3)
1321                 set(FFTW3_INCLUDE_DIRS ${FFTW3}/include)
1322                 set(FFTW3_LIBRARIES fftw3)
1323                 set(FFTW3_LIBPATH ${FFTW3}/lib)
1324         endif()
1325
1326         set(PNG_LIBRARIES png)
1327         set(JPEG_LIBRARIES jpeg)
1328
1329         set(ZLIB /usr)
1330         set(ZLIB_INCLUDE_DIRS "${ZLIB}/include")
1331         set(ZLIB_LIBRARIES z bz2)
1332
1333         set(FREETYPE ${LIBDIR}/freetype)
1334         set(FREETYPE_INCLUDE_DIRS ${FREETYPE}/include ${FREETYPE}/include/freetype2)
1335         set(FREETYPE_LIBPATH ${FREETYPE}/lib)
1336         set(FREETYPE_LIBRARY freetype)
1337
1338         if(WITH_IMAGE_OPENEXR)
1339                 set(OPENEXR ${LIBDIR}/openexr)
1340                 set(OPENEXR_INCLUDE_DIRS ${OPENEXR}/include/OpenEXR)
1341                 set(OPENEXR_LIBRARIES Iex Half IlmImf Imath IlmThread)
1342                 set(OPENEXR_LIBPATH ${OPENEXR}/lib)
1343         endif()
1344
1345         if(WITH_CODEC_FFMPEG)
1346                 set(FFMPEG ${LIBDIR}/ffmpeg)
1347                 set(FFMPEG_INCLUDE_DIRS ${FFMPEG}/include)
1348                 set(FFMPEG_LIBRARIES avcodec avdevice avformat avutil mp3lame swscale x264 xvidcore theora theoradec theoraenc vorbis vorbisenc vorbisfile ogg)
1349                 set(FFMPEG_LIBPATH ${FFMPEG}/lib)
1350                 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D__STDC_CONSTANT_MACROS")
1351         endif()
1352
1353         find_library(SYSTEMSTUBS_LIBRARY
1354                 NAMES
1355                 SystemStubs
1356                 PATHS
1357         )
1358         mark_as_advanced(SYSTEMSTUBS_LIBRARY)
1359         if(SYSTEMSTUBS_LIBRARY)
1360                 set(PLATFORM_LINKLIBS stdc++ SystemStubs)
1361         else()
1362                 set(PLATFORM_LINKLIBS stdc++)
1363         endif()
1364
1365         if(WITH_COCOA)
1366                 set(PLATFORM_CFLAGS "-pipe -funsigned-char -DGHOST_COCOA")
1367                 set(PLATFORM_LINKFLAGS "-fexceptions -framework CoreServices -framework Foundation -framework IOKit -framework AppKit -framework Cocoa -framework Carbon -framework AudioUnit -framework AudioToolbox -framework CoreAudio")
1368                 if(USE_QTKIT)
1369                         set(PLATFORM_CFLAGS "${PLATFORM_CFLAGS} -DUSE_QTKIT")
1370                         set(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} -framework QTKit")
1371                         if(CMAKE_OSX_ARCHITECTURES MATCHES i386)
1372                                 set(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} -framework QuickTime")
1373                                 #libSDL still needs 32bit carbon quicktime
1374                         endif()
1375                 elseif(WITH_CODEC_QUICKTIME)
1376                         set(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} -framework QuickTime")
1377                 endif()
1378
1379                 # XXX - SOME MAC DEV PLEASE TEST WITH THE SDK INSTALLED!
1380                 # ALSO SHOULD BE MOVED INTO OWN MODULE WHEN FUNCTIONAL
1381                 if(WITH_INPUT_NDOF)
1382                         # This thread it *should* work and check the framework - campbell
1383                         # http://www.cmake.org/pipermail/cmake/2005-December/007740.html
1384                         find_library(3D_CONNEXION_CLIENT_LIBRARY
1385                                 NAMES 3DconnexionClient
1386                         )
1387                         if(NOT 3D_CONNEXION_CLIENT_LIBRARY)
1388                                 set(WITH_INPUT_NDOF OFF)
1389                         endif()
1390
1391                         if(WITH_INPUT_NDOF)
1392                                 set(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} -weak_framework 3DconnexionClient")
1393                         endif()
1394                 endif()
1395
1396         else()
1397                 set(PLATFORM_CFLAGS "-pipe -funsigned-char")
1398                 set(PLATFORM_LINKFLAGS "-fexceptions -framework CoreServices -framework Foundation -framework IOKit -framework AppKit -framework Carbon -framework AGL -framework AudioUnit -framework AudioToolbox -framework CoreAudio -framework QuickTime")
1399                 set(WITH_INPUT_NDOF OFF)  # unsupported
1400         endif()
1401         
1402         if(WITH_PYTHON_MODULE)
1403                 set(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} /Library/Frameworks/Python.framework/Versions/${PYTHON_VERSION}/python")# force cmake to link right framework
1404         endif()
1405         
1406         if(WITH_OPENCOLLADA)
1407                 set(OPENCOLLADA ${LIBDIR}/opencollada)
1408
1409                 set(OPENCOLLADA_INCLUDE_DIRS
1410                         ${LIBDIR}/opencollada/include/COLLADAStreamWriter
1411                         ${LIBDIR}/opencollada/include/COLLADABaseUtils
1412                         ${LIBDIR}/opencollada/include/COLLADAFramework
1413                         ${LIBDIR}/opencollada/include/COLLADASaxFrameworkLoader
1414                         ${LIBDIR}/opencollada/include/GeneratedSaxParser
1415                 )
1416
1417                 set(OPENCOLLADA_LIBPATH ${OPENCOLLADA}/lib)
1418                 set(OPENCOLLADA_LIBRARIES "OpenCOLLADASaxFrameworkLoader -lOpenCOLLADAFramework -lOpenCOLLADABaseUtils -lOpenCOLLADAStreamWriter -lMathMLSolver -lGeneratedSaxParser -lUTF -lxml2 -lbuffer -lftoa")
1419                 #pcre is bundled with openCollada
1420                 #set(PCRE ${LIBDIR}/pcre)
1421                 #set(PCRE_LIBPATH ${PCRE}/lib)
1422                 set(PCRE_LIBRARIES pcre)
1423                 #libxml2 is used
1424                 #set(EXPAT ${LIBDIR}/expat)
1425                 #set(EXPAT_LIBPATH ${EXPAT}/lib)
1426                 set(EXPAT_LIB)
1427         endif()
1428
1429         if(WITH_SDL)
1430                 set(SDL ${LIBDIR}/sdl)
1431                 set(SDL_INCLUDE_DIR ${SDL}/include)
1432                 set(SDL_LIBRARY SDL)
1433                 set(SDL_LIBPATH ${SDL}/lib)
1434         endif()
1435
1436         set(PNG "${LIBDIR}/png")
1437         set(PNG_INCLUDE_DIR "${PNG}/include")
1438         set(PNG_LIBPATH ${PNG}/lib)
1439
1440         set(JPEG "${LIBDIR}/jpeg")
1441         set(JPEG_INCLUDE_DIR "${JPEG}/include")
1442         set(JPEG_LIBPATH ${JPEG}/lib)
1443
1444         if(WITH_IMAGE_TIFF)
1445                 set(TIFF ${LIBDIR}/tiff)
1446                 set(TIFF_INCLUDE_DIR ${TIFF}/include)
1447                 set(TIFF_LIBRARY tiff)
1448                 set(TIFF_LIBPATH ${TIFF}/lib)
1449         endif()
1450
1451         if (WITH_INPUT_NDOF)
1452                 # linker needs "-weak_framework 3DconnexionClient"
1453         endif()
1454
1455         if(WITH_BOOST)
1456                 set(BOOST ${LIBDIR}/boost)
1457                 set(BOOST_INCLUDE_DIR ${BOOST}/include)
1458                 set(BOOST_LIBRARIES boost_date_time-mt boost_filesystem-mt boost_regex-mt boost_system-mt boost_thread-mt)
1459                 set(BOOST_LIBPATH ${BOOST}/lib)
1460                 set(BOOST_DEFINITIONS)
1461         endif()
1462
1463         if(WITH_OPENIMAGEIO)
1464                 set(OPENIMAGEIO ${LIBDIR}/openimageio)
1465                 set(OPENIMAGEIO_INCLUDE_DIRS ${OPENIMAGEIO}/include)
1466                 set(OPENIMAGEIO_LIBRARIES OpenImageIO ${PNG_LIBRARIES} ${JPEG_LIBRARIES} ${TIFF_LIBRARY} ${OPENEXR_LIBRARIES} ${ZLIB_LIBRARIES})
1467                 set(OPENIMAGEIO_LIBPATH ${OPENIMAGEIO}/lib ${JPEG_LIBPATH} ${PNG_LIBPATH} ${TIFF_LIBPATH} ${OPENEXR_LIBPATH} ${ZLIB_LIBPATH})
1468                 set(OPENIMAGEIO_DEFINITIONS "-DOIIO_STATIC_BUILD")
1469         endif()
1470
1471         if(WITH_OPENCOLORIO)
1472                 set(OPENCOLORIO ${LIBDIR}/opencolorio)
1473                 set(OPENCOLORIO_INCLUDE_DIRS ${OPENCOLORIO}/include)
1474                 set(OPENCOLORIO_LIBRARIES OpenColorIO tinyxml yaml-cpp)
1475                 set(OPENCOLORIO_LIBPATH ${OPENCOLORIO}/lib)
1476                 set(OPENCOLORIO_DEFINITIONS "-DOCIO_STATIC_BUILD")
1477         endif()
1478
1479         set(EXETYPE MACOSX_BUNDLE)
1480
1481         set(CMAKE_C_FLAGS_DEBUG "-fno-strict-aliasing -g")
1482         set(CMAKE_CXX_FLAGS_DEBUG "-fno-strict-aliasing -g")
1483         if(CMAKE_OSX_ARCHITECTURES MATCHES "i386")
1484                 set(CMAKE_CXX_FLAGS_RELEASE "-O2 -mdynamic-no-pic -ftree-vectorize -msse -msse2 -fvariable-expansion-in-unroller")
1485                 set(CMAKE_C_FLAGS_RELEASE "-O2 -mdynamic-no-pic -ftree-vectorize -msse -msse2 -fvariable-expansion-in-unroller")
1486         elseif(CMAKE_OSX_ARCHITECTURES MATCHES "x86_64")
1487                 set(CMAKE_CXX_FLAGS_RELEASE "-O2 -mdynamic-no-pic -ftree-vectorize -msse -msse2 -msse3 -mssse3 -fvariable-expansion-in-unroller")
1488                 set(CMAKE_C_FLAGS_RELEASE "-O2 -mdynamic-no-pic -ftree-vectorize -msse -msse2 -msse3 -mssse3 -fvariable-expansion-in-unroller")
1489         else()
1490                 set(CMAKE_C_FLAGS_RELEASE "-mdynamic-no-pic -fno-strict-aliasing")
1491                 set(CMAKE_CXX_FLAGS_RELEASE "-mdynamic-no-pic -fno-strict-aliasing")
1492         endif()
1493 endif()
1494
1495 #-----------------------------------------------------------------------------
1496 # Common.
1497
1498 if(APPLE OR WIN32)
1499         if(NOT EXISTS "${LIBDIR}/")
1500                 message(FATAL_ERROR "Apple and Windows require pre-compiled libs at: '${LIBDIR}'")
1501         endif()
1502 endif()
1503
1504 if(WITH_CYCLES)
1505         if(NOT WITH_OPENIMAGEIO)
1506                 message(FATAL_ERROR "Cycles reqires WITH_OPENIMAGEIO, the library may not have been found. Configure OIIO or disable WITH_CYCLES")
1507         endif()
1508         if(NOT WITH_BOOST)
1509                 message(FATAL_ERROR "Cycles reqires WITH_BOOST, the library may not have been found. Configure BOOST or disable WITH_CYCLES")
1510         endif()
1511 endif()
1512
1513
1514 # See TEST_SSE_SUPPORT() for how this is defined.
1515
1516 if(WITH_RAYOPTIMIZATION)
1517         if(SUPPORT_SSE_BUILD)
1518                 set(PLATFORM_CFLAGS " ${COMPILER_SSE_FLAG} ${PLATFORM_CFLAGS}")
1519                 add_definitions(-D__SSE__ -D__MMX__)
1520         endif()
1521         if(SUPPORT_SSE2_BUILD)
1522                 set(PLATFORM_CFLAGS " ${COMPILER_SSE2_FLAG} ${PLATFORM_CFLAGS}")
1523                 add_definitions(-D__SSE2__)
1524                 if(NOT SUPPORT_SSE_BUILD) # dont double up
1525                         add_definitions(-D__MMX__)
1526                 endif()
1527         endif()
1528 endif()
1529
1530
1531 # set the endian define
1532 if(MSVC)
1533         # for some reason this fails on msvc
1534         add_definitions(-D__LITTLE_ENDIAN__)
1535 else()
1536         include(TestBigEndian)
1537         test_big_endian(_SYSTEM_BIG_ENDIAN)
1538         if(_SYSTEM_BIG_ENDIAN)
1539                 add_definitions(-D__BIG_ENDIAN__)
1540         else()
1541                 add_definitions(-D__LITTLE_ENDIAN__)
1542         endif()
1543         unset(_SYSTEM_BIG_ENDIAN)
1544 endif()
1545
1546
1547 if(WITH_IMAGE_OPENJPEG)
1548         if(WITH_SYSTEM_OPENJPEG)
1549                 # dealt with above
1550         else()
1551                 set(OPENJPEG_INCLUDE_DIRS "${CMAKE_SOURCE_DIR}/extern/libopenjpeg")
1552                 add_definitions(-DOPJ_STATIC)
1553         endif()
1554 endif()
1555
1556 if(WITH_IMAGE_REDCODE)
1557         set(REDCODE ${CMAKE_SOURCE_DIR}/extern)
1558         set(REDCODE_INC ${REDCODE})
1559 endif()
1560
1561 #-----------------------------------------------------------------------------
1562 # Blender WebPlugin
1563
1564 if(WITH_WEBPLUGIN)
1565         set(GECKO_DIR "${CMAKE_SOURCE_DIR}/../gecko-sdk/" CACHE PATH "Gecko SDK path")
1566         set(WEBPLUGIN_SANDBOX_MODE "apparmor" CACHE STRING "WEB Plugin sandbox mode, can be apparmor, privsep, none")
1567
1568         set(WITH_PLAYER ON)
1569 endif()
1570
1571
1572 #-----------------------------------------------------------------------------
1573 # Configure OpenGL.
1574 find_package(OpenGL)
1575 blender_include_dirs_sys("${OPENGL_INCLUDE_DIR}")
1576 # unset(OPENGL_LIBRARIES CACHE) # not compat with older cmake
1577 # unset(OPENGL_xmesa_INCLUDE_DIR CACHE) # not compat with older cmake
1578
1579 #-----------------------------------------------------------------------------
1580 # Configure OpenMP.
1581 if(WITH_OPENMP)
1582         find_package(OpenMP)
1583         if(OPENMP_FOUND)
1584                 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
1585                 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
1586
1587                 if(APPLE AND ${CMAKE_GENERATOR} MATCHES "Xcode")
1588                         set(CMAKE_XCODE_ATTRIBUTE_ENABLE_OPENMP_SUPPORT "YES")
1589                 endif()
1590         else()
1591                 set(WITH_OPENMP OFF)
1592         endif()
1593
1594         mark_as_advanced(
1595                 OpenMP_C_FLAGS
1596                 OpenMP_CXX_FLAGS
1597         )
1598 endif()
1599
1600 #-----------------------------------------------------------------------------
1601 # Configure GLEW
1602
1603 if(WITH_SYSTEM_GLEW)
1604         find_package(GLEW)
1605
1606         if(NOT GLEW_FOUND)
1607                 message(FATAL_ERROR "GLEW is required to build blender, install it or disable WITH_SYSTEM_GLEW")
1608         endif()
1609
1610         mark_as_advanced(
1611                 GLEW_LIBRARY
1612                 GLEW_INCLUDE_PATH
1613         )
1614 else()
1615         # set(GLEW_LIBRARY "")  # unused
1616         set(GLEW_INCLUDE_PATH "${CMAKE_SOURCE_DIR}/extern/glew/include")
1617 endif()
1618
1619 #-----------------------------------------------------------------------------
1620 # Configure Python.
1621
1622 if(WITH_PYTHON_MODULE)
1623         add_definitions(-DPy_ENABLE_SHARED)
1624 endif()
1625
1626 #-----------------------------------------------------------------------------
1627 # Extra compile flags
1628
1629 if(CMAKE_COMPILER_IS_GNUCC)
1630
1631         ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_ALL -Wall)
1632         ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_CAST_ALIGN -Wcast-align)
1633         ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_ERROR_DECLARATION_AFTER_STATEMENT -Werror=declaration-after-statement)
1634         ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_ERROR_IMPLICIT_FUNCTION_DECLARATION -Werror=implicit-function-declaration)
1635         ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_ERROR_RETURN_TYPE -Werror=return-type)
1636         # system headers sometimes do this, disable for now, was: -Werror=strict-prototypes
1637         ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_STRICT_PROTOTYPES -Wstrict-prototypes)
1638         ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_NO_CHAR_SUBSCRIPTS -Wno-char-subscripts)
1639         ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_NO_UNKNOWN_PRAGMAS -Wno-unknown-pragmas)
1640         ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_POINTER_ARITH -Wpointer-arith)
1641         ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_UNUSED_PARAMETER -Wunused-parameter)
1642         ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_WRITE_STRINGS -Wwrite-strings)
1643
1644         # # this causes too many warnings, disable
1645         # ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_UNDEFINED -Wundef)
1646
1647         # disable because it gives warnings for printf() & friends.
1648         # ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_DOUBLE_PROMOTION -Wdouble-promotion -Wno-error=double-promotion)
1649
1650         if(NOT APPLE)
1651                 ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_NO_ERROR_UNUSED_BUT_SET_VARIABLE -Wno-error=unused-but-set-variable)
1652         endif()
1653
1654         ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_ALL -Wall)
1655         ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_NO_INVALID_OFFSETOF -Wno-invalid-offsetof)
1656         ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_NO_SIGN_COMPARE -Wno-sign-compare)
1657
1658         # # this causes too many warnings, disable
1659         # ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_UNDEFINED -Wundef)
1660
1661         # flags to undo strict flags
1662         ADD_CHECK_C_COMPILER_FLAG(CC_REMOVE_STRICT_FLAGS C_WARN_NO_DEPRECATED_DECLARATIONS -Wno-deprecated-declarations)
1663         ADD_CHECK_C_COMPILER_FLAG(CC_REMOVE_STRICT_FLAGS C_WARN_NO_UNUSED_PARAMETER        -Wno-unused-parameter)
1664
1665         if(NOT APPLE)
1666                 ADD_CHECK_C_COMPILER_FLAG(CC_REMOVE_STRICT_FLAGS C_WARN_NO_ERROR_UNUSED_BUT_SET_VARIABLE -Wno-error=unused-but-set-variable)
1667         endif()
1668
1669 elseif(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
1670
1671         ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_ALL -Wall)
1672         ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_NO_AUTOLOGICAL_COMPARE -Wno-tautological-compare)
1673         ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_NO_UNKNOWN_PRAGMAS -Wno-unknown-pragmas)
1674         ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_NO_CHAR_SUBSCRIPTS -Wno-char-subscripts)
1675
1676         ADD_CHECK_C_COMPILER_FLAG(CXX_WARNINGS C_WARN_ALL -Wall)
1677         ADD_CHECK_C_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_NO_AUTOLOGICAL_COMPARE -Wno-tautological-compare)
1678         ADD_CHECK_C_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_NO_UNKNOWN_PRAGMAS -Wno-unknown-pragmas)
1679         ADD_CHECK_C_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_NO_CHAR_SUBSCRIPTS -Wno-char-subscripts)
1680         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.
1681         ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_NO_INVALID_OFFSETOF -Wno-invalid-offsetof)
1682
1683 elseif(CMAKE_C_COMPILER_ID MATCHES "Intel")
1684
1685         ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_ALL -Wall)
1686         ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_POINTER_ARITH -Wpointer-arith)
1687         ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_NO_UNKNOWN_PRAGMAS -Wno-unknown-pragmas)
1688
1689         ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_ALL -Wall)
1690         ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_NO_INVALID_OFFSETOF -Wno-invalid-offsetof)
1691         ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_NO_SIGN_COMPARE -Wno-sign-compare)
1692
1693         # disable numbered, false positives
1694         set(C_WARNINGS "${C_WARNINGS} -wd188,186,144,913,556")
1695         set(CXX_WARNINGS "${CXX_WARNINGS} -wd188,186,144,913,556")
1696
1697 endif()
1698
1699 # MSVC2010 fails to links C++ libs right
1700 if(MSVC10)
1701         if(WITH_OPENCOLLADA)
1702                 message(WARNING "MSVC 2010 does not support OpenCollada, disabling WITH_OPENCOLLADA. To enable support use Use MSVC 2008")
1703         endif()
1704 endif()
1705
1706 # ensure python header is found since detection can fail, this could happen
1707 # with _any_ library but since we used a fixed python version this tends to
1708 # be most problematic.
1709 if(WITH_PYTHON)
1710         if(NOT EXISTS "${PYTHON_INCLUDE_DIR}/Python.h")
1711                 message(FATAL_ERROR "Missing: \"${PYTHON_INCLUDE_DIR}/Python.h\",\n"
1712                                                         "Set the cache entry 'PYTHON_INCLUDE_DIR' to point "
1713                                                         "to a valid python include path. Containing "
1714                                                         "Python.h for python version \"${PYTHON_VERSION}\"")
1715         endif()
1716
1717         if(WITH_PYTHON_INSTALL AND WITH_PYTHON_INSTALL_NUMPY)
1718                 # set but invalid
1719                 if(NOT ${PYTHON_NUMPY_PATH} STREQUAL "")
1720                         if(NOT EXISTS "${PYTHON_NUMPY_PATH}/numpy")
1721                                 message(WARNING "PYTHON_NUMPY_PATH is invalid, numpy not found in '${PYTHON_NUMPY_PATH}' "
1722                                                 "WITH_PYTHON_INSTALL_NUMPY option will be ignored when installing python")
1723                                 set(WITH_PYTHON_INSTALL_NUMPY OFF)
1724                         endif()
1725                 # not set, so initialize
1726                 else()
1727                         string(REPLACE "." ";" _PY_VER_SPLIT "${PYTHON_VERSION}")
1728                         list(GET _PY_VER_SPLIT 0 _PY_VER_MAJOR)
1729
1730                         # re-cache
1731                         unset(PYTHON_NUMPY_PATH CACHE)
1732                         find_path(PYTHON_NUMPY_PATH
1733                           NAMES
1734                             numpy
1735                           HINTS
1736                             "${PYTHON_LIBPATH}/python${PYTHON_VERSION}/"
1737                             "${PYTHON_LIBPATH}/python${_PY_VER_MAJOR}/"
1738                           PATH_SUFFIXES
1739                             site-packages
1740                             dist-packages
1741                            NO_DEFAULT_PATH
1742                         )
1743
1744                         if(NOT EXISTS "${PYTHON_NUMPY_PATH}")
1745                                 message(WARNING "'numpy' path could not be found in:\n"
1746                                                 "'${PYTHON_LIBPATH}/python${PYTHON_VERSION}/site-packages/numpy', "
1747                                                 "'${PYTHON_LIBPATH}/python${_PY_VER_MAJOR}/site-packages/numpy', "
1748                                                 "'${PYTHON_LIBPATH}/python${PYTHON_VERSION}/dist-packages/numpy', "
1749                                                 "'${PYTHON_LIBPATH}/python${_PY_VER_MAJOR}/dist-packages/numpy', "
1750                                                 "WITH_PYTHON_INSTALL_NUMPY option will be ignored when installing python")
1751                                 set(WITH_PYTHON_INSTALL_NUMPY OFF)
1752                         else()
1753                                 message(STATUS "numpy found at '${PYTHON_NUMPY_PATH}'")
1754                         endif()
1755
1756                         unset(_PY_VER_SPLIT)
1757                         unset(_PY_VER_MAJOR)
1758                 endif()
1759         endif()
1760 endif()
1761
1762
1763 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${PLATFORM_CFLAGS} ${C_WARNINGS}")
1764 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${PLATFORM_CFLAGS} ${CXX_WARNINGS}")
1765
1766 #-------------------------------------------------------------------------------
1767 # Global Defines
1768
1769 # better not set includes here but this debugging option is off by default.
1770 if(WITH_CXX_GUARDEDALLOC)
1771         include_directories(${CMAKE_SOURCE_DIR}/intern/guardedalloc)
1772         add_definitions(-DWITH_CXX_GUARDEDALLOC)
1773 endif()
1774
1775 if(WITH_ASSERT_ABORT)
1776         add_definitions(-DWITH_ASSERT_ABORT)
1777 endif()
1778
1779 # message(STATUS "Using CFLAGS: ${CMAKE_C_FLAGS}")
1780 # message(STATUS "Using CXXFLAGS: ${CMAKE_CXX_FLAGS}")
1781
1782 #-----------------------------------------------------------------------------
1783 # Libraries
1784
1785 add_subdirectory(source)
1786 add_subdirectory(intern)
1787 add_subdirectory(extern)
1788
1789
1790 #-----------------------------------------------------------------------------
1791 # Blender Application
1792 if(WITH_BLENDER)
1793         add_subdirectory(source/creator)
1794 endif()
1795
1796
1797 #-----------------------------------------------------------------------------
1798 # Blender Player
1799 if(WITH_PLAYER)
1800         add_subdirectory(source/blenderplayer)
1801 endif()
1802
1803 #-----------------------------------------------------------------------------
1804 # CPack for generating packages
1805 include(build_files/cmake/packaging.cmake)
1806
1807
1808 #-----------------------------------------------------------------------------
1809 # Print Final Configuration
1810
1811 if(FIRST_RUN)
1812         set(_config_msg "\n* Blender Configuration *")
1813         macro(info_cfg_option
1814                 _setting)
1815                 set(_msg "   * ${_setting}")
1816                 string(LENGTH "${_msg}" _len)
1817                 while("32" GREATER "${_len}")
1818                         set(_msg "${_msg} ")
1819                          math(EXPR _len "${_len} + 1")
1820                 endwhile()
1821
1822                 set(_config_msg "${_config_msg}\n${_msg}${${_setting}}")
1823         endmacro()
1824
1825         macro(info_cfg_text
1826                 _text)
1827                 set(_config_msg "${_config_msg}\n\n  ${_text}")
1828
1829
1830         endmacro()
1831
1832         info_cfg_text("Build Options:")
1833         info_cfg_option(WITH_GAMEENGINE)
1834         info_cfg_option(WITH_PLAYER)
1835         info_cfg_option(WITH_BULLET)
1836         info_cfg_option(WITH_IK_ITASC)
1837         info_cfg_option(WITH_OPENCOLLADA)
1838         info_cfg_option(WITH_FFTW3)
1839         info_cfg_option(WITH_INTERNATIONAL)
1840         info_cfg_option(WITH_INPUT_NDOF)
1841         info_cfg_option(WITH_CYCLES)
1842         info_cfg_option(WITH_OPENCOLORIO)
1843
1844         info_cfg_text("Compiler Options:")
1845         info_cfg_option(WITH_BUILDINFO)
1846         info_cfg_option(WITH_OPENMP)
1847         info_cfg_option(WITH_RAYOPTIMIZATION)
1848
1849         info_cfg_text("System Options:")
1850         info_cfg_option(WITH_INSTALL_PORTABLE)
1851         info_cfg_option(WITH_X11_XF86VMODE)
1852         info_cfg_option(WITH_X11_XINPUT)
1853         info_cfg_option(WITH_MEM_JEMALLOC)
1854         info_cfg_option(WITH_SYSTEM_GLEW)
1855         info_cfg_option(WITH_SYSTEM_OPENJPEG)
1856
1857         info_cfg_text("Image Formats:")
1858         info_cfg_option(WITH_IMAGE_CINEON)
1859         info_cfg_option(WITH_IMAGE_DDS)
1860         info_cfg_option(WITH_IMAGE_HDR)
1861         info_cfg_option(WITH_IMAGE_OPENEXR)
1862         info_cfg_option(WITH_IMAGE_OPENJPEG)
1863         info_cfg_option(WITH_IMAGE_REDCODE)
1864         info_cfg_option(WITH_IMAGE_TIFF)
1865
1866         info_cfg_text("Audio:")
1867         info_cfg_option(WITH_OPENAL)
1868         info_cfg_option(WITH_SDL)
1869         info_cfg_option(WITH_JACK)
1870         info_cfg_option(WITH_CODEC_FFMPEG)
1871         info_cfg_option(WITH_CODEC_SNDFILE)
1872
1873         info_cfg_text("Compression:")
1874         info_cfg_option(WITH_LZMA)
1875         info_cfg_option(WITH_LZO)
1876
1877         info_cfg_text("Python:")
1878         info_cfg_option(WITH_PYTHON_INSTALL)
1879         info_cfg_option(WITH_PYTHON_INSTALL_NUMPY)
1880         info_cfg_option(WITH_PYTHON_MODULE)
1881         info_cfg_option(WITH_PYTHON_SAFETY)
1882
1883         info_cfg_text("Modifiers:")
1884         info_cfg_option(WITH_MOD_BOOLEAN)
1885         info_cfg_option(WITH_MOD_REMESH)
1886         info_cfg_option(WITH_MOD_DECIMATE)
1887         info_cfg_option(WITH_MOD_FLUID)
1888         info_cfg_option(WITH_MOD_OCEANSIM)
1889
1890         info_cfg_text("")
1891
1892         message("${_config_msg}")
1893 endif()