Fixed typo in OCIO GLSL module, was using address to a pointer..
[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                                 ${OPENCOLLADA}/include/opencollada/COLLADAStreamWriter
1071                                 ${OPENCOLLADA}/include/opencollada/COLLADABaseUtils
1072                                 ${OPENCOLLADA}/include/opencollada/COLLADAFramework
1073                                 ${OPENCOLLADA}/include/opencollada/COLLADASaxFrameworkLoader
1074                                 ${OPENCOLLADA}/include/opencollada/GeneratedSaxParser
1075                         )
1076                         set_lib_path(OPENCOLLADA_LIBPATH "opencollada")
1077
1078                         set(OPENCOLLADA_LIBRARIES
1079                                 ${OPENCOLLADA_LIBPATH}/lib/opencollada/OpenCOLLADASaxFrameworkLoader.lib
1080                                 ${OPENCOLLADA_LIBPATH}/lib/opencollada/OpenCOLLADAFramework.lib
1081                                 ${OPENCOLLADA_LIBPATH}/lib/opencollada/OpenCOLLADABaseUtils.lib
1082                                 ${OPENCOLLADA_LIBPATH}/lib/opencollada/OpenCOLLADAStreamWriter.lib
1083                                 ${OPENCOLLADA_LIBPATH}/lib/opencollada/MathMLSolver.lib
1084                                 ${OPENCOLLADA_LIBPATH}/lib/opencollada/GeneratedSaxParser.lib
1085                                 ${OPENCOLLADA_LIBPATH}/lib/opencollada/xml.lib
1086                                 ${OPENCOLLADA_LIBPATH}/lib/opencollada/buffer.lib
1087                                 ${OPENCOLLADA_LIBPATH}/lib/opencollada/ftoa.lib
1088                                 ${OPENCOLLADA_LIBPATH}/lib/opencollada/UTF.lib
1089                         )
1090                         set(PCRE_LIBRARIES
1091                                 ${OPENCOLLADA_LIBPATH}/lib/opencollada/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                                 ${OPENCOLLADA}/include/opencollada/COLLADAStreamWriter
1293                                 ${OPENCOLLADA}/include/opencollada/COLLADABaseUtils
1294                                 ${OPENCOLLADA}/include/opencollada/COLLADAFramework
1295                                 ${OPENCOLLADA}/include/opencollada/COLLADASaxFrameworkLoader
1296                                 ${OPENCOLLADA}/include/opencollada/GeneratedSaxParser
1297                         )
1298                         set(OPENCOLLADA_LIBPATH ${OPENCOLLADA}/lib/opencollada)
1299                         set(OPENCOLLADA_LIBRARIES OpenCOLLADAStreamWriter OpenCOLLADASaxFrameworkLoader OpenCOLLADAFramework OpenCOLLADABaseUtils GeneratedSaxParser UTF MathMLSolver buffer ftoa xml)
1300                         set(PCRE_LIBRARIES pcre)
1301                 endif()
1302
1303                 if(WITH_CODEC_FFMPEG)
1304                         set(FFMPEG ${LIBDIR}/ffmpeg)
1305                         set(FFMPEG_INCLUDE_DIRS ${FFMPEG}/include)
1306                         if(WITH_MINGW64)
1307                                 set(FFMPEG_LIBRARIES avcodec.dll avformat.dll avdevice.dll avutil.dll swscale.dll swresample.dll)
1308                         else()
1309                                 set(FFMPEG_LIBRARIES avcodec-53 avformat-53 avdevice-53 avutil-51 swscale-2)
1310                         endif()
1311                         set(FFMPEG_LIBPATH ${FFMPEG}/lib)
1312                 endif()
1313
1314                 if(WITH_IMAGE_OPENEXR)
1315                         set(OPENEXR ${LIBDIR}/openexr)
1316                         set(OPENEXR_INCLUDE_DIR ${OPENEXR}/include)
1317                         set(OPENEXR_INCLUDE_DIRS ${OPENEXR}/include/OpenEXR)
1318                         set(OPENEXR_LIBRARIES Half IlmImf Imath IlmThread Iex)
1319                         set(OPENEXR_LIBPATH ${OPENEXR}/lib)
1320                 endif()
1321
1322                 if(WITH_IMAGE_TIFF)
1323                         set(TIFF ${LIBDIR}/tiff)
1324                         set(TIFF_LIBRARY tiff)
1325                         set(TIFF_INCLUDE_DIR ${TIFF}/include)
1326                         set(TIFF_LIBPATH ${TIFF}/lib)
1327                 endif()
1328
1329                 if(WITH_JACK)
1330                         set(JACK ${LIBDIR}/jack)
1331                         set(JACK_INCLUDE_DIRS ${JACK}/include/jack ${JACK}/include)
1332                         set(JACK_LIBRARIES jack)
1333                         set(JACK_LIBPATH ${JACK}/lib)
1334
1335                         # TODO, gives linking errors, force off
1336                         set(WITH_JACK OFF)
1337                 endif()
1338
1339                 if(WITH_PYTHON)
1340                         # normally cached but not since we include them with blender
1341                         set(PYTHON_VERSION 3.3) #  CACHE STRING)
1342                         set(PYTHON_INCLUDE_DIR "${LIBDIR}/python/include/python${PYTHON_VERSION}")  # CACHE PATH)
1343                         set(PYTHON_LIBRARY "${LIBDIR}/python/lib/python33mw.lib")  # CACHE FILEPATH)
1344
1345                         # uncached vars
1346                         set(PYTHON_INCLUDE_DIRS "${PYTHON_INCLUDE_DIR}")
1347                         set(PYTHON_LIBRARIES  "${PYTHON_LIBRARY}")
1348                 endif()
1349
1350                 if(WITH_BOOST)
1351                         set(BOOST ${LIBDIR}/boost)
1352                         set(BOOST_INCLUDE_DIR ${BOOST}/include)
1353                         if(WITH_MINGW64)
1354                                 set(BOOST_POSTFIX "mgw47-mt-s-1_49")
1355                                 set(BOOST_DEBUG_POSTFIX "mgw47-mt-sd-1_49")
1356                         else()
1357                                 set(BOOST_POSTFIX "mgw46-mt-s-1_49")
1358                                 set(BOOST_DEBUG_POSTFIX "mgw46-mt-sd-1_49")
1359                         endif()
1360                         set(BOOST_LIBRARIES
1361                                 optimized boost_date_time-${BOOST_POSTFIX} boost_filesystem-${BOOST_POSTFIX}
1362                                 boost_regex-${BOOST_POSTFIX}
1363                                 boost_system-${BOOST_POSTFIX} boost_thread-${BOOST_POSTFIX}
1364                                 debug boost_date_time-${BOOST_DEBUG_POSTFIX} boost_filesystem-${BOOST_DEBUG_POSTFIX}
1365                                 boost_regex-${BOOST_DEBUG_POSTFIX}
1366                                 boost_system-${BOOST_DEBUG_POSTFIX} boost_thread-${BOOST_DEBUG_POSTFIX})
1367                         if(WITH_INTERNATIONAL)
1368                                 set(BOOST_LIBRARIES ${BOOST_LIBRARIES}
1369                                         optimized boost_locale-${BOOST_POSTFIX}
1370                                         debug boost_locale-${BOOST_DEBUG_POSTFIX}) 
1371                         endif()
1372                         if(WITH_CYCLES_OSL)
1373                                 set(BOOST_LIBRARIES ${BOOST_LIBRARIES}
1374                                         optimized boost_wave-${BOOST_POSTFIX}
1375                                         debug boost_wave-${BOOST_DEBUG_POSTFIX}) 
1376                         endif()
1377                         set(BOOST_LIBPATH ${BOOST}/lib)
1378                         set(BOOST_DEFINITIONS "-DBOOST_ALL_NO_LIB -DBOOST_THREAD_USE_LIB ")
1379                 endif()
1380                         
1381                 if(WITH_OPENIMAGEIO)
1382                         set(OPENIMAGEIO ${LIBDIR}/openimageio)
1383                         set(OPENIMAGEIO_INCLUDE_DIRS ${OPENIMAGEIO}/include)
1384                         set(OPENIMAGEIO_LIBRARIES OpenImageIO)
1385                         set(OPENIMAGEIO_LIBPATH ${OPENIMAGEIO}/lib)
1386                         set(OPENIMAGEIO_DEFINITIONS "")
1387                 endif()
1388                 
1389                 if(WITH_LLVM)
1390                         set(LLVM_DIRECTORY ${LIBDIR}/llvm CACHE PATH    "Path to the LLVM installation")
1391                         set(LLVM_LIB_DIR ${LLVM_DIRECTORY}/lib)
1392                         #Explicitly set llvm lib order.
1393                         #---- WARNING ON GCC ORDER OF LIBS IS IMPORTANT, DO NOT CHANGE! ---------
1394                         set(LLVM_LIBRARY LLVMSelectionDAG LLVMCodeGen LLVMScalarOpts LLVMAnalysis LLVMArchive
1395                                 LLVMAsmParser LLVMAsmPrinter
1396                                 LLVMBitReader LLVMBitWriter
1397                                 LLVMDebugInfo LLVMExecutionEngine
1398                                 LLVMInstCombine LLVMInstrumentation
1399                                 LLVMInterpreter LLVMJIT
1400                                 LLVMLinker LLVMMC
1401                                 LLVMMCDisassembler LLVMMCJIT
1402                                 LLVMMCParser LLVMObject
1403                                 LLVMRuntimeDyld 
1404                                 LLVMSupport
1405                                 LLVMTableGen LLVMTarget
1406                                 LLVMTransformUtils LLVMVectorize
1407                                 LLVMX86AsmParser LLVMX86AsmPrinter
1408                                 LLVMX86CodeGen LLVMX86Desc
1409                                 LLVMX86Disassembler LLVMX86Info
1410                                 LLVMX86Utils LLVMipa
1411                                 LLVMipo LLVMCore)
1412                         #imagehelp is needed by LLVM 3.1 on MinGW, check lib\Support\Windows\Signals.inc
1413                         set(PLATFORM_LINKLIBS "${PLATFORM_LINKLIBS} -limagehlp")
1414                         set(LLVM_STATIC YES)
1415                 endif()
1416                 
1417                 if(WITH_OPENCOLORIO)
1418                         set(OPENCOLORIO ${LIBDIR}/opencolorio)
1419                         set(OPENCOLORIO_INCLUDE_DIRS ${OPENCOLORIO}/include)
1420                         set(OPENCOLORIO_LIBRARIES OpenColorIO)
1421                         set(OPENCOLORIO_LIBPATH ${OPENCOLORIO}/lib)
1422                         set(OPENCOLORIO_DEFINITIONS)
1423                 endif()
1424
1425                 set(PLATFORM_LINKFLAGS "-Xlinker --stack=2097152")
1426
1427                 ## DISABLE - causes linking errors 
1428                 ## for re-distribution, so users dont need mingw installed
1429                 # set(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} -static-libgcc -static-libstdc++")
1430
1431         endif()
1432
1433 elseif(APPLE)
1434
1435         if(${CMAKE_OSX_DEPLOYMENT_TARGET} STREQUAL "10.5" OR ${CMAKE_OSX_DEPLOYMENT_TARGET} STRGREATER "10.5")
1436                 set(WITH_LIBS10.5 ON CACHE BOOL "Use 10.5 libs" FORCE) # valid also for 10.6/10.7
1437         endif()
1438
1439         if(WITH_LIBS10.5)
1440                 set(LIBDIR ${CMAKE_SOURCE_DIR}/../lib/darwin-9.x.universal)
1441         else()
1442                 if(CMAKE_OSX_ARCHITECTURES MATCHES i386)
1443                         set(LIBDIR ${CMAKE_SOURCE_DIR}/../lib/darwin-8.x.i386)
1444                 else()
1445                         set(LIBDIR ${CMAKE_SOURCE_DIR}/../lib/darwin-8.0.0-powerpc)
1446                 endif()
1447         endif()
1448
1449
1450         if(WITH_OPENAL)
1451                 find_package(OpenAL)
1452                 if(OPENAL_FOUND)
1453                         set(WITH_OPENAL ON)
1454                         set(OPENAL_INCLUDE_DIR "${LIBDIR}/openal/include")
1455                 else()
1456                         set(WITH_OPENAL OFF)
1457                 endif()
1458         endif()
1459
1460         if(WITH_JACK)
1461                 find_library(JACK_FRAMEWORK
1462                         NAMES jackmp
1463                 )
1464                 set(JACK_INCLUDE_DIRS ${JACK_FRAMEWORK}/headers)
1465                 if(NOT JACK_FRAMEWORK)
1466                         set(WITH_JACK OFF)
1467                 endif()
1468         endif()
1469
1470         if(WITH_CODEC_SNDFILE)
1471                 set(SNDFILE ${LIBDIR}/sndfile)
1472                 set(SNDFILE_INCLUDE_DIRS ${SNDFILE}/include)
1473                 set(SNDFILE_LIBRARIES sndfile FLAC ogg vorbis vorbisenc)
1474                 set(SNDFILE_LIBPATH ${SNDFILE}/lib ${FFMPEG}/lib)  # TODO, deprecate
1475         endif()
1476
1477         if(WITH_PYTHON)
1478                 # we use precompiled libraries for py 3.3 and up by default
1479                 set(PYTHON_VERSION 3.3)
1480                 if(NOT WITH_PYTHON_MODULE AND NOT WITH_PYTHON_FRAMEWORK)
1481                         # normally cached but not since we include them with blender
1482                         set(PYTHON_INCLUDE_DIR "${LIBDIR}/python/include/python${PYTHON_VERSION}m")
1483                         # set(PYTHON_BINARY "${LIBDIR}/python/bin/python${PYTHON_VERSION}") # not used yet
1484                         set(PYTHON_LIBRARY python${PYTHON_VERSION}m)
1485                         set(PYTHON_LIBPATH "${LIBDIR}/python/lib/python${PYTHON_VERSION}")
1486                         # set(PYTHON_LINKFLAGS "-u _PyMac_Error")  # won't  build with this enabled
1487                 else()
1488                         # module must be compiled against Python framework
1489                         set(PYTHON_INCLUDE_DIR "/Library/Frameworks/Python.framework/Versions/${PYTHON_VERSION}/include/python${PYTHON_VERSION}m")
1490                         set(PYTHON_BINARY "/Library/Frameworks/Python.framework/Versions/${PYTHON_VERSION}/bin/python${PYTHON_VERSION}")
1491                         #set(PYTHON_LIBRARY python${PYTHON_VERSION})
1492                         set(PYTHON_LIBPATH "/Library/Frameworks/Python.framework/Versions/${PYTHON_VERSION}/lib/python${PYTHON_VERSION}/config-${PYTHON_VERSION}m")
1493                         #set(PYTHON_LINKFLAGS "-u _PyMac_Error -framework Python")  # won't  build with this enabled
1494                 endif()
1495                 
1496                 # uncached vars
1497                 set(PYTHON_INCLUDE_DIRS "${PYTHON_INCLUDE_DIR}")
1498                 set(PYTHON_LIBRARIES  "${PYTHON_LIBRARY}")
1499         endif()
1500
1501         if(WITH_FFTW3)
1502                 set(FFTW3 ${LIBDIR}/fftw3)
1503                 set(FFTW3_INCLUDE_DIRS ${FFTW3}/include)
1504                 set(FFTW3_LIBRARIES fftw3)
1505                 set(FFTW3_LIBPATH ${FFTW3}/lib)
1506         endif()
1507
1508         set(PNG_LIBRARIES png)
1509         set(JPEG_LIBRARIES jpeg)
1510
1511         set(ZLIB /usr)
1512         set(ZLIB_INCLUDE_DIRS "${ZLIB}/include")
1513         set(ZLIB_LIBRARIES z bz2)
1514
1515         set(FREETYPE ${LIBDIR}/freetype)
1516         set(FREETYPE_INCLUDE_DIRS ${FREETYPE}/include ${FREETYPE}/include/freetype2)
1517         set(FREETYPE_LIBPATH ${FREETYPE}/lib)
1518         set(FREETYPE_LIBRARY freetype)
1519
1520         if(WITH_IMAGE_OPENEXR)
1521                 set(OPENEXR ${LIBDIR}/openexr)
1522                 set(OPENEXR_INCLUDE_DIR ${OPENEXR}/include)
1523                 set(OPENEXR_INCLUDE_DIRS ${OPENEXR}/include/OpenEXR)
1524                 set(OPENEXR_LIBRARIES Iex Half IlmImf Imath IlmThread)
1525                 set(OPENEXR_LIBPATH ${OPENEXR}/lib)
1526         endif()
1527
1528         if(WITH_CODEC_FFMPEG)
1529                 set(FFMPEG ${LIBDIR}/ffmpeg)
1530                 set(FFMPEG_INCLUDE_DIRS ${FFMPEG}/include)
1531                 set(FFMPEG_LIBRARIES avcodec avdevice avformat avutil mp3lame swscale x264 xvidcore theora theoradec theoraenc vorbis vorbisenc vorbisfile ogg)
1532                 set(FFMPEG_LIBPATH ${FFMPEG}/lib)
1533                 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D__STDC_CONSTANT_MACROS")
1534         endif()
1535
1536         find_library(SYSTEMSTUBS_LIBRARY
1537                 NAMES
1538                 SystemStubs
1539                 PATHS
1540         )
1541         mark_as_advanced(SYSTEMSTUBS_LIBRARY)
1542         if(SYSTEMSTUBS_LIBRARY)
1543                 set(PLATFORM_LINKLIBS stdc++ SystemStubs)
1544         else()
1545                 set(PLATFORM_LINKLIBS stdc++)
1546         endif()
1547
1548         if(WITH_COCOA)
1549                 set(PLATFORM_CFLAGS "-pipe -funsigned-char -DGHOST_COCOA")
1550                 set(PLATFORM_LINKFLAGS "-fexceptions -framework CoreServices -framework Foundation -framework IOKit -framework AppKit -framework Cocoa -framework Carbon -framework AudioUnit -framework AudioToolbox -framework CoreAudio")
1551                 if(USE_QTKIT)
1552                         set(PLATFORM_CFLAGS "${PLATFORM_CFLAGS} -DUSE_QTKIT")
1553                         set(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} -framework QTKit")
1554                         if(CMAKE_OSX_ARCHITECTURES MATCHES i386)
1555                                 set(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} -framework QuickTime")
1556                                 #libSDL still needs 32bit carbon quicktime
1557                         endif()
1558                 elseif(WITH_CODEC_QUICKTIME)
1559                         set(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} -framework QuickTime")
1560                 endif()
1561
1562                 # XXX - SOME MAC DEV PLEASE TEST WITH THE SDK INSTALLED!
1563                 # ALSO SHOULD BE MOVED INTO OWN MODULE WHEN FUNCTIONAL
1564                 if(WITH_INPUT_NDOF)
1565                         # This thread it *should* work and check the framework - campbell
1566                         # http://www.cmake.org/pipermail/cmake/2005-December/007740.html
1567                         find_library(3DCONNEXION_CLIENT_FRAMEWORK
1568                                 NAMES 3DconnexionClient
1569                         )
1570                         if(NOT 3DCONNEXION_CLIENT_FRAMEWORK)
1571                                 set(WITH_INPUT_NDOF OFF)
1572                         endif()
1573
1574                         if(WITH_INPUT_NDOF)
1575                                 set(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} -F/Library/Frameworks -weak_framework 3DconnexionClient")
1576                                 set(NDOF_INCLUDE_DIRS /Library/Frameworks/3DconnexionClient.framework/Headers )
1577                         endif()
1578                 endif()
1579
1580         if(WITH_JACK)
1581                 set(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} -weak_framework jackmp")
1582         endif()
1583
1584         else()
1585                 set(PLATFORM_CFLAGS "-pipe -funsigned-char")
1586                 set(PLATFORM_LINKFLAGS "-fexceptions -framework CoreServices -framework Foundation -framework IOKit -framework AppKit -framework Carbon -framework AGL -framework AudioUnit -framework AudioToolbox -framework CoreAudio -framework QuickTime")
1587                 set(WITH_INPUT_NDOF OFF)  # unsupported
1588         endif()
1589         
1590         if(WITH_PYTHON_MODULE OR WITH_PYTHON_FRAMEWORK)
1591                 set(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} /Library/Frameworks/Python.framework/Versions/${PYTHON_VERSION}/Python")# force cmake to link right framework
1592         endif()
1593         
1594         if(WITH_OPENCOLLADA)
1595                 set(OPENCOLLADA ${LIBDIR}/opencollada)
1596
1597                 set(OPENCOLLADA_INCLUDE_DIRS
1598                         ${LIBDIR}/opencollada/include/COLLADAStreamWriter
1599                         ${LIBDIR}/opencollada/include/COLLADABaseUtils
1600                         ${LIBDIR}/opencollada/include/COLLADAFramework
1601                         ${LIBDIR}/opencollada/include/COLLADASaxFrameworkLoader
1602                         ${LIBDIR}/opencollada/include/GeneratedSaxParser
1603                 )
1604
1605                 set(OPENCOLLADA_LIBPATH ${OPENCOLLADA}/lib)
1606                 set(OPENCOLLADA_LIBRARIES "OpenCOLLADASaxFrameworkLoader -lOpenCOLLADAFramework -lOpenCOLLADABaseUtils -lOpenCOLLADAStreamWriter -lMathMLSolver -lGeneratedSaxParser -lUTF -lxml2 -lbuffer -lftoa")
1607                 #pcre is bundled with openCollada
1608                 #set(PCRE ${LIBDIR}/pcre)
1609                 #set(PCRE_LIBPATH ${PCRE}/lib)
1610                 set(PCRE_LIBRARIES pcre)
1611                 #libxml2 is used
1612                 #set(EXPAT ${LIBDIR}/expat)
1613                 #set(EXPAT_LIBPATH ${EXPAT}/lib)
1614                 set(EXPAT_LIB)
1615         endif()
1616
1617         if(WITH_SDL)
1618                 set(SDL ${LIBDIR}/sdl)
1619                 set(SDL_INCLUDE_DIR ${SDL}/include)
1620                 set(SDL_LIBRARY SDL)
1621                 set(SDL_LIBPATH ${SDL}/lib)
1622         endif()
1623
1624         set(PNG "${LIBDIR}/png")
1625         set(PNG_INCLUDE_DIR "${PNG}/include")
1626         set(PNG_LIBPATH ${PNG}/lib)
1627
1628         set(JPEG "${LIBDIR}/jpeg")
1629         set(JPEG_INCLUDE_DIR "${JPEG}/include")
1630         set(JPEG_LIBPATH ${JPEG}/lib)
1631
1632         if(WITH_IMAGE_TIFF)
1633                 set(TIFF ${LIBDIR}/tiff)
1634                 set(TIFF_INCLUDE_DIR ${TIFF}/include)
1635                 set(TIFF_LIBRARY tiff)
1636                 set(TIFF_LIBPATH ${TIFF}/lib)
1637         endif()
1638
1639         if(WITH_INPUT_NDOF)
1640                 # linker needs "-weak_framework 3DconnexionClient"
1641         endif()
1642
1643         if(WITH_BOOST)
1644                 set(BOOST ${LIBDIR}/boost)
1645                 set(BOOST_INCLUDE_DIR ${BOOST}/include)
1646                 set(BOOST_LIBRARIES boost_date_time-mt boost_filesystem-mt boost_regex-mt boost_system-mt boost_thread-mt boost_wave-mt)
1647                 if(WITH_INTERNATIONAL)
1648                         list(APPEND BOOST_LIBRARIES boost_locale-mt)
1649                         set(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} -liconv") # boost_locale needs it !
1650                 endif()
1651                 set(BOOST_LIBPATH ${BOOST}/lib)
1652                 set(BOOST_DEFINITIONS)
1653         endif()
1654
1655         if(WITH_OPENIMAGEIO)
1656                 set(OPENIMAGEIO ${LIBDIR}/openimageio)
1657                 set(OPENIMAGEIO_INCLUDE_DIRS ${OPENIMAGEIO}/include)
1658                 set(OPENIMAGEIO_LIBRARIES ${OPENIMAGEIO}/lib/libOpenImageIO.a ${PNG_LIBRARIES} ${JPEG_LIBRARIES} ${TIFF_LIBRARY} ${OPENEXR_LIBRARIES} ${ZLIB_LIBRARIES})
1659                 set(OPENIMAGEIO_LIBPATH ${OPENIMAGEIO}/lib ${JPEG_LIBPATH} ${PNG_LIBPATH} ${TIFF_LIBPATH} ${OPENEXR_LIBPATH} ${ZLIB_LIBPATH})
1660                 set(OPENIMAGEIO_DEFINITIONS "-DOIIO_STATIC_BUILD")
1661         endif()
1662
1663         if(WITH_OPENCOLORIO)
1664                 set(OPENCOLORIO ${LIBDIR}/opencolorio)
1665                 set(OPENCOLORIO_INCLUDE_DIRS ${OPENCOLORIO}/include)
1666                 set(OPENCOLORIO_LIBRARIES OpenColorIO tinyxml yaml-cpp)
1667                 set(OPENCOLORIO_LIBPATH ${OPENCOLORIO}/lib)
1668                 set(OPENCOLORIO_DEFINITIONS "-DOCIO_STATIC_BUILD")
1669         endif()
1670
1671         if(WITH_LLVM)
1672                 set(LLVM_DIRECTORY ${LIBDIR}/llvm CACHE PATH    "Path to the LLVM installation")
1673                 set(LLVM_VERSION "3.1" CACHE STRING     "Version of LLVM to use")
1674                 set(LLVM_STATIC YES)
1675                 if(EXISTS "${LLVM_DIRECTORY}/bin/llvm-config")
1676                         set(LLVM_CONFIG "${LLVM_DIRECTORY}/bin/llvm-config")
1677                 else()
1678                         set(LLVM_CONFIG llvm-config)
1679                 endif()
1680                 execute_process(COMMAND ${LLVM_CONFIG} --version
1681                                 OUTPUT_VARIABLE LLVM_VERSION
1682                                 OUTPUT_STRIP_TRAILING_WHITESPACE)
1683                 execute_process(COMMAND ${LLVM_CONFIG} --prefix
1684                                 OUTPUT_VARIABLE LLVM_DIRECTORY
1685                                 OUTPUT_STRIP_TRAILING_WHITESPACE)
1686                 execute_process(COMMAND ${LLVM_CONFIG} --libdir
1687                                 OUTPUT_VARIABLE LLVM_LIB_DIR
1688                                 OUTPUT_STRIP_TRAILING_WHITESPACE)
1689                 find_library(LLVM_LIBRARY
1690                              NAMES LLVMAnalysis # first of a whole bunch of libs to get
1691                              PATHS ${LLVM_LIB_DIR})
1692
1693                 if(LLVM_LIBRARY AND LLVM_DIRECTORY AND LLVM_LIB_DIR)
1694                         if(LLVM_STATIC)
1695                                 # if static LLVM libraries were requested, use llvm-config to generate
1696                                 # the list of what libraries we need, and substitute that in the right
1697                                 # way for LLVM_LIBRARY.
1698                                 execute_process(COMMAND ${LLVM_CONFIG} --libfiles
1699                                                 OUTPUT_VARIABLE LLVM_LIBRARY
1700                                                 OUTPUT_STRIP_TRAILING_WHITESPACE)
1701                                 string(REPLACE " " ";" LLVM_LIBRARY ${LLVM_LIBRARY})
1702                         endif()
1703                 else()
1704                         message(FATAL_ERROR "LLVM not found.")
1705                 endif()
1706         endif()
1707
1708         if(WITH_CYCLES_OSL)
1709                 set(CYCLES_OSL ${LIBDIR}/osl CACHE PATH "Path to OpenShadingLanguage installation")
1710         
1711                 find_library(OSL_LIB_EXEC NAMES oslexec PATHS ${CYCLES_OSL}/lib)
1712                 find_library(OSL_LIB_COMP NAMES oslcomp PATHS ${CYCLES_OSL}/lib)
1713                 find_library(OSL_LIB_QUERY NAMES oslquery PATHS ${CYCLES_OSL}/lib)
1714                 # WARNING! depends on correct order of OSL libs linking
1715                 list(APPEND OSL_LIBRARIES ${OSL_LIB_COMP} -force_load ${OSL_LIB_EXEC} ${OSL_LIB_QUERY})
1716                 find_path(OSL_INCLUDES OSL/oslclosure.h PATHS ${CYCLES_OSL}/include)
1717                 find_program(OSL_COMPILER NAMES oslc PATHS ${CYCLES_OSL}/bin)
1718         
1719                 if(OSL_INCLUDES AND OSL_LIBRARIES AND OSL_COMPILER)
1720                         set(OSL_FOUND TRUE)
1721                 else()
1722                         message(STATUS "OSL not found")
1723                 endif()
1724         endif()
1725
1726         set(EXETYPE MACOSX_BUNDLE)
1727
1728         set(CMAKE_C_FLAGS_DEBUG "-fno-strict-aliasing -g")
1729         set(CMAKE_CXX_FLAGS_DEBUG "-fno-strict-aliasing -g")
1730         if(CMAKE_OSX_ARCHITECTURES MATCHES "x86_64" OR CMAKE_OSX_ARCHITECTURES MATCHES "i386")
1731                 set(CMAKE_CXX_FLAGS_RELEASE "-O2 -mdynamic-no-pic -msse -msse2 -msse3 -mssse3")
1732                 set(CMAKE_C_FLAGS_RELEASE "-O2 -mdynamic-no-pic  -msse -msse2 -msse3 -mssse3")
1733                 if(NOT CMAKE_CXX_COMPILER_ID MATCHES "Clang")
1734                         set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -ftree-vectorize  -fvariable-expansion-in-unroller")
1735                         set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -ftree-vectorize  -fvariable-expansion-in-unroller")
1736                 endif()
1737         else()
1738                 set(CMAKE_C_FLAGS_RELEASE "-mdynamic-no-pic -fno-strict-aliasing")
1739                 set(CMAKE_CXX_FLAGS_RELEASE "-mdynamic-no-pic -fno-strict-aliasing")
1740         endif()
1741 endif()
1742
1743 #-----------------------------------------------------------------------------
1744 # Common.
1745
1746 if(APPLE OR WIN32)
1747         if(NOT EXISTS "${LIBDIR}/")
1748                 message(FATAL_ERROR "Apple and Windows require pre-compiled libs at: '${LIBDIR}'")
1749         endif()
1750 endif()
1751
1752 if(NOT WITH_FFTW3 AND WITH_MOD_OCEANSIM)
1753         message(FATAL_ERROR "WITH_MOD_OCEANSIM requires WITH_FFTW3 to be ON")
1754 endif()
1755
1756 if(WITH_CYCLES)
1757         if(NOT WITH_OPENIMAGEIO)
1758                 message(FATAL_ERROR "Cycles reqires WITH_OPENIMAGEIO, the library may not have been found. Configure OIIO or disable WITH_CYCLES")
1759         endif()
1760         if(NOT WITH_BOOST)
1761                 message(FATAL_ERROR "Cycles reqires WITH_BOOST, the library may not have been found. Configure BOOST or disable WITH_CYCLES")
1762         endif()
1763
1764         if(WITH_CYCLES_OSL)
1765                 if(NOT WITH_LLVM)
1766                         message(FATAL_ERROR "Cycles OSL reqires WITH_LLVM, the library may not have been found. Configure LLVM or disable WITH_CYCLES_OSL")
1767                 endif()
1768         endif()
1769 endif()
1770
1771 if(WITH_INTERNATIONAL)
1772         if(NOT WITH_BOOST)
1773                 message(FATAL_ERROR "Internationalization reqires WITH_BOOST, the library may not have been found. Configure BOOST or disable WITH_INTERNATIONAL")
1774         endif()
1775 endif()
1776
1777 # See TEST_SSE_SUPPORT() for how this is defined.
1778
1779 if(WITH_RAYOPTIMIZATION)
1780         if(SUPPORT_SSE_BUILD)
1781                 set(PLATFORM_CFLAGS " ${COMPILER_SSE_FLAG} ${PLATFORM_CFLAGS}")
1782                 add_definitions(-D__SSE__ -D__MMX__)
1783         endif()
1784         if(SUPPORT_SSE2_BUILD)
1785                 set(PLATFORM_CFLAGS " ${COMPILER_SSE2_FLAG} ${PLATFORM_CFLAGS}")
1786                 add_definitions(-D__SSE2__)
1787                 if(NOT SUPPORT_SSE_BUILD) # dont double up
1788                         add_definitions(-D__MMX__)
1789                 endif()
1790         endif()
1791 endif()
1792
1793
1794 # set the endian define
1795 if(MSVC)
1796         # for some reason this fails on msvc
1797         add_definitions(-D__LITTLE_ENDIAN__)
1798         
1799 # OSX-Note: as we do crosscompiling with specific set architecture,
1800 # endianess-detection and autosetting is counterproductive
1801 # so we just set endianess according CMAKE_OSX_ARCHITECTURES
1802
1803 elseif(CMAKE_OSX_ARCHITECTURES MATCHES i386 OR CMAKE_OSX_ARCHITECTURES MATCHES x86_64)
1804         add_definitions(-D__LITTLE_ENDIAN__)
1805 elseif(CMAKE_OSX_ARCHITECTURES MATCHES ppc OR CMAKE_OSX_ARCHITECTURES MATCHES ppc64)            
1806         add_definitions(-D__BIG_ENDIAN__)
1807         
1808 else()
1809         include(TestBigEndian)
1810         test_big_endian(_SYSTEM_BIG_ENDIAN)
1811         if(_SYSTEM_BIG_ENDIAN)
1812                 add_definitions(-D__BIG_ENDIAN__)
1813         else()
1814                 add_definitions(-D__LITTLE_ENDIAN__)
1815         endif()
1816         unset(_SYSTEM_BIG_ENDIAN)
1817 endif()
1818
1819
1820 if(WITH_IMAGE_OPENJPEG)
1821         if(WITH_SYSTEM_OPENJPEG)
1822                 # dealt with above
1823         else()
1824                 set(OPENJPEG_INCLUDE_DIRS "${CMAKE_SOURCE_DIR}/extern/libopenjpeg")
1825                 add_definitions(-DOPJ_STATIC)
1826         endif()
1827 endif()
1828
1829 if(WITH_IMAGE_REDCODE)
1830         set(REDCODE ${CMAKE_SOURCE_DIR}/extern)
1831         set(REDCODE_INC ${REDCODE})
1832 endif()
1833
1834 #-----------------------------------------------------------------------------
1835 # Blender WebPlugin
1836
1837 if(WITH_WEBPLUGIN)
1838         set(GECKO_DIR "${CMAKE_SOURCE_DIR}/../gecko-sdk/" CACHE PATH "Gecko SDK path")
1839         set(WEBPLUGIN_SANDBOX_MODE "apparmor" CACHE STRING "WEB Plugin sandbox mode, can be apparmor, privsep, none")
1840
1841         set(WITH_PLAYER ON)
1842 endif()
1843
1844
1845 #-----------------------------------------------------------------------------
1846 # Configure OpenGL.
1847 find_package(OpenGL)
1848 blender_include_dirs_sys("${OPENGL_INCLUDE_DIR}")
1849 # unset(OPENGL_LIBRARIES CACHE) # not compat with older cmake
1850 # unset(OPENGL_xmesa_INCLUDE_DIR CACHE) # not compat with older cmake
1851
1852 #-----------------------------------------------------------------------------
1853 # Configure OpenMP.
1854 if(WITH_OPENMP)
1855         find_package(OpenMP)
1856         if(OPENMP_FOUND)
1857                 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
1858                 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
1859
1860                 if(APPLE AND ${CMAKE_GENERATOR} MATCHES "Xcode")
1861                         set(CMAKE_XCODE_ATTRIBUTE_ENABLE_OPENMP_SUPPORT "YES")
1862                 endif()
1863         else()
1864                 set(WITH_OPENMP OFF)
1865         endif()
1866
1867         mark_as_advanced(
1868                 OpenMP_C_FLAGS
1869                 OpenMP_CXX_FLAGS
1870         )
1871 endif()
1872
1873 #-----------------------------------------------------------------------------
1874 # Configure GLEW
1875
1876 if(WITH_SYSTEM_GLEW)
1877         find_package(GLEW)
1878
1879         if(NOT GLEW_FOUND)
1880                 message(FATAL_ERROR "GLEW is required to build blender, install it or disable WITH_SYSTEM_GLEW")
1881         endif()
1882
1883         mark_as_advanced(
1884                 GLEW_LIBRARY
1885                 GLEW_INCLUDE_PATH
1886         )
1887 else()
1888         # set(GLEW_LIBRARY "")  # unused
1889         set(GLEW_INCLUDE_PATH "${CMAKE_SOURCE_DIR}/extern/glew/include")
1890 endif()
1891
1892
1893 #-----------------------------------------------------------------------------
1894 # Configure Bullet
1895
1896 if(WITH_BULLET AND WITH_SYSTEM_BULLET)
1897         find_package(Bullet)
1898         if(NOT BULLET_FOUND)
1899                 set(WITH_BULLET OFF)
1900         endif()
1901 else()
1902         set(BULLET_INCLUDE_DIRS "${CMAKE_SOURCE_DIR}/extern/bullet2/src")
1903         # set(BULLET_LIBRARIES "")
1904 endif()
1905
1906 #-----------------------------------------------------------------------------
1907 # Configure Python.
1908
1909 if(WITH_PYTHON_MODULE)
1910         add_definitions(-DPy_ENABLE_SHARED)
1911 endif()
1912
1913 #-----------------------------------------------------------------------------
1914 # Extra compile flags
1915
1916 if(CMAKE_COMPILER_IS_GNUCC)
1917
1918         ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_ALL -Wall)
1919         ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_CAST_ALIGN -Wcast-align)
1920         ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_ERROR_DECLARATION_AFTER_STATEMENT -Werror=declaration-after-statement)
1921         ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_ERROR_IMPLICIT_FUNCTION_DECLARATION -Werror=implicit-function-declaration)
1922         ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_ERROR_RETURN_TYPE  -Werror=return-type)
1923         # system headers sometimes do this, disable for now, was: -Werror=strict-prototypes
1924         ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_STRICT_PROTOTYPES  -Wstrict-prototypes)
1925         ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_MISSING_PROTOTYPES -Wmissing-prototypes)
1926         ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_NO_CHAR_SUBSCRIPTS -Wno-char-subscripts)
1927         ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_NO_UNKNOWN_PRAGMAS -Wno-unknown-pragmas)
1928         ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_POINTER_ARITH -Wpointer-arith)
1929         ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_UNUSED_PARAMETER -Wunused-parameter)
1930         ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_WRITE_STRINGS -Wwrite-strings)
1931         ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_LOGICAL_OP -Wlogical-op)
1932         ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_UNDEF -Wundef)
1933         ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_INIT_SELF -Winit-self)  # needs -Wuninitialized
1934         ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_NO_NULL -Wnonnull)  # C only
1935         ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_MISSING_INCLUDE_DIRS -Wmissing-include-dirs)
1936         ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_NO_DIV_BY_ZERO -Wno-div-by-zero)
1937
1938         # gcc 4.2 gives annoying warnings on every file with this
1939         if(NOT "${CMAKE_C_COMPILER_VERSION}" VERSION_LESS "4.3")
1940                 ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_UNINITIALIZED -Wuninitialized)
1941         endif()
1942
1943         # versions before gcc4.6 give many BLI_math warnings
1944         if(NOT "${CMAKE_C_COMPILER_VERSION}" VERSION_LESS "4.6")
1945                 ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_REDUNDANT_DECLS       -Wredundant-decls)
1946                 ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_REDUNDANT_DECLS -Wredundant-decls)
1947         endif()
1948
1949         # disable because it gives warnings for printf() & friends.
1950         # ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_DOUBLE_PROMOTION -Wdouble-promotion -Wno-error=double-promotion)
1951
1952         if(NOT APPLE)
1953                 ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_NO_ERROR_UNUSED_BUT_SET_VARIABLE -Wno-error=unused-but-set-variable)
1954         endif()
1955
1956         ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_ALL -Wall)
1957         ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_NO_INVALID_OFFSETOF -Wno-invalid-offsetof)
1958         ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_NO_SIGN_COMPARE -Wno-sign-compare)
1959         ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_LOGICAL_OP -Wlogical-op)
1960         ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_INIT_SELF -Winit-self)  # needs -Wuninitialized
1961         ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_MISSING_INCLUDE_DIRS -Wmissing-include-dirs)
1962         ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_NO_DIV_BY_ZERO -Wno-div-by-zero)
1963
1964         # gcc 4.2 gives annoying warnings on every file with this
1965         if(NOT "${CMAKE_C_COMPILER_VERSION}" VERSION_LESS "4.3")
1966                 ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_UNINITIALIZED -Wuninitialized)
1967         endif()
1968
1969         # causes too many warnings
1970         if(NOT APPLE)
1971                 ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_UNDEF -Wundef)
1972                 ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_MISSING_DECLARATIONS -Wmissing-declarations)
1973         endif()
1974
1975         # flags to undo strict flags
1976         ADD_CHECK_C_COMPILER_FLAG(CC_REMOVE_STRICT_FLAGS C_WARN_NO_DEPRECATED_DECLARATIONS -Wno-deprecated-declarations)
1977         ADD_CHECK_C_COMPILER_FLAG(CC_REMOVE_STRICT_FLAGS C_WARN_NO_UNUSED_PARAMETER        -Wno-unused-parameter)
1978
1979         if(NOT APPLE)
1980                 ADD_CHECK_C_COMPILER_FLAG(CC_REMOVE_STRICT_FLAGS C_WARN_NO_ERROR_UNUSED_BUT_SET_VARIABLE -Wno-error=unused-but-set-variable)
1981         endif()
1982
1983 elseif(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
1984
1985         # strange, clang complains these are not supported, but then yses them.
1986         ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_ALL -Wall)
1987         ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_ERROR_DECLARATION_AFTER_STATEMENT -Werror=declaration-after-statement)
1988         ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_ERROR_IMPLICIT_FUNCTION_DECLARATION -Werror=implicit-function-declaration)
1989         ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_ERROR_RETURN_TYPE  -Werror=return-type)
1990         ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_NO_AUTOLOGICAL_COMPARE -Wno-tautological-compare)
1991         ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_NO_UNKNOWN_PRAGMAS -Wno-unknown-pragmas)
1992         ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_NO_CHAR_SUBSCRIPTS -Wno-char-subscripts)
1993         ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_STRICT_PROTOTYPES  -Wstrict-prototypes)
1994         ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_MISSING_PROTOTYPES -Wmissing-prototypes)
1995         ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_UNUSED_PARAMETER -Wunused-parameter)
1996
1997         ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_ALL -Wall)
1998         ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_NO_AUTOLOGICAL_COMPARE -Wno-tautological-compare)
1999         ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_NO_UNKNOWN_PRAGMAS     -Wno-unknown-pragmas)
2000         ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_NO_CHAR_SUBSCRIPTS     -Wno-char-subscripts)
2001         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.
2002         ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_NO_SIGN_COMPARE        -Wno-sign-compare)
2003         ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_NO_INVALID_OFFSETOF    -Wno-invalid-offsetof)
2004
2005         # gives too many unfixable warnings
2006         # ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_UNUSED_MACROS      -Wunused-macros)
2007         # ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_UNUSED_MACROS          -Wunused-macros)
2008
2009         # flags to undo strict flags
2010         ADD_CHECK_C_COMPILER_FLAG(CC_REMOVE_STRICT_FLAGS C_WARN_NO_UNUSED_PARAMETER -Wno-unused-parameter)
2011         ADD_CHECK_C_COMPILER_FLAG(CC_REMOVE_STRICT_FLAGS C_WARN_NO_UNUSED_MACROS    -Wno-unused-macros)
2012
2013 elseif(CMAKE_C_COMPILER_ID MATCHES "Intel")
2014
2015         ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_ALL -Wall)
2016         ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_POINTER_ARITH -Wpointer-arith)
2017         ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_NO_UNKNOWN_PRAGMAS -Wno-unknown-pragmas)
2018
2019         ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_ALL -Wall)
2020         ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_NO_INVALID_OFFSETOF -Wno-invalid-offsetof)
2021         ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_NO_SIGN_COMPARE -Wno-sign-compare)
2022
2023         # disable numbered, false positives
2024         set(C_WARNINGS "${C_WARNINGS} -wd188,186,144,913,556")
2025         set(CXX_WARNINGS "${CXX_WARNINGS} -wd188,186,144,913,556")
2026
2027 endif()
2028
2029 # MSVC2010 fails to links C++ libs right
2030 if(MSVC10)
2031         if(WITH_OPENCOLLADA)
2032                 message(WARNING "MSVC 2010 does not support OpenCollada, disabling WITH_OPENCOLLADA. To enable support use Use MSVC 2008")
2033         endif()
2034 endif()
2035
2036 # ensure python header is found since detection can fail, this could happen
2037 # with _any_ library but since we used a fixed python version this tends to
2038 # be most problematic.
2039 if(WITH_PYTHON)
2040         if(NOT EXISTS "${PYTHON_INCLUDE_DIR}/Python.h")
2041                 message(FATAL_ERROR "Missing: \"${PYTHON_INCLUDE_DIR}/Python.h\",\n"
2042                                                         "Set the cache entry 'PYTHON_INCLUDE_DIR' to point "
2043                                                         "to a valid python include path. Containing "
2044                                                         "Python.h for python version \"${PYTHON_VERSION}\"")
2045         endif()
2046
2047         if(WITH_PYTHON_INSTALL AND WITH_PYTHON_INSTALL_NUMPY)
2048                 # set but invalid
2049                 # -- disabled until we make numpy bundled with blender - campbell
2050                 if((NOT ${PYTHON_NUMPY_PATH} STREQUAL "") AND (NOT ${PYTHON_NUMPY_PATH} MATCHES NOTFOUND))
2051 #                       if(NOT EXISTS "${PYTHON_NUMPY_PATH}/numpy")
2052 #                               message(WARNING "PYTHON_NUMPY_PATH is invalid, numpy not found in '${PYTHON_NUMPY_PATH}' "
2053 #                                               "WITH_PYTHON_INSTALL_NUMPY option will be ignored when installing python")
2054 #                               set(WITH_PYTHON_INSTALL_NUMPY OFF)
2055 #                       endif()
2056                 # not set, so initialize
2057                 else()
2058                         string(REPLACE "." ";" _PY_VER_SPLIT "${PYTHON_VERSION}")
2059                         list(GET _PY_VER_SPLIT 0 _PY_VER_MAJOR)
2060
2061                         # re-cache
2062                         unset(PYTHON_NUMPY_PATH CACHE)
2063                         find_path(PYTHON_NUMPY_PATH
2064                           NAMES
2065                             numpy
2066                           HINTS
2067                             "${PYTHON_LIBPATH}/python${PYTHON_VERSION}/"
2068                             "${PYTHON_LIBPATH}/python${_PY_VER_MAJOR}/"
2069                           PATH_SUFFIXES
2070                             site-packages
2071                             dist-packages
2072                            NO_DEFAULT_PATH
2073                         )
2074
2075                         if(NOT EXISTS "${PYTHON_NUMPY_PATH}")
2076                                 message(WARNING "'numpy' path could not be found in:\n"
2077                                                 "'${PYTHON_LIBPATH}/python${PYTHON_VERSION}/site-packages/numpy', "
2078                                                 "'${PYTHON_LIBPATH}/python${_PY_VER_MAJOR}/site-packages/numpy', "
2079                                                 "'${PYTHON_LIBPATH}/python${PYTHON_VERSION}/dist-packages/numpy', "
2080                                                 "'${PYTHON_LIBPATH}/python${_PY_VER_MAJOR}/dist-packages/numpy', "
2081                                                 "WITH_PYTHON_INSTALL_NUMPY option will be ignored when installing python")
2082                                 set(WITH_PYTHON_INSTALL_NUMPY OFF)
2083                         else()
2084                                 message(STATUS "numpy found at '${PYTHON_NUMPY_PATH}'")
2085                         endif()
2086
2087                         unset(_PY_VER_SPLIT)
2088                         unset(_PY_VER_MAJOR)
2089                 endif()
2090         endif()
2091 endif()
2092
2093 if(WITH_GCC_MUDFLAP)
2094         set(PLATFORM_CFLAGS "${PLATFORM_CFLAGS} -fmudflapth -funwind-tables")
2095         set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -lpthread -lmudflapth -rdynamic")
2096         ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS     C_WARN_NO_ERROR_MUDFLAP   -Wno-error=mudflap)
2097         ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_NO_ERROR_MUDFLAP -Wno-error=mudflap)
2098 endif()
2099
2100 # Include warnings first, so its possible to disable them with user defined flags
2101 # eg: -Wno-uninitialized
2102 set(CMAKE_C_FLAGS "${C_WARNINGS} ${CMAKE_C_FLAGS} ${PLATFORM_CFLAGS}")
2103 set(CMAKE_CXX_FLAGS "${CXX_WARNINGS} ${CMAKE_CXX_FLAGS} ${PLATFORM_CFLAGS}")
2104
2105 #-------------------------------------------------------------------------------
2106 # Global Defines
2107
2108 # better not set includes here but this debugging option is off by default.
2109 if(WITH_CXX_GUARDEDALLOC)
2110         include_directories(${CMAKE_SOURCE_DIR}/intern/guardedalloc)
2111         add_definitions(-DWITH_CXX_GUARDEDALLOC)
2112 endif()
2113
2114 if(WITH_ASSERT_ABORT)
2115         add_definitions(-DWITH_ASSERT_ABORT)
2116 endif()
2117
2118 # message(STATUS "Using CFLAGS: ${CMAKE_C_FLAGS}")
2119 # message(STATUS "Using CXXFLAGS: ${CMAKE_CXX_FLAGS}")
2120
2121 #-----------------------------------------------------------------------------
2122 # Libraries
2123
2124 add_subdirectory(source)
2125 add_subdirectory(intern)
2126 add_subdirectory(extern)
2127
2128
2129 #-----------------------------------------------------------------------------
2130 # Blender Application
2131 if(WITH_BLENDER)
2132         add_subdirectory(source/creator)
2133 endif()
2134
2135
2136 #-----------------------------------------------------------------------------
2137 # Blender Player
2138 if(WITH_PLAYER)
2139         add_subdirectory(source/blenderplayer)
2140 endif()
2141
2142 #-----------------------------------------------------------------------------
2143 # CPack for generating packages
2144 include(build_files/cmake/packaging.cmake)
2145
2146
2147 #-----------------------------------------------------------------------------
2148 # Print Final Configuration
2149
2150 if(FIRST_RUN)
2151         set(_config_msg "\n* Blender Configuration *")
2152         macro(info_cfg_option
2153                 _setting)
2154                 set(_msg "   * ${_setting}")
2155                 string(LENGTH "${_msg}" _len)
2156                 while("32" GREATER "${_len}")
2157                         set(_msg "${_msg} ")
2158                          math(EXPR _len "${_len} + 1")
2159                 endwhile()
2160
2161                 set(_config_msg "${_config_msg}\n${_msg}${${_setting}}")
2162         endmacro()
2163
2164         macro(info_cfg_text
2165                 _text)
2166                 set(_config_msg "${_config_msg}\n\n  ${_text}")
2167
2168
2169         endmacro()
2170
2171         info_cfg_text("Build Options:")
2172         info_cfg_option(WITH_GAMEENGINE)
2173         info_cfg_option(WITH_PLAYER)
2174         info_cfg_option(WITH_BULLET)
2175         info_cfg_option(WITH_IK_SOLVER)
2176         info_cfg_option(WITH_IK_ITASC)
2177         info_cfg_option(WITH_OPENCOLLADA)
2178         info_cfg_option(WITH_FFTW3)
2179         info_cfg_option(WITH_INTERNATIONAL)
2180         info_cfg_option(WITH_INPUT_NDOF)
2181         info_cfg_option(WITH_CYCLES)
2182         info_cfg_option(WITH_OPENCOLORIO)
2183
2184         info_cfg_text("Compiler Options:")
2185         info_cfg_option(WITH_BUILDINFO)
2186         info_cfg_option(WITH_OPENMP)
2187         info_cfg_option(WITH_RAYOPTIMIZATION)
2188
2189         info_cfg_text("System Options:")
2190         info_cfg_option(WITH_INSTALL_PORTABLE)
2191         info_cfg_option(WITH_X11_XF86VMODE)
2192         info_cfg_option(WITH_X11_XINPUT)
2193         info_cfg_option(WITH_MEM_JEMALLOC)
2194         info_cfg_option(WITH_SYSTEM_GLEW)
2195         info_cfg_option(WITH_SYSTEM_OPENJPEG)
2196
2197         info_cfg_text("Image Formats:")
2198         info_cfg_option(WITH_IMAGE_CINEON)
2199         info_cfg_option(WITH_IMAGE_DDS)
2200         info_cfg_option(WITH_IMAGE_HDR)
2201         info_cfg_option(WITH_IMAGE_OPENEXR)
2202         info_cfg_option(WITH_IMAGE_OPENJPEG)
2203         info_cfg_option(WITH_IMAGE_REDCODE)
2204         info_cfg_option(WITH_IMAGE_TIFF)
2205
2206         info_cfg_text("Audio:")
2207         info_cfg_option(WITH_OPENAL)
2208         info_cfg_option(WITH_SDL)
2209         info_cfg_option(WITH_JACK)
2210         info_cfg_option(WITH_JACK_DYNLOAD)
2211         info_cfg_option(WITH_CODEC_AVI)
2212         info_cfg_option(WITH_CODEC_FFMPEG)
2213         info_cfg_option(WITH_CODEC_SNDFILE)
2214
2215         info_cfg_text("Compression:")
2216         info_cfg_option(WITH_LZMA)
2217         info_cfg_option(WITH_LZO)
2218
2219         info_cfg_text("Python:")
2220         info_cfg_option(WITH_PYTHON_INSTALL)
2221         info_cfg_option(WITH_PYTHON_INSTALL_NUMPY)
2222         info_cfg_option(WITH_PYTHON_MODULE)
2223         info_cfg_option(WITH_PYTHON_SAFETY)
2224         if(APPLE)
2225                 info_cfg_option(WITH_PYTHON_FRAMEWORK)
2226         endif()
2227
2228         info_cfg_text("Modifiers:")
2229         info_cfg_option(WITH_MOD_BOOLEAN)
2230         info_cfg_option(WITH_MOD_REMESH)
2231         info_cfg_option(WITH_MOD_FLUID)
2232         info_cfg_option(WITH_MOD_OCEANSIM)
2233
2234         # debug
2235         message(STATUS "HAVE_STDBOOL_H = ${HAVE_STDBOOL_H}")
2236
2237         info_cfg_text("")
2238
2239         message("${_config_msg}")
2240 endif()