3e8b812e57caa99b970f8c6f2900dc509d4ebb2b
[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(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR})
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)
56 SET(LIBRARY_OUTPUT_PATH  ${CMAKE_BINARY_DIR}/lib)
57
58 # Note! - Could create this from the blender version string
59 # ...but thats quite involved, make sure this matches the blender version.
60 SET(BLENDER_VERSION  2.5)
61
62 #-----------------------------------------------------------------------------
63 # Load some macros.
64 INCLUDE(CMake/macros.cmake)
65
66 #-----------------------------------------------------------------------------
67 # Set default config options
68
69 # Blender internal features
70 OPTION(WITH_INTERNATIONAL "Enable I18N   (International fonts and text)" ON)
71 OPTION(WITH_LCMS          "Enable color correction with lcms" OFF)
72 OPTION(WITH_PYTHON        "Enable Embedded Python API" ON)
73 OPTION(WITH_BUILDINFO     "Include extra build details" ON)
74 OPTION(WITH_ELBEEM        "Enable Elbeem (Fluid Simulation)" ON)
75 OPTION(WITH_FFTW3         "Enable FFTW3 support (Used for smoke and audio effects)" OFF)
76 OPTION(WITH_BULLET        "Enable Bullet (Physics Engine)" ON)
77 OPTION(WITH_GAMEENGINE    "Enable Game Engine" ON)
78 OPTION(WITH_PLAYER        "Build Player" OFF)
79 # (unix defaults to OpenMP On)
80 IF(UNIX AND NOT APPLE)
81         OPTION(WITH_OPENMP        "Enable OpenMP (has to be supported by the compiler)" ON)
82 ELSE()
83         OPTION(WITH_OPENMP        "Enable OpenMP (has to be supported by the compiler)" OFF)
84 ENDIF()
85
86 # Image format support
87 OPTION(WITH_OPENEXR       "Enable OpenEXR Support (http://www.openexr.com)" ON)
88 OPTION(WITH_OPENJPEG      "Enable OpenJpeg Support (http://www.openjpeg.org/)" OFF)
89 OPTION(WITH_TIFF          "Enable LibTIFF Support" ON)
90 OPTION(WITH_DDS           "Enable DDS Support" ON)
91
92 # Audio format support
93 OPTION(WITH_FFMPEG        "Enable FFMPeg Support (http://ffmpeg.mplayerhq.hu/)" OFF)
94 OPTION(WITH_SNDFILE       "Enable libsndfile Support (http://www.mega-nerd.com/libsndfile)" OFF)
95 IF(APPLE OR WIN32)
96         OPTION(WITH_QUICKTIME     "Enable Quicktime Support" OFF)
97 ENDIF(APPLE OR WIN32)
98
99 # 3D format support
100 # disable opencollada on non-apple unix because opencollada has no package for debian
101 IF(UNIX AND NOT APPLE)
102         OPTION(WITH_OPENCOLLADA         "Enable OpenCollada Support (http://www.opencollada.org/)"      OFF)
103 ELSE()
104         OPTION(WITH_OPENCOLLADA         "Enable OpenCollada Support (http://www.opencollada.org/)"      OFF)
105 ENDIF()
106
107 # Sound output
108 OPTION(WITH_SDL           "Enable SDL for sound and joystick support" ON)
109 OPTION(WITH_OPENAL        "Enable OpenAL Support (http://www.openal.org)" ON)
110 OPTION(WITH_JACK          "Enable Jack Support (http://www.jackaudio.org)" OFF)
111
112 # Compression
113 OPTION(WITH_LZO           "Enable fast LZO compression (used for pointcache)" ON)
114 OPTION(WITH_LZMA          "Enable best LZMA compression, (used for pointcache)" ON)
115
116 # Misc
117 OPTION(WITH_RAYOPTIMIZATION     "Enable use of SIMD (SSE) optimizations for the raytracer" ON) 
118 OPTION(WITH_CXX_GUARDEDALLOC "Enable GuardedAlloc for C++ memory allocation tracking" OFF)
119 OPTION(WITH_INSTALL       "Install accompanying scripts and language files needed to run blender" ON)
120
121 IF(APPLE)
122         OPTION(WITH_COCOA         "Use Cocoa framework instead of deprecated Carbon" ON)
123         OPTION(USE_QTKIT          "Use QtKit instead of Carbon quicktime (needed for having partial quicktime for 64bit)" OFF)
124         OPTION(WITH_LIBS10.5  "Use 10.5 libs (needed for 64bit builds)" OFF)
125 ENDIF(APPLE)
126
127 IF(NOT WITH_BULLET AND WITH_GAMEENGINE)
128         MESSAGE("WARNING: WITH_GAMEENGINE needs WITH_BULLET")
129 ENDIF(NOT WITH_BULLET AND WITH_GAMEENGINE)
130
131 IF(NOT WITH_GAMEENGINE AND WITH_PLAYER)
132         MESSAGE("WARNING: WITH_PLAYER needs WITH_GAMEENGINE")
133 ENDIF(NOT WITH_GAMEENGINE AND WITH_PLAYER)
134
135 TEST_SSE_SUPPORT()
136
137 # disabled for now, not supported
138 # OPTION(WITH_WEBPLUGIN     "Enable Web Plugin (Unix only)" OFF)
139
140 # For alternate Python locations the commandline can be used to override detected/default cache settings, e.g:
141 # On Unix: 
142 #   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
143 # On Macs: 
144 #   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
145 #
146 # When changing any of this remember to update the notes in doc/blender-cmake.txt
147
148 #-----------------------------------------------------------------------------
149 #Platform specifics
150
151 IF(UNIX AND NOT APPLE)
152
153         IF(WITH_OPENAL)
154                 FIND_PACKAGE(OpenAL)
155                 IF(NOT OPENAL_FOUND)
156                         SET(WITH_OPENAL OFF)
157                 ENDIF(NOT OPENAL_FOUND)
158         ENDIF(WITH_OPENAL)
159
160         IF(WITH_JACK)
161                 SET(JACK /usr)
162                 SET(JACK_INC ${JACK}/include/jack)
163                 SET(JACK_LIB jack)
164                 SET(JACK_LIBPATH ${JACK}/lib)
165         ENDIF(WITH_JACK)
166
167         IF(WITH_SNDFILE)
168         SET(SNDFILE /usr)
169         SET(SNDFILE_INC ${SNDFILE}/include)
170         SET(SNDFILE_LIB sndfile)
171         SET(SNDFILE_LIBPATH ${SNDFILE}/lib)
172         ENDIF(WITH_SNDFILE)
173
174         IF(WITH_INTERNATIONAL)
175                 FIND_LIBRARY(INTL_LIBRARY
176                         NAMES intl
177                         PATHS
178                         /sw/lib
179                 )
180
181                 FIND_LIBRARY(ICONV_LIBRARY
182                         NAMES iconv
183                         PATHS
184                         /sw/lib
185                 )
186
187                 IF(INTL_LIBRARY AND ICONV_LIBRARY)
188                         SET(GETTEXT_LIB ${INTL_LIBRARY} ${ICONV_LIBRARY})
189                 ENDIF(INTL_LIBRARY AND ICONV_LIBRARY)
190         ENDIF(WITH_INTERNATIONAL)
191
192         FIND_PACKAGE(Freetype)
193         # UNSET(FREETYPE_INCLUDE_DIRS CACHE) # cant use
194
195
196         IF(WITH_PYTHON)
197                 # No way to set py31. remove for now.
198                 # FIND_PACKAGE(PythonLibs)
199                 SET(PYTHON /usr)
200                 SET(PYTHON_VERSION 3.1)
201                 SET(PYTHON_INC "${PYTHON}/include/python${PYTHON_VERSION}" CACHE STRING "")
202                 # SET(PYTHON_BINARY python) # not used yet
203                 SET(PYTHON_LIB python${PYTHON_VERSION} CACHE STRING "")
204                 SET(PYTHON_LIBPATH ${PYTHON}/lib CACHE STRING "")
205         
206                 # FIND_PACKAGE(PythonInterp) # not used yet
207                 # SET(PYTHON_BINARY ${PYTHON_EXECUTABLE} CACHE STRING "")
208
209                 SET(PYTHON_LINKFLAGS "-Xlinker -export-dynamic")
210         ENDIF(WITH_PYTHON)
211
212         IF(WITH_SDL)
213                 FIND_PACKAGE(SDL)
214                 # UNSET(SDLMAIN_LIBRARY CACHE)
215                 IF(NOT SDL_FOUND)
216                         SET(WITH_SDL OFF)
217                 ENDIF(NOT SDL_FOUND)
218         ENDIF(WITH_SDL)
219
220         IF(WITH_OPENEXR)
221                 SET(OPENEXR /usr CACHE FILEPATH "OPENEXR Directory")
222                 FIND_PATH(OPENEXR_INC
223                         ImfXdr.h
224                         PATHS
225                         ${OPENEXR}/include/OpenEXR
226                         /usr/local/include/OpenEXR
227                         /sw/include/OpenEXR
228                         /opt/local/include/OpenEXR
229                         /opt/csw/include/OpenEXR
230                         /opt/include/OpenEXR
231                 )
232                 SET(OPENEXR_LIB Half IlmImf Iex Imath)
233                 
234                 IF(NOT OPENEXR_INC)
235                         SET(WITH_OPENEXR OFF)
236                 ENDIF(NOT OPENEXR_INC)
237         ENDIF(WITH_OPENEXR)
238
239         IF(WITH_TIFF)
240                 FIND_PACKAGE(TIFF)
241                 IF(NOT TIFF_FOUND)
242                         SET(WITH_TIFF OFF)
243                 ENDIF(NOT TIFF_FOUND)
244         ENDIF(WITH_TIFF)
245
246         FIND_PACKAGE(JPEG REQUIRED)
247
248         FIND_PACKAGE(PNG REQUIRED)
249
250         FIND_PACKAGE(ZLIB REQUIRED)
251
252         IF(WITH_LCMS)
253                 SET(LCMS /usr CACHE FILEPATH "LCMS directory")
254                 SET(LCMS_INCLUDE_DIR ${LCMS}/include)
255                 SET(LCMS_LIBRARY lcms)
256                 SET(LCMS_LIBPATH ${LCMS}/lib)
257         ENDIF(WITH_LCMS)
258
259         IF(WITH_FFMPEG)
260                 SET(FFMPEG /usr CACHE FILEPATH "FFMPEG Directory")
261                 SET(FFMPEG_INC ${FFMPEG}/include)
262                 SET(FFMPEG_LIB avformat avcodec avutil avdevice swscale CACHE STRING "FFMPEG Libraries")
263                 SET(FFMPEG_LIBPATH ${FFMPEG}/lib)
264                 SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D__STDC_CONSTANT_MACROS")
265         ENDIF(WITH_FFMPEG)
266
267         IF(WITH_FFTW3)
268                 SET(FFTW3 /usr)
269                 SET(FFTW3_INC ${FFTW3}/include)
270                 SET(FFTW3_LIB fftw3)
271                 SET(FFTW3_LIBPATH ${FFTW3}/lib)
272         ENDIF(WITH_FFTW3)
273
274         SET(LIBSAMPLERATE /usr)
275         SET(LIBSAMPLERATE_INC ${LIBSAMPLERATE}/include)
276         SET(LIBSAMPLERATE_LIB samplerate)
277         SET(LIBSAMPLERATE_LIBPATH ${LIBSAMPLERATE}/lib)
278
279         IF (WITH_OPENCOLLADA)
280                 SET(OPENCOLLADA /usr/local/opencollada CACHE FILEPATH "OpenCollada Directory")
281                 SET(OPENCOLLADA_LIBPATH ${OPENCOLLADA}/lib)
282                 SET(OPENCOLLADA_LIB OpenCOLLADAStreamWriter OpenCOLLADASaxFrameworkLoader OpenCOLLADAFramework OpenCOLLADABaseUtils GeneratedSaxParser UTF MathMLSolver pcre ftoa buffer)
283                 SET(OPENCOLLADA_INC ${OPENCOLLADA})
284                 SET(PCRE /usr CACHE FILEPATH "PCRE Directory")
285                 SET(PCRE_LIBPATH ${PCRE}/lib)
286                 SET(PCRE_LIB pcre)
287                 SET(EXPAT /usr CACHE FILEPATH "Expat Directory")
288                 SET(EXPAT_LIBPATH ${EXPAT}/lib)
289                 SET(EXPAT_LIB expat)
290         ENDIF (WITH_OPENCOLLADA)
291
292
293         # Could use ${X11_Xinput_LIB} ${X11_X11_LIB} too
294         SET(LLIBS "-lXi -lutil -lc -lm -lpthread -lstdc++ -lX11")
295
296         IF(CMAKE_SYSTEM_NAME MATCHES "Linux")
297                 # BSD's dont use libdl.so
298                 SET(LLIBS "${LLIBS} -ldl")
299
300                 # binreloc is linux only
301                 SET(BINRELOC ${CMAKE_SOURCE_DIR}/extern/binreloc)
302                 SET(BINRELOC_INC ${BINRELOC}/include)
303         ENDIF(CMAKE_SYSTEM_NAME MATCHES "Linux")
304
305         IF(WITH_OPENMP)
306                 SET(LLIBS "${LLIBS} -lgomp")
307                 SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fopenmp")
308                 SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fopenmp")
309         ENDIF(WITH_OPENMP)
310
311
312         SET(PLATFORM_CFLAGS "-pipe -fPIC -funsigned-char -fno-strict-aliasing -Wno-char-subscripts")
313
314         IF(WITH_RAYOPTIMIZATION AND SUPPORT_SSE_BUILD)
315                 SET(PLATFORM_CFLAGS " -msse -msse2 ${PLATFORM_CFLAGS}")
316                 ADD_DEFINITIONS(-D__SSE__)
317                 ADD_DEFINITIONS(-D__MMX__)
318         ENDIF(WITH_RAYOPTIMIZATION AND SUPPORT_SSE_BUILD)
319
320         SET(PLATFORM_LINKFLAGS "-pthread")
321
322         # Better warnings
323         SET(C_WARNINGS "-Wall -Wno-char-subscripts -Wpointer-arith -Wcast-align -Wdeclaration-after-statement -Wno-unknown-pragmas")
324         SET(CXX_WARNINGS "-Wall -Wno-invalid-offsetof -Wno-sign-compare")
325
326         INCLUDE_DIRECTORIES(${JPEG_INCLUDE_DIR} ${PNG_INCLUDE_DIR} ${ZLIB_INCLUDE_DIR} )
327 ENDIF(UNIX AND NOT APPLE)
328
329
330 IF(WIN32)
331
332         # this file is included anyway when building under Windows with cl.exe
333         #  INCLUDE(${CMAKE_ROOT}/Modules/Platform/Windows-cl.cmake)
334   
335         SET(LIBDIR ${CMAKE_SOURCE_DIR}/../lib/windows)
336
337         # Setup 64bit and 64bit windows systems
338         IF(CMAKE_CL_64)
339                 message("64 bit compiler detected.")
340                 SET(LIBDIR ${CMAKE_SOURCE_DIR}/../lib/win64)
341         ENDIF(CMAKE_CL_64)
342         
343         ADD_DEFINITIONS(-DWIN32)
344
345         IF(WITH_INTERNATIONAL)
346                 SET(ICONV ${LIBDIR}/iconv)
347                 SET(ICONV_INC ${ICONV}/include)
348                 SET(ICONV_LIB iconv)
349                 SET(ICONV_LIBPATH ${ICONV}/lib)
350         ENDIF(WITH_INTERNATIONAL)
351
352         SET(LIBSAMPLERATE ${LIBDIR}/samplerate)
353         SET(LIBSAMPLERATE_INC ${LIBSAMPLERATE}/include)
354         SET(LIBSAMPLERATE_LIB libsamplerate)
355         SET(LIBSAMPLERATE_LIBPATH ${LIBSAMPLERATE}/lib)
356
357         SET(PNG "${LIBDIR}/png")
358         SET(PNG_INC "${PNG}/include")
359         SET(PNG_LIBPATH ${PNG}/lib)
360
361         SET(JPEG "${LIBDIR}/jpeg")
362         SET(JPEG_INC "${JPEG}/include")
363         SET(JPEG_LIBPATH ${JPEG}/lib)
364
365         SET(WINTAB_INC ${LIBDIR}/wintab/include) 
366
367         IF(WITH_PYTHON)
368                 SET(PYTHON ${LIBDIR}/python)
369                 SET(PYTHON_VERSION 3.1)
370                 SET(PYTHON_INC "${PYTHON}/include/python${PYTHON_VERSION}")
371                 # SET(PYTHON_BINARY python) # not used yet
372                 SET(PYTHON_LIB python31)
373                 SET(PYTHON_LIBPATH ${PYTHON}/lib)
374         ENDIF(WITH_PYTHON)
375
376         IF(WITH_OPENAL)
377                 SET(OPENAL ${LIBDIR}/openal)
378                 SET(OPENAL_INCLUDE_DIR ${OPENAL}/include)
379                 SET(OPENAL_LIBRARY wrap_oal)
380                 SET(OPENAL_LIBPATH ${OPENAL}/lib)
381         ENDIF(WITH_OPENAL)
382
383         IF(WITH_SNDFILE)
384                 SET(SNDFILE ${LIBDIR}/sndfile)
385                 SET(SNDFILE_INC ${SNDFILE}/include)
386                 SET(SNDFILE_LIB libsndfile-1)
387                 SET(SNDFILE_LIBPATH ${SNDFILE}/lib)
388         ENDIF(WITH_SNDFILE)
389
390         IF(WITH_SDL)
391                 SET(SDL ${LIBDIR}/sdl)
392                 SET(SDL_INCLUDE_DIR ${SDL}/include)
393                 SET(SDL_LIBRARY SDL)
394                 SET(SDL_LIBPATH ${SDL}/lib)
395         ENDIF(WITH_SDL)
396
397         IF(WITH_QUICKTIME)
398                 SET(QUICKTIME ${LIBDIR}/QTDevWin)
399                 SET(QUICKTIME_INC ${QUICKTIME}/CIncludes)
400                 SET(QUICKTIME_LIB qtmlClient)
401                 SET(QUICKTIME_LIBPATH ${QUICKTIME}/Libraries)
402         ENDIF(WITH_QUICKTIME)
403
404         IF(WITH_RAYOPTIMIZATION AND SUPPORT_SSE_BUILD)
405                 ADD_DEFINITIONS(-D__SSE__)
406                 ADD_DEFINITIONS(-D__MMX__)
407         ENDIF(WITH_RAYOPTIMIZATION AND SUPPORT_SSE_BUILD)
408
409         IF(MSVC)
410                 IF(CMAKE_CL_64)
411                         SET(LLIBS kernel32 user32 vfw32 winmm ws2_32 )
412                 ELSE(CMAKE_CL_64)
413                         SET(LLIBS kernel32 user32 gdi32 comdlg32 advapi32 shell32 ole32 oleaut32 uuid ws2_32 vfw32 winmm)
414                 ENDIF(CMAKE_CL_64)
415                 
416                 SET(CMAKE_CXX_FLAGS "/D_CRT_NONSTDC_NO_DEPRECATE /D_CRT_SECURE_NO_DEPRECATE /D_SCL_SECURE_NO_DEPRECATE /wd4800 /wd4244 /wd4305" CACHE STRING "MSVC MT C++ flags " FORCE)
417                 SET(CMAKE_C_FLAGS   "/D_CRT_NONSTDC_NO_DEPRECATE /D_CRT_SECURE_NO_DEPRECATE /D_SCL_SECURE_NO_DEPRECATE /wd4800 /wd4244 /wd4305" CACHE STRING "MSVC MT C++ flags " FORCE)
418
419                 SET(CMAKE_CXX_FLAGS_DEBUG "/D_DEBUG /Od /Gm /EHsc /RTC1 /MTd /W3 /nologo /ZI /J" CACHE STRING "MSVC MT flags " FORCE)
420                 SET(CMAKE_CXX_FLAGS_RELEASE "/O2 /Ob2 /DNDEBUG /EHsc /MT /W3 /nologo /J" CACHE STRING "MSVC MT flags " FORCE)
421                 SET(CMAKE_CXX_FLAGS_MINSIZEREL "/O1 /Ob1 /DNDEBUG /EHsc /MT /W3 /nologo /J" CACHE STRING "MSVC MT flags " FORCE)
422                 SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "/O2 /Ob1 /DNDEBUG /EHsc /MT /W3 /nologo /Zi /J" CACHE STRING "MSVC MT flags " FORCE)
423                 SET(CMAKE_C_FLAGS_DEBUG "/D_DEBUG /Od /Gm /EHsc /RTC1 /MTd /W3 /nologo /ZI /J" CACHE STRING "MSVC MT flags " FORCE)
424                 SET(CMAKE_C_FLAGS_RELEASE "/O2 /Ob2 /DNDEBUG /EHsc /MT /W3 /nologo /J" CACHE STRING "MSVC MT flags " FORCE)
425                 SET(CMAKE_C_FLAGS_MINSIZEREL "/O1 /Ob1 /DNDEBUG /EHsc /MT /W3 /nologo /J" CACHE STRING "MSVC MT flags " FORCE)
426                 SET(CMAKE_C_FLAGS_RELWITHDEBINFO "/O2 /Ob1 /DNDEBUG /EHsc /MT /W3 /nologo /Zi /J" CACHE STRING "MSVC MT flags " FORCE)
427                 
428                 IF(WITH_OPENMP)
429                         SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /openmp ")
430                         SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /openmp ")
431                 ENDIF(WITH_OPENMP)
432                 
433                 IF(WITH_INTERNATIONAL)
434                         SET(GETTEXT ${LIBDIR}/gettext)
435                         SET(GETTEXT_INC ${GETTEXT}/include)
436                         SET(GETTEXT_LIBPATH ${GETTEXT}/lib)
437                         IF(CMAKE_CL_64)
438                                 SET(GETTEXT_LIB gettext)
439                         ELSE(CMAKE_CL_64)
440                                 SET(GETTEXT_LIB gnu_gettext)
441                         ENDIF(CMAKE_CL_64)
442                 ENDIF(WITH_INTERNATIONAL)
443
444                 IF(CMAKE_CL_64)
445                         SET(PNG_LIBRARIES libpng)
446                 ELSE(CMAKE_CL_64)
447                         SET(PNG_LIBRARIES libpng_st)
448                 ENDIF(CMAKE_CL_64)
449                 SET(JPEG_LIBRARY libjpeg)
450
451                 SET(ZLIB ${LIBDIR}/zlib)
452                 SET(ZLIB_INC ${ZLIB}/include)
453                 SET(ZLIB_LIBPATH ${ZLIB}/lib)
454                 IF(CMAKE_CL_64)
455                         SET(ZLIB_LIBRARIES libz)
456                 ELSE(CMAKE_CL_64)
457                         SET(ZLIB_LIBRARIES zlib)
458                 ENDIF(CMAKE_CL_64)
459
460                 SET(PTHREADS ${LIBDIR}/pthreads)
461                 SET(PTHREADS_INC ${PTHREADS}/include)
462                 SET(PTHREADS_LIBPATH ${PTHREADS}/lib)
463                 SET(PTHREADS_LIB pthreadVC2)
464                 
465                 SET(FREETYPE ${LIBDIR}/freetype)
466                 SET(FREETYPE_INCLUDE_DIRS ${FREETYPE}/include ${FREETYPE}/include/freetype2)
467                 SET(FREETYPE_LIBPATH ${FREETYPE}/lib)
468                 SET(FREETYPE_LIBRARY freetype2ST)
469
470                 IF(WITH_FFTW3)
471                         SET(FFTW3 ${LIBDIR}/fftw3)
472                         SET(FFTW3_LIB libfftw)
473                         SET(FFTW3_INC ${FFTW3}/include)
474                         SET(FFTW3_LIBPATH ${FFTW3}/lib)
475                 ENDIF(WITH_FFTW3)
476
477                 IF(WITH_OPENCOLLADA)
478                         SET(OPENCOLLADA ${LIBDIR}/opencollada)
479                         SET(OPENCOLLADA_INC ${OPENCOLLADA}/include)
480                         SET(OPENCOLLADA_LIBPATH ${OPENCOLLADA}/lib)
481                         SET(OPENCOLLADA_LIB OpenCOLLADASaxFrameworkLoader OpenCOLLADAFramework OpenCOLLADABaseUtils OpenCOLLADAStreamWriter MathMLSolver GeneratedSaxParser xml2 buffer ftoa)
482                         #pcre is bundled with openCollada
483                         #SET(PCRE ${LIBDIR}/pcre)
484                         #SET(PCRE_LIBPATH ${PCRE}/lib)
485                         SET(PCRE_LIB pcre)
486                 ENDIF(WITH_OPENCOLLADA)
487                 
488                 # TODO: IF(WITH_LCMS)
489         
490                 IF(WITH_FFMPEG)
491                         SET(FFMPEG ${LIBDIR}/ffmpeg)
492                         SET(FFMPEG_INC ${FFMPEG}/include ${FFMPEG}/include/msvc)
493                         SET(FFMPEG_LIB avcodec-52 avformat-52 avdevice-52 avutil-50 swscale-0)
494                         SET(FFMPEG_LIBPATH ${FFMPEG}/lib)
495                 ENDIF(WITH_FFMPEG)
496
497                 IF(WITH_OPENEXR)
498                         SET(OPENEXR ${LIBDIR}/openexr)
499                         SET(OPENEXR_INC ${OPENEXR}/include ${OPENEXR}/include/IlmImf ${OPENEXR}/include/Iex ${OPENEXR}/include/Imath)
500                         SET(OPENEXR_LIB Iex Half IlmImf Imath IlmThread)
501                         IF (MSVC80)
502                                 SET(OPENEXR_LIBPATH ${OPENEXR}/lib_vs2005)
503                         ELSE (MSVC80)
504                                 SET(OPENEXR_LIBPATH ${OPENEXR}/lib_msvc)
505                         ENDIF(MSVC80)
506                         IF (MSVC90)
507                                 SET(OPENEXR_LIBPATH ${OPENEXR}/lib_vs2008)
508                         ENDIF(MSVC90)
509                 ENDIF(WITH_OPENEXR)
510
511                 IF(WITH_TIFF)
512                         SET(TIFF ${LIBDIR}/tiff)
513                         SET(TIFF_LIBRARY libtiff)
514                         SET(TIFF_INCLUDE_DIR ${TIFF}/include)
515                         SET(TIFF_LIBPATH ${TIFF}/lib)
516                 ENDIF(WITH_TIFF)
517
518                 IF(WITH_JACK)
519                         SET(JACK ${LIBDIR}/jack)
520                         SET(JACK_INC ${JACK}/include/jack ${JACK}/include)
521                         SET(JACK_LIB libjack)
522                         SET(JACK_LIBPATH ${JACK}/lib)
523                 ENDIF(WITH_JACK)
524
525                 # MSVC only, Mingw doesnt need
526                 IF(CMAKE_CL_64)
527                         SET(PLATFORM_LINKFLAGS "/MACHINE:X64 /NODEFAULTLIB:libc.lib;MSVCRT.lib ")
528                 ELSE(CMAKE_CL_64)
529                         SET(PLATFORM_LINKFLAGS "/NODEFAULTLIB:libc.lib ")
530                 ENDIF(CMAKE_CL_64)
531           
532                 SET(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} /NODEFAULTLIB:libcmt.lib;libc.lib ")
533
534         ELSE(MSVC) # MINGW
535                 SET(LLIBS "-lshell32 -lshfolder -lgdi32 -lmsvcrt -lwinmm -lmingw32 -lm -lws2_32 -lz -lstdc++ -lole32 -luuid")
536
537                 SET(CMAKE_CXX_FLAGS                "-pipe -funsigned-char -fno-strict-aliasing" CACHE STRING "Mingw C++ flags ")
538                 SET(CMAKE_C_FLAGS                  "-pipe -funsigned-char -fno-strict-aliasing" CACHE STRING "Mingw C flags ")
539
540                 SET(CMAKE_CXX_FLAGS_DEBUG          "-O0 -g" CACHE STRING "Mingw debug C++ flags ")
541                 SET(CMAKE_CXX_FLAGS_RELEASE        "   -O2" CACHE STRING "Mingw release C++ flags ")
542                 SET(CMAKE_CXX_FLAGS_MINSIZEREL     "   -Os" CACHE STRING "Mingw minsize release C++ flags ")
543                 SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O2 -g" CACHE STRING "Mingw release, debug C++ flags ")
544
545                 SET(CMAKE_C_FLAGS_DEBUG            "-O0 -g" CACHE STRING "Mingw debug C flags ")
546                 SET(CMAKE_C_FLAGS_RELEASE          "-O2"    CACHE STRING "Mingw release C flags ")
547                 SET(CMAKE_C_FLAGS_MINSIZEREL       "-Os"    CACHE STRING "Mingw minsize release C flags ")
548                 SET(CMAKE_C_FLAGS_RELWITHDEBINFO   "-O2 -g" CACHE STRING "Mingw release, debug C++ flags ")
549                 ADD_DEFINITIONS(-DFREE_WINDOWS)
550                 
551                 IF(WITH_OPENMP)
552                         SET(LLIBS "${LLIBS} -lgomp")
553                         SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fopenmp")
554                         SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fopenmp")
555                 ENDIF(WITH_OPENMP)
556
557                 IF(WITH_INTERNATIONAL)
558                         SET(GETTEXT ${LIBDIR}/gcc/gettext)
559                         SET(GETTEXT_INC ${GETTEXT}/include)
560                         SET(GETTEXT_LIBPATH ${GETTEXT}/lib)
561                         SET(GETTEXT_LIB intl)
562                 ENDIF(WITH_INTERNATIONAL)
563
564                 SET(JPEG_LIBRARY libjpeg)
565                 SET(PNG_LIBRARIES png)
566
567                 SET(ZLIB ${LIBDIR}/zlib)
568                 SET(ZLIB_INC ${ZLIB}/include)
569                 SET(ZLIB_LIBPATH ${ZLIB}/lib)
570                 SET(ZLIB_LIBRARIES z)
571
572                 SET(PTHREADS ${LIBDIR}/pthreads)
573                 SET(PTHREADS_INC ${PTHREADS}/include)
574                 SET(PTHREADS_LIBPATH ${PTHREADS}/lib)
575                 SET(PTHREADS_LIB pthreadGC2)
576                 
577                 SET(FREETYPE ${LIBDIR}/gcc/freetype)
578                 SET(FREETYPE_INCLUDE_DIRS ${FREETYPE}/include ${FREETYPE}/include/freetype2)
579                 SET(FREETYPE_LIBPATH ${FREETYPE}/lib)
580                 SET(FREETYPE_LIBRARY freetype)
581
582                 IF(WITH_FFTW3)
583                         SET(FFTW3 ${LIBDIR}/gcc/fftw3)
584                         SET(FFTW3_LIB fftw3)
585                         SET(FFTW3_INC ${FFTW3}/include)
586                         SET(FFTW3_LIBPATH ${FFTW3}/lib)
587                 ENDIF(WITH_FFTW3)
588
589                 IF(WITH_OPENCOLLADA)
590                         SET(OPENCOLLADA ${LIBDIR}/gcc/opencollada)
591                         SET(OPENCOLLADA_INC ${OPENCOLLADA}/include)
592                         SET(OPENCOLLADA_LIBPATH ${OPENCOLLADA}/lib ${OPENCOLLADA}/lib)
593                         SET(OPENCOLLADA_LIB OpenCOLLADAStreamWriter OpenCOLLADASaxFrameworkLoader OpenCOLLADAFramework OpenCOLLADABaseUtils GeneratedSaxParser UTF MathMLSolver expat pcre buffer ftoa)
594                         #pcre is bundled with openCollada
595                         #SET(PCRE ${LIBDIR}/pcre)
596                         #SET(PCRE_LIBPATH ${PCRE}/lib)
597                         SET(PCRE_LIB pcre)
598                 ENDIF(WITH_OPENCOLLADA)
599                 
600                 IF(WITH_FFMPEG)
601                         SET(FFMPEG ${LIBDIR}/ffmpeg)
602                         SET(FFMPEG_INC ${FFMPEG}/include ${FFMPEG}/include)
603                         SET(FFMPEG_LIB avcodec-52 avformat-52 avdevice-52 avutil-50 swscale-0)
604                         SET(FFMPEG_LIBPATH ${FFMPEG}/lib)
605                 ENDIF(WITH_FFMPEG)
606
607                 IF(WITH_OPENEXR)
608                         SET(OPENEXR ${LIBDIR}/gcc/openexr)
609                         SET(OPENEXR_INC ${OPENEXR}/include ${OPENEXR}/include/OpenEXR)
610                         SET(OPENEXR_LIB Half IlmImf Imath IlmThread)
611                         SET(OPENEXR_LIBPATH ${OPENEXR}/lib)
612                 ENDIF(WITH_OPENEXR)
613
614                 IF(WITH_TIFF)
615                         SET(TIFF ${LIBDIR}/gcc/tiff)
616                         SET(TIFF_LIBRARY tiff)
617                         SET(TIFF_INCLUDE_DIR ${TIFF}/include)
618                         SET(TIFF_LIBPATH ${TIFF}/lib)
619                 ENDIF(WITH_TIFF)
620
621                 IF(WITH_JACK)
622                         SET(JACK ${LIBDIR}/jack)
623                         SET(JACK_INC ${JACK}/include/jack ${JACK}/include)
624                         SET(JACK_LIB jack)
625                         SET(JACK_LIBPATH ${JACK}/lib)
626                         
627                         # TODO, gives linking errors, force off
628                         SET(WITH_JACK OFF)
629                 ENDIF(WITH_JACK)
630
631         ENDIF(MSVC)
632
633 ENDIF(WIN32)
634
635
636 IF(APPLE)
637         IF(WITH_LIBS10.5)
638                 SET(LIBDIR ${CMAKE_SOURCE_DIR}/../lib/darwin-9.x.universal)
639         ELSE(WITH_LIBS10.5)
640                 IF(CMAKE_OSX_ARCHITECTURES MATCHES i386)
641                         SET(LIBDIR ${CMAKE_SOURCE_DIR}/../lib/darwin-8.x.i386)
642                 ELSE(CMAKE_OSX_ARCHITECTURES MATCHES i386)
643                         SET(LIBDIR ${CMAKE_SOURCE_DIR}/../lib/darwin-8.0.0-powerpc)
644                 ENDIF(CMAKE_OSX_ARCHITECTURES MATCHES i386)
645         ENDIF(WITH_LIBS10.5)
646         
647
648         IF(WITH_OPENAL)
649                 FIND_PACKAGE(OpenAL)
650                 IF(OPENAL_FOUND)
651                         SET(WITH_OPENAL ON)
652                         SET(OPENAL_INCLUDE_DIR "${LIBDIR}/openal/include")
653                 ELSE(OPENAL_FOUND)
654                         SET(WITH_OPENAL OFF)
655                 ENDIF(OPENAL_FOUND)
656         ENDIF(WITH_OPENAL)
657
658         IF(WITH_JACK)
659                 SET(JACK /usr)
660                 SET(JACK_INC ${JACK}/include/jack)
661                 SET(JACK_LIB jack)
662                 SET(JACK_LIBPATH ${JACK}/lib)
663         ENDIF(WITH_JACK)
664
665         IF(WITH_SNDFILE)
666                 SET(SNDFILE ${LIBDIR}/sndfile)
667                 SET(SNDFILE_INC ${SNDFILE}/include)
668                 SET(SNDFILE_LIB sndfile FLAC ogg vorbis vorbisenc)
669                 SET(SNDFILE_LIBPATH ${SNDFILE}/lib ${FFMPEG}/lib)
670         ENDIF(WITH_SNDFILE)
671
672         SET(PYTHON_VERSION 3.1)
673
674         IF(PYTHON_VERSION MATCHES 3.1)
675                 # we use precompiled libraries for py 3.1 and up by default
676
677                 SET(PYTHON ${LIBDIR}/python)
678                 SET(PYTHON_INC "${PYTHON}/include/python${PYTHON_VERSION}")
679                 # SET(PYTHON_BINARY "${PYTHON}/bin/python${PYTHON_VERSION}") # not used yet
680                 SET(PYTHON_LIB python${PYTHON_VERSION})
681                 SET(PYTHON_LIBPATH "${PYTHON}/lib/python${PYTHON_VERSION}")
682                 # SET(PYTHON_LINKFLAGS "-u _PyMac_Error")  # won't  build with this enabled
683         ELSE(PYTHON_VERSION MATCHES 3.1)
684                 # otherwise, use custom system framework
685
686                 SET(PYTHON /System/Library/Frameworks/Python.framework/Versions/)
687                 SET(PYTHON_VERSION 3.1)
688                 SET(PYTHON_INC "${PYTHON}${PYTHON_VERSION}/include/python${PYTHON_VERSION}")
689                 # SET(PYTHON_BINARY ${PYTHON}${PYTHON_VERSION}/bin/python${PYTHON_VERSION}) # not used yet
690                 SET(PYTHON_LIB "")
691                 SET(PYTHON_LIBPATH ${PYTHON}${PYTHON_VERSION}/lib/python${PYTHON_VERSION}/config)
692                 SET(PYTHON_LINKFLAGS "-u _PyMac_Error -framework System -framework Python")
693         ENDIF(PYTHON_VERSION MATCHES 3.1)
694
695         IF(WITH_INTERNATIONAL)
696                 SET(GETTEXT ${LIBDIR}/gettext)
697                 SET(GETTEXT_INC "${GETTEXT}/include")
698                 SET(GETTEXT_LIB intl iconv)
699                 SET(GETTEXT_LIBPATH ${GETTEXT}/lib)
700         ENDIF(WITH_INTERNATIONAL)
701   
702         IF(WITH_FFTW3)
703                 SET(FFTW3 ${LIBDIR}/fftw3)
704                 SET(FFTW3_INC ${FFTW3}/include)
705                 SET(FFTW3_LIB fftw3)
706                 SET(FFTW3_LIBPATH ${FFTW3}/lib)
707         ENDIF(WITH_FFTW3)
708
709         SET(PNG_LIBRARIES png)
710         SET(JPEG_LIBRARY jpeg)
711
712         SET(ZLIB /usr)
713         SET(ZLIB_INC "${ZLIB}/include")
714         SET(ZLIB_LIBRARIES z bz2)
715
716         SET(FREETYPE ${LIBDIR}/freetype)
717         SET(FREETYPE_INCLUDE_DIRS ${FREETYPE}/include ${FREETYPE}/include/freetype2)
718         SET(FREETYPE_LIBPATH ${FREETYPE}/lib)
719         SET(FREETYPE_LIBRARY freetype)
720
721         IF(WITH_OPENEXR)
722                 SET(OPENEXR ${LIBDIR}/openexr)
723                 SET(OPENEXR_INC ${OPENEXR}/include/OpenEXR ${OPENEXR}/include)
724                 SET(OPENEXR_LIB Iex Half IlmImf Imath IlmThread)
725                 SET(OPENEXR_LIBPATH ${OPENEXR}/lib)
726         ENDIF(WITH_OPENEXR)
727
728         IF(WITH_LCMS)
729                 SET(LCMS ${LIBDIR}/lcms)
730                 SET(LCMS_INCLUDE_DIR ${LCMS}/include)
731                 SET(LCMS_LIBRARY lcms)
732                 SET(LCMS_LIBPATH ${LCMS}/lib)
733         ENDIF(WITH_LCMS)
734
735         IF(WITH_FFMPEG)
736                 SET(FFMPEG ${LIBDIR}/ffmpeg)
737                 SET(FFMPEG_INC ${FFMPEG}/include)
738                 SET(FFMPEG_LIB avcodec avdevice avformat avutil mp3lame swscale x264 xvidcore theora theoradec theoraenc vorbis vorbisenc vorbisfile ogg)
739                 SET(FFMPEG_LIBPATH ${FFMPEG}/lib)
740                 SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D__STDC_CONSTANT_MACROS")
741         ENDIF(WITH_FFMPEG)
742
743         SET(LIBSAMPLERATE ${LIBDIR}/samplerate)
744         SET(LIBSAMPLERATE_INC ${LIBSAMPLERATE}/include)
745         SET(LIBSAMPLERATE_LIB samplerate)
746         SET(LIBSAMPLERATE_LIBPATH ${LIBSAMPLERATE}/lib)
747
748         SET(LLIBS stdc++ SystemStubs)
749
750         IF (WITH_COCOA)
751                 SET(PLATFORM_CFLAGS "-pipe -funsigned-char -DGHOST_COCOA")
752                 SET(PLATFORM_LINKFLAGS "-fexceptions -framework CoreServices -framework Foundation -framework IOKit -framework AppKit -framework Cocoa -framework Carbon -framework AudioUnit -framework AudioToolbox -framework CoreAudio")
753                 IF(USE_QTKIT)
754                         SET(PLATFORM_CFLAGS "${PLATFORM_CFLAGS} -DUSE_QTKIT")
755                         SET(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} -framework QTKit")
756                         IF(CMAKE_OSX_ARCHITECTURES MATCHES i386)
757                                 SET(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} -framework QuickTime")
758                                 #libSDL still needs 32bit carbon quicktime 
759                         ENDIF(CMAKE_OSX_ARCHITECTURES MATCHES i386)
760                 ELSEIF(WITH_QUICKTIME)
761                         SET(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} -framework QuickTime")
762                 ENDIF(USE_QTKIT)
763         ELSE (WITH_COCOA)
764                 SET(PLATFORM_CFLAGS "-pipe -funsigned-char")
765                 SET(PLATFORM_LINKFLAGS "-fexceptions -framework CoreServices -framework Foundation -framework IOKit -framework AppKit -framework Carbon -framework AGL -framework AudioUnit -framework AudioToolbox -framework CoreAudio -framework QuickTime")
766         ENDIF (WITH_COCOA)
767
768         IF(WITH_OPENMP)
769                 SET(LLIBS "${LLIBS} -lgomp")
770                 SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fopenmp")
771                 SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fopenmp")
772         ENDIF(WITH_OPENMP)
773
774         IF (WITH_OPENCOLLADA)
775                 SET(OPENCOLLADA ${LIBDIR}/opencollada)
776                 SET(OPENCOLLADA_INC ${OPENCOLLADA}/include)
777                 SET(OPENCOLLADA_LIBPATH ${OPENCOLLADA}/lib)
778                 SET(OPENCOLLADA_LIB "OpenCOLLADASaxFrameworkLoader -lOpenCOLLADAFramework -lOpenCOLLADABaseUtils -lOpenCOLLADAStreamWriter -lMathMLSolver -lGeneratedSaxParser -lUTF -lxml2 -lbuffer -lftoa" )
779                 #pcre is bundled with openCollada
780                 #SET(PCRE ${LIBDIR}/pcre)
781                 #SET(PCRE_LIBPATH ${PCRE}/lib)
782                 SET(PCRE_LIB pcre)
783                 #libxml2 is used
784                 #SET(EXPAT ${LIBDIR}/expat)
785                 #SET(EXPAT_LIBPATH ${EXPAT}/lib)
786                 SET(EXPAT_LIB)
787         ENDIF (WITH_OPENCOLLADA)
788
789         IF(WITH_SDL)
790                 SET(SDL ${LIBDIR}/sdl)
791                 SET(SDL_INCLUDE_DIR ${SDL}/include)
792                 SET(SDL_LIBRARY SDL)
793                 SET(SDL_LIBPATH ${SDL}/lib)
794         ENDIF(WITH_SDL)
795
796         SET(PNG "${LIBDIR}/png")
797         SET(PNG_INC "${PNG}/include")
798         SET(PNG_LIBPATH ${PNG}/lib)
799
800         SET(JPEG "${LIBDIR}/jpeg")
801         SET(JPEG_INC "${JPEG}/include")
802         SET(JPEG_LIBPATH ${JPEG}/lib)
803
804         IF(WITH_TIFF)
805                 SET(TIFF ${LIBDIR}/tiff)
806                 SET(TIFF_INCLUDE_DIR ${TIFF}/include)
807                 SET(TIFF_LIBRARY tiff)
808                 SET(TIFF_LIBPATH ${TIFF}/lib)
809         ENDIF(WITH_TIFF)
810
811         IF(WITH_RAYOPTIMIZATION AND SUPPORT_SSE_BUILD)
812                 SET(PLATFORM_CFLAGS " -msse -msse2 ${PLATFORM_CFLAGS}")
813                 ADD_DEFINITIONS(-D__SSE__)
814                 ADD_DEFINITIONS(-D__MMX__)
815         ENDIF(WITH_RAYOPTIMIZATION AND SUPPORT_SSE_BUILD)
816
817         SET(EXETYPE MACOSX_BUNDLE)
818
819         SET(CMAKE_C_FLAGS_DEBUG "-fno-strict-aliasing -g")
820         SET(CMAKE_CXX_FLAGS_DEBUG "-fno-strict-aliasing -g")
821         IF(CMAKE_OSX_ARCHITECTURES MATCHES "i386")
822                 SET(CMAKE_CXX_FLAGS_RELEASE "-O3 -mdynamic-no-pic -ftree-vectorize -msse -msse2 -fvariable-expansion-in-unroller")
823                 SET(CMAKE_C_FLAGS_RELEASE "-O3 -mdynamic-no-pic -ftree-vectorize -msse -msse2 -fvariable-expansion-in-unroller")
824         ELSEIF(CMAKE_OSX_ARCHITECTURES MATCHES "x86_64")
825                 SET(CMAKE_CXX_FLAGS_RELEASE "-O3 -mdynamic-no-pic -ftree-vectorize -msse -msse2 -msse3 -mssse3 -fvariable-expansion-in-unroller")
826                 SET(CMAKE_C_FLAGS_RELEASE "-O3 -mdynamic-no-pic -ftree-vectorize -msse -msse2 -msse3 -mssse3 -fvariable-expansion-in-unroller")
827         ELSE(CMAKE_OSX_ARCHITECTURES MATCHES "x86_64")
828                 SET(CMAKE_C_FLAGS_RELEASE "-mdynamic-no-pic -fno-strict-aliasing")
829                 SET(CMAKE_CXX_FLAGS_RELEASE "-mdynamic-no-pic -fno-strict-aliasing")
830         ENDIF(CMAKE_OSX_ARCHITECTURES MATCHES "i386")
831
832         # Better warnings
833         SET(C_WARNINGS "-Wall -Wno-char-subscripts -Wpointer-arith -Wcast-align -Wdeclaration-after-statement -Wno-unknown-pragmas")
834         SET(CXX_WARNINGS "-Wall -Wno-invalid-offsetof -Wno-sign-compare")
835
836 ENDIF(APPLE)
837
838
839 # buildinfo
840 IF(WITH_BUILDINFO)
841         # BUILD_PLATFORM and BUILD_PLATFORM are taken from CMake
842         IF(UNIX)
843                 EXEC_PROGRAM("date \"+%Y-%m-%d\"" OUTPUT_VARIABLE BUILD_DATE)
844                 EXEC_PROGRAM("date \"+%H:%M:%S\"" OUTPUT_VARIABLE BUILD_TIME)  
845                 EXEC_PROGRAM("svnversion ${CMAKE_SOURCE_DIR}" OUTPUT_VARIABLE BUILD_REV RETURN_VALUE BUILD_REV_RETURN)
846                 IF(BUILD_REV_RETURN)
847                         SET(BUILD_REV "unknown")
848                 ENDIF(BUILD_REV_RETURN)
849         ENDIF(UNIX)
850         
851         IF(WIN32)
852                 EXEC_PROGRAM("cmd /c date /t" OUTPUT_VARIABLE BUILD_DATE)
853                 EXEC_PROGRAM("cmd /c time /t" OUTPUT_VARIABLE BUILD_TIME)  
854                 EXEC_PROGRAM("svnversion ${CMAKE_SOURCE_DIR}" OUTPUT_VARIABLE BUILD_REV RETURN_VALUE BUILD_REV_RETURN)
855                 IF(BUILD_REV_RETURN)
856                         SET(BUILD_REV "unknown")
857                 ENDIF(BUILD_REV_RETURN)
858         ENDIF(WIN32)
859 ENDIF(WITH_BUILDINFO)
860         
861 #-----------------------------------------------------------------------------
862 # Common.
863 IF(WITH_OPENJPEG)
864         set(OPENJPEG ${CMAKE_SOURCE_DIR}/extern/libopenjpeg)
865         set(OPENJPEG_INC ${OPENJPEG})
866         set(OPENJPEG_LIb extern_libopenjpeg)
867 ENDIF(WITH_OPENJPEG)
868
869 #-----------------------------------------------------------------------------
870 # Blender WebPlugin
871
872 IF(WITH_WEBPLUGIN) 
873         SET(GECKO_DIR "${CMAKE_SOURCE_DIR}/../gecko-sdk/" CACHE PATH "Gecko SDK path")
874         SET(WEBPLUGIN_SANDBOX_MODE "apparmor" CACHE STRING "WEB Plugin sandbox mode, can be apparmor, privsep, none")
875
876         SET(WITH_PLAYER ON)
877 ENDIF(WITH_WEBPLUGIN)
878
879
880 #-----------------------------------------------------------------------------
881 # Configure OpenGL.
882 FIND_PACKAGE(OpenGL)
883 INCLUDE_DIRECTORIES(${OPENGL_INCLUDE_DIR})
884 # UNSET(OPENGL_LIBRARIES CACHE) # not compat with older cmake 
885 # UNSET(OPENGL_xmesa_INCLUDE_DIR CACHE) # not compat with older cmake 
886
887 #-----------------------------------------------------------------------------
888 # Extra compile flags
889 SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${PLATFORM_CFLAGS} ${C_WARNINGS}")
890 SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${PLATFORM_CFLAGS} ${CXX_WARNINGS}")
891
892 # better not define flags here but this is a debugging option thats off by default.
893 IF(WITH_CXX_GUARDEDALLOC)
894         SET(CMAKE_CXX_FLAGS " -DWITH_CXX_GUARDEDALLOC -I${CMAKE_SOURCE_DIR}/intern/guardedalloc ${CMAKE_CXX_FLAGS}")
895 ENDIF(WITH_CXX_GUARDEDALLOC)
896
897 #-----------------------------------------------------------------------------
898 # Libraries
899 FILE(WRITE ${CMAKE_BINARY_DIR}/cmake_blender_libs.txt "")
900 ADD_SUBDIRECTORY(intern)
901 ADD_SUBDIRECTORY(extern)
902 ADD_SUBDIRECTORY(source)
903
904
905 #-----------------------------------------------------------------------------
906 # Blender Application
907 ADD_SUBDIRECTORY(source/creator)
908
909
910 #-----------------------------------------------------------------------------
911 # Blender Player
912 IF(WITH_PLAYER)
913         ADD_SUBDIRECTORY(source/blenderplayer)
914 ENDIF(WITH_PLAYER)