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