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