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