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