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