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