fix [#26656] video sequence editor rendering stops at frame 9999
[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 message(FATAL_ERROR "CMake generation for blender is not allowed within the source directory! 
35 Remove the CMakeCache.txt file and try again from another folder, e.g.: 
36
37         rm CMakeCache.txt 
38         cd ..
39         mkdir cmake-make 
40         cd cmake-make
41         cmake ../blender
42 ")
43 endif()
44
45 cmake_minimum_required(VERSION 2.8)
46
47 # quiet output for Makefiles, 'make -s' helps too
48 # set_property(GLOBAL PROPERTY RULE_MESSAGES OFF)
49
50 project(Blender)
51
52 enable_testing()
53
54 #-----------------------------------------------------------------------------
55 # Redirect output files
56
57 set(EXECUTABLE_OUTPUT_PATH ${CMAKE_BINARY_DIR}/bin CACHE INTERNAL "" FORCE )
58 set(LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR}/lib CACHE INTERNAL "" FORCE )
59
60 #-----------------------------------------------------------------------------
61 # Load some macros.
62 include(build_files/cmake/macros.cmake)
63
64 #-----------------------------------------------------------------------------
65 # Set default config options
66
67 get_blender_version()
68
69 # Blender internal features
70 option(WITH_INTERNATIONAL "Enable I18N (International fonts and text)" ON)
71 option(WITH_PYTHON        "Enable Embedded Python API  (only disable for development)" ON)
72 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)
73 option(WITH_PYTHON_MODULE "Enable building as a python module (experemental, only enable for development)" OFF)
74 option(WITH_BUILDINFO     "Include extra build details (only disable for development & faster builds)" ON)
75 option(WITH_IK_ITASC      "Enable ITASC IK solver (only disable for development & for incompatible C++ compilers)" ON)
76 option(WITH_FFTW3         "Enable FFTW3 support (Used for smoke and audio effects)" OFF)
77 option(WITH_BULLET        "Enable Bullet (Physics Engine)" ON)
78 option(WITH_GAMEENGINE    "Enable Game Engine" ON)
79 option(WITH_PLAYER        "Build Player" OFF)
80 # (unix defaults to OpenMP On)
81 if(UNIX AND NOT APPLE)
82         option(WITH_OPENMP        "Enable OpenMP (has to be supported by the compiler)" ON)
83 else()
84         option(WITH_OPENMP        "Enable OpenMP (has to be supported by the compiler)" OFF)
85 endif()
86
87 if(UNIX AND NOT APPLE)
88         option(WITH_X11_XINPUT "Enable X11 Xinput (tablet support)"     ON)
89 endif()
90
91 # Modifiers
92 option(WITH_MOD_FLUID           "Enable Elbeem Modifier (Fluid Simulation)" ON)
93 option(WITH_MOD_DECIMATE        "Enable Decimate Modifier" ON)
94 option(WITH_MOD_BOOLEAN         "Enable Boolean Modifier" ON)
95
96 # Image format support
97 option(WITH_IMAGE_OPENEXR       "Enable OpenEXR Support (http://www.openexr.com)" ON)
98 option(WITH_IMAGE_OPENJPEG      "Enable OpenJpeg Support (http://www.openjpeg.org)" ON)
99 option(WITH_IMAGE_TIFF          "Enable LibTIFF Support" ON)
100 option(WITH_IMAGE_DDS           "Enable DDS Image Support" ON)
101 option(WITH_IMAGE_CINEON        "Enable CINEON and DPX Image Support" ON)
102 option(WITH_IMAGE_HDR           "Enable HDR Image Support" ON)
103 option(WITH_IMAGE_REDCODE       "Enable RedCode Image Support" OFF)
104
105 # Audio/Video format support
106 option(WITH_CODEC_FFMPEG        "Enable FFMPeg Support (http://ffmpeg.mplayerhq.hu)" OFF)
107 option(WITH_CODEC_SNDFILE       "Enable libsndfile Support (http://www.mega-nerd.com/libsndfile)" OFF)
108 if(APPLE OR (WIN32 AND NOT UNIX))
109         option(WITH_CODEC_QUICKTIME     "Enable Quicktime Support" OFF)
110 endif()
111
112 # 3D format support
113 # disable opencollada on non-apple unix because opencollada has no package for debian
114 option(WITH_OPENCOLLADA         "Enable OpenCollada Support (http://www.opencollada.org)"       OFF)
115
116 # Sound output
117 option(WITH_SDL           "Enable SDL for sound and joystick support" ON)
118 option(WITH_OPENAL        "Enable OpenAL Support (http://www.openal.org)" ON)
119 option(WITH_JACK          "Enable Jack Support (http://www.jackaudio.org)" OFF)
120 option(WITH_SAMPLERATE    "Enable samplerate conversion" ON)
121
122 # Compression
123 option(WITH_LZO           "Enable fast LZO compression (used for pointcache)" ON)
124 option(WITH_LZMA          "Enable best LZMA compression, (used for pointcache)" ON)
125
126 # Misc
127 option(WITH_RAYOPTIMIZATION     "Enable use of SIMD (SSE) optimizations for the raytracer" ON) 
128 if(UNIX AND NOT APPLE)
129         option(WITH_INSTALL_PORTABLE "Install redistributeable runtime, otherwise install into CMAKE_INSTALL_PREFIX" ON)
130 endif()
131 option(WITH_PYTHON_INSTALL       "Copy system python into the blender install folder" ON)
132
133 # Debug
134 option(WITH_CXX_GUARDEDALLOC "Enable GuardedAlloc for C++ memory allocation tracking (only enable for development)" OFF)
135 mark_as_advanced(WITH_CXX_GUARDEDALLOC)
136
137 option(WITH_ASSERT_ABORT "Call abort() when raising an assertion through BLI_assert()" OFF)
138 mark_as_advanced(WITH_ASSERT_ABORT)
139
140 if(APPLE)
141         if(NOT CMAKE_OSX_ARCHITECTURES)
142                 set(CMAKE_OSX_ARCHITECTURES x86_64 CACHE STRING
143                 "Choose the architecture you want to build Blender for: i386, x86_64 or ppc"
144                 FORCE)
145         endif()
146         if(NOT CMAKE_OSX_DEPLOYMENT_TARGET)
147                 set(CMAKE_OSX_DEPLOYMENT_TARGET 10.5 CACHE STRING
148                 "Choose the minimum OSX version required: 10.4 or 10.5"
149                 FORCE)
150         endif()
151         option(WITH_COCOA         "Use Cocoa framework instead of deprecated Carbon" ON)
152         option(USE_QTKIT          "Use QtKit instead of Carbon quicktime (needed for having partial quicktime for 64bit)" OFF)
153         option(WITH_LIBS10.5  "Use 10.5 libs (needed for 64bit builds)" OFF)
154 endif()
155
156 # only for developers who want to make this functional
157 # option(WITH_LCMS          "Enable color correction with lcms" OFF)
158
159 if(NOT WITH_GAMEENGINE AND WITH_PLAYER)
160         message(FATAL_ERROR "WITH_PLAYER requires WITH_GAMEENGINE")
161 endif()
162
163 if(NOT WITH_SAMPLERATE AND (WITH_OPENAL OR WITH_SDL OR WITH_JACK))
164         message(FATAL_ERROR "WITH_OPENAL/WITH_SDL/WITH_JACK require WITH_SAMPLERATE")
165 endif()
166
167 if(NOT WITH_IMAGE_OPENJPEG AND WITH_IMAGE_REDCODE)
168         message(FATAL_ERROR "WITH_IMAGE_REDCODE requires WITH_IMAGE_OPENJPEG")
169 endif()
170
171 # python module, needs some different options
172 if(WITH_PYTHON_MODULE AND WITH_PLAYER)
173         message(FATAL_ERROR "WITH_PYTHON_MODULE requires WITH_PLAYER to be OFF")
174 endif()
175
176 if(WITH_PYTHON_MODULE AND WITH_PYTHON_INSTALL)
177         message(FATAL_ERROR "WITH_PYTHON_MODULE requires WITH_PYTHON_INSTALL to be OFF")
178 endif()
179
180 # remove old vars
181 unset(WITH_INSTALL CACHE)
182
183 TEST_SSE_SUPPORT()
184
185 #-----------------------------------------------------------------------------
186 # Initialize un-cached vars, avoid unused warning
187
188 # linux only, not cached
189 set(WITH_BINRELOC OFF)
190
191 # these are added to later on.
192 set(C_WARNINGS "")
193 set(CXX_WARNINGS "")
194
195
196 # disabled for now, not supported
197 # option(WITH_WEBPLUGIN     "Enable Web Plugin (Unix only)" OFF)
198
199 # For alternate Python locations the commandline can be used to override detected/default cache settings, e.g:
200 # On Unix: 
201 #   cmake ../blender \
202 #         -D PYTHON_VERSION=3.2 \
203 #         -D PYTHON_INCLUDE_DIRS=/opt/py32/include/python3.2d \
204 #         -D PYTHON_LIBPATH=/opt/py32/lib \
205 #         -D PYTHON_LIBRARY=python3.2d
206 #
207 # On Macs: 
208 #   cmake ../blender \
209 #         -D PYTHON_INCLUDE_DIRS=/System/Library/Frameworks/Python.framework/Versions/3.2/include/python3.2 \
210 #         -D PYTHON_LIBPATH=/System/Library/Frameworks/Python.framework/Versions/3.2/lib/python3.2/config \
211 #         -G Xcode
212 #
213 # When changing any of this remember to update the notes in doc/build_systems/cmake.txt
214
215 #-----------------------------------------------------------------------------
216 #Platform specifics
217
218 if(UNIX AND NOT APPLE)
219         
220         # needed for ubuntu 11.04
221         if(EXISTS "/usr/lib/x86_64-linux-gnu")
222                 set(CMAKE_LIBRARY_PATH "/usr/lib/x86_64-linux-gnu;${CMAKE_LIBRARY_PATH}")
223         endif()
224
225         if(WITH_OPENAL)
226                 find_package(OpenAL)
227                 if(NOT OPENAL_FOUND)
228                         set(WITH_OPENAL OFF)
229                 endif()
230         endif()
231
232         if(WITH_JACK)
233                 set(JACK /usr)
234                 set(JACK_INC ${JACK}/include/jack)
235                 set(JACK_LIB jack)
236                 set(JACK_LIBPATH ${JACK}/lib)
237         endif()
238
239         if(WITH_CODEC_SNDFILE)
240                 set(SNDFILE /usr)
241                 set(SNDFILE_INC ${SNDFILE}/include)
242                 set(SNDFILE_LIB sndfile)
243                 set(SNDFILE_LIBPATH ${SNDFILE}/lib)
244         endif()
245
246         if(WITH_INTERNATIONAL)
247                 find_library(INTL_LIBRARY
248                         NAMES intl
249                         PATHS
250                         /sw/lib
251                 )
252
253                 find_library(ICONV_LIBRARY
254                         NAMES iconv
255                         PATHS
256                         /sw/lib
257                 )
258                 mark_as_advanced(ICONV_LIBRARY)
259                 mark_as_advanced(INTL_LIBRARY)
260
261                 if(INTL_LIBRARY AND ICONV_LIBRARY)
262                         set(GETTEXT_LIB ${INTL_LIBRARY} ${ICONV_LIBRARY})
263                 endif()
264         endif()
265
266         find_package(Freetype)
267         # unset(FREETYPE_INCLUDE_DIRS CACHE) # cant use
268
269
270         if(WITH_PYTHON)
271                 # No way to set py32. remove for now.
272                 # find_package(PythonLibs)
273
274                 # defines...
275                 
276                 #  PYTHON_VERSION
277                 #  PYTHON_INCLUDE_DIRS
278                 #  PYTHON_LIBRARY
279                 #  PYTHON_LIBPATH
280                 #  PYTHON_LINKFLAGS
281
282                 include(build_files/cmake/FindPythonLibsUnix.cmake)
283
284         endif()
285
286         if(WITH_SDL)
287                 find_package(SDL)
288                 mark_as_advanced(SDLMAIN_LIBRARY)
289                 mark_as_advanced(SDL_INCLUDE_DIR)
290                 mark_as_advanced(SDL_LIBRARY)
291                 mark_as_advanced(SDL_LIBRARY_TEMP)
292                 # unset(SDLMAIN_LIBRARY CACHE)
293                 if(NOT SDL_FOUND)
294                         set(WITH_SDL OFF)
295                 endif()
296         endif()
297
298         if(WITH_IMAGE_OPENEXR)
299                 set(OPENEXR /usr CACHE FILEPATH "OPENEXR Directory")
300                 mark_as_advanced(OPENEXR)
301                 find_path(OPENEXR_INC
302                         ImfXdr.h
303                         PATHS
304                         ${OPENEXR}/include/OpenEXR
305                         /usr/local/include/OpenEXR
306                         /sw/include/OpenEXR
307                         /opt/local/include/OpenEXR
308                         /opt/csw/include/OpenEXR
309                         /opt/include/OpenEXR
310                 )
311                 mark_as_advanced(OPENEXR_INC)
312
313                 set(OPENEXR_LIB Half IlmImf Iex Imath)
314                 
315                 if(NOT OPENEXR_INC)
316                         set(WITH_IMAGE_OPENEXR OFF)
317                 endif()
318         endif()
319
320         if(WITH_IMAGE_TIFF)
321                 find_package(TIFF)
322                 if(NOT TIFF_FOUND)
323                         set(WITH_IMAGE_TIFF OFF)
324                 endif()
325         endif()
326
327         find_package(JPEG REQUIRED)
328
329         find_package(PNG REQUIRED)
330
331         find_package(ZLIB REQUIRED)
332
333         if(WITH_LCMS)
334                 set(LCMS /usr CACHE FILEPATH "LCMS directory")
335                 set(LCMS_INCLUDE_DIR ${LCMS}/include)
336                 set(LCMS_LIBRARY lcms)
337                 set(LCMS_LIBPATH ${LCMS}/lib)
338         endif()
339
340         if(WITH_CODEC_FFMPEG)
341                 set(FFMPEG /usr CACHE FILEPATH "FFMPEG Directory")
342                 mark_as_advanced(FFMPEG)
343                 set(FFMPEG_INC ${FFMPEG}/include)
344                 set(FFMPEG_LIB avformat avcodec avutil avdevice swscale CACHE STRING "FFMPEG Libraries")
345                 mark_as_advanced(FFMPEG_LIB)
346                 set(FFMPEG_LIBPATH ${FFMPEG}/lib)
347                 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D__STDC_CONSTANT_MACROS")
348         endif()
349
350         if(WITH_FFTW3)
351                 set(FFTW3 /usr)
352                 set(FFTW3_INC ${FFTW3}/include)
353                 set(FFTW3_LIB fftw3)
354                 set(FFTW3_LIBPATH ${FFTW3}/lib)
355         endif()
356
357         if(WITH_SAMPLERATE)
358                 set(LIBSAMPLERATE /usr)
359                 set(LIBSAMPLERATE_INC ${LIBSAMPLERATE}/include)
360                 set(LIBSAMPLERATE_LIB samplerate)
361                 set(LIBSAMPLERATE_LIBPATH ${LIBSAMPLERATE}/lib)
362         endif()
363
364         if(WITH_OPENCOLLADA)
365                 set(OPENCOLLADA /usr/local/opencollada CACHE FILEPATH "OpenCollada Directory")
366                 mark_as_advanced(OPENCOLLADA)
367                 set(OPENCOLLADA_LIBPATH ${OPENCOLLADA}/lib)
368                 set(OPENCOLLADA_LIB OpenCOLLADAStreamWriter OpenCOLLADASaxFrameworkLoader OpenCOLLADAFramework OpenCOLLADABaseUtils GeneratedSaxParser UTF MathMLSolver pcre ftoa buffer xml2)
369                 set(OPENCOLLADA_INC ${OPENCOLLADA})
370
371                 set(PCRE /usr CACHE FILEPATH "PCRE Directory")
372                 mark_as_advanced(PCRE)
373                 set(PCRE_LIBPATH ${PCRE}/lib)
374                 set(PCRE_LIB pcre)
375
376                 set(EXPAT /usr CACHE FILEPATH "Expat Directory")
377                 mark_as_advanced(EXPAT)
378                 set(EXPAT_LIBPATH ${EXPAT}/lib)
379                 set(EXPAT_LIB expat)
380         endif()
381
382         find_package(X11 REQUIRED)
383         find_path(X11_XF86keysym_INCLUDE_PATH X11/XF86keysym.h ${X11_INC_SEARCH_PATH})
384         mark_as_advanced(X11_XF86keysym_INCLUDE_PATH)
385
386         # OpenSuse needs lutil, ArchLinux not, for now keep, can avoid by using --as-needed
387         set(LLIBS "-lutil -lc -lm -lpthread -lstdc++ ${X11_X11_LIB}")
388
389         if(WITH_X11_XINPUT)
390                 list(APPEND LLIBS ${X11_Xinput_LIB})
391         endif()
392
393         if(CMAKE_SYSTEM_NAME MATCHES "Linux")
394                 if(NOT WITH_PYTHON_MODULE)
395                         # BSD's dont use libdl.so
396                         list(APPEND LLIBS -ldl)
397
398                         # binreloc is linux only
399                         set(BINRELOC ${CMAKE_SOURCE_DIR}/extern/binreloc)
400                         set(BINRELOC_INC ${BINRELOC}/include)
401                         set(WITH_BINRELOC ON)
402                 endif()
403         endif()
404
405         set(PLATFORM_LINKFLAGS "-pthread")
406
407         set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE")
408         set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE")
409
410         # GNU Compiler
411         if(CMAKE_COMPILER_IS_GNUCC)
412                 set(PLATFORM_CFLAGS "-pipe -fPIC -funsigned-char -fno-strict-aliasing")
413         # Intel C++ Compiler
414         elseif(CMAKE_C_COMPILER_ID MATCHES "Intel")
415                 # think these next two are broken
416                 find_program(XIAR xiar) 
417                 if(XIAR) 
418                         set(CMAKE_AR "${XIAR}")
419                 endif() 
420                 mark_as_advanced(XIAR)
421
422                 find_program(XILD xild) 
423                 if(XILD) 
424                         set(CMAKE_LINKER "${XILD}")
425                 endif() 
426                 mark_as_advanced(XILD)
427
428                 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fp-model precise -prec_div -parallel")
429                 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fp-model precise -prec_div -parallel")
430
431                 # set(PLATFORM_CFLAGS "${PLATFORM_CFLAGS} -diag-enable sc3")
432                 set(PLATFORM_CFLAGS "-pipe -fPIC -funsigned-char -fno-strict-aliasing")
433                 set(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} -static-intel")
434         endif()
435
436 elseif(WIN32)
437
438         # this file is included anyway when building under Windows with cl.exe
439         #  include(${CMAKE_ROOT}/Modules/Platform/Windows-cl.cmake)
440
441         set(LIBDIR ${CMAKE_SOURCE_DIR}/../lib/windows)
442
443         # Setup 64bit and 64bit windows systems
444         if(CMAKE_CL_64)
445                 message("64 bit compiler detected.")
446                 set(LIBDIR ${CMAKE_SOURCE_DIR}/../lib/win64)
447         endif()
448         
449         add_definitions(-DWIN32)
450
451         if(WITH_INTERNATIONAL)
452                 set(ICONV ${LIBDIR}/iconv)
453                 set(ICONV_INC ${ICONV}/include)
454                 set(ICONV_LIB iconv)
455                 set(ICONV_LIBPATH ${ICONV}/lib)
456         endif()
457
458         if(WITH_SAMPLERATE)
459                 set(LIBSAMPLERATE ${LIBDIR}/samplerate)
460                 set(LIBSAMPLERATE_INC ${LIBSAMPLERATE}/include)
461                 set(LIBSAMPLERATE_LIB libsamplerate)
462                 set(LIBSAMPLERATE_LIBPATH ${LIBSAMPLERATE}/lib)
463         endif()
464
465         set(PNG "${LIBDIR}/png")
466         set(PNG_INCLUDE_DIR "${PNG}/include")
467         set(PNG_LIBPATH ${PNG}/lib) # not cmake defined
468
469         set(JPEG "${LIBDIR}/jpeg")
470         set(JPEG_INCLUDE_DIR "${JPEG}/include")
471         set(JPEG_LIBPATH ${JPEG}/lib) # not cmake defined
472
473         set(WINTAB_INC ${LIBDIR}/wintab/include) 
474
475         if(WITH_OPENAL)
476                 set(OPENAL ${LIBDIR}/openal)
477                 set(OPENAL_INCLUDE_DIR ${OPENAL}/include)
478                 set(OPENAL_LIBRARY wrap_oal)
479                 set(OPENAL_LIBPATH ${OPENAL}/lib)
480         endif()
481
482         if(WITH_CODEC_SNDFILE)
483                 set(SNDFILE ${LIBDIR}/sndfile)
484                 set(SNDFILE_INC ${SNDFILE}/include)
485                 set(SNDFILE_LIB libsndfile-1)
486                 set(SNDFILE_LIBPATH ${SNDFILE}/lib)
487         endif()
488
489         if(WITH_SDL)
490                 set(SDL ${LIBDIR}/sdl)
491                 set(SDL_INCLUDE_DIR ${SDL}/include)
492                 set(SDL_LIBRARY SDL)
493                 set(SDL_LIBPATH ${SDL}/lib)
494         endif()
495
496         if(WITH_CODEC_QUICKTIME)
497                 set(QUICKTIME ${LIBDIR}/QTDevWin)
498                 set(QUICKTIME_INC ${QUICKTIME}/CIncludes)
499                 set(QUICKTIME_LIB qtmlClient)
500                 set(QUICKTIME_LIBPATH ${QUICKTIME}/Libraries)
501         endif()
502
503         if(WITH_RAYOPTIMIZATION AND SUPPORT_SSE_BUILD)
504                 add_definitions(-D__SSE__ -D__MMX__)
505         endif()
506
507         if(MSVC)
508                 if(CMAKE_CL_64)
509                         set(LLIBS kernel32 user32 vfw32 winmm ws2_32 )
510                 else()
511                         set(LLIBS kernel32 user32 gdi32 comdlg32 advapi32 shell32 ole32 oleaut32 uuid ws2_32 vfw32 winmm)
512                 endif()
513                 
514                 set(CMAKE_CXX_FLAGS "/D_CRT_NONSTDC_NO_DEPRECATE /D_CRT_SECURE_NO_DEPRECATE /D_SCL_SECURE_NO_DEPRECATE /we4013 /wd4018 /wd4800 /wd4244 /wd4305 /wd4065 /wd4267" CACHE STRING "MSVC MT C++ flags " FORCE)
515                 set(CMAKE_C_FLAGS   "/D_CRT_NONSTDC_NO_DEPRECATE /D_CRT_SECURE_NO_DEPRECATE /D_SCL_SECURE_NO_DEPRECATE /we4013 /wd4018 /wd4800 /wd4244 /wd4305 /wd4065 /wd4267" CACHE STRING "MSVC MT C++ flags " FORCE)
516
517                 if(CMAKE_CL_64)
518                         set(CMAKE_CXX_FLAGS_DEBUG "/D_DEBUG /Od /Gm /EHsc /RTC1 /MTd /W3 /nologo /Zi /J" CACHE STRING "MSVC MT flags " FORCE)
519                 else()
520                         set(CMAKE_CXX_FLAGS_DEBUG "/D_DEBUG /Od /Gm /EHsc /RTC1 /MTd /W3 /nologo /ZI /J" CACHE STRING "MSVC MT flags " FORCE)
521                 endif()
522                 set(CMAKE_CXX_FLAGS_RELEASE "/O2 /Ob2 /DNDEBUG /EHsc /MT /W3 /nologo /J" CACHE STRING "MSVC MT flags " FORCE)
523                 set(CMAKE_CXX_FLAGS_MINSIZEREL "/O1 /Ob1 /DNDEBUG /EHsc /MT /W3 /nologo /J" CACHE STRING "MSVC MT flags " FORCE)
524                 set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "/O2 /Ob1 /DNDEBUG /EHsc /MT /W3 /nologo /Zi /J" CACHE STRING "MSVC MT flags " FORCE)
525                 if(CMAKE_CL_64)
526                         set(CMAKE_C_FLAGS_DEBUG "/D_DEBUG /Od /Gm /EHsc /RTC1 /MTd /W3 /nologo /Zi /J" CACHE STRING "MSVC MT flags " FORCE)
527                 else()
528                         set(CMAKE_C_FLAGS_DEBUG "/D_DEBUG /Od /Gm /EHsc /RTC1 /MTd /W3 /nologo /ZI /J" CACHE STRING "MSVC MT flags " FORCE)
529                 endif()
530                 set(CMAKE_C_FLAGS_RELEASE "/O2 /Ob2 /DNDEBUG /EHsc /MT /W3 /nologo /J" CACHE STRING "MSVC MT flags " FORCE)
531                 set(CMAKE_C_FLAGS_MINSIZEREL "/O1 /Ob1 /DNDEBUG /EHsc /MT /W3 /nologo /J" CACHE STRING "MSVC MT flags " FORCE)
532                 set(CMAKE_C_FLAGS_RELWITHDEBINFO "/O2 /Ob1 /DNDEBUG /EHsc /MT /W3 /nologo /Zi /J" CACHE STRING "MSVC MT flags " FORCE)
533
534                 if(WITH_INTERNATIONAL)
535                         set(GETTEXT ${LIBDIR}/gettext)
536                         set(GETTEXT_INC ${GETTEXT}/include)
537                         set(GETTEXT_LIBPATH ${GETTEXT}/lib)
538                         if(CMAKE_CL_64)
539                                 set(GETTEXT_LIB gettext)
540                         else()
541                                 set(GETTEXT_LIB gnu_gettext)
542                         endif()
543                 endif()
544
545                 if(CMAKE_CL_64)
546                         set(PNG_LIBRARIES libpng)
547                 else()
548                         set(PNG_LIBRARIES libpng_st)
549                 endif()
550                 set(JPEG_LIBRARIES libjpeg)
551
552                 set(ZLIB ${LIBDIR}/zlib)
553                 set(ZLIB_INCLUDE_DIRS ${ZLIB}/include)
554                 set(ZLIB_LIBPATH ${ZLIB}/lib)
555                 if(CMAKE_CL_64)
556                         set(ZLIB_LIBRARIES libz)
557                 else()
558                         set(ZLIB_LIBRARIES zlib)
559                 endif()
560
561                 set(PTHREADS ${LIBDIR}/pthreads)
562                 set(PTHREADS_INC ${PTHREADS}/include)
563                 set(PTHREADS_LIBPATH ${PTHREADS}/lib)
564                 set(PTHREADS_LIB pthreadVC2)
565                 
566                 set(FREETYPE ${LIBDIR}/freetype)
567                 set(FREETYPE_INCLUDE_DIRS ${FREETYPE}/include ${FREETYPE}/include/freetype2)
568                 set(FREETYPE_LIBPATH ${FREETYPE}/lib)
569                 set(FREETYPE_LIBRARY freetype2ST)
570
571                 if(WITH_FFTW3)
572                         set(FFTW3 ${LIBDIR}/fftw3)
573                         set(FFTW3_LIB libfftw)
574                         set(FFTW3_INC ${FFTW3}/include)
575                         set(FFTW3_LIBPATH ${FFTW3}/lib)
576                 endif()
577
578                 if(WITH_OPENCOLLADA)
579                         set(OPENCOLLADA ${LIBDIR}/opencollada)
580                         set(OPENCOLLADA_INC ${OPENCOLLADA}/include)
581                         set(OPENCOLLADA_LIBPATH ${OPENCOLLADA}/lib)
582                         set(OPENCOLLADA_LIB OpenCOLLADASaxFrameworkLoader OpenCOLLADAFramework OpenCOLLADABaseUtils OpenCOLLADAStreamWriter MathMLSolver GeneratedSaxParser xml2 buffer ftoa UTF)
583                         set(PCRE_LIB pcre)
584                 endif()
585                 
586                 if(WITH_LCMS)
587                         set(LCMS ${LIBDIR}/lcms)
588                         set(LCMS_INCLUDE_DIR ${LCMS}/include)
589                         set(LCMS_LIBPATH ${LCMS}/lib)
590                         set(LCMS_LIB lcms)
591                 endif()
592
593                 if(WITH_CODEC_FFMPEG)
594                         set(FFMPEG ${LIBDIR}/ffmpeg)
595                         set(FFMPEG_INC ${FFMPEG}/include ${FFMPEG}/include/msvc)
596                         set(FFMPEG_LIB avcodec-52 avformat-52 avdevice-52 avutil-50 swscale-0)
597                         set(FFMPEG_LIBPATH ${FFMPEG}/lib)
598                 endif()
599
600                 if(WITH_IMAGE_OPENEXR)
601                         if(MSVC80)
602                                 set(MSVC_LIB _vs2005)
603                                 set(MSVC_INC)
604                         elseif(MSVC90)
605                                 set(MSVC_LIB _vs2008)
606                                 set(MSVC_INC)
607                         elseif(MSVC10)
608                                 set(MSVC_LIB _vs2010)
609                                 set(MSVC_INC _vs2010)
610                         else()
611                                 set(MSVC_LIB msvc)
612                                 set(MSVC_INC)
613                         endif()
614                         set(OPENEXR ${LIBDIR}/openexr)                  
615                         set(OPENEXR_LIB Iex Half IlmImf Imath IlmThread)
616                         set(OPENEXR_LIBPATH ${OPENEXR}/lib${MSVC_LIB})
617                         set(OPENEXR_INCUDE ${OPENEXR}/include${MSVC_INC})
618                         set(OPENEXR_INC ${OPENEXR_INCUDE}/ ${OPENEXR_INCUDE}/IlmImf ${OPENEXR_INCUDE}/Iex ${OPENEXR_INCUDE}/Imath)
619                 endif()
620
621                 if(WITH_IMAGE_TIFF)
622                         set(TIFF ${LIBDIR}/tiff)
623                         set(TIFF_LIBRARY libtiff)
624                         set(TIFF_INCLUDE_DIR ${TIFF}/include)
625                         set(TIFF_LIBPATH ${TIFF}/lib)
626                 endif()
627
628                 if(WITH_JACK)
629                         set(JACK ${LIBDIR}/jack)
630                         set(JACK_INC ${JACK}/include/jack ${JACK}/include)
631                         set(JACK_LIB libjack)
632                         set(JACK_LIBPATH ${JACK}/lib)
633                 endif()
634
635                 if(WITH_PYTHON)
636                         set(PYTHON ${LIBDIR}/python)
637                         set(PYTHON_VERSION 3.2)
638                         set(PYTHON_INCLUDE_DIRS "${PYTHON}/include/python${PYTHON_VERSION}")
639                         # set(PYTHON_BINARY python) # not used yet
640                         set(PYTHON_LIBRARY python32)
641                         set(PYTHON_LIBPATH ${PYTHON}/lib)
642                 endif()
643
644                 # MSVC only, Mingw doesnt need
645                 if(CMAKE_CL_64)
646                         set(PLATFORM_LINKFLAGS "/MACHINE:X64 /NODEFAULTLIB:libc.lib /STACK:2097152 ")
647                 else()
648                         set(PLATFORM_LINKFLAGS "/NODEFAULTLIB:libc.lib /STACK:2097152 ")
649                 endif()
650
651                 set(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} /NODEFAULTLIB:libcmt.lib;libc.lib ")
652
653         else()
654                 # keep GCC spesific stuff here
655                 if(CMAKE_COMPILER_IS_GNUCC)
656                         set(LLIBS "-lshell32 -lshfolder -lgdi32 -lmsvcrt -lwinmm -lmingw32 -lm -lws2_32 -lz -lstdc++ -lole32 -luuid")
657                         set(PLATFORM_CFLAGS "-pipe -funsigned-char -fno-strict-aliasing")
658
659                         set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE")
660                         set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE")
661                 endif()
662
663                 add_definitions(-DFREE_WINDOWS)
664
665                 set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -D_DEBUG")
666                 set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -D_DEBUG")
667
668                 if(WITH_INTERNATIONAL)
669                         set(GETTEXT ${LIBDIR}/gcc/gettext)
670                         set(GETTEXT_INC ${GETTEXT}/include)
671                         set(GETTEXT_LIBPATH ${GETTEXT}/lib)
672                         set(GETTEXT_LIB intl)
673                 endif()
674
675                 set(JPEG_LIBRARIES libjpeg)
676                 set(PNG_LIBRARIES png)
677
678                 set(ZLIB ${LIBDIR}/zlib)
679                 set(ZLIB_INCLUDE_DIRS ${ZLIB}/include)
680                 set(ZLIB_LIBPATH ${ZLIB}/lib)
681                 set(ZLIB_LIBRARIES z)
682
683                 set(PTHREADS ${LIBDIR}/pthreads)
684                 set(PTHREADS_INC ${PTHREADS}/include)
685                 set(PTHREADS_LIBPATH ${PTHREADS}/lib)
686                 set(PTHREADS_LIB pthreadGC2)
687                 
688                 set(FREETYPE ${LIBDIR}/gcc/freetype)
689                 set(FREETYPE_INCLUDE_DIRS ${FREETYPE}/include ${FREETYPE}/include/freetype2)
690                 set(FREETYPE_LIBPATH ${FREETYPE}/lib)
691                 set(FREETYPE_LIBRARY freetype)
692
693                 if(WITH_FFTW3)
694                         set(FFTW3 ${LIBDIR}/gcc/fftw3)
695                         set(FFTW3_LIB fftw3)
696                         set(FFTW3_INC ${FFTW3}/include)
697                         set(FFTW3_LIBPATH ${FFTW3}/lib)
698                 endif()
699
700                 if(WITH_OPENCOLLADA)
701                         set(OPENCOLLADA ${LIBDIR}/gcc/opencollada)
702                         set(OPENCOLLADA_INC ${OPENCOLLADA}/include)
703                         set(OPENCOLLADA_LIBPATH ${OPENCOLLADA}/lib ${OPENCOLLADA}/lib)
704                         set(OPENCOLLADA_LIB OpenCOLLADAStreamWriter OpenCOLLADASaxFrameworkLoader OpenCOLLADAFramework OpenCOLLADABaseUtils GeneratedSaxParser UTF MathMLSolver expat pcre buffer ftoa)
705                         set(PCRE_LIB pcre)
706                 endif()
707                 
708                 if(WITH_CODEC_FFMPEG)
709                         set(FFMPEG ${LIBDIR}/ffmpeg)
710                         set(FFMPEG_INC ${FFMPEG}/include ${FFMPEG}/include)
711                         set(FFMPEG_LIB avcodec-52 avformat-52 avdevice-52 avutil-50 swscale-0)
712                         set(FFMPEG_LIBPATH ${FFMPEG}/lib)
713                 endif()
714
715                 if(WITH_IMAGE_OPENEXR)
716                         set(OPENEXR ${LIBDIR}/gcc/openexr)
717                         set(OPENEXR_INC ${OPENEXR}/include ${OPENEXR}/include/OpenEXR)
718                         set(OPENEXR_LIB Half IlmImf Imath IlmThread)
719                         set(OPENEXR_LIBPATH ${OPENEXR}/lib)
720
721                         # TODO, gives linking errors, force off
722                         set(WITH_IMAGE_OPENEXR OFF)
723                 endif()
724
725                 if(WITH_IMAGE_TIFF)
726                         set(TIFF ${LIBDIR}/gcc/tiff)
727                         set(TIFF_LIBRARY tiff)
728                         set(TIFF_INCLUDE_DIR ${TIFF}/include)
729                         set(TIFF_LIBPATH ${TIFF}/lib)
730                 endif()
731
732                 if(WITH_JACK)
733                         set(JACK ${LIBDIR}/jack)
734                         set(JACK_INC ${JACK}/include/jack ${JACK}/include)
735                         set(JACK_LIB jack)
736                         set(JACK_LIBPATH ${JACK}/lib)
737                         
738                         # TODO, gives linking errors, force off
739                         set(WITH_JACK OFF)
740                 endif()
741
742                 if(WITH_PYTHON)
743                         set(PYTHON ${LIBDIR}/python)
744                         set(PYTHON_VERSION 3.2)
745                         set(PYTHON_INCLUDE_DIRS "${PYTHON}/include/python${PYTHON_VERSION}")
746                         # set(PYTHON_BINARY python) # not used yet
747                         set(PYTHON_LIBRARY python32mw)
748                         set(PYTHON_LIBPATH ${PYTHON}/lib)
749                 endif()
750
751                 set(PLATFORM_LINKFLAGS "--stack,2097152")
752
753         endif()
754
755         # used in many places so include globally, like OpenGL
756         blender_include_dirs("${PTHREADS_INC}")
757
758 elseif(APPLE)
759
760         if (${CMAKE_OSX_DEPLOYMENT_TARGET} STREQUAL "10.5")
761                 set(WITH_LIBS10.5 ON CACHE BOOL "Use 10.5 libs" FORCE)
762         endif()
763
764         if(WITH_LIBS10.5)
765                 set(LIBDIR ${CMAKE_SOURCE_DIR}/../lib/darwin-9.x.universal)
766         else()
767                 if(CMAKE_OSX_ARCHITECTURES MATCHES i386)
768                         set(LIBDIR ${CMAKE_SOURCE_DIR}/../lib/darwin-8.x.i386)
769                 else()
770                         set(LIBDIR ${CMAKE_SOURCE_DIR}/../lib/darwin-8.0.0-powerpc)
771                 endif()
772         endif()
773         
774
775         if(WITH_OPENAL)
776                 find_package(OpenAL)
777                 if(OPENAL_FOUND)
778                         set(WITH_OPENAL ON)
779                         set(OPENAL_INCLUDE_DIR "${LIBDIR}/openal/include")
780                 else()
781                         set(WITH_OPENAL OFF)
782                 endif()
783         endif()
784
785         if(WITH_JACK)
786                 set(JACK /usr)
787                 set(JACK_INC ${JACK}/include/jack)
788                 set(JACK_LIB jack)
789                 set(JACK_LIBPATH ${JACK}/lib)
790         endif()
791
792         if(WITH_CODEC_SNDFILE)
793                 set(SNDFILE ${LIBDIR}/sndfile)
794                 set(SNDFILE_INC ${SNDFILE}/include)
795                 set(SNDFILE_LIB sndfile FLAC ogg vorbis vorbisenc)
796                 set(SNDFILE_LIBPATH ${SNDFILE}/lib ${FFMPEG}/lib)
797         endif()
798
799         set(PYTHON_VERSION 3.2)
800
801         if(PYTHON_VERSION MATCHES 3.2)
802                 # we use precompiled libraries for py 3.2 and up by default
803
804                 set(PYTHON ${LIBDIR}/python)
805                 set(PYTHON_INCLUDE_DIRS "${PYTHON}/include/python${PYTHON_VERSION}")
806                 # set(PYTHON_BINARY "${PYTHON}/bin/python${PYTHON_VERSION}") # not used yet
807                 set(PYTHON_LIBRARY python${PYTHON_VERSION})
808                 set(PYTHON_LIBPATH "${PYTHON}/lib/python${PYTHON_VERSION}")
809                 # set(PYTHON_LINKFLAGS "-u _PyMac_Error")  # won't  build with this enabled
810         else()
811                 # otherwise, use custom system framework
812
813                 set(PYTHON /System/Library/Frameworks/Python.framework/Versions/)
814                 set(PYTHON_VERSION 3.2)
815                 set(PYTHON_INCLUDE_DIRS "${PYTHON}${PYTHON_VERSION}/include/python${PYTHON_VERSION}")
816                 # set(PYTHON_BINARY ${PYTHON}${PYTHON_VERSION}/bin/python${PYTHON_VERSION}) # not used yet
817                 set(PYTHON_LIBRARY "")
818                 set(PYTHON_LIBPATH ${PYTHON}${PYTHON_VERSION}/lib/python${PYTHON_VERSION}/config)
819                 set(PYTHON_LINKFLAGS "-u _PyMac_Error -framework System -framework Python")
820         endif()
821
822         if(WITH_INTERNATIONAL)
823                 set(GETTEXT ${LIBDIR}/gettext)
824                 set(GETTEXT_INC "${GETTEXT}/include")
825                 set(GETTEXT_LIB intl iconv)
826                 set(GETTEXT_LIBPATH ${GETTEXT}/lib)
827         endif()
828   
829         if(WITH_FFTW3)
830                 set(FFTW3 ${LIBDIR}/fftw3)
831                 set(FFTW3_INC ${FFTW3}/include)
832                 set(FFTW3_LIB fftw3)
833                 set(FFTW3_LIBPATH ${FFTW3}/lib)
834         endif()
835
836         set(PNG_LIBRARIES png)
837         set(JPEG_LIBRARIES jpeg)
838
839         set(ZLIB /usr)
840         set(ZLIB_INCLUDE_DIRS "${ZLIB}/include")
841         set(ZLIB_LIBRARIES z bz2)
842
843         set(FREETYPE ${LIBDIR}/freetype)
844         set(FREETYPE_INCLUDE_DIRS ${FREETYPE}/include ${FREETYPE}/include/freetype2)
845         set(FREETYPE_LIBPATH ${FREETYPE}/lib)
846         set(FREETYPE_LIBRARY freetype)
847
848         if(WITH_IMAGE_OPENEXR)
849                 set(OPENEXR ${LIBDIR}/openexr)
850                 set(OPENEXR_INC ${OPENEXR}/include/OpenEXR ${OPENEXR}/include)
851                 set(OPENEXR_LIB Iex Half IlmImf Imath IlmThread)
852                 set(OPENEXR_LIBPATH ${OPENEXR}/lib)
853         endif()
854
855         if(WITH_LCMS)
856                 set(LCMS ${LIBDIR}/lcms)
857                 set(LCMS_INCLUDE_DIR ${LCMS}/include)
858                 set(LCMS_LIBRARY lcms)
859                 set(LCMS_LIBPATH ${LCMS}/lib)
860         endif()
861
862         if(WITH_CODEC_FFMPEG)
863                 set(FFMPEG ${LIBDIR}/ffmpeg)
864                 set(FFMPEG_INC ${FFMPEG}/include)
865                 set(FFMPEG_LIB avcodec avdevice avformat avutil mp3lame swscale x264 xvidcore theora theoradec theoraenc vorbis vorbisenc vorbisfile ogg)
866                 set(FFMPEG_LIBPATH ${FFMPEG}/lib)
867                 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D__STDC_CONSTANT_MACROS")
868         endif()
869
870         if(WITH_SAMPLERATE)
871                 set(LIBSAMPLERATE ${LIBDIR}/samplerate)
872                 set(LIBSAMPLERATE_INC ${LIBSAMPLERATE}/include)
873                 set(LIBSAMPLERATE_LIB samplerate)
874                 set(LIBSAMPLERATE_LIBPATH ${LIBSAMPLERATE}/lib)
875         endif()
876
877         set(LLIBS stdc++ SystemStubs)
878
879         if(WITH_COCOA)
880                 set(PLATFORM_CFLAGS "-pipe -funsigned-char -DGHOST_COCOA")
881                 set(PLATFORM_LINKFLAGS "-fexceptions -framework CoreServices -framework Foundation -framework IOKit -framework AppKit -framework Cocoa -framework Carbon -framework AudioUnit -framework AudioToolbox -framework CoreAudio")
882                 if(USE_QTKIT)
883                         set(PLATFORM_CFLAGS "${PLATFORM_CFLAGS} -DUSE_QTKIT")
884                         set(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} -framework QTKit")
885                         if(CMAKE_OSX_ARCHITECTURES MATCHES i386)
886                                 set(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} -framework QuickTime")
887                                 #libSDL still needs 32bit carbon quicktime 
888                         endif()
889                 elseif(WITH_CODEC_QUICKTIME)
890                         set(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} -framework QuickTime")
891                 endif()
892         else()
893                 set(PLATFORM_CFLAGS "-pipe -funsigned-char")
894                 set(PLATFORM_LINKFLAGS "-fexceptions -framework CoreServices -framework Foundation -framework IOKit -framework AppKit -framework Carbon -framework AGL -framework AudioUnit -framework AudioToolbox -framework CoreAudio -framework QuickTime")
895         endif()
896
897         if(WITH_OPENCOLLADA)
898                 set(OPENCOLLADA ${LIBDIR}/opencollada)
899                 set(OPENCOLLADA_INC ${OPENCOLLADA}/include)
900                 set(OPENCOLLADA_LIBPATH ${OPENCOLLADA}/lib)
901                 set(OPENCOLLADA_LIB "OpenCOLLADASaxFrameworkLoader -lOpenCOLLADAFramework -lOpenCOLLADABaseUtils -lOpenCOLLADAStreamWriter -lMathMLSolver -lGeneratedSaxParser -lUTF -lxml2 -lbuffer -lftoa" )
902                 #pcre is bundled with openCollada
903                 #set(PCRE ${LIBDIR}/pcre)
904                 #set(PCRE_LIBPATH ${PCRE}/lib)
905                 set(PCRE_LIB pcre)
906                 #libxml2 is used
907                 #set(EXPAT ${LIBDIR}/expat)
908                 #set(EXPAT_LIBPATH ${EXPAT}/lib)
909                 set(EXPAT_LIB)
910         endif()
911
912         if(WITH_SDL)
913                 set(SDL ${LIBDIR}/sdl)
914                 set(SDL_INCLUDE_DIR ${SDL}/include)
915                 set(SDL_LIBRARY SDL)
916                 set(SDL_LIBPATH ${SDL}/lib)
917         endif()
918
919         set(PNG "${LIBDIR}/png")
920         set(PNG_INCLUDE_DIR "${PNG}/include")
921         set(PNG_LIBPATH ${PNG}/lib)
922
923         set(JPEG "${LIBDIR}/jpeg")
924         set(JPEG_INCLUDE_DIR "${JPEG}/include")
925         set(JPEG_LIBPATH ${JPEG}/lib)
926
927         if(WITH_IMAGE_TIFF)
928                 set(TIFF ${LIBDIR}/tiff)
929                 set(TIFF_INCLUDE_DIR ${TIFF}/include)
930                 set(TIFF_LIBRARY tiff)
931                 set(TIFF_LIBPATH ${TIFF}/lib)
932         endif()
933
934         set(EXETYPE MACOSX_BUNDLE)
935
936         set(CMAKE_C_FLAGS_DEBUG "-fno-strict-aliasing -g")
937         set(CMAKE_CXX_FLAGS_DEBUG "-fno-strict-aliasing -g")
938         if(CMAKE_OSX_ARCHITECTURES MATCHES "i386")
939                 set(CMAKE_CXX_FLAGS_RELEASE "-O3 -mdynamic-no-pic -ftree-vectorize -msse -msse2 -fvariable-expansion-in-unroller")
940                 set(CMAKE_C_FLAGS_RELEASE "-O3 -mdynamic-no-pic -ftree-vectorize -msse -msse2 -fvariable-expansion-in-unroller")
941         elseif(CMAKE_OSX_ARCHITECTURES MATCHES "x86_64")
942                 set(CMAKE_CXX_FLAGS_RELEASE "-O3 -mdynamic-no-pic -ftree-vectorize -msse -msse2 -msse3 -mssse3 -fvariable-expansion-in-unroller")
943                 set(CMAKE_C_FLAGS_RELEASE "-O3 -mdynamic-no-pic -ftree-vectorize -msse -msse2 -msse3 -mssse3 -fvariable-expansion-in-unroller")
944         else()
945                 set(CMAKE_C_FLAGS_RELEASE "-mdynamic-no-pic -fno-strict-aliasing")
946                 set(CMAKE_CXX_FLAGS_RELEASE "-mdynamic-no-pic -fno-strict-aliasing")
947         endif()
948 endif()
949
950 #-----------------------------------------------------------------------------
951 # Common.
952
953 if(WITH_RAYOPTIMIZATION)
954         if(CMAKE_COMPILER_IS_GNUCC)
955                 if(SUPPORT_SSE_BUILD)
956                         set(PLATFORM_CFLAGS " -msse ${PLATFORM_CFLAGS}")
957                         add_definitions(-D__SSE__ -D__MMX__)
958                 endif()
959                 if(SUPPORT_SSE2_BUILD)
960                         set(PLATFORM_CFLAGS " -msse2 ${PLATFORM_CFLAGS}")
961                         add_definitions(-D__SSE2__)
962                         if(NOT SUPPORT_SSE_BUILD) # dont double up
963                                 add_definitions(-D__MMX__)
964                         endif()
965                 endif()
966         endif()
967 endif()
968
969 if(WITH_IMAGE_OPENJPEG)
970         if(UNIX AND NOT APPLE)
971                 set(OPENJPEG /usr)
972                 set(OPENJPEG_INC ${OPENJPEG}/include)
973                 set(OPENJPEG_LIB openjpeg)
974                 set(OPENJPEG_LIBPATH ${OPENJPEG}/lib)
975         else()
976                 set(OPENJPEG ${CMAKE_SOURCE_DIR}/extern/libopenjpeg)
977                 set(OPENJPEG_INC ${OPENJPEG})
978         endif()
979 endif()
980
981 if(WITH_IMAGE_REDCODE)
982         set(REDCODE ${CMAKE_SOURCE_DIR}/extern)
983         set(REDCODE_INC ${REDCODE})
984 endif()
985
986 #-----------------------------------------------------------------------------
987 # Blender WebPlugin
988
989 if(WITH_WEBPLUGIN) 
990         set(GECKO_DIR "${CMAKE_SOURCE_DIR}/../gecko-sdk/" CACHE PATH "Gecko SDK path")
991         set(WEBPLUGIN_SANDBOX_MODE "apparmor" CACHE STRING "WEB Plugin sandbox mode, can be apparmor, privsep, none")
992
993         set(WITH_PLAYER ON)
994 endif()
995
996
997 #-----------------------------------------------------------------------------
998 # Configure OpenGL.
999 find_package(OpenGL)
1000 blender_include_dirs("${OPENGL_INCLUDE_DIR}")
1001 # unset(OPENGL_LIBRARIES CACHE) # not compat with older cmake 
1002 # unset(OPENGL_xmesa_INCLUDE_DIR CACHE) # not compat with older cmake 
1003
1004 #-----------------------------------------------------------------------------
1005 # Configure OpenMP.
1006 if(WITH_OPENMP)
1007         find_package(OpenMP)    
1008         if(OPENMP_FOUND)
1009                 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
1010                 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
1011
1012                 if(APPLE AND ${CMAKE_GENERATOR} MATCHES "Xcode")
1013                         set(CMAKE_XCODE_ATTRIBUTE_ENABLE_OPENMP_SUPPORT "YES")
1014                 endif()
1015         else()
1016                 set(WITH_OPENMP OFF)
1017         endif()
1018
1019         mark_as_advanced(OpenMP_C_FLAGS)
1020         mark_as_advanced(OpenMP_CXX_FLAGS)
1021 endif() 
1022
1023 #-----------------------------------------------------------------------------
1024 # Configure Python.
1025
1026 if(WITH_PYTHON_MODULE)
1027         add_definitions(-DPy_ENABLE_SHARED)
1028 endif() 
1029
1030 #-----------------------------------------------------------------------------
1031 # Extra compile flags
1032
1033 if((NOT WIN32) AND (NOT MSVC))
1034         # used for internal debug checks
1035         set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DDEBUG")
1036         set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DDEBUG")
1037         
1038         # assert() checks for this.
1039         set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -DNDEBUG")
1040         set(CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS_MINSIZEREL} -DNDEBUG")
1041         set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -DNDEBUG")
1042
1043         set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -DNDEBUG")
1044         set(CMAKE_C_FLAGS_MINSIZEREL "${CMAKE_C_FLAGS_MINSIZEREL} -DNDEBUG")
1045         set(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO} -DNDEBUG")
1046 endif()
1047
1048 if(CMAKE_COMPILER_IS_GNUCC)
1049
1050         ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_ALL -Wall)
1051         ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_CAST_ALIGN -Wcast-align)
1052         ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_ERROR_DECLARATION_AFTER_STATEMENT -Werror=declaration-after-statement)
1053         ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_ERROR_IMPLICIT_FUNCTION_DECLARATION -Werror=implicit-function-declaration)
1054         ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_ERROR_RETURN_TYPE -Werror=return-type)
1055         # system headers sometimes do this, disable for now, was: -Werror=strict-prototypes
1056         ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_STRICT_PROTOTYPES -Wstrict-prototypes)
1057         ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_NO_CHAR_SUBSCRIPTS -Wno-char-subscripts)
1058         ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_NO_UNKNOWN_PRAGMAS -Wno-unknown-pragmas)
1059         ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_POINTER_ARITH -Wpointer-arith)
1060         ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_UNUSED_PARAMETER -Wunused-parameter)
1061         ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_WRITE_STRINGS -Wwrite-strings)
1062         ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_DOUBLE_PROMOTION -Wdouble-promotion -Wno-error=double-promotion)
1063         ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_NO_ERROR_UNUSED_BUT_SET_VARIABLE -Wno-error=unused-but-set-variable)
1064
1065         ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_ALL -Wall)
1066         ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_NO_INVALID_OFFSETOF -Wno-invalid-offsetof)
1067         ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_NO_SIGN_COMPARE -Wno-sign-compare)
1068
1069 elseif(CMAKE_C_COMPILER_ID MATCHES "Intel")
1070
1071         ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_ALL -Wall)
1072         ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_POINTER_ARITH -Wpointer-arith)
1073         ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_NO_UNKNOWN_PRAGMAS -Wno-unknown-pragmas)
1074
1075         ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_ALL -Wall)
1076         ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_NO_INVALID_OFFSETOF -Wno-invalid-offsetof)
1077         ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_NO_SIGN_COMPARE -Wno-sign-compare)
1078
1079 endif()
1080
1081 if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
1082         if(WITH_IK_ITASC OR WITH_MOD_FLUID)
1083                 message(WARNING "Using Clang as CXX compiler: disabling WITH_IK_ITASC and WITH_MOD_FLUID, these features will be missing.")
1084                 set(WITH_IK_ITASC OFF)
1085                 set(WITH_MOD_FLUID OFF)
1086         endif()
1087 endif()
1088
1089 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${PLATFORM_CFLAGS} ${C_WARNINGS}")
1090 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${PLATFORM_CFLAGS} ${CXX_WARNINGS}")
1091
1092 #-------------------------------------------------------------------------------
1093 # Global Defines
1094
1095 # better not define flags here but this is a debugging option thats off by default.
1096 if(WITH_CXX_GUARDEDALLOC)
1097         set(CMAKE_CXX_FLAGS " -DWITH_CXX_GUARDEDALLOC -I${CMAKE_SOURCE_DIR}/intern/guardedalloc ${CMAKE_CXX_FLAGS}")
1098 endif()
1099
1100 if(WITH_ASSERT_ABORT)
1101         add_definitions(-DWITH_ASSERT_ABORT)
1102 endif()
1103
1104 # message(STATUS "Using CFLAGS: ${CMAKE_C_FLAGS}")
1105 # message(STATUS "Using CXXFLAGS: ${CMAKE_CXX_FLAGS}")
1106
1107 #-----------------------------------------------------------------------------
1108 # Libraries
1109
1110 add_subdirectory(source)
1111 add_subdirectory(intern)
1112 add_subdirectory(extern)
1113
1114
1115 #-----------------------------------------------------------------------------
1116 # Blender Application
1117 add_subdirectory(source/creator)
1118
1119
1120 #-----------------------------------------------------------------------------
1121 # Blender Player
1122 if(WITH_PLAYER)
1123         add_subdirectory(source/blenderplayer)
1124 endif()
1125
1126 #-----------------------------------------------------------------------------
1127 # CPack for generating packages
1128 include(build_files/cmake/packaging.cmake)