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