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