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