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