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