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