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