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