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