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