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