svn merge ^/trunk/blender -r50023:50036
[blender.git] / CMakeLists.txt
1 # ***** BEGIN GPL LICENSE BLOCK *****
2 #
3 # This program is free software; you can redistribute it and/or
4 # modify it under the terms of the GNU General Public License
5 # as published by the Free Software Foundation; either version 2
6 # of the License, or (at your option) any later version.
7 #
8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11 # GNU General Public License for more details.
12 #
13 # You should have received a copy of the GNU General Public License
14 # along with this program; if not, write to the Free Software Foundation,
15 # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16 #
17 # The Original Code is Copyright (C) 2006, Blender Foundation
18 # All rights reserved.
19 #
20 # The Original Code is: all of this file.
21 #
22 # Contributor(s): Jacques Beaurain.
23 #
24 # ***** END GPL LICENSE BLOCK *****
25
26 #-----------------------------------------------------------------------------
27 # We don't allow in-source builds. This causes no end of troubles because
28 # all out-of-source builds will use the CMakeCache.txt file there and even
29 # build the libs and objects in it.
30
31 if(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR})
32         if(NOT DEFINED WITH_IN_SOURCE_BUILD)
33                 message(FATAL_ERROR
34                         "CMake generation for blender is not allowed within the source directory!"
35                         "\n Remove the CMakeCache.txt file and try again from another folder, e.g.:"
36                         "\n "
37                         "\n rm CMakeCache.txt"
38                         "\n cd .."
39                         "\n mkdir cmake-make"
40                         "\n cd cmake-make"
41                         "\n cmake ../blender"
42                         "\n "
43                         "\n Alternately define WITH_IN_SOURCE_BUILD to force this option (not recommended!)"
44                 )
45         endif()
46 endif()
47
48 cmake_minimum_required(VERSION 2.8)
49
50 if(NOT EXECUTABLE_OUTPUT_PATH)
51         set(FIRST_RUN "TRUE")
52 endif()
53
54 # this starts out unset
55 list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/build_files/cmake/Modules")
56
57 # avoid having empty buildtype
58 set(CMAKE_BUILD_TYPE_INIT "Release")
59
60 # quiet output for Makefiles, 'make -s' helps too
61 # set_property(GLOBAL PROPERTY RULE_MESSAGES OFF)
62
63 # global compile definitions since add_definitions() adds for all.
64 set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS_DEBUG           DEBUG _DEBUG)
65 set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS_RELEASE         NDEBUG)
66 set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS_MINSIZEREL      NDEBUG)
67 set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS_RELWITHDEBINFO  NDEBUG)
68
69
70 #-----------------------------------------------------------------------------
71 # Set policy
72
73 # see "cmake --help-policy CMP0003"
74 # So library linking is more sane
75 cmake_policy(SET CMP0003 NEW)
76
77 # So BUILDINFO and BLENDERPATH strings are automatically quoted
78 cmake_policy(SET CMP0005 NEW)
79
80 # So syntax problems are errors
81 cmake_policy(SET CMP0010 NEW)
82
83 # Input directories must have CMakeLists.txt
84 cmake_policy(SET CMP0014 NEW)
85
86 #-----------------------------------------------------------------------------
87 # Load some macros.
88 include(build_files/cmake/macros.cmake)
89
90
91 #-----------------------------------------------------------------------------
92 # Initialize project.
93
94 blender_project_hack_pre()
95
96 project(Blender)
97
98 blender_project_hack_post()
99
100 enable_testing()
101
102 #-----------------------------------------------------------------------------
103 # Redirect output files
104
105 set(EXECUTABLE_OUTPUT_PATH ${CMAKE_BINARY_DIR}/bin CACHE INTERNAL "" FORCE)
106 set(LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR}/lib CACHE INTERNAL "" FORCE)
107
108 #-----------------------------------------------------------------------------
109 # Set default config options
110
111 get_blender_version()
112
113
114 # Blender internal features
115 option(WITH_BLENDER "Build blender (disable to build only the blender player)" ON)
116 mark_as_advanced(WITH_BLENDER)
117
118 option(WITH_INTERNATIONAL "Enable I18N (International fonts and text)" ON)
119
120 option(WITH_PYTHON        "Enable Embedded Python API  (only disable for development)" ON)
121 option(WITH_PYTHON_SECURITY "Disables execution of scripts within blend files by default (recommend to leave off)" OFF)
122 mark_as_advanced(WITH_PYTHON)  # dont want people disabling this unless they really know what they are doing.
123 mark_as_advanced(WITH_PYTHON_SECURITY)  # some distrobutions see this as a security issue, rather than have them patch it, make a build option.
124
125 option(WITH_PYTHON_SAFETY "Enable internal API error checking to track invalid data to prevent crash on access (at the expense of some effeciency, only enable for development)." OFF)
126 option(WITH_PYTHON_MODULE "Enable building as a python module which runs without a user interface, like running regular blender in background mode (experimental, only enable for development)" OFF)
127 option(WITH_BUILDINFO     "Include extra build details (only disable for development & faster builds)" ON)
128 option(WITH_IK_ITASC      "Enable ITASC IK solver (only disable for development & for incompatible C++ compilers)" ON)
129 option(WITH_IK_SOLVER     "Enable Legacy IK solver (only disable for development)" ON)
130 option(WITH_FFTW3         "Enable FFTW3 support (Used for smoke and audio effects)" OFF)
131 option(WITH_BULLET        "Enable Bullet (Physics Engine)" ON)
132 option(WITH_GAMEENGINE    "Enable Game Engine" ON)
133 option(WITH_PLAYER        "Build Player" OFF)
134 option(WITH_OPENCOLORIO   "Enable OpenColorIO color management" ON)
135 option(WITH_COMPOSITOR    "Enable the tile based nodal compositor" ON)
136 option(WITH_COMPOSITOR_LEGACY "Enable legacy compositor" ON)
137
138 # GHOST Windowing Library Options
139 option(WITH_GHOST_DEBUG   "Enable debugging output for the GHOST library" OFF)
140 mark_as_advanced(WITH_GHOST_DEBUG)
141
142 option(WITH_GHOST_SDL    "Enable building blender against SDL for windowing rather then the native APIs" OFF)
143 mark_as_advanced(WITH_GHOST_SDL)
144
145 # Misc...
146 option(WITH_HEADLESS      "Build without graphical support (renderfarm, server mode only)" OFF)
147 mark_as_advanced(WITH_HEADLESS)
148
149 option(WITH_AUDASPACE    "Build with blenders audio library (only disable if you know what you're doing!)" ON)
150 mark_as_advanced(WITH_AUDASPACE)
151
152
153 # (unix defaults to OpenMP On)
154 if((UNIX AND NOT APPLE) OR (MINGW))
155         set(PLATFORM_DEFAULT ON)
156 else()
157         set(PLATFORM_DEFAULT OFF)
158 endif()
159 option(WITH_OPENMP        "Enable OpenMP (has to be supported by the compiler)" ${PLATFORM_DEFAULT})
160 unset(PLATFORM_DEFAULT)
161
162
163 if(UNIX AND NOT APPLE)
164         option(WITH_X11_XINPUT "Enable X11 Xinput (tablet support and unicode input)"   ON)
165         option(WITH_X11_XF86VMODE "Enable X11 video mode switching"     ON)
166         option(WITH_SYSTEM_GLEW "Use GLEW OpenGL wrapper library provided by the operating system" ON)
167
168         # freebsd doesn't seems to support XDND
169         if(NOT ${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD")
170                 option(WITH_GHOST_XDND   "Enable drag'n'drop support on Linux using XDND protocol" ON)
171         endif()
172 else()
173         # not an option for other OS's
174         set(WITH_SYSTEM_GLEW OFF)
175 endif()
176
177
178 # (unix defaults to System OpenJPEG On)
179 if(UNIX AND NOT APPLE)
180         set(PLATFORM_DEFAULT ON)
181 else()
182         set(PLATFORM_DEFAULT OFF)
183 endif()
184 option(WITH_SYSTEM_OPENJPEG "Use the operating systems OpenJPEG library" ${PLATFORM_DEFAULT})
185 unset(PLATFORM_DEFAULT)
186
187
188 # Modifiers
189 option(WITH_MOD_FLUID           "Enable Elbeem Modifier (Fluid Simulation)" ON)
190 option(WITH_MOD_SMOKE           "Enable Smoke Modifier (Smoke Simulation)" ON)
191 option(WITH_MOD_DECIMATE        "Enable Decimate Modifier" ON)
192 option(WITH_MOD_BOOLEAN         "Enable Boolean Modifier" ON)
193 option(WITH_MOD_REMESH          "Enable Remesh Modifier" ON)
194 option(WITH_MOD_CLOTH_ELTOPO    "Enable Experimental cloth solver" OFF)
195 mark_as_advanced(WITH_MOD_CLOTH_ELTOPO)
196 option(WITH_MOD_OCEANSIM        "Enable Ocean Modifier" OFF)
197
198 # Image format support
199 option(WITH_IMAGE_OPENEXR       "Enable OpenEXR Support (http://www.openexr.com)" ON)
200 option(WITH_IMAGE_OPENJPEG      "Enable OpenJpeg Support (http://www.openjpeg.org)" ON)
201 option(WITH_IMAGE_TIFF          "Enable LibTIFF Support" ON)
202 option(WITH_IMAGE_DDS           "Enable DDS Image Support" ON)
203 option(WITH_IMAGE_CINEON        "Enable CINEON and DPX Image Support" ON)
204 option(WITH_IMAGE_HDR           "Enable HDR Image Support" ON)
205 option(WITH_IMAGE_REDCODE       "Enable RedCode Image Support" OFF)
206 option(WITH_IMAGE_FRAMESERVER   "Enable image FrameServer Support for rendering" ON)
207
208 # Audio/Video format support
209 option(WITH_CODEC_FFMPEG        "Enable FFMPeg Support (http://ffmpeg.org)" OFF)
210
211 option(WITH_CODEC_SNDFILE       "Enable libsndfile Support (http://www.mega-nerd.com/libsndfile)" OFF)
212 if(APPLE OR (WIN32 AND NOT UNIX))
213         option(WITH_CODEC_QUICKTIME     "Enable Quicktime Support" OFF)
214 endif()
215
216 # 3D format support
217 # disable opencollada on non-apple unix because opencollada has no package for debian
218 option(WITH_OPENCOLLADA         "Enable OpenCollada Support (http://www.opencollada.org)"       OFF)
219
220 # Sound output
221 option(WITH_SDL           "Enable SDL for sound and joystick support" ON)
222 option(WITH_OPENAL        "Enable OpenAL Support (http://www.openal.org)" ON)
223 option(WITH_JACK          "Enable Jack Support (http://www.jackaudio.org)" OFF)
224
225 # Compression
226 option(WITH_LZO           "Enable fast LZO compression (used for pointcache)" ON)
227 option(WITH_LZMA          "Enable best LZMA compression, (used for pointcache)" ON)
228
229 # Camera/motion tracking
230 option(WITH_LIBMV         "Enable libmv structure from motion library" ON)
231
232 # Misc
233 option(WITH_INPUT_NDOF "Enable NDOF input devices (SpaceNavigator and friends)" ON)
234 option(WITH_RAYOPTIMIZATION     "Enable use of SIMD (SSE) optimizations for the raytracer" ON)
235 if(UNIX AND NOT APPLE)
236         option(WITH_INSTALL_PORTABLE "Install redistributeable runtime, otherwise install into CMAKE_INSTALL_PREFIX" ON)
237 endif()
238 option(WITH_PYTHON_INSTALL       "Copy system python into the blender install folder" ON)
239 option(WITH_PYTHON_INSTALL_NUMPY "Copy system numpy into the blender install folder"  ON)
240 set(PYTHON_NUMPY_PATH            "" CACHE PATH "Python to python site-packages or dist-packages containing 'numpy' module")
241 mark_as_advanced(PYTHON_NUMPY_PATH)
242
243 if(MINGW)
244         option(WITH_MINGW64                   "Use the 64-bit version of MinGW" OFF)
245         mark_as_advanced(WITH_MINGW64)
246 endif()
247
248 # Cycles
249 option(WITH_CYCLES                                      "Enable cycles Render Engine" ON)
250 option(WITH_CYCLES_TEST                         "Build cycles test application" OFF)
251 option(WITH_CYCLES_OSL                          "Build Cycles with OSL support" OFF)
252 option(WITH_CYCLES_CUDA_BINARIES        "Build cycles CUDA binaries" OFF)
253 set(CYCLES_CUDA_BINARIES_ARCH sm_13 sm_20 sm_21 sm_30 CACHE STRING "CUDA architectures to build binaries for")
254 mark_as_advanced(CYCLES_CUDA_BINARIES_ARCH)
255 unset(PLATFORM_DEFAULT)
256
257 # disable for now, but plan to support on all platforms eventually
258 option(WITH_MEM_JEMALLOC   "Enable malloc replacement (http://www.canonware.com/jemalloc)" OFF)
259 mark_as_advanced(WITH_MEM_JEMALLOC)
260
261 # Debug
262 option(WITH_CXX_GUARDEDALLOC "Enable GuardedAlloc for C++ memory allocation tracking (only enable for development)" OFF)
263 mark_as_advanced(WITH_CXX_GUARDEDALLOC)
264
265 option(WITH_ASSERT_ABORT "Call abort() when raising an assertion through BLI_assert()" OFF)
266 mark_as_advanced(WITH_ASSERT_ABORT)
267
268
269 if(APPLE)
270         if(NOT CMAKE_OSX_ARCHITECTURES)
271                 set(CMAKE_OSX_ARCHITECTURES x86_64 CACHE STRING
272                 "Choose the architecture you want to build Blender for: i386, x86_64 or ppc"
273                 FORCE)
274         endif()
275         
276         execute_process(COMMAND uname -r OUTPUT_VARIABLE MAC_SYS) # check for actual system-version
277         if (${MAC_SYS} MATCHES 12)
278                 set(OSX_SYSTEM 10.8)
279         elseif (${MAC_SYS} MATCHES 11)
280                 set(OSX_SYSTEM 10.7)
281         elseif(${MAC_SYS} MATCHES 10)
282                 set(OSX_SYSTEM 10.6)
283         elseif(${MAC_SYS} MATCHES 9)
284                 set(OSX_SYSTEM 10.5)
285         else()
286                 set(OSX_SYSTEM unsupported)
287         endif()
288         message(STATUS "Detected system-version: " ${OSX_SYSTEM})
289         
290         if(NOT CMAKE_OSX_DEPLOYMENT_TARGET)
291                         set(CMAKE_OSX_DEPLOYMENT_TARGET "10.5" CACHE STRING "" FORCE) # 10.5 is our minimum target, if you have higher sdk, weak linking happens
292         endif()
293
294         if(${CMAKE_GENERATOR} MATCHES "Xcode")
295         
296                 ##### workaround for actual official cmake incompatibility with xcode 4.3 ##### 
297                 if(${XCODE_VERSION} MATCHES '') # cmake fails due looking for xcode in the wrong path, thus will be empty var
298                         message("Official cmake does not yet support Xcode 4.3, get a patched version here: http://www.jensverwiebe.de/Blender/CMake%202.8-7patched.zip")
299                 endif()
300                 ### end workaround for actual official cmake incompatibility with xcode 4.3 ### 
301                 
302                 if(${XCODE_VERSION} VERSION_EQUAL 4 OR ${XCODE_VERSION} VERSION_GREATER 4 AND ${XCODE_VERSION} VERSION_LESS 4.3)
303                         # Xcode 4 defaults to the Apple LLVM Compiler.
304                         # Override the default compiler selection because Blender only compiles with gcc up to xcode 4.2
305                         set(CMAKE_XCODE_ATTRIBUTE_GCC_VERSION "com.apple.compilers.llvmgcc42")
306                         message(STATUS "Setting compiler to: " ${CMAKE_XCODE_ATTRIBUTE_GCC_VERSION})
307                 endif()
308         else() # unix makefile generator does not fill XCODE_VERSION var, so we get it with a command
309                 execute_process(COMMAND xcodebuild -version OUTPUT_VARIABLE XCODE_VERS_BUILD_NR)
310                 string(SUBSTRING "${XCODE_VERS_BUILD_NR}" 6 3 XCODE_VERSION) # truncate away build-nr
311                 unset(XCODE_VERS_BUILD_NR)
312         endif()
313         
314         message(STATUS "Detected Xcode-version: " ${XCODE_VERSION})
315         
316         option(WITH_COCOA         "Use Cocoa framework instead of deprecated Carbon" ON)
317         option(USE_QTKIT          "Use QtKit instead of Carbon quicktime (needed for having partial quicktime for 64bit)" OFF)
318         option(WITH_LIBS10.5  "Use 10.5 libs (needed for 64bit builds)" OFF)
319 endif()
320
321
322 #-----------------------------------------------------------------------------
323 # Check for conflicting/unsupported configurations
324
325 if(NOT WITH_BLENDER AND NOT WITH_PLAYER AND NOT WITH_CYCLES_TEST)
326         message(FATAL_ERROR "At least one of WITH_BLENDER or WITH_PLAYER must be enabled, nothing to do!")
327 endif()
328
329 if(NOT WITH_GAMEENGINE AND WITH_PLAYER)
330         message(FATAL_ERROR "WITH_PLAYER requires WITH_GAMEENGINE")
331 endif()
332
333 if(NOT WITH_AUDASPACE AND (WITH_OPENAL OR WITH_SDL OR WITH_JACK OR WITH_GAMEENGINE))
334         message(FATAL_ERROR "WITH_OPENAL/WITH_SDL/WITH_JACK/WITH_CODEC_FFMPEG/WITH_GAMEENGINE require WITH_AUDASPACE")
335 endif()
336
337 if(NOT WITH_SDL AND WITH_GHOST_SDL)
338         message(FATAL_ERROR "WITH_GHOST_SDL requires WITH_SDL to be ON")
339 endif()
340
341 if(WITH_IMAGE_REDCODE AND ((NOT WITH_IMAGE_OPENJPEG) OR (NOT WITH_CODEC_FFMPEG)))
342         message(FATAL_ERROR "WITH_IMAGE_REDCODE requires WITH_IMAGE_OPENJPEG and WITH_CODEC_FFMPEG")
343 endif()
344
345 # python module, needs some different options
346 if(WITH_PYTHON_MODULE AND WITH_PLAYER)
347         message(FATAL_ERROR "WITH_PYTHON_MODULE requires WITH_PLAYER to be OFF")
348 endif()
349
350 if(WITH_PYTHON_MODULE AND WITH_PYTHON_INSTALL)
351         message(FATAL_ERROR "WITH_PYTHON_MODULE requires WITH_PYTHON_INSTALL to be OFF")
352 endif()
353
354
355 if(NOT WITH_FFTW3 AND WITH_MOD_OCEANSIM)
356         message(FATAL_ERROR "WITH_MOD_OCEANSIM requires WITH_FFTW3 to be ON")
357 endif()
358
359 # may as well build python module without a UI
360 if(WITH_PYTHON_MODULE)
361         set(WITH_HEADLESS ON)
362 endif()
363
364 # auto enable openimageio for cycles
365 if(WITH_CYCLES)
366         set(WITH_OPENIMAGEIO ON)
367 endif()
368
369 # auto enable boost for cycles and booleans
370 if(WITH_CYCLES OR WITH_MOD_BOOLEAN)
371         set(WITH_BOOST ON)
372 endif()
373
374 # don't store paths to libs for portable distrobution
375 if(WITH_INSTALL_PORTABLE)
376         set(CMAKE_SKIP_BUILD_RPATH TRUE)
377 endif()
378
379 if(WITH_GHOST_SDL OR WITH_HEADLESS)
380         set(WITH_GHOST_XDND OFF)
381 endif()
382
383 if(MINGW)
384         if(WITH_CODEC_QUICKTIME)
385                 message(FATAL_ERROR "MINGW requires WITH_CODEC_QUICKTIME to be OFF "
386                                     "because it is currently unsupported, remove this "
387                                     "line if youre a developer who wants to add support.")
388         endif()
389 endif()
390
391 TEST_SSE_SUPPORT(COMPILER_SSE_FLAG COMPILER_SSE2_FLAG)
392
393
394 #-----------------------------------------------------------------------------
395 # Check for valid directories
396 # ... svn extern paths can be missing because of svn-git.
397
398 if(WITH_INTERNATIONAL)
399         if(NOT EXISTS "${CMAKE_SOURCE_DIR}/release/datafiles/locale")
400                 message(WARNING "Translation path '${CMAKE_SOURCE_DIR}/release/datafiles/locale' is missing, "
401                                                 "This is an 'svn external', which are known not to work with bridges to other version "
402                                                 "control systems, disabling 'WITH_INTERNATIONAL'.")
403                 set(WITH_INTERNATIONAL OFF)
404         endif()
405 endif()
406
407 if(WITH_PYTHON)
408         if(NOT EXISTS "${CMAKE_SOURCE_DIR}/release/scripts/addons")
409                 message(WARNING "Addons path '${CMAKE_SOURCE_DIR}/release/scripts/addons' is missing, "
410                                                 "This is an 'svn external', which are known not to work with bridges to other version "
411                                                 "control systems: * CONTINUING WITHOUT ADDONS *")
412         endif()
413 endif()
414
415 #-----------------------------------------------------------------------------
416 # Initialize un-cached vars, avoid unused warning
417
418 # linux only, not cached
419 set(WITH_BINRELOC OFF)
420
421 # MAXOSX only, set to avoid uninitialized
422 set(EXETYPE "")
423
424 # C/C++ flags
425 set(PLATFORM_CFLAGS)
426
427 # these are added to later on.
428 set(C_WARNINGS)
429 set(CXX_WARNINGS)
430
431 # for gcc -Wno-blah-blah
432 set(CC_REMOVE_STRICT_FLAGS)
433
434 # libraries to link the binary with passed to target_link_libraries()
435 # known as LLIBS to scons
436 set(PLATFORM_LINKLIBS "")
437
438 # Added to linker flags in setup_liblinks
439 # - CMAKE_EXE_LINKER_FLAGS
440 # - CMAKE_EXE_LINKER_FLAGS_DEBUG
441 set(PLATFORM_LINKFLAGS "")
442 set(PLATFORM_LINKFLAGS_DEBUG "")
443
444
445 # disabled for now, not supported
446 # option(WITH_WEBPLUGIN     "Enable Web Plugin (Unix only)" OFF)
447
448 # For alternate Python locations the commandline can be used to override detected/default cache settings, e.g:
449 # On Unix:
450 #   cmake ../blender \
451 #         -D PYTHON_VERSION=3.2 \
452 #         -D PYTHON_INCLUDE_DIR=/opt/py32/include/python3.2d \
453 #         -D PYTHON_LIBRARY=/opt/py32/lib/libpython3.2d.so
454 #
455 # On Macs:
456 #   cmake ../blender \
457 #         -D PYTHON_INCLUDE_DIR=/System/Library/Frameworks/Python.framework/Versions/3.2/include/python3.2 \
458 #         -D PYTHON_LIBPATH=/System/Library/Frameworks/Python.framework/Versions/3.2/lib/python3.2/config \
459 #         -G Xcode
460 #
461 # When changing any of this remember to update the notes in doc/build_systems/cmake.txt
462
463 #-----------------------------------------------------------------------------
464 #Platform specifics
465
466 if(UNIX AND NOT APPLE)
467
468         # set lib directory if it exists
469         if(CMAKE_SYSTEM_NAME MATCHES "Linux")
470                 if("${CMAKE_SIZEOF_VOID_P}" EQUAL "8")
471                         set(LIBDIR ${CMAKE_SOURCE_DIR}/../lib/linux64)
472                 else()
473                         set(LIBDIR ${CMAKE_SOURCE_DIR}/../lib/linux)
474                 endif()
475
476                 if(NOT EXISTS ${LIBDIR})
477                         unset(LIBDIR)
478                 endif()
479         endif()
480
481         find_package(JPEG REQUIRED)
482         find_package(PNG REQUIRED)
483         find_package(ZLIB REQUIRED)
484         find_package(Freetype REQUIRED)
485
486         if(WITH_PYTHON)
487                 # No way to set py32. remove for now.
488                 # find_package(PythonLibs)
489
490                 # Use our own instead, since wothout py is such a rare case,
491                 # require this package
492                 find_package(PythonLibsUnix REQUIRED)
493         endif()
494
495
496         if(WITH_IMAGE_OPENEXR)
497                 find_package(OpenEXR)  # our own module
498                 if(NOT OPENEXR_FOUND)
499                         set(WITH_IMAGE_OPENEXR OFF)
500                 endif()
501         endif()
502
503         if(WITH_IMAGE_OPENJPEG)
504                 find_package(OpenJPEG)
505                 if(NOT OPENJPEG_FOUND)
506                         set(WITH_IMAGE_OPENJPEG OFF)
507                 endif()
508         endif()
509
510         if(WITH_IMAGE_TIFF)
511                 find_package(TIFF)
512                 if(NOT TIFF_FOUND)
513                         set(WITH_IMAGE_TIFF OFF)
514                 endif()
515         endif()
516
517         # Audio IO
518         if(WITH_OPENAL)
519                 find_package(OpenAL)
520                 if(NOT OPENAL_FOUND)
521                         set(WITH_OPENAL OFF)
522                 endif()
523         endif()
524
525         if(WITH_SDL)
526                 find_package(SDL)
527                 mark_as_advanced(
528                         SDLMAIN_LIBRARY
529                         SDL_INCLUDE_DIR
530                         SDL_LIBRARY
531                         SDL_LIBRARY_TEMP
532                 )
533                 # unset(SDLMAIN_LIBRARY CACHE)
534                 if(NOT SDL_FOUND)
535                         set(WITH_SDL OFF)
536                 endif()
537         endif()
538
539         if(WITH_JACK)
540                 find_package(Jack)
541                 if(NOT JACK_FOUND)
542                         set(WITH_JACK OFF)
543                 endif()
544         endif()
545
546         # Codecs
547         if(WITH_CODEC_SNDFILE)
548                 find_package(SndFile)
549                 if(NOT SNDFILE_FOUND)
550                         set(WITH_CODEC_SNDFILE OFF)
551                 endif()
552         endif()
553
554         if(WITH_CODEC_FFMPEG)
555                 # use lib dir if available and nothing else specified
556                 if(LIBDIR AND NOT FFMPEG)
557                         set(FFMPEG ${LIBDIR}/ffmpeg CACHE PATH "FFMPEG Directory")
558                         # XXX, some distros might need 'theoraenc theoradec' too
559                         set(FFMPEG_LIBRARIES avformat avcodec avutil avdevice swscale dirac_encoder mp3lame ogg orc-0.4 schroedinger-1.0 theora vorbis vorbisenc vpx x264 xvidcore faad asound CACHE STRING "FFMPEG Libraries")
560                 else()
561                         set(FFMPEG /usr CACHE PATH "FFMPEG Directory")
562                         set(FFMPEG_LIBRARIES avformat avcodec avutil avdevice swscale CACHE STRING "FFMPEG Libraries")
563                 endif()
564
565                 mark_as_advanced(FFMPEG)
566                 set(FFMPEG_INCLUDE_DIRS ${FFMPEG}/include ${FFMPEG}/include/ffmpeg)
567                 mark_as_advanced(FFMPEG_LIBRARIES)
568                 set(FFMPEG_LIBPATH ${FFMPEG}/lib)
569                 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D__STDC_CONSTANT_MACROS")
570         endif()
571
572         if(WITH_INTERNATIONAL)
573                 find_library(INTL_LIBRARY
574                         NAMES intl
575                         PATHS
576                         /sw/lib
577                 )
578
579                 find_library(ICONV_LIBRARY
580                         NAMES iconv
581                         PATHS
582                         /sw/lib
583                 )
584                 mark_as_advanced(
585                         ICONV_LIBRARY
586                         INTL_LIBRARY
587                 )
588
589                 if(INTL_LIBRARY AND ICONV_LIBRARY)
590                         set(GETTEXT_LIBRARIES ${INTL_LIBRARY} ${ICONV_LIBRARY})
591                 endif()
592         endif()
593
594         if(WITH_FFTW3)
595                 find_package(Fftw3)
596                 if(NOT FFTW3_FOUND)
597                         set(WITH_FFTW3 OFF)
598                 endif()
599         endif()
600
601         if(WITH_OPENCOLLADA)
602                 find_package(OpenCOLLADA)
603                 if(OPENCOLLADA_FOUND)
604                         find_package(XML2)
605                         find_package(PCRE)
606                 else()
607                         set(WITH_OPENCOLLADA OFF)
608                 endif()
609         endif()
610
611         if(WITH_MEM_JEMALLOC)
612                 find_package(JeMalloc)
613                 if(NOT JEMALLOC_FOUND)
614                         set(WITH_MEM_JEMALLOC OFF)
615                 endif()
616         endif()
617
618         if (WITH_INPUT_NDOF)
619                 find_package(Spacenav)
620                 if(NOT SPACENAV_FOUND)
621                         set(WITH_INPUT_NDOF OFF)
622                 endif()
623
624                 # use generic names within blenders buildsystem.
625                 if(SPACENAV_FOUND)
626                         set(NDOF_INCLUDE_DIRS ${SPACENAV_INCLUDE_DIRS})
627                         set(NDOF_LIBRARIES ${SPACENAV_LIBRARIES})
628                 endif()
629         endif()
630
631         if(WITH_BOOST)
632                 # uses in build instructions to override include and library variables
633                 if(NOT BOOST_CUSTOM)
634                         # use lib dir if available and nothing else specified
635                         if(LIBDIR AND NOT BOOST_ROOT)
636                                 set(BOOST_ROOT ${LIBDIR}/boost)
637                                 set(Boost_USE_MULTITHREADED OFF)
638                         else()
639                                 set(Boost_USE_MULTITHREADED ON)
640                         endif()
641                         find_package(Boost 1.34 COMPONENTS filesystem regex system thread)
642                         mark_as_advanced(Boost_DIR)  # why doesnt boost do this?
643                 endif()
644
645                 set(BOOST_INCLUDE_DIR ${Boost_INCLUDE_DIRS})
646                 set(BOOST_LIBRARIES ${Boost_LIBRARIES})
647                 set(BOOST_LIBPATH ${Boost_LIBRARY_DIRS})
648                 set(BOOST_DEFINITIONS "-DBOOST_ALL_NO_LIB")
649         endif()
650
651         if(WITH_OPENIMAGEIO)
652                 # use lib dir if available and nothing else specified
653                 if(LIBDIR AND NOT OPENIMAGEIO_ROOT_DIR)
654                         set(OPENIMAGEIO_ROOT_DIR ${LIBDIR}/oiio)
655                 endif()
656
657                 find_package(OpenImageIO)
658
659                 set(OPENIMAGEIO_LIBRARIES ${OPENIMAGEIO_LIBRARIES} ${PNG_LIBRARIES} ${JPEG_LIBRARIES} ${ZLIB_LIBRARIES} ${BOOST_LIBRARIES})
660                 set(OPENIMAGEIO_LIBPATH)  # TODO, remove and reference the absolute path everywhere
661                 set(OPENIMAGEIO_DEFINITIONS)
662
663                 if(WITH_IMAGE_TIFF)
664                         list(APPEND OPENIMAGEIO_LIBRARIES "${TIFF_LIBRARY}")
665                 endif()
666                 if(WITH_IMAGE_OPENEXR)
667                         list(APPEND OPENIMAGEIO_LIBRARIES "${OPENEXR_LIBRARIES}")
668                 endif()
669
670                 if(NOT OPENIMAGEIO_FOUND)
671                         set(WITH_OPENIMAGEIO OFF)
672                         message(STATUS "OpenImageIO not found, disabling WITH_CYCLES")
673                 endif()
674         endif()
675
676         if(WITH_OPENCOLORIO)
677                 # use lib dir if available and nothing else specified
678                 if(LIBDIR AND NOT OPENCOLORIO_ROOT_DIR)
679                         set(OPENCOLORIO_ROOT_DIR ${LIBDIR}/ocio)
680                 endif()
681
682                 find_package(OpenColorIO)
683
684                 set(OPENCOLORIO_LIBRARIES ${OPENCOLORIO_LIBRARIES})
685                 set(OPENCOLORIO_LIBPATH)  # TODO, remove and reference the absolute path everywhere
686                 set(OPENCOLORIO_DEFINITIONS)
687
688                 if(NOT OPENCOLORIO_FOUND)
689                         set(WITH_OPENCOLORIO OFF)
690                         message(STATUS "OpenColorIO not found")
691                 endif()
692         endif()
693
694         # OpenSuse needs lutil, ArchLinux not, for now keep, can avoid by using --as-needed
695         set(PLATFORM_LINKLIBS "-lutil -lc -lm -lpthread -lstdc++")
696
697         if((NOT WITH_HEADLESS) AND (NOT WITH_GHOST_SDL))
698                 find_package(X11 REQUIRED)
699                 find_path(X11_XF86keysym_INCLUDE_PATH X11/XF86keysym.h ${X11_INC_SEARCH_PATH})
700                 mark_as_advanced(X11_XF86keysym_INCLUDE_PATH)
701
702                 set(PLATFORM_LINKLIBS "${PLATFORM_LINKLIBS} ${X11_X11_LIB}")
703
704                 if(WITH_X11_XINPUT)
705                         set(PLATFORM_LINKLIBS "${PLATFORM_LINKLIBS} ${X11_Xinput_LIB}")
706                 endif()
707
708                 if(WITH_X11_XF86VMODE)
709                         # XXX, why dont cmake make this available?
710                         FIND_LIBRARY(X11_Xxf86vmode_LIB Xxf86vm   ${X11_LIB_SEARCH_PATH})
711                         mark_as_advanced(X11_Xxf86vmode_LIB)
712                         if(X11_Xxf86vmode_LIB)
713                                 set(PLATFORM_LINKLIBS "${PLATFORM_LINKLIBS} ${X11_Xxf86vmode_LIB}")
714                         else()
715                                 set(WITH_X11_XF86VMODE OFF)
716                         endif()
717                 endif()
718         endif()
719
720         if(CMAKE_SYSTEM_NAME MATCHES "Linux")
721                 if(NOT WITH_PYTHON_MODULE)
722                         # BSD's dont use libdl.so
723                 set(PLATFORM_LINKLIBS "${PLATFORM_LINKLIBS} -ldl")
724                         # binreloc is linux only
725                         set(BINRELOC_INCLUDE_DIRS ${CMAKE_SOURCE_DIR}/extern/binreloc/include)
726                         set(WITH_BINRELOC ON)
727                 endif()
728         endif()
729
730         set(PLATFORM_LINKFLAGS "-pthread")
731
732         # lfs on glibc, all compilers should use
733         add_definitions(-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE)
734
735         # GNU Compiler
736         if(CMAKE_COMPILER_IS_GNUCC)
737                 set(PLATFORM_CFLAGS "-pipe -fPIC -funsigned-char -fno-strict-aliasing")
738         # CLang is the same as GCC for now.
739         elseif(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
740                 set(PLATFORM_CFLAGS "-pipe -fPIC -funsigned-char -fno-strict-aliasing")
741         # Solaris CC
742         elseif(CMAKE_CXX_COMPILER_ID MATCHES "SunPro") 
743                 set(PLATFORM_CFLAGS "-pipe -features=extensions -fPIC -D__FUNCTION__=__func__")
744                 
745         # Intel C++ Compiler
746         elseif(CMAKE_C_COMPILER_ID MATCHES "Intel")
747                 # think these next two are broken
748                 find_program(XIAR xiar)
749                 if(XIAR)
750                         set(CMAKE_AR "${XIAR}")
751                 endif()
752                 mark_as_advanced(XIAR)
753
754                 find_program(XILD xild)
755                 if(XILD)
756                         set(CMAKE_LINKER "${XILD}")
757                 endif()
758                 mark_as_advanced(XILD)
759
760                 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fp-model precise -prec_div -parallel")
761                 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fp-model precise -prec_div -parallel")
762
763                 # set(PLATFORM_CFLAGS "${PLATFORM_CFLAGS} -diag-enable sc3")
764                 set(PLATFORM_CFLAGS "-pipe -fPIC -funsigned-char -fno-strict-aliasing")
765                 set(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} -static-intel")
766         endif()
767
768 elseif(WIN32)
769
770         # this file is included anyway when building under Windows with cl.exe
771         #  include(${CMAKE_ROOT}/Modules/Platform/Windows-cl.cmake)
772
773         if(CMAKE_COMPILER_IS_GNUCC)
774                 set(LIBDIR ${CMAKE_SOURCE_DIR}/../lib/mingw32)
775
776                 # Setup 64bit and 64bit windows systems         
777                 if(WITH_MINGW64)
778                         message("Set 64 bit compiler for MinGW.")
779                         set(LIBDIR ${CMAKE_SOURCE_DIR}/../lib/mingw64)
780                 endif()
781         else()
782                 set(LIBDIR ${CMAKE_SOURCE_DIR}/../lib/windows)
783
784                 # Setup 64bit and 64bit windows systems
785                 if(CMAKE_CL_64)
786                         message("64 bit compiler detected.")
787                         set(LIBDIR ${CMAKE_SOURCE_DIR}/../lib/win64)
788                 endif()
789         endif()
790                 
791         add_definitions(-DWIN32)
792
793         if(WITH_INTERNATIONAL)
794                 set(ICONV ${LIBDIR}/iconv)
795                 set(ICONV_INCLUDE_DIRS ${ICONV}/include)
796                 set(ICONV_LIBRARIES iconv)
797                 set(ICONV_LIBPATH ${ICONV}/lib)
798         endif()
799
800         set(JPEG "${LIBDIR}/jpeg")
801         set(JPEG_INCLUDE_DIR "${JPEG}/include")
802         set(JPEG_LIBPATH ${JPEG}/lib) # not cmake defined
803
804         set(WINTAB_INC ${LIBDIR}/wintab/include)
805
806         if(WITH_OPENAL)
807                 set(OPENAL ${LIBDIR}/openal)
808                 set(OPENAL_INCLUDE_DIR ${OPENAL}/include)
809                 set(OPENAL_LIBRARY wrap_oal)
810                 set(OPENAL_LIBPATH ${OPENAL}/lib)
811         endif()
812
813         if(WITH_CODEC_SNDFILE)
814                 set(SNDFILE ${LIBDIR}/sndfile)
815                 set(SNDFILE_INCLUDE_DIRS ${SNDFILE}/include)
816                 set(SNDFILE_LIBRARIES libsndfile-1)
817                 set(SNDFILE_LIBPATH ${SNDFILE}/lib) # TODO, deprecate
818         endif()
819
820         if(WITH_SDL)
821                 set(SDL ${LIBDIR}/sdl)
822                 set(SDL_INCLUDE_DIR ${SDL}/include)
823                 set(SDL_LIBRARY SDL)
824                 set(SDL_LIBPATH ${SDL}/lib)
825         endif()
826
827         if(WITH_CODEC_QUICKTIME)
828                 set(QUICKTIME ${LIBDIR}/QTDevWin)
829                 set(QUICKTIME_INCLUDE_DIRS ${QUICKTIME}/CIncludes)
830                 set(QUICKTIME_LIBRARIES qtmlClient)
831                 set(QUICKTIME_LIBPATH ${QUICKTIME}/Libraries)
832         endif()
833
834         if(WITH_RAYOPTIMIZATION AND SUPPORT_SSE_BUILD)
835                 add_definitions(-D__SSE__ -D__MMX__)
836         endif()
837
838         if(MSVC)
839                 set(PLATFORM_LINKLIBS ws2_32 vfw32 winmm kernel32 user32 gdi32 comdlg32 advapi32 shfolder shell32 ole32 oleaut32 uuid)
840
841                 add_definitions(/D_CRT_NONSTDC_NO_DEPRECATE /D_CRT_SECURE_NO_DEPRECATE /D_SCL_SECURE_NO_DEPRECATE /D_CONSOLE /D_LIB)
842
843                 set(CMAKE_CXX_FLAGS "/nologo /J /Gd /EHsc" CACHE STRING "MSVC MT C++ flags " FORCE)
844                 set(CMAKE_C_FLAGS   "/nologo /J /Gd"       CACHE STRING "MSVC MT C++ flags " FORCE)
845
846                 if(CMAKE_CL_64)
847                         set(CMAKE_CXX_FLAGS_DEBUG "/Od /Gm /RTC1 /MTd /Zi" CACHE STRING "MSVC MT flags " FORCE)
848                 else()
849                         set(CMAKE_CXX_FLAGS_DEBUG "/Od /Gm /RTC1 /MTd /ZI" CACHE STRING "MSVC MT flags " FORCE)
850                 endif()
851                 set(CMAKE_CXX_FLAGS_RELEASE "/O2 /Ob2 /MT" CACHE STRING "MSVC MT flags " FORCE)
852                 set(CMAKE_CXX_FLAGS_MINSIZEREL "/O1 /Ob1 /MT" CACHE STRING "MSVC MT flags " FORCE)
853                 set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "/O2 /Ob1 /MT /Zi" CACHE STRING "MSVC MT flags " FORCE)
854                 if(CMAKE_CL_64)
855                         set(CMAKE_C_FLAGS_DEBUG "/Od /Gm /RTC1 /MTd /Zi" CACHE STRING "MSVC MT flags " FORCE)
856                 else()
857                         set(CMAKE_C_FLAGS_DEBUG "/Od /Gm /RTC1 /MTd /ZI" CACHE STRING "MSVC MT flags " FORCE)
858                 endif()
859                 set(CMAKE_C_FLAGS_RELEASE "/O2 /Ob2 /MT" CACHE STRING "MSVC MT flags " FORCE)
860                 set(CMAKE_C_FLAGS_MINSIZEREL "/O1 /Ob1 /MT" CACHE STRING "MSVC MT flags " FORCE)
861                 set(CMAKE_C_FLAGS_RELWITHDEBINFO "/O2 /Ob1 /MT /Zi" CACHE STRING "MSVC MT flags " FORCE)
862
863                 # most msvc warnings are C & C++
864                 set(_WARNINGS "/W3 /wd4018 /wd4244 /wd4305 /wd4800 /wd4181 /wd4065 /wd4267 /we4013 /wd4200")
865                 set(C_WARNINGS "${_WARNINGS}")
866                 set(CXX_WARNINGS "${_WARNINGS}")
867                 unset(_WARNINGS)
868
869                 if(WITH_INTERNATIONAL)
870                         set(GETTEXT ${LIBDIR}/gettext)
871                         set(GETTEXT_INCLUDE_DIRS ${GETTEXT}/include)
872                         set(GETTEXT_LIBPATH ${GETTEXT}/lib)
873                         set(GETTEXT_LIBRARIES gnu_gettext)
874                 endif()
875                 
876                 if(WITH_MOD_CLOTH_ELTOPO)
877                         set(LAPACK ${LIBDIR}/lapack)
878                         # set(LAPACK_INCLUDE_DIR ${LAPACK}/include)
879                         set(LAPACK_LIBPATH ${LAPACK}/lib)       
880                         set(LAPACK_LIBRARIES
881                                 ${LIBDIR}/lapack/lib/libf2c.lib
882                                 ${LIBDIR}/lapack/lib/clapack_nowrap.lib
883                                 ${LIBDIR}/lapack/lib/BLAS_nowrap.lib
884                         )
885                 endif()
886
887                 set(PNG_LIBRARIES libpng)
888                 set(JPEG_LIBRARIES libjpeg)
889                 
890                 set(PNG "${LIBDIR}/png")
891                 set(PNG_INCLUDE_DIR "${PNG}/include")
892                 set(PNG_LIBPATH ${PNG}/lib) # not cmake defined
893
894                 set(ZLIB_INCLUDE_DIRS ${LIBDIR}/zlib/include)
895                 if(CMAKE_CL_64)
896                         set(ZLIB_LIBRARIES ${LIBDIR}/zlib/lib/libz.lib)
897                 else()
898                         set(ZLIB_LIBRARIES ${LIBDIR}/zlib/lib/zlib.lib)
899                 endif()
900
901                 set(PTHREADS_INCLUDE_DIRS ${LIBDIR}/pthreads/include)
902                 set(PTHREADS_LIBRARIES ${LIBDIR}/pthreads/lib/pthreadVC2.lib)
903
904                 set(FREETYPE ${LIBDIR}/freetype)
905                 set(FREETYPE_INCLUDE_DIRS
906                         ${LIBDIR}/freetype/include
907                         ${LIBDIR}/freetype/include/freetype2
908                 )
909                 set(FREETYPE_LIBRARY ${LIBDIR}/freetype/lib/freetype2ST.lib)
910
911                 if(WITH_FFTW3)
912                         set(FFTW3 ${LIBDIR}/fftw3)
913                         set(FFTW3_LIBRARIES libfftw)
914                         set(FFTW3_INCLUDE_DIRS ${FFTW3}/include)
915                         set(FFTW3_LIBPATH ${FFTW3}/lib)
916                 endif()
917
918                 if(WITH_OPENCOLLADA)
919                         set(OPENCOLLADA ${LIBDIR}/opencollada)
920
921                         set(OPENCOLLADA_INCLUDE_DIRS
922                                 ${LIBDIR}/opencollada/include/COLLADAStreamWriter/include
923                                 ${LIBDIR}/opencollada/include/COLLADABaseUtils/include
924                                 ${LIBDIR}/opencollada/include/COLLADAFramework/include
925                                 ${LIBDIR}/opencollada/include/COLLADASaxFrameworkLoader/include
926                                 ${LIBDIR}/opencollada/include/GeneratedSaxParser/include
927                         )
928                         set_lib_path(OPENCOLLADA_LIBPATH "opencollada")
929
930                         set(OPENCOLLADA_LIBRARIES
931                                 ${OPENCOLLADA_LIBPATH}/lib/OpenCOLLADASaxFrameworkLoader.lib
932                                 ${OPENCOLLADA_LIBPATH}/lib/OpenCOLLADAFramework.lib
933                                 ${OPENCOLLADA_LIBPATH}/lib/OpenCOLLADABaseUtils.lib
934                                 ${OPENCOLLADA_LIBPATH}/lib/OpenCOLLADAStreamWriter.lib
935                                 ${OPENCOLLADA_LIBPATH}/lib/MathMLSolver.lib
936                                 ${OPENCOLLADA_LIBPATH}/lib/GeneratedSaxParser.lib
937                                 ${OPENCOLLADA_LIBPATH}/lib/xml2.lib
938                                 ${OPENCOLLADA_LIBPATH}/lib/buffer.lib
939                                 ${OPENCOLLADA_LIBPATH}/lib/ftoa.lib
940                                 ${OPENCOLLADA_LIBPATH}/lib/UTF.lib
941                         )
942                         set(PCRE_LIBRARIES
943                                 ${OPENCOLLADA_LIBPATH}/lib/pcre.lib
944                         )
945                         
946                         unset(OPENCOLLADA_LIBPATH)
947                         
948                 endif()
949
950                 if(WITH_CODEC_FFMPEG)
951                         set(FFMPEG_INCLUDE_DIRS
952                                 ${LIBDIR}/ffmpeg/include
953                                 ${LIBDIR}/ffmpeg/include/msvc
954                         )
955                         set(FFMPEG_LIBRARIES
956                                 ${LIBDIR}/ffmpeg/lib/avcodec-53.lib
957                                 ${LIBDIR}/ffmpeg/lib/avformat-53.lib
958                                 ${LIBDIR}/ffmpeg/lib/avdevice-53.lib
959                                 ${LIBDIR}/ffmpeg/lib/avutil-51.lib
960                                 ${LIBDIR}/ffmpeg/lib/swscale-2.lib
961                         )
962                 endif()
963
964                 if(WITH_IMAGE_OPENEXR)
965                         set_lib_path(OPENEXR "openexr")
966                         set(OPENEXR_INCLUDE_DIR ${OPENEXR}/include)
967                         set(OPENEXR_LIBPATH ${OPENEXR}/lib)
968                         set(OPENEXR_LIBRARIES
969                                 ${OPENEXR_LIBPATH}/Iex.lib
970                                 ${OPENEXR_LIBPATH}/Half.lib
971                                 ${OPENEXR_LIBPATH}/IlmImf.lib
972                                 ${OPENEXR_LIBPATH}/Imath.lib
973                                 ${OPENEXR_LIBPATH}/IlmThread.lib
974                         )
975                         set(OPENEXR_INCLUDE_DIRS
976                                 ${OPENEXR_INCLUDE_DIR}
977                                 ${OPENEXR_INCLUDE_DIR}/IlmImf
978                                 ${OPENEXR_INCLUDE_DIR}/Iex
979                                 ${OPENEXR_INCLUDE_DIR}/Imath
980                         )
981                 endif()
982
983                 if(WITH_IMAGE_TIFF)
984                         set(TIFF_LIBRARY ${LIBDIR}/tiff/lib/libtiff.lib)
985                         set(TIFF_INCLUDE_DIR ${LIBDIR}/tiff/include)
986                 endif()
987
988                 if(WITH_JACK)
989                         set(JACK_INCLUDE_DIRS
990                                 ${LIBDIR}/jack/include/jack
991                                 ${LIBDIR}/jack/include
992                         )
993                         set(JACK_LIBRARIES ${LIBDIR}/jack/lib/libjack.lib)
994                 endif()
995
996                 if(WITH_PYTHON)
997                         # normally cached but not since we include them with blender
998                         set(PYTHON_VERSION 3.2) # CACHE STRING)
999                         set_lib_path(PYTHON "python")
1000                         set(PYTHON_LIBRARY ${PYTHON}/lib/python32.lib) #CACHE FILEPATH
1001                         #Shared includes for both vc2008 and vc2010
1002                         set(PYTHON_INCLUDE_DIR ${LIBDIR}/python/include/python${PYTHON_VERSION})
1003
1004                         # uncached vars
1005                         set(PYTHON_INCLUDE_DIRS "${PYTHON_INCLUDE_DIR}")
1006                         set(PYTHON_LIBRARIES  "${PYTHON_LIBRARY}")
1007                 endif()
1008
1009                 if(WITH_BOOST)
1010                         set(BOOST ${LIBDIR}/boost)
1011                         set(BOOST_INCLUDE_DIR ${BOOST}/include)
1012                         if(MSVC10)
1013                                 set(BOOST_LIBPATH ${BOOST}/vc2010/lib)
1014                                 set(BOOST_POSTFIX "vc100-mt-s-1_49.lib")
1015                                 set(BOOST_DEBUG_POSTFIX "vc100-mt-sgd-1_49.lib")
1016                         else()
1017                                 set(BOOST_LIBPATH ${BOOST}/lib)
1018                                 set(BOOST_POSTFIX "vc90-mt-s-1_49.lib")
1019                                 set(BOOST_DEBUG_POSTFIX "vc90-mt-sgd-1_49.lib")                                 
1020                         endif()
1021                         set(BOOST_LIBRARIES
1022                                 optimized libboost_date_time-${BOOST_POSTFIX} optimized libboost_filesystem-${BOOST_POSTFIX}
1023                                 optimized libboost_regex-${BOOST_POSTFIX} optimized libboost_system-${BOOST_POSTFIX} optimized libboost_thread-${BOOST_POSTFIX}
1024                                 debug libboost_date_time-${BOOST_DEBUG_POSTFIX} debug libboost_filesystem-${BOOST_DEBUG_POSTFIX}
1025                                 debug libboost_regex-${BOOST_DEBUG_POSTFIX} debug libboost_system-${BOOST_DEBUG_POSTFIX} debug libboost_thread-${BOOST_DEBUG_POSTFIX})
1026                         set(BOOST_DEFINITIONS "-DBOOST_ALL_NO_LIB")
1027                 endif()
1028                         
1029                 if(WITH_OPENIMAGEIO)
1030                         set(OPENIMAGEIO ${LIBDIR}/openimageio)
1031                         set(OPENIMAGEIO_INCLUDE_DIRS ${OPENIMAGEIO}/include)
1032                         set(OPENIMAGEIO_LIBRARIES OpenImageIO)
1033                         set(OPENIMAGEIO_LIBPATH ${OPENIMAGEIO}/lib)
1034                         set(OPENIMAGEIO_DEFINITIONS)
1035                 endif()
1036
1037                 if(WITH_OPENCOLORIO)
1038                         set(OPENCOLORIO ${LIBDIR}/opencolorio)
1039                         set(OPENCOLORIO_INCLUDE_DIRS ${OPENCOLORIO}/include)
1040                         set(OPENCOLORIO_LIBRARIES OpenColorIO)
1041                         set_lib_path(OPENCOLORIO_LIBPATH "opencolorio/lib")
1042                         set(OPENCOLORIO_DEFINITIONS)
1043                 endif()
1044
1045                 set(PLATFORM_LINKFLAGS "/SUBSYSTEM:CONSOLE /STACK:2097152 /INCREMENTAL:NO /NODEFAULTLIB:msvcrt.lib /NODEFAULTLIB:msvcmrt.lib /NODEFAULTLIB:msvcurt.lib /NODEFAULTLIB:msvcrtd.lib")
1046
1047                 # MSVC only, Mingw doesnt need
1048                 if(CMAKE_CL_64)
1049                         set(PLATFORM_LINKFLAGS "/MACHINE:X64 /OPT:NOREF ${PLATFORM_LINKFLAGS}")
1050                 else()
1051                         set(PLATFORM_LINKFLAGS "/MACHINE:IX86 /LARGEADDRESSAWARE ${PLATFORM_LINKFLAGS}")
1052                 endif()
1053
1054                 set(PLATFORM_LINKFLAGS_DEBUG "/NODEFAULTLIB:libcmt.lib /NODEFAULTLIB:libc.lib")
1055
1056                 # used in many places so include globally, like OpenGL
1057                 blender_include_dirs("${PTHREADS_INCLUDE_DIRS}")
1058
1059         elseif(CMAKE_COMPILER_IS_GNUCC)
1060         # keep GCC specific stuff here          
1061                 set(PLATFORM_LINKLIBS "-lshell32 -lshfolder -lgdi32 -lmsvcrt -lwinmm -lmingw32 -lm -lws2_32 -lz -lstdc++ -lole32 -luuid -lwsock32 -lpsapi")
1062                 set(PLATFORM_CFLAGS "-pipe -funsigned-char -fno-strict-aliasing")
1063
1064                 if(WITH_MINGW64)
1065                         #We need to take care though not to have these on debug builds because they may play funky with gdb
1066                         if(CMAKE_BUILD_TYPE MATCHES "Release")
1067                                 set(PLATFORM_CFLAGS "${PLATFORM_CFLAGS} -mmmx -ftree-vectorize")
1068                         endif()
1069                         set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fpermissive")
1070                         set(PLATFORM_LINKLIBS "${PLATFORM_LINKLIBS} -lpthread")
1071                         
1072                         add_definitions(-DFREE_WINDOWS64 -DMS_WIN64)
1073                 endif()
1074
1075                 add_definitions(-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE)
1076
1077
1078                 add_definitions(-DFREE_WINDOWS)
1079
1080                 if(WITH_INTERNATIONAL)
1081                         set(GETTEXT ${LIBDIR}/gettext)
1082                         set(GETTEXT_INCLUDE_DIRS ${GETTEXT}/include)
1083                         set(GETTEXT_LIBPATH ${GETTEXT}/lib)
1084                         set(GETTEXT_LIBRARIES intl)
1085                 endif()
1086                 
1087                 set(PNG "${LIBDIR}/png")
1088                 set(PNG_INCLUDE_DIR "${PNG}/include")
1089                 set(PNG_LIBPATH ${PNG}/lib) # not cmake defined
1090
1091                 if(WITH_MINGW64)
1092                         set(JPEG_LIBRARIES jpeg)
1093                 else()
1094                         set(JPEG_LIBRARIES libjpeg)
1095                 endif()
1096                 set(PNG_LIBRARIES png)
1097
1098                 set(ZLIB ${LIBDIR}/zlib)
1099                 set(ZLIB_INCLUDE_DIRS ${ZLIB}/include)
1100                 set(ZLIB_LIBPATH ${ZLIB}/lib)
1101                 set(ZLIB_LIBRARIES z)
1102
1103                 #comes with own pthread library
1104                 if(NOT WITH_MINGW64)
1105                         set(PTHREADS ${LIBDIR}/pthreads)
1106                         set(PTHREADS_INCLUDE_DIRS ${PTHREADS}/include)
1107                         set(PTHREADS_LIBPATH ${PTHREADS}/lib)
1108                         set(PTHREADS_LIBRARIES pthreadGC2)
1109                 endif()
1110                 
1111                 set(FREETYPE ${LIBDIR}/freetype)
1112                 set(FREETYPE_INCLUDE_DIRS ${FREETYPE}/include ${FREETYPE}/include/freetype2)
1113                 set(FREETYPE_LIBPATH ${FREETYPE}/lib)
1114                 set(FREETYPE_LIBRARY freetype)
1115
1116                 if(WITH_FFTW3)
1117                         set(FFTW3 ${LIBDIR}/fftw3)
1118                         set(FFTW3_LIBRARIES fftw3)
1119                         set(FFTW3_INCLUDE_DIRS ${FFTW3}/include)
1120                         set(FFTW3_LIBPATH ${FFTW3}/lib)
1121                 endif()
1122
1123                 if(WITH_OPENCOLLADA)
1124                         set(OPENCOLLADA ${LIBDIR}/opencollada)
1125                         set(OPENCOLLADA_INCLUDE_DIRS
1126                                 ${LIBDIR}/opencollada/include/COLLADAStreamWriter/include
1127                                 ${LIBDIR}/opencollada/include/COLLADABaseUtils/include
1128                                 ${LIBDIR}/opencollada/include/COLLADAFramework/include
1129                                 ${LIBDIR}/opencollada/include/COLLADASaxFrameworkLoader/include
1130                                 ${LIBDIR}/opencollada/include/GeneratedSaxParser/include
1131                         )
1132                         set(OPENCOLLADA_LIBPATH ${OPENCOLLADA}/lib ${OPENCOLLADA}/lib)
1133                         if(WITH_MINGW64)
1134                                 set(OPENCOLLADA_LIBRARIES OpenCOLLADAStreamWriter OpenCOLLADASaxFrameworkLoader OpenCOLLADAFramework OpenCOLLADABaseUtils GeneratedSaxParser UTF MathMLSolver pcre buffer ftoa xml)
1135                         else()
1136                                 set(OPENCOLLADA_LIBRARIES OpenCOLLADAStreamWriter OpenCOLLADASaxFrameworkLoader OpenCOLLADAFramework OpenCOLLADABaseUtils GeneratedSaxParser UTF MathMLSolver expat pcre buffer ftoa)
1137                         endif()
1138                         set(PCRE_LIBRARIES pcre)
1139                 endif()
1140
1141                 if(WITH_CODEC_FFMPEG)
1142                         set(FFMPEG ${LIBDIR}/ffmpeg)
1143                         set(FFMPEG_INCLUDE_DIRS ${FFMPEG}/include)
1144                         if(WITH_MINGW64)
1145                                 set(FFMPEG_LIBRARIES avcodec.dll avformat.dll avdevice.dll avutil.dll swscale.dll swresample.dll)
1146                         else()
1147                                 set(FFMPEG_LIBRARIES avcodec-53 avformat-53 avdevice-53 avutil-51 swscale-2)
1148                         endif()
1149                         set(FFMPEG_LIBPATH ${FFMPEG}/lib)
1150                 endif()
1151
1152                 if(WITH_IMAGE_OPENEXR)
1153                         set(OPENEXR ${LIBDIR}/openexr)
1154                         set(OPENEXR_INCLUDE_DIRS ${OPENEXR}/include/OpenEXR)
1155                         set(OPENEXR_LIBRARIES Half IlmImf Imath IlmThread Iex)
1156                         set(OPENEXR_LIBPATH ${OPENEXR}/lib)
1157                 endif()
1158
1159                 if(WITH_IMAGE_TIFF)
1160                         set(TIFF ${LIBDIR}/tiff)
1161                         set(TIFF_LIBRARY tiff)
1162                         set(TIFF_INCLUDE_DIR ${TIFF}/include)
1163                         set(TIFF_LIBPATH ${TIFF}/lib)
1164                 endif()
1165
1166                 if(WITH_JACK)
1167                         set(JACK ${LIBDIR}/jack)
1168                         set(JACK_INCLUDE_DIRS ${JACK}/include/jack ${JACK}/include)
1169                         set(JACK_LIBRARIES jack)
1170                         set(JACK_LIBPATH ${JACK}/lib)
1171
1172                         # TODO, gives linking errors, force off
1173                         set(WITH_JACK OFF)
1174                 endif()
1175
1176                 if(WITH_PYTHON)
1177                         # normally cached but not since we include them with blender
1178                         set(PYTHON_VERSION 3.2) #  CACHE STRING)
1179                         set(PYTHON_INCLUDE_DIR "${LIBDIR}/python/include/python${PYTHON_VERSION}")  # CACHE PATH)
1180                         set(PYTHON_LIBRARY "${LIBDIR}/python/lib/python32mw.lib")  # CACHE FILEPATH)
1181
1182                         # uncached vars
1183                         set(PYTHON_INCLUDE_DIRS "${PYTHON_INCLUDE_DIR}")
1184                         set(PYTHON_LIBRARIES  "${PYTHON_LIBRARY}")
1185                 endif()
1186
1187                 if(WITH_BOOST)
1188                         set(BOOST ${LIBDIR}/boost)
1189                         set(BOOST_INCLUDE_DIR ${BOOST}/include)
1190                         if(WITH_MINGW64)
1191                                 set(BOOST_POSTFIX "mgw47-mt-s-1_49")
1192                                 set(BOOST_DEBUG_POSTFIX "mgw47-mt-sd-1_49")
1193                         else()
1194                                 set(BOOST_POSTFIX "mgw46-mt-s-1_47")
1195                                 set(BOOST_DEBUG_POSTFIX "mgw46-mt-sd-1_47")
1196                         endif()         
1197                         set(BOOST_LIBRARIES
1198                                 optimized boost_date_time-${BOOST_POSTFIX} boost_filesystem-${BOOST_POSTFIX}
1199                                 boost_regex-${BOOST_POSTFIX} boost_system-${BOOST_POSTFIX} boost_thread-${BOOST_POSTFIX}
1200                                 debug boost_date_time-${BOOST_DEBUG_POSTFIX} boost_filesystem-${BOOST_DEBUG_POSTFIX}
1201                                 boost_regex-${BOOST_DEBUG_POSTFIX} boost_system-${BOOST_DEBUG_POSTFIX} boost_thread-${BOOST_DEBUG_POSTFIX})
1202                         set(BOOST_LIBPATH ${BOOST}/lib)
1203                         set(BOOST_DEFINITIONS "-DBOOST_ALL_NO_LIB -DBOOST_THREAD_USE_LIB ")
1204                 endif()
1205                         
1206                 if(WITH_OPENIMAGEIO)
1207                         set(OPENIMAGEIO ${LIBDIR}/openimageio)
1208                         set(OPENIMAGEIO_INCLUDE_DIRS ${OPENIMAGEIO}/include)
1209                         set(OPENIMAGEIO_LIBRARIES OpenImageIO)
1210                         set(OPENIMAGEIO_LIBPATH ${OPENIMAGEIO}/lib)
1211                         set(OPENIMAGEIO_DEFINITIONS)
1212                 endif()
1213                 
1214                 if(WITH_OPENCOLORIO)
1215                         set(OPENCOLORIO ${LIBDIR}/opencolorio)
1216                         set(OPENCOLORIO_INCLUDE_DIRS ${OPENCOLORIO}/include)
1217                         set(OPENCOLORIO_LIBRARIES OpenColorIO)
1218                         set(OPENCOLORIO_LIBPATH ${OPENCOLORIO}/lib)
1219                         set(OPENCOLORIO_DEFINITIONS)
1220                 endif()
1221
1222                 set(PLATFORM_LINKFLAGS "-Xlinker --stack=2097152")
1223
1224                 ## DISABLE - causes linking errors 
1225                 ## for re-distrobution, so users dont need mingw installed
1226                 # set(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} -static-libgcc -static-libstdc++")
1227
1228         endif()
1229
1230 elseif(APPLE)
1231
1232         if(${CMAKE_OSX_DEPLOYMENT_TARGET} STREQUAL "10.5" OR ${CMAKE_OSX_DEPLOYMENT_TARGET} STRGREATER "10.5")
1233                 set(WITH_LIBS10.5 ON CACHE BOOL "Use 10.5 libs" FORCE) # valid also for 10.6/10.7
1234         endif()
1235
1236         if(${XCODE_VERSION} VERSION_LESS 4.3)
1237                 set(CMAKE_OSX_SYSROOT /Developer/SDKs/MacOSX${OSX_SYSTEM}.sdk CACHE PATH "" FORCE)  # use guaranteed existing sdk
1238         else()
1239                 # note: i don't use xcode-select path on purpose, cause also /Applications/Xcode.app would be allowed
1240                 # absolute pathes are more foolproof here !
1241                 set(OSX_SYSROOT_PREFIX /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform)
1242                 set(OSX_DEVELOPER_PREFIX /Developer/SDKs/MacOSX${OSX_SYSTEM}.sdk) # use guaranteed existing sdk
1243                 set(CMAKE_OSX_SYSROOT ${OSX_SYSROOT_PREFIX}/${OSX_DEVELOPER_PREFIX} CACHE PATH "" FORCE)
1244         endif() 
1245         
1246         if(WITH_LIBS10.5)
1247                 set(LIBDIR ${CMAKE_SOURCE_DIR}/../lib/darwin-9.x.universal)
1248         else()
1249                 if(CMAKE_OSX_ARCHITECTURES MATCHES i386)
1250                         set(LIBDIR ${CMAKE_SOURCE_DIR}/../lib/darwin-8.x.i386)
1251                 else()
1252                         set(LIBDIR ${CMAKE_SOURCE_DIR}/../lib/darwin-8.0.0-powerpc)
1253                 endif()
1254         endif()
1255
1256
1257         if(WITH_OPENAL)
1258                 find_package(OpenAL)
1259                 if(OPENAL_FOUND)
1260                         set(WITH_OPENAL ON)
1261                         set(OPENAL_INCLUDE_DIR "${LIBDIR}/openal/include")
1262                 else()
1263                         set(WITH_OPENAL OFF)
1264                 endif()
1265         endif()
1266
1267         if(WITH_JACK)
1268                 set(JACK /usr)
1269                 set(JACK_INCLUDE_DIRS ${JACK}/include/jack)
1270                 set(JACK_LIBRARIES jack)
1271                 set(JACK_LIBPATH ${JACK}/lib)
1272         endif()
1273
1274         if(WITH_CODEC_SNDFILE)
1275                 set(SNDFILE ${LIBDIR}/sndfile)
1276                 set(SNDFILE_INCLUDE_DIRS ${SNDFILE}/include)
1277                 set(SNDFILE_LIBRARIES sndfile FLAC ogg vorbis vorbisenc)
1278                 set(SNDFILE_LIBPATH ${SNDFILE}/lib ${FFMPEG}/lib)  # TODO, deprecate
1279         endif()
1280
1281         if(WITH_PYTHON)
1282                 if(NOT WITH_PYTHON_MODULE)
1283                         # we use precompiled libraries for py 3.2 and up by default
1284
1285                         # normally cached but not since we include them with blender
1286                         set(PYTHON_VERSION 3.2)
1287                         set(PYTHON_INCLUDE_DIR "${LIBDIR}/python/include/python${PYTHON_VERSION}")
1288                         # set(PYTHON_BINARY "${LIBDIR}/python/bin/python${PYTHON_VERSION}") # not used yet
1289                         set(PYTHON_LIBRARY python${PYTHON_VERSION})
1290                         set(PYTHON_LIBPATH "${LIBDIR}/python/lib/python${PYTHON_VERSION}")
1291                         # set(PYTHON_LINKFLAGS "-u _PyMac_Error")  # won't  build with this enabled
1292                 else()
1293                         # module must be compiled against Python framework
1294
1295                         # normally cached but not since we include them with blender
1296                         set(PYTHON_VERSION 3.2)
1297                         set(PYTHON_INCLUDE_DIR "/Library/Frameworks/Python.framework/Versions/${PYTHON_VERSION}/include/python${PYTHON_VERSION}m")
1298                         set(PYTHON_BINARY "/Library/Frameworks/Python.framework/Versions/${PYTHON_VERSION}/bin/python${PYTHON_VERSION}")
1299                         #set(PYTHON_LIBRARY python${PYTHON_VERSION})
1300                         set(PYTHON_LIBPATH "/Library/Frameworks/Python.framework/Versions/${PYTHON_VERSION}/lib/python${PYTHON_VERSION}/config-3.2m")
1301                         #set(PYTHON_LINKFLAGS "-u _PyMac_Error -framework Python")  # won't  build with this enabled
1302                 endif()
1303                 
1304                 # uncached vars
1305                 set(PYTHON_INCLUDE_DIRS "${PYTHON_INCLUDE_DIR}")
1306                 set(PYTHON_LIBRARIES  "${PYTHON_LIBRARY}")
1307         endif()
1308
1309         if(WITH_INTERNATIONAL)
1310                 set(GETTEXT ${LIBDIR}/gettext)
1311                 set(GETTEXT_INCLUDE_DIRS "${GETTEXT}/include")
1312                 set(GETTEXT_LIBRARIES intl iconv)
1313                 set(GETTEXT_LIBPATH ${GETTEXT}/lib)
1314         endif()
1315
1316         if(WITH_FFTW3)
1317                 set(FFTW3 ${LIBDIR}/fftw3)
1318                 set(FFTW3_INCLUDE_DIRS ${FFTW3}/include)
1319                 set(FFTW3_LIBRARIES fftw3)
1320                 set(FFTW3_LIBPATH ${FFTW3}/lib)
1321         endif()
1322
1323         set(PNG_LIBRARIES png)
1324         set(JPEG_LIBRARIES jpeg)
1325
1326         set(ZLIB /usr)
1327         set(ZLIB_INCLUDE_DIRS "${ZLIB}/include")
1328         set(ZLIB_LIBRARIES z bz2)
1329
1330         set(FREETYPE ${LIBDIR}/freetype)
1331         set(FREETYPE_INCLUDE_DIRS ${FREETYPE}/include ${FREETYPE}/include/freetype2)
1332         set(FREETYPE_LIBPATH ${FREETYPE}/lib)
1333         set(FREETYPE_LIBRARY freetype)
1334
1335         if(WITH_IMAGE_OPENEXR)
1336                 set(OPENEXR ${LIBDIR}/openexr)
1337                 set(OPENEXR_INCLUDE_DIRS ${OPENEXR}/include/OpenEXR)
1338                 set(OPENEXR_LIBRARIES Iex Half IlmImf Imath IlmThread)
1339                 set(OPENEXR_LIBPATH ${OPENEXR}/lib)
1340         endif()
1341
1342         if(WITH_CODEC_FFMPEG)
1343                 set(FFMPEG ${LIBDIR}/ffmpeg)
1344                 set(FFMPEG_INCLUDE_DIRS ${FFMPEG}/include)
1345                 set(FFMPEG_LIBRARIES avcodec avdevice avformat avutil mp3lame swscale x264 xvidcore theora theoradec theoraenc vorbis vorbisenc vorbisfile ogg)
1346                 set(FFMPEG_LIBPATH ${FFMPEG}/lib)
1347                 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D__STDC_CONSTANT_MACROS")
1348         endif()
1349
1350         find_library(SYSTEMSTUBS_LIBRARY
1351                 NAMES
1352                 SystemStubs
1353                 PATHS
1354         )
1355         mark_as_advanced(SYSTEMSTUBS_LIBRARY)
1356         if(SYSTEMSTUBS_LIBRARY)
1357                 set(PLATFORM_LINKLIBS stdc++ SystemStubs)
1358         else()
1359                 set(PLATFORM_LINKLIBS stdc++)
1360         endif()
1361
1362         if(WITH_COCOA)
1363                 set(PLATFORM_CFLAGS "-pipe -funsigned-char -DGHOST_COCOA")
1364                 set(PLATFORM_LINKFLAGS "-fexceptions -framework CoreServices -framework Foundation -framework IOKit -framework AppKit -framework Cocoa -framework Carbon -framework AudioUnit -framework AudioToolbox -framework CoreAudio")
1365                 if(USE_QTKIT)
1366                         set(PLATFORM_CFLAGS "${PLATFORM_CFLAGS} -DUSE_QTKIT")
1367                         set(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} -framework QTKit")
1368                         if(CMAKE_OSX_ARCHITECTURES MATCHES i386)
1369                                 set(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} -framework QuickTime")
1370                                 #libSDL still needs 32bit carbon quicktime
1371                         endif()
1372                 elseif(WITH_CODEC_QUICKTIME)
1373                         set(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} -framework QuickTime")
1374                 endif()
1375
1376                 # XXX - SOME MAC DEV PLEASE TEST WITH THE SDK INSTALLED!
1377                 # ALSO SHOULD BE MOVED INTO OWN MODULE WHEN FUNCTIONAL
1378                 if(WITH_INPUT_NDOF)
1379                         # This thread it *should* work and check the framework - campbell
1380                         # http://www.cmake.org/pipermail/cmake/2005-December/007740.html
1381                         find_library(3D_CONNEXION_CLIENT_LIBRARY
1382                                 NAMES 3DconnexionClient
1383                         )
1384                         if(NOT 3D_CONNEXION_CLIENT_LIBRARY)
1385                                 set(WITH_INPUT_NDOF OFF)
1386                         endif()
1387
1388                         if(WITH_INPUT_NDOF)
1389                                 set(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} -weak_framework 3DconnexionClient")
1390                         endif()
1391                 endif()
1392
1393         else()
1394                 set(PLATFORM_CFLAGS "-pipe -funsigned-char")
1395                 set(PLATFORM_LINKFLAGS "-fexceptions -framework CoreServices -framework Foundation -framework IOKit -framework AppKit -framework Carbon -framework AGL -framework AudioUnit -framework AudioToolbox -framework CoreAudio -framework QuickTime")
1396                 set(WITH_INPUT_NDOF OFF)  # unsupported
1397         endif()
1398         
1399         if(WITH_PYTHON_MODULE)
1400                 set(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} /Library/Frameworks/Python.framework/Versions/${PYTHON_VERSION}/python")# force cmake to link right framework
1401         endif()
1402         
1403         if(WITH_OPENCOLLADA)
1404                 set(OPENCOLLADA ${LIBDIR}/opencollada)
1405
1406                 set(OPENCOLLADA_INCLUDE_DIRS
1407                         ${LIBDIR}/opencollada/include/COLLADAStreamWriter
1408                         ${LIBDIR}/opencollada/include/COLLADABaseUtils
1409                         ${LIBDIR}/opencollada/include/COLLADAFramework
1410                         ${LIBDIR}/opencollada/include/COLLADASaxFrameworkLoader
1411                         ${LIBDIR}/opencollada/include/GeneratedSaxParser
1412                 )
1413
1414                 set(OPENCOLLADA_LIBPATH ${OPENCOLLADA}/lib)
1415                 set(OPENCOLLADA_LIBRARIES "OpenCOLLADASaxFrameworkLoader -lOpenCOLLADAFramework -lOpenCOLLADABaseUtils -lOpenCOLLADAStreamWriter -lMathMLSolver -lGeneratedSaxParser -lUTF -lxml2 -lbuffer -lftoa")
1416                 #pcre is bundled with openCollada
1417                 #set(PCRE ${LIBDIR}/pcre)
1418                 #set(PCRE_LIBPATH ${PCRE}/lib)
1419                 set(PCRE_LIBRARIES pcre)
1420                 #libxml2 is used
1421                 #set(EXPAT ${LIBDIR}/expat)
1422                 #set(EXPAT_LIBPATH ${EXPAT}/lib)
1423                 set(EXPAT_LIB)
1424         endif()
1425
1426         if(WITH_SDL)
1427                 set(SDL ${LIBDIR}/sdl)
1428                 set(SDL_INCLUDE_DIR ${SDL}/include)
1429                 set(SDL_LIBRARY SDL)
1430                 set(SDL_LIBPATH ${SDL}/lib)
1431         endif()
1432
1433         set(PNG "${LIBDIR}/png")
1434         set(PNG_INCLUDE_DIR "${PNG}/include")
1435         set(PNG_LIBPATH ${PNG}/lib)
1436
1437         set(JPEG "${LIBDIR}/jpeg")
1438         set(JPEG_INCLUDE_DIR "${JPEG}/include")
1439         set(JPEG_LIBPATH ${JPEG}/lib)
1440
1441         if(WITH_IMAGE_TIFF)
1442                 set(TIFF ${LIBDIR}/tiff)
1443                 set(TIFF_INCLUDE_DIR ${TIFF}/include)
1444                 set(TIFF_LIBRARY tiff)
1445                 set(TIFF_LIBPATH ${TIFF}/lib)
1446         endif()
1447
1448         if (WITH_INPUT_NDOF)
1449                 # linker needs "-weak_framework 3DconnexionClient"
1450         endif()
1451
1452         if(WITH_BOOST)
1453                 set(BOOST ${LIBDIR}/boost)
1454                 set(BOOST_INCLUDE_DIR ${BOOST}/include)
1455                 set(BOOST_LIBRARIES boost_date_time-mt boost_filesystem-mt boost_regex-mt boost_system-mt boost_thread-mt)
1456                 set(BOOST_LIBPATH ${BOOST}/lib)
1457                 set(BOOST_DEFINITIONS)
1458         endif()
1459
1460         if(WITH_OPENIMAGEIO)
1461                 set(OPENIMAGEIO ${LIBDIR}/openimageio)
1462                 set(OPENIMAGEIO_INCLUDE_DIRS ${OPENIMAGEIO}/include)
1463                 set(OPENIMAGEIO_LIBRARIES OpenImageIO ${PNG_LIBRARIES} ${JPEG_LIBRARIES} ${TIFF_LIBRARY} ${OPENEXR_LIBRARIES} ${ZLIB_LIBRARIES})
1464                 set(OPENIMAGEIO_LIBPATH ${OPENIMAGEIO}/lib ${JPEG_LIBPATH} ${PNG_LIBPATH} ${TIFF_LIBPATH} ${OPENEXR_LIBPATH} ${ZLIB_LIBPATH})
1465                 set(OPENIMAGEIO_DEFINITIONS "-DOIIO_STATIC_BUILD")
1466         endif()
1467
1468         if(WITH_OPENCOLORIO)
1469                 set(OPENCOLORIO ${LIBDIR}/opencolorio)
1470                 set(OPENCOLORIO_INCLUDE_DIRS ${OPENCOLORIO}/include)
1471                 set(OPENCOLORIO_LIBRARIES OpenColorIO tinyxml yaml-cpp)
1472                 set(OPENCOLORIO_LIBPATH ${OPENCOLORIO}/lib)
1473                 set(OPENCOLORIO_DEFINITIONS "-DOCIO_STATIC_BUILD")
1474         endif()
1475
1476         set(EXETYPE MACOSX_BUNDLE)
1477
1478         set(CMAKE_C_FLAGS_DEBUG "-fno-strict-aliasing -g")
1479         set(CMAKE_CXX_FLAGS_DEBUG "-fno-strict-aliasing -g")
1480         if(CMAKE_OSX_ARCHITECTURES MATCHES "i386")
1481                 set(CMAKE_CXX_FLAGS_RELEASE "-O2 -mdynamic-no-pic -ftree-vectorize -msse -msse2 -fvariable-expansion-in-unroller")
1482                 set(CMAKE_C_FLAGS_RELEASE "-O2 -mdynamic-no-pic -ftree-vectorize -msse -msse2 -fvariable-expansion-in-unroller")
1483         elseif(CMAKE_OSX_ARCHITECTURES MATCHES "x86_64")
1484                 set(CMAKE_CXX_FLAGS_RELEASE "-O2 -mdynamic-no-pic -ftree-vectorize -msse -msse2 -msse3 -mssse3 -fvariable-expansion-in-unroller")
1485                 set(CMAKE_C_FLAGS_RELEASE "-O2 -mdynamic-no-pic -ftree-vectorize -msse -msse2 -msse3 -mssse3 -fvariable-expansion-in-unroller")
1486         else()
1487                 set(CMAKE_C_FLAGS_RELEASE "-mdynamic-no-pic -fno-strict-aliasing")
1488                 set(CMAKE_CXX_FLAGS_RELEASE "-mdynamic-no-pic -fno-strict-aliasing")
1489         endif()
1490 endif()
1491
1492 #-----------------------------------------------------------------------------
1493 # Common.
1494
1495 if(APPLE OR WIN32)
1496         if(NOT EXISTS "${LIBDIR}/")
1497                 message(FATAL_ERROR "Apple and Windows require pre-compiled libs at: '${LIBDIR}'")
1498         endif()
1499 endif()
1500
1501 if(WITH_CYCLES)
1502         if(NOT WITH_OPENIMAGEIO)
1503                 message(FATAL_ERROR "Cycles reqires WITH_OPENIMAGEIO, the library may not have been found. Configure OIIO or disable WITH_CYCLES")
1504         endif()
1505         if(NOT WITH_BOOST)
1506                 message(FATAL_ERROR "Cycles reqires WITH_BOOST, the library may not have been found. Configure BOOST or disable WITH_CYCLES")
1507         endif()
1508 endif()
1509
1510
1511 # See TEST_SSE_SUPPORT() for how this is defined.
1512
1513 if(WITH_RAYOPTIMIZATION)
1514         if(SUPPORT_SSE_BUILD)
1515                 set(PLATFORM_CFLAGS " ${COMPILER_SSE_FLAG} ${PLATFORM_CFLAGS}")
1516                 add_definitions(-D__SSE__ -D__MMX__)
1517         endif()
1518         if(SUPPORT_SSE2_BUILD)
1519                 set(PLATFORM_CFLAGS " ${COMPILER_SSE2_FLAG} ${PLATFORM_CFLAGS}")
1520                 add_definitions(-D__SSE2__)
1521                 if(NOT SUPPORT_SSE_BUILD) # dont double up
1522                         add_definitions(-D__MMX__)
1523                 endif()
1524         endif()
1525 endif()
1526
1527
1528 # set the endian define
1529 if(MSVC)
1530         # for some reason this fails on msvc
1531         add_definitions(-D__LITTLE_ENDIAN__)
1532         
1533 # OSX-Note: as we do crosscompiling with specific set architecture,
1534 # endianess-detection and autosetting is counterproductive
1535 # so we just set endianess according CMAKE_OSX_ARCHITECTURES
1536
1537 elseif(CMAKE_OSX_ARCHITECTURES MATCHES i386 OR CMAKE_OSX_ARCHITECTURES MATCHES x86_64)
1538         add_definitions(-D__LITTLE_ENDIAN__)
1539 elseif(CMAKE_OSX_ARCHITECTURES MATCHES ppc OR CMAKE_OSX_ARCHITECTURES MATCHES ppc64)            
1540         add_definitions(-D__BIG_ENDIAN__)
1541         
1542 else()
1543         include(TestBigEndian)
1544         test_big_endian(_SYSTEM_BIG_ENDIAN)
1545         if(_SYSTEM_BIG_ENDIAN)
1546                 add_definitions(-D__BIG_ENDIAN__)
1547         else()
1548                 add_definitions(-D__LITTLE_ENDIAN__)
1549         endif()
1550         unset(_SYSTEM_BIG_ENDIAN)
1551 endif()
1552
1553
1554 if(WITH_IMAGE_OPENJPEG)
1555         if(WITH_SYSTEM_OPENJPEG)
1556                 # dealt with above
1557         else()
1558                 set(OPENJPEG_INCLUDE_DIRS "${CMAKE_SOURCE_DIR}/extern/libopenjpeg")
1559                 add_definitions(-DOPJ_STATIC)
1560         endif()
1561 endif()
1562
1563 if(WITH_IMAGE_REDCODE)
1564         set(REDCODE ${CMAKE_SOURCE_DIR}/extern)
1565         set(REDCODE_INC ${REDCODE})
1566 endif()
1567
1568 #-----------------------------------------------------------------------------
1569 # Blender WebPlugin
1570
1571 if(WITH_WEBPLUGIN)
1572         set(GECKO_DIR "${CMAKE_SOURCE_DIR}/../gecko-sdk/" CACHE PATH "Gecko SDK path")
1573         set(WEBPLUGIN_SANDBOX_MODE "apparmor" CACHE STRING "WEB Plugin sandbox mode, can be apparmor, privsep, none")
1574
1575         set(WITH_PLAYER ON)
1576 endif()
1577
1578
1579 #-----------------------------------------------------------------------------
1580 # Configure OpenGL.
1581 find_package(OpenGL)
1582 blender_include_dirs_sys("${OPENGL_INCLUDE_DIR}")
1583 # unset(OPENGL_LIBRARIES CACHE) # not compat with older cmake
1584 # unset(OPENGL_xmesa_INCLUDE_DIR CACHE) # not compat with older cmake
1585
1586 #-----------------------------------------------------------------------------
1587 # Configure OpenMP.
1588 if(WITH_OPENMP)
1589         find_package(OpenMP)
1590         if(OPENMP_FOUND)
1591                 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
1592                 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
1593
1594                 if(APPLE AND ${CMAKE_GENERATOR} MATCHES "Xcode")
1595                         set(CMAKE_XCODE_ATTRIBUTE_ENABLE_OPENMP_SUPPORT "YES")
1596                 endif()
1597         else()
1598                 set(WITH_OPENMP OFF)
1599         endif()
1600
1601         mark_as_advanced(
1602                 OpenMP_C_FLAGS
1603                 OpenMP_CXX_FLAGS
1604         )
1605 endif()
1606
1607 #-----------------------------------------------------------------------------
1608 # Configure GLEW
1609
1610 if(WITH_SYSTEM_GLEW)
1611         find_package(GLEW)
1612
1613         if(NOT GLEW_FOUND)
1614                 message(FATAL_ERROR "GLEW is required to build blender, install it or disable WITH_SYSTEM_GLEW")
1615         endif()
1616
1617         mark_as_advanced(
1618                 GLEW_LIBRARY
1619                 GLEW_INCLUDE_PATH
1620         )
1621 else()
1622         # set(GLEW_LIBRARY "")  # unused
1623         set(GLEW_INCLUDE_PATH "${CMAKE_SOURCE_DIR}/extern/glew/include")
1624 endif()
1625
1626 #-----------------------------------------------------------------------------
1627 # Configure Python.
1628
1629 if(WITH_PYTHON_MODULE)
1630         add_definitions(-DPy_ENABLE_SHARED)
1631 endif()
1632
1633 #-----------------------------------------------------------------------------
1634 # Extra compile flags
1635
1636 if(CMAKE_COMPILER_IS_GNUCC)
1637
1638         ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_ALL -Wall)
1639         ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_CAST_ALIGN -Wcast-align)
1640         ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_ERROR_DECLARATION_AFTER_STATEMENT -Werror=declaration-after-statement)
1641         ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_ERROR_IMPLICIT_FUNCTION_DECLARATION -Werror=implicit-function-declaration)
1642         ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_ERROR_RETURN_TYPE -Werror=return-type)
1643         # system headers sometimes do this, disable for now, was: -Werror=strict-prototypes
1644         ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_STRICT_PROTOTYPES -Wstrict-prototypes)
1645         ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_NO_CHAR_SUBSCRIPTS -Wno-char-subscripts)
1646         ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_NO_UNKNOWN_PRAGMAS -Wno-unknown-pragmas)
1647         ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_POINTER_ARITH -Wpointer-arith)
1648         ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_UNUSED_PARAMETER -Wunused-parameter)
1649         ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_WRITE_STRINGS -Wwrite-strings)
1650
1651         # # this causes too many warnings, disable
1652         # ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_UNDEFINED -Wundef)
1653
1654         # disable because it gives warnings for printf() & friends.
1655         # ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_DOUBLE_PROMOTION -Wdouble-promotion -Wno-error=double-promotion)
1656
1657         if(NOT APPLE)
1658                 ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_NO_ERROR_UNUSED_BUT_SET_VARIABLE -Wno-error=unused-but-set-variable)
1659         endif()
1660
1661         ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_ALL -Wall)
1662         ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_NO_INVALID_OFFSETOF -Wno-invalid-offsetof)
1663         ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_NO_SIGN_COMPARE -Wno-sign-compare)
1664
1665         # # this causes too many warnings, disable
1666         # ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_UNDEFINED -Wundef)
1667
1668         # flags to undo strict flags
1669         ADD_CHECK_C_COMPILER_FLAG(CC_REMOVE_STRICT_FLAGS C_WARN_NO_DEPRECATED_DECLARATIONS -Wno-deprecated-declarations)
1670         ADD_CHECK_C_COMPILER_FLAG(CC_REMOVE_STRICT_FLAGS C_WARN_NO_UNUSED_PARAMETER        -Wno-unused-parameter)
1671
1672         if(NOT APPLE)
1673                 ADD_CHECK_C_COMPILER_FLAG(CC_REMOVE_STRICT_FLAGS C_WARN_NO_ERROR_UNUSED_BUT_SET_VARIABLE -Wno-error=unused-but-set-variable)
1674         endif()
1675
1676 elseif(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
1677
1678         ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_ALL -Wall)
1679         ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_NO_AUTOLOGICAL_COMPARE -Wno-tautological-compare)
1680         ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_NO_UNKNOWN_PRAGMAS -Wno-unknown-pragmas)
1681         ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_NO_CHAR_SUBSCRIPTS -Wno-char-subscripts)
1682
1683         ADD_CHECK_C_COMPILER_FLAG(CXX_WARNINGS C_WARN_ALL -Wall)
1684         ADD_CHECK_C_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_NO_AUTOLOGICAL_COMPARE -Wno-tautological-compare)
1685         ADD_CHECK_C_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_NO_UNKNOWN_PRAGMAS -Wno-unknown-pragmas)
1686         ADD_CHECK_C_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_NO_CHAR_SUBSCRIPTS -Wno-char-subscripts)
1687         ADD_CHECK_C_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.
1688         ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_NO_INVALID_OFFSETOF -Wno-invalid-offsetof)
1689
1690 elseif(CMAKE_C_COMPILER_ID MATCHES "Intel")
1691
1692         ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_ALL -Wall)
1693         ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_POINTER_ARITH -Wpointer-arith)
1694         ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_NO_UNKNOWN_PRAGMAS -Wno-unknown-pragmas)
1695
1696         ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_ALL -Wall)
1697         ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_NO_INVALID_OFFSETOF -Wno-invalid-offsetof)
1698         ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_NO_SIGN_COMPARE -Wno-sign-compare)
1699
1700         # disable numbered, false positives
1701         set(C_WARNINGS "${C_WARNINGS} -wd188,186,144,913,556")
1702         set(CXX_WARNINGS "${CXX_WARNINGS} -wd188,186,144,913,556")
1703
1704 endif()
1705
1706 # MSVC2010 fails to links C++ libs right
1707 if(MSVC10)
1708         if(WITH_OPENCOLLADA)
1709                 message(WARNING "MSVC 2010 does not support OpenCollada, disabling WITH_OPENCOLLADA. To enable support use Use MSVC 2008")
1710         endif()
1711 endif()
1712
1713 # ensure python header is found since detection can fail, this could happen
1714 # with _any_ library but since we used a fixed python version this tends to
1715 # be most problematic.
1716 if(WITH_PYTHON)
1717         if(NOT EXISTS "${PYTHON_INCLUDE_DIR}/Python.h")
1718                 message(FATAL_ERROR "Missing: \"${PYTHON_INCLUDE_DIR}/Python.h\",\n"
1719                                                         "Set the cache entry 'PYTHON_INCLUDE_DIR' to point "
1720                                                         "to a valid python include path. Containing "
1721                                                         "Python.h for python version \"${PYTHON_VERSION}\"")
1722         endif()
1723
1724         if(WITH_PYTHON_INSTALL AND WITH_PYTHON_INSTALL_NUMPY)
1725                 # set but invalid
1726                 if(NOT ${PYTHON_NUMPY_PATH} STREQUAL "")
1727                         if(NOT EXISTS "${PYTHON_NUMPY_PATH}/numpy")
1728                                 message(WARNING "PYTHON_NUMPY_PATH is invalid, numpy not found in '${PYTHON_NUMPY_PATH}' "
1729                                                 "WITH_PYTHON_INSTALL_NUMPY option will be ignored when installing python")
1730                                 set(WITH_PYTHON_INSTALL_NUMPY OFF)
1731                         endif()
1732                 # not set, so initialize
1733                 else()
1734                         string(REPLACE "." ";" _PY_VER_SPLIT "${PYTHON_VERSION}")
1735                         list(GET _PY_VER_SPLIT 0 _PY_VER_MAJOR)
1736
1737                         # re-cache
1738                         unset(PYTHON_NUMPY_PATH CACHE)
1739                         find_path(PYTHON_NUMPY_PATH
1740                           NAMES
1741                             numpy
1742                           HINTS
1743                             "${PYTHON_LIBPATH}/python${PYTHON_VERSION}/"
1744                             "${PYTHON_LIBPATH}/python${_PY_VER_MAJOR}/"
1745                           PATH_SUFFIXES
1746                             site-packages
1747                             dist-packages
1748                            NO_DEFAULT_PATH
1749                         )
1750
1751                         if(NOT EXISTS "${PYTHON_NUMPY_PATH}")
1752                                 message(WARNING "'numpy' path could not be found in:\n"
1753                                                 "'${PYTHON_LIBPATH}/python${PYTHON_VERSION}/site-packages/numpy', "
1754                                                 "'${PYTHON_LIBPATH}/python${_PY_VER_MAJOR}/site-packages/numpy', "
1755                                                 "'${PYTHON_LIBPATH}/python${PYTHON_VERSION}/dist-packages/numpy', "
1756                                                 "'${PYTHON_LIBPATH}/python${_PY_VER_MAJOR}/dist-packages/numpy', "
1757                                                 "WITH_PYTHON_INSTALL_NUMPY option will be ignored when installing python")
1758                                 set(WITH_PYTHON_INSTALL_NUMPY OFF)
1759                         else()
1760                                 message(STATUS "numpy found at '${PYTHON_NUMPY_PATH}'")
1761                         endif()
1762
1763                         unset(_PY_VER_SPLIT)
1764                         unset(_PY_VER_MAJOR)
1765                 endif()
1766         endif()
1767 endif()
1768
1769
1770 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${PLATFORM_CFLAGS} ${C_WARNINGS}")
1771 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${PLATFORM_CFLAGS} ${CXX_WARNINGS}")
1772
1773 #-------------------------------------------------------------------------------
1774 # Global Defines
1775
1776 # better not set includes here but this debugging option is off by default.
1777 if(WITH_CXX_GUARDEDALLOC)
1778         include_directories(${CMAKE_SOURCE_DIR}/intern/guardedalloc)
1779         add_definitions(-DWITH_CXX_GUARDEDALLOC)
1780 endif()
1781
1782 if(WITH_ASSERT_ABORT)
1783         add_definitions(-DWITH_ASSERT_ABORT)
1784 endif()
1785
1786 # message(STATUS "Using CFLAGS: ${CMAKE_C_FLAGS}")
1787 # message(STATUS "Using CXXFLAGS: ${CMAKE_CXX_FLAGS}")
1788
1789 #-----------------------------------------------------------------------------
1790 # Libraries
1791
1792 add_subdirectory(source)
1793 add_subdirectory(intern)
1794 add_subdirectory(extern)
1795
1796
1797 #-----------------------------------------------------------------------------
1798 # Blender Application
1799 if(WITH_BLENDER)
1800         add_subdirectory(source/creator)
1801 endif()
1802
1803
1804 #-----------------------------------------------------------------------------
1805 # Blender Player
1806 if(WITH_PLAYER)
1807         add_subdirectory(source/blenderplayer)
1808 endif()
1809
1810 #-----------------------------------------------------------------------------
1811 # CPack for generating packages
1812 include(build_files/cmake/packaging.cmake)
1813
1814
1815 #-----------------------------------------------------------------------------
1816 # Print Final Configuration
1817
1818 if(FIRST_RUN)
1819         set(_config_msg "\n* Blender Configuration *")
1820         macro(info_cfg_option
1821                 _setting)
1822                 set(_msg "   * ${_setting}")
1823                 string(LENGTH "${_msg}" _len)
1824                 while("32" GREATER "${_len}")
1825                         set(_msg "${_msg} ")
1826                          math(EXPR _len "${_len} + 1")
1827                 endwhile()
1828
1829                 set(_config_msg "${_config_msg}\n${_msg}${${_setting}}")
1830         endmacro()
1831
1832         macro(info_cfg_text
1833                 _text)
1834                 set(_config_msg "${_config_msg}\n\n  ${_text}")
1835
1836
1837         endmacro()
1838
1839         info_cfg_text("Build Options:")
1840         info_cfg_option(WITH_GAMEENGINE)
1841         info_cfg_option(WITH_PLAYER)
1842         info_cfg_option(WITH_BULLET)
1843         info_cfg_option(WITH_IK_SOLVER)
1844         info_cfg_option(WITH_IK_ITASC)
1845         info_cfg_option(WITH_OPENCOLLADA)
1846         info_cfg_option(WITH_FFTW3)
1847         info_cfg_option(WITH_INTERNATIONAL)
1848         info_cfg_option(WITH_INPUT_NDOF)
1849         info_cfg_option(WITH_CYCLES)
1850         info_cfg_option(WITH_OPENCOLORIO)
1851
1852         info_cfg_text("Compiler Options:")
1853         info_cfg_option(WITH_BUILDINFO)
1854         info_cfg_option(WITH_OPENMP)
1855         info_cfg_option(WITH_RAYOPTIMIZATION)
1856
1857         info_cfg_text("System Options:")
1858         info_cfg_option(WITH_INSTALL_PORTABLE)
1859         info_cfg_option(WITH_X11_XF86VMODE)
1860         info_cfg_option(WITH_X11_XINPUT)
1861         info_cfg_option(WITH_MEM_JEMALLOC)
1862         info_cfg_option(WITH_SYSTEM_GLEW)
1863         info_cfg_option(WITH_SYSTEM_OPENJPEG)
1864
1865         info_cfg_text("Image Formats:")
1866         info_cfg_option(WITH_IMAGE_CINEON)
1867         info_cfg_option(WITH_IMAGE_DDS)
1868         info_cfg_option(WITH_IMAGE_HDR)
1869         info_cfg_option(WITH_IMAGE_OPENEXR)
1870         info_cfg_option(WITH_IMAGE_OPENJPEG)
1871         info_cfg_option(WITH_IMAGE_REDCODE)
1872         info_cfg_option(WITH_IMAGE_TIFF)
1873
1874         info_cfg_text("Audio:")
1875         info_cfg_option(WITH_OPENAL)
1876         info_cfg_option(WITH_SDL)
1877         info_cfg_option(WITH_JACK)
1878         info_cfg_option(WITH_CODEC_FFMPEG)
1879         info_cfg_option(WITH_CODEC_SNDFILE)
1880
1881         info_cfg_text("Compression:")
1882         info_cfg_option(WITH_LZMA)
1883         info_cfg_option(WITH_LZO)
1884
1885         info_cfg_text("Python:")
1886         info_cfg_option(WITH_PYTHON_INSTALL)
1887         info_cfg_option(WITH_PYTHON_INSTALL_NUMPY)
1888         info_cfg_option(WITH_PYTHON_MODULE)
1889         info_cfg_option(WITH_PYTHON_SAFETY)
1890
1891         info_cfg_text("Modifiers:")
1892         info_cfg_option(WITH_MOD_BOOLEAN)
1893         info_cfg_option(WITH_MOD_REMESH)
1894         info_cfg_option(WITH_MOD_DECIMATE)
1895         info_cfg_option(WITH_MOD_FLUID)
1896         info_cfg_option(WITH_MOD_OCEANSIM)
1897
1898         info_cfg_text("")
1899
1900         message("${_config_msg}")
1901 endif()