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