svn merge -r 22571:22800 https://svn.blender.org/svnroot/bf-blender/trunk/blender
[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., 59 Temple Place - Suite 330, Boston, MA  02111-1307, 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.4)
46 PROJECT(Blender)
47
48 #-----------------------------------------------------------------------------
49 # Redirect output files
50
51 SET(EXECUTABLE_OUTPUT_PATH ${CMAKE_BINARY_DIR}/bin)
52 SET(LIBRARY_OUTPUT_PATH  ${CMAKE_BINARY_DIR}/lib)
53
54 #-----------------------------------------------------------------------------
55 # Set default config options
56 OPTION(WITH_PLAYER              "Build Player"                                          OFF)
57 OPTION(WITH_GAMEENGINE          "Enable Game Engine"                                    ON)
58 OPTION(WITH_BULLET              "Enable Bullet (Physics Engine)"                        ON)
59 OPTION(WITH_INTERNATIONAL       "Enable I18N   (International fonts and text)"          ON)
60 OPTION(WITH_ELBEEM              "Enable Elbeem (Fluid Simulation)"                      ON)
61 OPTION(WITH_QUICKTIME           "Enable Quicktime Support"                              OFF)
62 OPTION(WITH_OPENEXR             "Enable OpenEXR Support (http://www.openexr.com)"       ON)
63 OPTION(WITH_DDS                 "Enable DDS Support"                                    ON)
64 OPTION(WITH_FFMPEG              "Enable FFMPeg Support (http://ffmpeg.mplayerhq.hu/)"   OFF)
65 OPTION(WITH_PYTHON              "Enable Embedded Python API"                            ON)
66 OPTION(WITH_SDL                 "Enable SDL for sound and joystick support"                             ON)
67 OPTION(WITH_OPENJPEG            "Enable OpenJpeg Support (http://www.openjpeg.org/)"    OFF)
68 OPTION(WITH_OPENAL              "Enable OpenAL Support (http://www.openal.org)"         ON)
69 OPTION(WITH_OPENMP              "Enable OpenMP (has to be supported by the compiler)"   OFF)
70 OPTION(WITH_WEBPLUGIN           "Enable Web Plugin (Unix only)"                         OFF)
71 OPTION(WITH_FFTW3               "Enable FFTW3 support"                          OFF)
72 OPTION(WITH_JACK                "Enable Jack Support (http://www.jackaudio.org)"                OFF)
73 OPTION(WITH_INSTALL "Install accompanying scripts and language files needed to run blender" ON)
74
75 IF(NOT WITH_GAMEENGINE AND WITH_PLAYER)
76   MESSAGE("WARNING: WITH_PLAYER needs WITH_GAMEENGINE")
77 ENDIF(NOT WITH_GAMEENGINE AND WITH_PLAYER)
78
79 # For alternate Python locations the commandline can be used to override detected/default cache settings, e.g:
80 # On Unix: 
81 #   cmake -D PYTHON_LIB=/usr/local/lib/python2.3/config/libpython2.3.so -D PYTHON_INC=/usr/local/include/python2.3 -D PYTHON_BINARY=/usr/local/bin/python2.3 -G "Unix Makefiles" ../blender
82 # On Macs: 
83 #   cmake -D PYTHON_INC=/System/Library/Frameworks/Python.framework/Versions/2.5/include/python2.5 -D PYTHON_LIBPATH=/System/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/config -D PYTHON_BINARY=/System/Library/Frameworks/Python.framework/Versions/2.5/bin/python2.5 -G Xcode ../blender
84 #
85 # When changing any of this remember to update the notes in doc/blender-cmake.txt
86
87 #-----------------------------------------------------------------------------
88 # Load some macros.
89 INCLUDE(CMake/macros.cmake)
90
91 #-----------------------------------------------------------------------------
92 #Platform specifics
93
94 IF(UNIX AND NOT APPLE)
95   IF(WITH_OPENAL)
96     FIND_PACKAGE(OpenAL)
97     IF(OPENAL_FOUND)
98       SET(WITH_OPENAL ON)
99     ELSE(OPENAL_FOUND)
100       SET(WITH_OPENAL OFF)
101     ENDIF(OPENAL_FOUND)
102   ENDIF(WITH_OPENAL)
103
104   IF(WITH_JACK)
105         SET(JACK /usr)
106         SET(JACK_INC ${JACK}/include/jack)
107         SET(JACK_LIB jack)
108         SET(JACK_LIBPATH ${JACK}/lib)
109   ENDIF(WITH_JACK)
110
111   FIND_LIBRARY(INTL_LIBRARY
112     NAMES intl
113     PATHS
114     /sw/lib
115   )
116   FIND_LIBRARY(ICONV_LIBRARY
117     NAMES iconv
118     PATHS
119     /sw/lib
120   )
121   
122   IF(INTL_LIBRARY AND ICONV_LIBRARY)
123     SET(GETTEXT_LIB ${INTL_LIBRARY} ${ICONV_LIBRARY})
124   ENDIF(INTL_LIBRARY AND ICONV_LIBRARY)
125
126   FIND_PACKAGE(Freetype)
127   # UNSET(FREETYPE_INCLUDE_DIRS CACHE) # cant use
128
129   # No way to set py31. remove for now.
130   # FIND_PACKAGE(PythonLibs)
131   SET(PYTHON /usr)
132   SET(PYTHON_VERSION 3.1)
133   SET(PYTHON_INC "${PYTHON}/include/python${PYTHON_VERSION}" CACHE STRING "")
134   # SET(PYTHON_BINARY python) # not used yet
135   SET(PYTHON_LIB python${PYTHON_VERSION} CACHE STRING "")
136   SET(PYTHON_LIBPATH ${PYTHON}/lib CACHE STRING "")
137   
138   # FIND_PACKAGE(PythonInterp) # not used yet
139   # SET(PYTHON_BINARY ${PYTHON_EXECUTABLE} CACHE STRING "")
140   
141   SET(PYTHON_LINKFLAGS "-Xlinker -export-dynamic")
142
143   IF(WITH_SDL)
144     FIND_PACKAGE(SDL)
145     # UNSET(SDLMAIN_LIBRARY CACHE)
146     IF(NOT SDL_FOUND)
147       SET(WITH_SDL OFF)
148     ENDIF(NOT SDL_FOUND)
149   ENDIF(WITH_SDL)
150
151   FIND_PATH(OPENEXR_INC
152     ImfXdr.h
153     PATHS
154     /usr/local/include/OpenEXR
155     /usr/include/OpenEXR
156     /sw/include/OpenEXR
157     /opt/local/include/OpenEXR
158     /opt/csw/include/OpenEXR
159     /opt/include/OpenEXR
160   )
161   SET(OPENEXR_LIB Half IlmImf Iex Imath)
162
163   SET(FFMPEG /usr)
164   SET(FFMPEG_INC ${FFMPEG}/include)
165   SET(FFMPEG_LIB avformat avcodec avutil avdevice swscale)
166   SET(FFMPEG_LIBPATH ${FFMPEG}/lib)
167   
168   IF(WITH_FFTW3)
169     SET(FFTW3 /usr)
170     SET(FFTW3_INC ${FFTW3}/include)
171     SET(FFTW3_LIB fftw3)
172     SET(FFTW3_LIBPATH ${FFTW3}/lib)
173   ENDIF(WITH_FFTW3)
174
175   SET(LIBSAMPLERATE /usr)
176   SET(LIBSAMPLERATE_INC ${LIBSAMPLERATE}/include)
177   SET(LIBSAMPLERATE_LIB samplerate)
178   SET(LIBSAMPLERATE_LIBPATH ${LIBSAMPLERATE}/lib)
179
180   FIND_PACKAGE(JPEG REQUIRED)
181
182   FIND_PACKAGE(PNG REQUIRED)
183
184   FIND_PACKAGE(ZLIB REQUIRED)
185
186   # Could use ${X11_Xinput_LIB} ${X11_X11_LIB} too
187   SET(LLIBS "-lXi -lutil -lc -lm -lpthread -lstdc++ -lX11")
188
189   IF(CMAKE_SYSTEM_NAME MATCHES "Linux")
190     # BSD's dont use libdl.so
191     SET(LLIBS "${LLIBS} -ldl")
192   ENDIF(CMAKE_SYSTEM_NAME MATCHES "Linux")
193
194   IF(WITH_OPENMP)
195     SET(LLIBS "${LLIBS} -lgomp")
196     SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fopenmp")
197     SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fopenmp")
198   ENDIF(WITH_OPENMP)
199
200
201   SET(PLATFORM_CFLAGS "-pipe -fPIC -funsigned-char -fno-strict-aliasing -DXP_UNIX -Wno-char-subscripts")
202
203   SET(PLATFORM_LINKFLAGS "-pthread")
204
205   # Better warnings
206   SET(C_WARNINGS "-Wall -Wno-char-subscripts -Wpointer-arith -Wcast-align -Wnested-externs -Wdeclaration-after-statement")
207
208   INCLUDE_DIRECTORIES(${JPEG_INCLUDE_DIR} ${PNG_INCLUDE_DIR} ${ZLIB_INCLUDE_DIR} )
209 ENDIF(UNIX AND NOT APPLE)
210
211 IF(WIN32)
212
213   # this file is included anyway when building under Windows with cl.exe
214   #  INCLUDE(${CMAKE_ROOT}/Modules/Platform/Windows-cl.cmake)
215   
216   SET(LIBDIR ${CMAKE_SOURCE_DIR}/../lib/windows)
217
218   # Setup 64bit and 64bit windows systems
219   IF(CMAKE_CL_64)
220     message("64 bit compiler detected.")
221     SET(LIBDIR ${CMAKE_SOURCE_DIR}/../lib/win64)
222   ENDIF(CMAKE_CL_64)
223
224   SET(PYTHON ${LIBDIR}/python)
225   SET(PYTHON_VERSION 3.1)
226   SET(PYTHON_INC "${PYTHON}/include/python${PYTHON_VERSION}")
227   # SET(PYTHON_BINARY python) # not used yet
228   SET(PYTHON_LIB python31)
229   SET(PYTHON_LIBPATH ${PYTHON}/lib)
230
231   IF(CMAKE_CL_64)
232     SET(WITH_OPENAL OFF)
233   ELSE(CMAKE_CL_64)
234     #SET(WITH_OPENAL ON)
235     SET(OPENAL ${LIBDIR}/openal)
236     SET(OPENAL_INCLUDE_DIR ${OPENAL}/include)
237     SET(OPENAL_LIBRARY wrap_oal)
238     SET(OPENAL_LIBPATH ${OPENAL}/lib)
239   ENDIF(CMAKE_CL_64)
240
241   IF(WITH_JACK)
242         SET(JACK ${LIBDIR}/jack)
243         SET(JACK_INC ${JACK}/include/jack)
244         SET(JACK_LIB jack)
245         SET(JACK_LIBPATH ${JACK}/lib)
246   ENDIF(WITH_JACK)
247
248   IF(CMAKE_CL_64)
249     SET(PNG_LIBRARIES libpng)
250   ELSE(CMAKE_CL_64)
251     SET(PNG_LIBRARIES libpng_st)
252   ENDIF(CMAKE_CL_64)
253   SET(JPEG_LIBRARY libjpeg)
254
255   SET(ZLIB ${LIBDIR}/zlib)
256   SET(ZLIB_INC ${ZLIB}/include)
257   SET(ZLIB_LIBRARIES zlib)
258   SET(ZLIB_LIBPATH ${ZLIB}/lib)
259   
260   SET(PTHREADS ${LIBDIR}/pthreads)
261   SET(PTHREADS_INC ${PTHREADS}/include)
262   SET(PTHREADS_LIB pthreadVC2)
263   SET(PTHREADS_LIBPATH ${PTHREADS}/lib)
264   
265   SET(ICONV ${LIBDIR}/iconv)
266   SET(ICONV_INC ${ICONV}/include)
267   SET(ICONV_LIB iconv)
268   SET(ICONV_LIBPATH ${ICONV}/lib)
269   
270   IF(WITH_FFTW3)
271       SET(FFTW3 ${LIBDIR}/fftw3)
272       SET(FFTW3_INC ${FFTW3}/include)
273       SET(FFTW3_LIB libfftw)
274       SET(FFTW3_LIBPATH ${FFTW3}/lib)
275   ENDIF(WITH_FFTW3)
276   
277   SET(GETTEXT ${LIBDIR}/gettext)
278   SET(GETTEXT_INC ${GETTEXT}/include)
279   IF(CMAKE_CL_64)
280     SET(GETTEXT_LIB gettextlib)
281   ELSE(CMAKE_CL_64)
282     SET(GETTEXT_LIB gnu_gettext)
283   ENDIF(CMAKE_CL_64)
284   SET(GETTEXT_LIBPATH ${GETTEXT}/lib)
285
286   SET(FREETYPE ${LIBDIR}/freetype)
287   SET(FREETYPE_INCLUDE_DIRS ${FREETYPE}/include ${FREETYPE}/include/freetype2)
288   SET(FREETYPE_LIBPATH ${FREETYPE}/lib)
289   SET(FREETYPE_LIBRARY freetype2ST)
290   
291   SET(OPENEXR ${LIBDIR}/openexr)
292   SET(OPENEXR_INC ${OPENEXR}/include ${OPENEXR}/include/IlmImf ${OPENEXR}/include/Iex ${OPENEXR}/include/Imath)
293   SET(OPENEXR_LIB Iex Half IlmImf Imath IlmThread)
294   IF (MSVC80)
295   SET(OPENEXR_LIBPATH ${OPENEXR}/lib_vs2005)
296   ELSE (MSVC80)
297   SET(OPENEXR_LIBPATH ${OPENEXR}/lib_msvc)
298   ENDIF(MSVC80)
299   IF (MSVC90)
300   SET(OPENEXR_LIBPATH ${OPENEXR}/lib_vs2008)
301   ENDIF(MSVC90)
302
303   
304   SET(QUICKTIME ${LIBDIR}/QTDevWin)
305   SET(QUICKTIME_INC ${QUICKTIME}/CIncludes)
306   SET(QUICKTIME_LIB qtmlClient)
307   SET(QUICKTIME_LIBPATH ${QUICKTIME}/Libraries)
308
309   SET(FFMPEG ${LIBDIR}/ffmpeg)
310   SET(FFMPEG_INC ${FFMPEG}/include)
311   SET(FFMPEG_LIB avcodec-52 avformat-52 avdevice-52 avutil-50 swscale-0)
312   SET(FFMPEG_LIBPATH ${FFMPEG}/lib)
313
314   SET(LIBSAMPLERATE ${LIBDIR}/samplerate)
315   SET(LIBSAMPLERATE_INC ${LIBSAMPLERATE}/include)
316   SET(LIBSAMPLERATE_LIB libsamplerate)
317   SET(LIBSAMPLERATE_LIBPATH ${LIBSAMPLERATE}/lib)
318
319   IF(CMAKE_CL_64)
320   SET(LLIBS kernel32 user32 vfw32 winmm ws2_32 )
321   ELSE(CMAKE_CL_64)
322   SET(LLIBS kernel32 user32 gdi32 comdlg32 advapi32 shell32 ole32 oleaut32 uuid ws2_32 vfw32 winmm)
323   ENDIF(CMAKE_CL_64)
324
325   SET(CMAKE_CXX_FLAGS_DEBUG "/D_CRT_NONSTDC_NO_DEPRECATE /D_CRT_SECURE_NO_DEPRECATE /D_SCL_SECURE_NO_DEPRECATE /wd4800 /wd4244 /wd4305 /D_DEBUG /Od /Gm /EHsc /RTC1 /MTd /W3 /nologo /ZI /J" CACHE STRING "MSVC MT flags " FORCE)
326   SET(CMAKE_CXX_FLAGS_RELEASE "/D_CRT_NONSTDC_NO_DEPRECATE /D_CRT_SECURE_NO_DEPRECATE /D_SCL_SECURE_NO_DEPRECATE /wd4800 /wd4244 /wd4305 /O2 /Ob2 /DNDEBUG /EHsc /MT /W3 /nologo /J" CACHE STRING "MSVC MT flags " FORCE)
327   SET(CMAKE_CXX_FLAGS_MINSIZEREL "/D_CRT_NONSTDC_NO_DEPRECATE /D_CRT_SECURE_NO_DEPRECATE /D_SCL_SECURE_NO_DEPRECATE /wd4800 /wd4244 /wd4305 /O1 /Ob1 /DNDEBUG /EHsc /MT /W3 /nologo /J" CACHE STRING "MSVC MT flags " FORCE)
328   SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "/D_CRT_NONSTDC_NO_DEPRECATE /D_CRT_SECURE_NO_DEPRECATE /D_SCL_SECURE_NO_DEPRECATE /wd4800 /wd4244 /wd4305 /O2 /Ob1 /DNDEBUG /EHsc /MT /W3 /nologo /Zi /J" CACHE STRING "MSVC MT flags " FORCE)
329   SET(CMAKE_C_FLAGS_DEBUG "/D_CRT_NONSTDC_NO_DEPRECATE /D_CRT_SECURE_NO_DEPRECATE /D_SCL_SECURE_NO_DEPRECATE /wd4800 /wd4244 /wd4305 /D_DEBUG /Od /Gm /EHsc /RTC1 /MTd /W3 /nologo /ZI /J" CACHE STRING "MSVC MT flags " FORCE)
330   SET(CMAKE_C_FLAGS_RELEASE "/D_CRT_NONSTDC_NO_DEPRECATE /D_CRT_SECURE_NO_DEPRECATE /D_SCL_SECURE_NO_DEPRECATE /wd4800 /wd4244 /wd4305 /O2 /Ob2 /DNDEBUG /EHsc /MT /W3 /nologo /J" CACHE STRING "MSVC MT flags " FORCE)
331   SET(CMAKE_C_FLAGS_MINSIZEREL "/D_CRT_NONSTDC_NO_DEPRECATE /D_CRT_SECURE_NO_DEPRECATE /D_SCL_SECURE_NO_DEPRECATE /wd4800 /wd4244 /wd4305 /O1 /Ob1 /DNDEBUG /EHsc /MT /W3 /nologo /J" CACHE STRING "MSVC MT flags " FORCE)
332   SET(CMAKE_C_FLAGS_RELWITHDEBINFO "/D_CRT_NONSTDC_NO_DEPRECATE /D_CRT_SECURE_NO_DEPRECATE /D_SCL_SECURE_NO_DEPRECATE /wd4800 /wd4244 /wd4305 /O2 /Ob1 /DNDEBUG /EHsc /MT /W3 /nologo /Zi /J" CACHE STRING "MSVC MT flags " FORCE)
333
334   IF(WITH_OPENMP)
335     SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /openmp ")
336     SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /openmp ")
337   ENDIF(WITH_OPENMP)
338
339   SET(SDL ${LIBDIR}/sdl)
340   SET(SDL_INCLUDE_DIR ${SDL}/include)
341   SET(SDL_LIBRARY SDL)
342   SET(SDL_LIBPATH ${SDL}/lib)
343
344   SET(PNG "${LIBDIR}/png")
345   SET(PNG_INC "${PNG}/include")
346   SET(PNG_LIBPATH ${PNG}/lib)
347
348   SET(JPEG "${LIBDIR}/jpeg")
349   SET(JPEG_INC "${JPEG}/include")
350   SET(JPEG_LIBPATH ${JPEG}/lib)
351
352   SET(TIFF ${LIBDIR}/tiff)
353   SET(TIFF_INC ${TIFF}/include)
354   
355   SET(WINTAB_INC ${LIBDIR}/wintab/include) 
356
357   IF(CMAKE_CL_64)
358   SET(PLATFORM_LINKFLAGS "/MANIFEST:NO /MANIFESTUAC:NO /MACHINE:X64 /NODEFAULTLIB:libc.lib;MSVCRT.lib ")
359   ELSE(CMAKE_CL_64)
360   SET(PLATFORM_LINKFLAGS "/NODEFAULTLIB:libc.lib ")
361   ENDIF(CMAKE_CL_64)
362   SET(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} /NODEFAULTLIB:libcmt.lib;libc.lib ")
363 ENDIF(WIN32)
364
365 IF(APPLE)
366   IF(CMAKE_OSX_ARCHITECTURES MATCHES i386)
367     SET(LIBDIR ${CMAKE_SOURCE_DIR}/../lib/darwin-8.x.i386)
368   ELSE(CMAKE_OSX_ARCHITECTURES MATCHES i386)
369     SET(LIBDIR ${CMAKE_SOURCE_DIR}/../lib/darwin-6.1-powerpc)
370   ENDIF(CMAKE_OSX_ARCHITECTURES MATCHES i386)
371
372   IF(WITH_OPENAL)
373     FIND_PACKAGE(OpenAL)
374     IF(OPENAL_FOUND)
375       SET(WITH_OPENAL ON)
376     ELSE(OPENAL_FOUND)
377       SET(WITH_OPENAL OFF)
378     ENDIF(OPENAL_FOUND)
379   ENDIF(WITH_OPENAL)
380
381   IF(WITH_JACK)
382         SET(JACK /usr)
383         SET(JACK_INC ${JACK}/include/jack)
384         SET(JACK_LIB jack)
385         SET(JACK_LIBPATH ${JACK}/lib)
386   ENDIF(WITH_JACK)
387
388   SET(PYTHON_VERSION 3.1)
389
390   IF(PYTHON_VERSION MATCHES 3.1)
391     # we use precompiled libraries for py 3.1 and up by default
392
393     SET(PYTHON ${LIBDIR}/python)
394     SET(PYTHON_INC "${PYTHON}/include/python${PYTHON_VERSION}" CACHE STRING "")
395     # SET(PYTHON_BINARY "${PYTHON}/bin/python${PYTHON_VERSION}" CACHE STRING "") # not used yet
396     SET(PYTHON_LIB python${PYTHON_VERSION})
397     SET(PYTHON_LIBPATH "${PYTHON}/lib/python${PYTHON_VERSION}" CACHE STRING "")
398     #    SET(PYTHON_LINKFLAGS "-u _PyMac_Error")  # won't  build with this enabled
399   ELSE(PYTHON_VERSION MATCHES 3.1)
400     # otherwise, use custom system framework
401
402     SET(PYTHON /System/Library/Frameworks/Python.framework/Versions/)
403     SET(PYTHON_VERSION 2.5)
404     SET(PYTHON_INC "${PYTHON}${PYTHON_VERSION}/include/python${PYTHON_VERSION}" CACHE STRING "")
405     # SET(PYTHON_BINARY ${PYTHON}${PYTHON_VERSION}/bin/python${PYTHON_VERSION} CACHE STRING "") # not used yet
406     SET(PYTHON_LIB "")
407     SET(PYTHON_LIBPATH ${PYTHON}${PYTHON_VERSION}/lib/python${PYTHON_VERSION}/config CACHE STRING "")
408     SET(PYTHON_LINKFLAGS "-u _PyMac_Error -framework System -framework Python")
409   ENDIF(PYTHON_VERSION MATCHES 3.1)
410
411   SET(GETTEXT ${LIBDIR}/gettext)
412   SET(GETTEXT_INC "${GETTEXT}/include")
413   SET(GETTEXT_LIB intl iconv)
414   SET(GETTEXT_LIBPATH ${GETTEXT}/lib)
415   
416   IF(WITH_FFTW3)
417     SET(FFTW3 ${LIBDIR}/fftw3)
418     SET(FFTW3_INC ${FFTW3}/include)
419     SET(FFTW3_LIB libfftw)
420     SET(FFTW3_LIBPATH ${FFTW3}/lib)
421   ENDIF(WITH_FFTW3)
422
423   SET(PNG_LIBRARIES png)
424   SET(JPEG_LIBRARY jpeg)
425
426   SET(ZLIB /usr)
427   SET(ZLIB_INC "${ZLIB}/include")
428   SET(ZLIB_LIBRARIES z)
429
430   SET(FREETYPE ${LIBDIR}/freetype)
431   SET(FREETYPE_INCLUDE_DIRS ${FREETYPE}/include ${FREETYPE}/include/freetype2)
432   SET(FREETYPE_LIBPATH ${FREETYPE}/lib)
433   SET(FREETYPE_LIBRARY freetype)
434
435   SET(OPENEXR ${LIBDIR}/openexr)
436   SET(OPENEXR_INC ${OPENEXR}/include/OpenEXR ${OPENEXR}/include)
437   SET(OPENEXR_LIB Iex Half IlmImf Imath IlmThread)
438   SET(OPENEXR_LIBPATH ${OPENEXR}/lib)
439
440   SET(FFMPEG ${LIBDIR}/ffmpeg)
441   SET(FFMPEG_INC ${CMAKE_SOURCE_DIR}/extern/ffmpeg)
442   SET(FFMPEG_LIB avcodec avdevice avformat avutil mp3lame swscale x264 xvidcore)
443   SET(FFMPEG_LIBPATH ${FFMPEG}/lib)
444
445   SET(LIBSAMPLERATE ${LIBDIR}/samplerate)
446   SET(LIBSAMPLERATE_INC ${LIBSAMPLERATE}/include)
447   SET(LIBSAMPLERATE_LIB samplerate)
448   SET(LIBSAMPLERATE_LIBPATH ${LIBSAMPLERATE}/lib)
449
450   SET(LLIBS stdc++ SystemStubs)
451
452   SET(PLATFORM_CFLAGS "-pipe -fPIC -funsigned-char -fno-strict-aliasing")
453   SET(PLATFORM_LINKFLAGS "-fexceptions -framework CoreServices -framework Foundation -framework IOKit -framework AppKit -framework Carbon -framework AGL -framework AudioUnit -framework AudioToolbox -framework CoreAudio -framework QuickTime")
454
455   IF(WITH_OPENMP)
456     SET(LLIBS "${LLIBS} -lgomp ")
457     SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fopenmp ")
458     SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fopenmp ")
459   ENDIF(WITH_OPENMP)
460
461   SET(SDL ${LIBDIR}/sdl)
462   SET(SDL_INCLUDE_DIR ${SDL}/include)
463   SET(SDL_LIBRARY SDL)
464   SET(SDL_LIBPATH ${SDL}/lib)
465
466   SET(PNG "${LIBDIR}/png")
467   SET(PNG_INC "${PNG}/include")
468   SET(PNG_LIBPATH ${PNG}/lib)
469
470   SET(JPEG "${LIBDIR}/jpeg")
471   SET(JPEG_INC "${JPEG}/include")
472   SET(JPEG_LIBPATH ${JPEG}/lib)
473
474   SET(TIFF ${LIBDIR}/tiff)
475   SET(TIFF_INC ${TIFF}/include)
476
477   SET(EXETYPE MACOSX_BUNDLE)
478 ENDIF(APPLE)
479
480 IF(CMAKE_SYSTEM_NAME MATCHES "Linux")
481   SET(BINRELOC ${CMAKE_SOURCE_DIR}/extern/binreloc)
482   SET(BINRELOC_INC ${BINRELOC}/include)
483 ENDIF(CMAKE_SYSTEM_NAME MATCHES "Linux")
484
485 #-----------------------------------------------------------------------------
486 # Common.
487
488 set(OPENJPEG ${CMAKE_SOURCE_DIR}/extern/libopenjpeg)
489 set(OPENJPEG_INC ${OPENJPEG})
490 set(OPENJPEG_LIb extern_libopenjpeg)
491
492 #-----------------------------------------------------------------------------
493 # Blender WebPlugin
494
495 IF(WITH_WEBPLUGIN) 
496   SET(GECKO_DIR "${CMAKE_SOURCE_DIR}/../gecko-sdk/" CACHE PATH "Gecko SDK path")
497   SET(WEBPLUGIN_SANDBOX_MODE "apparmor" CACHE STRING "WEB Plugin sandbox mode, can be apparmor, privsep, none")
498
499   SET(WITH_PLAYER ON)
500 ENDIF(WITH_WEBPLUGIN)
501
502
503 #-----------------------------------------------------------------------------
504 # Configure OpenGL.
505 FIND_PACKAGE(OpenGL)
506 INCLUDE_DIRECTORIES(${OPENGL_INCLUDE_DIR})
507 # UNSET(OPENGL_LIBRARIES CACHE) # not compat with older cmake 
508 # UNSET(OPENGL_xmesa_INCLUDE_DIR CACHE) # not compat with older cmake 
509
510 #-----------------------------------------------------------------------------
511 # Extra compile flags
512 IF(WITH_GAMEENGINE)
513   SET(PLATFORM_CFLAGS "${PLATFORM_CFLAGS} -DGAMEBLENDER ")
514 ENDIF(WITH_GAMEENGINE)
515 IF(WITH_BULLET)
516   SET(PLATFORM_CFLAGS "${PLATFORM_CFLAGS} -DWITH_BULLET ")
517 ENDIF(WITH_BULLET)
518 SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${PLATFORM_CFLAGS} ${C_WARNINGS}")
519 SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${PLATFORM_CFLAGS} ")
520
521 #-----------------------------------------------------------------------------
522 # Libraries
523 FILE(WRITE ${CMAKE_BINARY_DIR}/cmake_blender_libs.txt "")
524 ADD_SUBDIRECTORY(intern)
525 ADD_SUBDIRECTORY(extern)
526 ADD_SUBDIRECTORY(source)
527
528
529 #-----------------------------------------------------------------------------
530 # Blender Application
531 ADD_SUBDIRECTORY(source/creator)
532
533
534 #-----------------------------------------------------------------------------
535 # Blender Player
536 IF(WITH_PLAYER)
537   ADD_SUBDIRECTORY(blenderplayer)
538 ENDIF(WITH_PLAYER)