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