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