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