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