svn merge -r 23207:23528 https://svn.blender.org/svnroot/bf-blender/trunk/blender
[blender.git] / CMakeLists.txt
1 # $Id$
2 # ***** BEGIN GPL LICENSE BLOCK *****
3 #
4 # This program is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU General Public License
6 # as published by the Free Software Foundation; either version 2
7 # of the License, or (at your option) any later version.
8 #
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 # GNU General Public License for more details.
13 #
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software Foundation,
16 # Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
17 #
18 # The Original Code is Copyright (C) 2006, Blender Foundation
19 # All rights reserved.
20 #
21 # The Original Code is: all of this file.
22 #
23 # Contributor(s): Jacques Beaurain.
24 #
25 # ***** END GPL LICENSE BLOCK *****
26
27 #-----------------------------------------------------------------------------
28 # We don't allow in-source builds. This causes no end of troubles because 
29 # all out-of-source builds will use the CMakeCache.txt file there and even 
30 # build the libs and objects in it. It will also conflict with the current 
31 # Makefile system for Blender
32
33 IF(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR})
34 MESSAGE(FATAL_ERROR "CMake generation for blender is not allowed within the source directory! 
35 Remove the CMakeCache.txt file and try again from another folder, e.g.: 
36
37         rm CMakeCache.txt 
38         cd ..
39         mkdir cmake-make 
40         cd cmake-make
41         cmake -G \"Unix Makefiles\" ../blender
42 ")
43 ENDIF(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR})
44
45 CMAKE_MINIMUM_REQUIRED(VERSION 2.4)
46 PROJECT(Blender)
47
48 #-----------------------------------------------------------------------------
49 # Redirect output files
50
51 SET(EXECUTABLE_OUTPUT_PATH ${CMAKE_BINARY_DIR}/bin)
52 SET(LIBRARY_OUTPUT_PATH  ${CMAKE_BINARY_DIR}/lib)
53
54 # 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(NOT WITH_GAMEENGINE AND WITH_PLAYER)
85         MESSAGE("WARNING: WITH_PLAYER needs WITH_GAMEENGINE")
86 ENDIF(NOT WITH_GAMEENGINE AND WITH_PLAYER)
87
88 # For alternate Python locations the commandline can be used to override detected/default cache settings, e.g:
89 # On Unix: 
90 #   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
91 # On Macs: 
92 #   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
93 #
94 # When changing any of this remember to update the notes in doc/blender-cmake.txt
95
96 #-----------------------------------------------------------------------------
97 # Load some macros.
98 INCLUDE(CMake/macros.cmake)
99
100 #-----------------------------------------------------------------------------
101 #Platform specifics
102
103 IF(UNIX AND NOT APPLE)
104         IF(WITH_OPENAL)
105                 FIND_PACKAGE(OpenAL)
106                 IF(OPENAL_FOUND)
107                         SET(WITH_OPENAL ON)
108                 ELSE(OPENAL_FOUND)
109                         SET(WITH_OPENAL OFF)
110                 ENDIF(OPENAL_FOUND)
111         ENDIF(WITH_OPENAL)
112
113         IF(WITH_JACK)
114                 SET(JACK /usr)
115                 SET(JACK_INC ${JACK}/include/jack)
116                 SET(JACK_LIB jack)
117                 SET(JACK_LIBPATH ${JACK}/lib)
118         ENDIF(WITH_JACK)
119
120         IF(WITH_SNDFILE)
121         SET(SNDFILE /usr)
122         SET(SNDFILE_INC ${SNDFILE}/include)
123         SET(SNDFILE_LIB sndfile)
124         SET(SNDFILE_LIBPATH ${SNDFILE}/lib)
125         ENDIF(WITH_SNDFILE)
126
127         FIND_LIBRARY(INTL_LIBRARY
128                 NAMES intl
129                 PATHS
130                 /sw/lib
131         )
132         FIND_LIBRARY(ICONV_LIBRARY
133                 NAMES iconv
134                 PATHS
135                 /sw/lib
136         )
137   
138         IF(INTL_LIBRARY AND ICONV_LIBRARY)
139                 SET(GETTEXT_LIB ${INTL_LIBRARY} ${ICONV_LIBRARY})
140         ENDIF(INTL_LIBRARY AND ICONV_LIBRARY)
141
142         FIND_PACKAGE(Freetype)
143         # UNSET(FREETYPE_INCLUDE_DIRS CACHE) # cant use
144
145         # No way to set py31. remove for now.
146         # FIND_PACKAGE(PythonLibs)
147         SET(PYTHON /usr)
148         SET(PYTHON_VERSION 3.1)
149         SET(PYTHON_INC "${PYTHON}/include/python${PYTHON_VERSION}" CACHE STRING "")
150         # SET(PYTHON_BINARY python) # not used yet
151         SET(PYTHON_LIB python${PYTHON_VERSION} CACHE STRING "")
152         SET(PYTHON_LIBPATH ${PYTHON}/lib CACHE STRING "")
153   
154         # FIND_PACKAGE(PythonInterp) # not used yet
155         # SET(PYTHON_BINARY ${PYTHON_EXECUTABLE} CACHE STRING "")
156   
157         SET(PYTHON_LINKFLAGS "-Xlinker -export-dynamic")
158
159         IF(WITH_SDL)
160                 FIND_PACKAGE(SDL)
161                 # UNSET(SDLMAIN_LIBRARY CACHE)
162                 IF(NOT SDL_FOUND)
163                         SET(WITH_SDL OFF)
164                 ENDIF(NOT SDL_FOUND)
165         ENDIF(WITH_SDL)
166
167         FIND_PATH(OPENEXR_INC
168                 ImfXdr.h
169                 PATHS
170                 /usr/local/include/OpenEXR
171                 /usr/include/OpenEXR
172                 /sw/include/OpenEXR
173                 /opt/local/include/OpenEXR
174                 /opt/csw/include/OpenEXR
175                 /opt/include/OpenEXR
176         )
177         SET(OPENEXR_LIB Half IlmImf Iex Imath)
178
179         SET(FFMPEG /usr)
180         SET(FFMPEG_INC ${FFMPEG}/include)
181         SET(FFMPEG_LIB avformat avcodec avutil avdevice swscale)
182         SET(FFMPEG_LIBPATH ${FFMPEG}/lib)
183   
184         IF(WITH_FFTW3)
185                 SET(FFTW3 /usr)
186                 SET(FFTW3_INC ${FFTW3}/include)
187                 SET(FFTW3_LIB fftw3)
188                 SET(FFTW3_LIBPATH ${FFTW3}/lib)
189         ENDIF(WITH_FFTW3)
190
191         SET(LIBSAMPLERATE /usr)
192         SET(LIBSAMPLERATE_INC ${LIBSAMPLERATE}/include)
193         SET(LIBSAMPLERATE_LIB samplerate)
194         SET(LIBSAMPLERATE_LIBPATH ${LIBSAMPLERATE}/lib)
195
196         FIND_PACKAGE(JPEG REQUIRED)
197
198         FIND_PACKAGE(PNG REQUIRED)
199
200         FIND_PACKAGE(ZLIB REQUIRED)
201
202         # Could use ${X11_Xinput_LIB} ${X11_X11_LIB} too
203         SET(LLIBS "-lXi -lutil -lc -lm -lpthread -lstdc++ -lX11")
204
205         IF(CMAKE_SYSTEM_NAME MATCHES "Linux")
206                 # BSD's dont use libdl.so
207                 SET(LLIBS "${LLIBS} -ldl")
208         ENDIF(CMAKE_SYSTEM_NAME MATCHES "Linux")
209
210         IF(WITH_OPENMP)
211                 SET(LLIBS "${LLIBS} -lgomp")
212                 SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fopenmp")
213                 SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fopenmp")
214         ENDIF(WITH_OPENMP)
215
216
217         SET(PLATFORM_CFLAGS "-pipe -fPIC -funsigned-char -fno-strict-aliasing -DXP_UNIX -Wno-char-subscripts")
218
219         SET(PLATFORM_LINKFLAGS "-pthread")
220
221         # Better warnings
222         SET(C_WARNINGS "-Wall -Wno-char-subscripts -Wpointer-arith -Wcast-align -Wdeclaration-after-statement")
223         SET(CXX_WARNINGS "-Wall -Wno-invalid-offsetof -Wno-sign-compare")
224
225         INCLUDE_DIRECTORIES(${JPEG_INCLUDE_DIR} ${PNG_INCLUDE_DIR} ${ZLIB_INCLUDE_DIR} )
226 ENDIF(UNIX AND NOT APPLE)
227
228 IF(WIN32)
229
230         # this file is included anyway when building under Windows with cl.exe
231         #  INCLUDE(${CMAKE_ROOT}/Modules/Platform/Windows-cl.cmake)
232   
233         SET(LIBDIR ${CMAKE_SOURCE_DIR}/../lib/windows)
234
235         # Setup 64bit and 64bit windows systems
236         IF(CMAKE_CL_64)
237                 message("64 bit compiler detected.")
238                 SET(LIBDIR ${CMAKE_SOURCE_DIR}/../lib/win64)
239         ENDIF(CMAKE_CL_64)
240
241         SET(PYTHON ${LIBDIR}/python)
242         SET(PYTHON_VERSION 3.1)
243         SET(PYTHON_INC "${PYTHON}/include/python${PYTHON_VERSION}")
244         # SET(PYTHON_BINARY python) # not used yet
245         SET(PYTHON_LIB python31)
246         SET(PYTHON_LIBPATH ${PYTHON}/lib)
247
248         IF(CMAKE_CL_64)
249                 SET(WITH_OPENAL OFF)
250         ELSE(CMAKE_CL_64)
251                 #SET(WITH_OPENAL ON)
252                 SET(OPENAL ${LIBDIR}/openal)
253                 SET(OPENAL_INCLUDE_DIR ${OPENAL}/include)
254                 SET(OPENAL_LIBRARY wrap_oal)
255                 SET(OPENAL_LIBPATH ${OPENAL}/lib)
256         ENDIF(CMAKE_CL_64)
257
258         IF(WITH_JACK)
259                 SET(JACK ${LIBDIR}/jack)
260                 SET(JACK_INC ${JACK}/include/jack ${JACK}/include)
261                 SET(JACK_LIB libjack)
262                 SET(JACK_LIBPATH ${JACK}/lib)
263         ENDIF(WITH_JACK)
264
265         IF(WITH_SNDFILE)
266                 SET(SNDFILE ${LIBDIR}/sndfile)
267                 SET(SNDFILE_INC ${SNDFILE}/include)
268                 SET(SNDFILE_LIB libsndfile-1)
269                 SET(SNDFILE_LIBPATH ${SNDFILE}/lib)
270         ENDIF(WITH_SNDFILE)
271
272         IF(CMAKE_CL_64)
273                 SET(PNG_LIBRARIES libpng)
274         ELSE(CMAKE_CL_64)
275                 SET(PNG_LIBRARIES libpng_st)
276         ENDIF(CMAKE_CL_64)
277         SET(JPEG_LIBRARY libjpeg)
278
279         SET(ZLIB ${LIBDIR}/zlib)
280         SET(ZLIB_INC ${ZLIB}/include)
281         IF(CMAKE_CL_64)
282                 SET(ZLIB_LIBRARIES libz)
283         ELSE(CMAKE_CL_64)
284                 SET(ZLIB_LIBRARIES zlib)
285         ENDIF(CMAKE_CL_64)
286         SET(ZLIB_LIBPATH ${ZLIB}/lib)
287   
288         SET(PTHREADS ${LIBDIR}/pthreads)
289         SET(PTHREADS_INC ${PTHREADS}/include)
290         SET(PTHREADS_LIB pthreadVC2)
291         SET(PTHREADS_LIBPATH ${PTHREADS}/lib)
292   
293         SET(ICONV ${LIBDIR}/iconv)
294         SET(ICONV_INC ${ICONV}/include)
295         SET(ICONV_LIB iconv)
296         SET(ICONV_LIBPATH ${ICONV}/lib)
297   
298         IF(WITH_FFTW3)
299                 SET(FFTW3 ${LIBDIR}/fftw3)
300                 SET(FFTW3_INC ${FFTW3}/include)
301                 SET(FFTW3_LIB libfftw)
302                 SET(FFTW3_LIBPATH ${FFTW3}/lib)
303         ENDIF(WITH_FFTW3)
304   
305         SET(GETTEXT ${LIBDIR}/gettext)
306         SET(GETTEXT_INC ${GETTEXT}/include)
307         IF(CMAKE_CL_64)
308                 SET(GETTEXT_LIB gettext)
309         ELSE(CMAKE_CL_64)
310                 SET(GETTEXT_LIB gnu_gettext)
311         ENDIF(CMAKE_CL_64)
312         SET(GETTEXT_LIBPATH ${GETTEXT}/lib)
313
314         SET(FREETYPE ${LIBDIR}/freetype)
315         SET(FREETYPE_INCLUDE_DIRS ${FREETYPE}/include ${FREETYPE}/include/freetype2)
316         SET(FREETYPE_LIBPATH ${FREETYPE}/lib)
317         SET(FREETYPE_LIBRARY freetype2ST)
318   
319         SET(OPENEXR ${LIBDIR}/openexr)
320         SET(OPENEXR_INC ${OPENEXR}/include ${OPENEXR}/include/IlmImf ${OPENEXR}/include/Iex ${OPENEXR}/include/Imath)
321         SET(OPENEXR_LIB Iex Half IlmImf Imath IlmThread)
322         IF (MSVC80)
323                 SET(OPENEXR_LIBPATH ${OPENEXR}/lib_vs2005)
324         ELSE (MSVC80)
325                 SET(OPENEXR_LIBPATH ${OPENEXR}/lib_msvc)
326         ENDIF(MSVC80)
327         IF (MSVC90)
328                 SET(OPENEXR_LIBPATH ${OPENEXR}/lib_vs2008)
329         ENDIF(MSVC90)
330
331   
332         SET(QUICKTIME ${LIBDIR}/QTDevWin)
333         SET(QUICKTIME_INC ${QUICKTIME}/CIncludes)
334         SET(QUICKTIME_LIB qtmlClient)
335         SET(QUICKTIME_LIBPATH ${QUICKTIME}/Libraries)
336
337         SET(FFMPEG ${LIBDIR}/ffmpeg)
338         SET(FFMPEG_INC ${FFMPEG}/include ${FFMPEG}/include/msvc)
339         SET(FFMPEG_LIB avcodec-52 avformat-52 avdevice-52 avutil-50 swscale-0)
340         SET(FFMPEG_LIBPATH ${FFMPEG}/lib)
341
342         SET(LIBSAMPLERATE ${LIBDIR}/samplerate)
343         SET(LIBSAMPLERATE_INC ${LIBSAMPLERATE}/include)
344         SET(LIBSAMPLERATE_LIB libsamplerate)
345         SET(LIBSAMPLERATE_LIBPATH ${LIBSAMPLERATE}/lib)
346
347         IF(CMAKE_CL_64)
348                 SET(LLIBS kernel32 user32 vfw32 winmm ws2_32 )
349         ELSE(CMAKE_CL_64)
350                 SET(LLIBS kernel32 user32 gdi32 comdlg32 advapi32 shell32 ole32 oleaut32 uuid ws2_32 vfw32 winmm)
351         ENDIF(CMAKE_CL_64)
352
353         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)
354         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)
355         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)
356         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)
357         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)
358         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)
359         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)
360         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)
361
362         IF(WITH_OPENMP)
363                 SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /openmp ")
364                 SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /openmp ")
365         ENDIF(WITH_OPENMP)
366
367         SET(SDL ${LIBDIR}/sdl)
368         SET(SDL_INCLUDE_DIR ${SDL}/include)
369         SET(SDL_LIBRARY SDL)
370         SET(SDL_LIBPATH ${SDL}/lib)
371
372         SET(PNG "${LIBDIR}/png")
373         SET(PNG_INC "${PNG}/include")
374         SET(PNG_LIBPATH ${PNG}/lib)
375
376         SET(JPEG "${LIBDIR}/jpeg")
377         SET(JPEG_INC "${JPEG}/include")
378         SET(JPEG_LIBPATH ${JPEG}/lib)
379
380         SET(TIFF ${LIBDIR}/tiff)
381         SET(TIFF_INC ${TIFF}/include)
382   
383         SET(WINTAB_INC ${LIBDIR}/wintab/include) 
384
385         IF(CMAKE_CL_64)
386                 SET(PLATFORM_LINKFLAGS "/MACHINE:X64 /NODEFAULTLIB:libc.lib;MSVCRT.lib ")
387         ELSE(CMAKE_CL_64)
388                 SET(PLATFORM_LINKFLAGS "/NODEFAULTLIB:libc.lib ")
389         ENDIF(CMAKE_CL_64)
390   
391         SET(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} /NODEFAULTLIB:libcmt.lib;libc.lib ")
392 ENDIF(WIN32)
393
394 IF(APPLE)
395         IF(CMAKE_OSX_ARCHITECTURES MATCHES i386)
396                 SET(LIBDIR ${CMAKE_SOURCE_DIR}/../lib/darwin-8.x.i386)
397         ELSE(CMAKE_OSX_ARCHITECTURES MATCHES i386)
398                 SET(LIBDIR ${CMAKE_SOURCE_DIR}/../lib/darwin-6.1-powerpc)
399         ENDIF(CMAKE_OSX_ARCHITECTURES MATCHES i386)
400
401         IF(WITH_OPENAL)
402                 FIND_PACKAGE(OpenAL)
403                 IF(OPENAL_FOUND)
404                         SET(WITH_OPENAL ON)
405                 ELSE(OPENAL_FOUND)
406                         SET(WITH_OPENAL OFF)
407                 ENDIF(OPENAL_FOUND)
408         ENDIF(WITH_OPENAL)
409
410         IF(WITH_JACK)
411                 SET(JACK /usr)
412                 SET(JACK_INC ${JACK}/include/jack)
413                 SET(JACK_LIB jack)
414                 SET(JACK_LIBPATH ${JACK}/lib)
415         ENDIF(WITH_JACK)
416
417         IF(WITH_SNDFILE)
418                 SET(SNDFILE ${LIBDIR}/sndfile)
419                 SET(SNDFILE_INC ${SNDFILE}/include)
420                 SET(SNDFILE_LIB sndfile)
421                 SET(SNDFILE_LIBPATH ${SNDFILE}/lib)
422         ENDIF(WITH_SNDFILE)
423
424         SET(PYTHON_VERSION 3.1)
425
426         IF(PYTHON_VERSION MATCHES 3.1)
427                 # we use precompiled libraries for py 3.1 and up by default
428
429                 SET(PYTHON ${LIBDIR}/python)
430                 SET(PYTHON_INC "${PYTHON}/include/python${PYTHON_VERSION}" CACHE STRING "")
431                 # SET(PYTHON_BINARY "${PYTHON}/bin/python${PYTHON_VERSION}" CACHE STRING "") # not used yet
432                 SET(PYTHON_LIB python${PYTHON_VERSION})
433                 SET(PYTHON_LIBPATH "${PYTHON}/lib/python${PYTHON_VERSION}" CACHE STRING "")
434                 #    SET(PYTHON_LINKFLAGS "-u _PyMac_Error")  # won't  build with this enabled
435         ELSE(PYTHON_VERSION MATCHES 3.1)
436                 # otherwise, use custom system framework
437
438                 SET(PYTHON /System/Library/Frameworks/Python.framework/Versions/)
439                 SET(PYTHON_VERSION 2.5)
440                 SET(PYTHON_INC "${PYTHON}${PYTHON_VERSION}/include/python${PYTHON_VERSION}" CACHE STRING "")
441                 # SET(PYTHON_BINARY ${PYTHON}${PYTHON_VERSION}/bin/python${PYTHON_VERSION} CACHE STRING "") # not used yet
442                 SET(PYTHON_LIB "")
443                 SET(PYTHON_LIBPATH ${PYTHON}${PYTHON_VERSION}/lib/python${PYTHON_VERSION}/config CACHE STRING "")
444                 SET(PYTHON_LINKFLAGS "-u _PyMac_Error -framework System -framework Python")
445         ENDIF(PYTHON_VERSION MATCHES 3.1)
446
447         SET(GETTEXT ${LIBDIR}/gettext)
448         SET(GETTEXT_INC "${GETTEXT}/include")
449         SET(GETTEXT_LIB intl iconv)
450         SET(GETTEXT_LIBPATH ${GETTEXT}/lib)
451   
452         IF(WITH_FFTW3)
453                 SET(FFTW3 ${LIBDIR}/fftw3)
454                 SET(FFTW3_INC ${FFTW3}/include)
455                 SET(FFTW3_LIB libfftw)
456                 SET(FFTW3_LIBPATH ${FFTW3}/lib)
457         ENDIF(WITH_FFTW3)
458
459         SET(PNG_LIBRARIES png)
460         SET(JPEG_LIBRARY jpeg)
461
462         SET(ZLIB /usr)
463         SET(ZLIB_INC "${ZLIB}/include")
464         SET(ZLIB_LIBRARIES z)
465
466         SET(FREETYPE ${LIBDIR}/freetype)
467         SET(FREETYPE_INCLUDE_DIRS ${FREETYPE}/include ${FREETYPE}/include/freetype2)
468         SET(FREETYPE_LIBPATH ${FREETYPE}/lib)
469         SET(FREETYPE_LIBRARY freetype)
470
471         SET(OPENEXR ${LIBDIR}/openexr)
472         SET(OPENEXR_INC ${OPENEXR}/include/OpenEXR ${OPENEXR}/include)
473         SET(OPENEXR_LIB Iex Half IlmImf Imath IlmThread)
474         SET(OPENEXR_LIBPATH ${OPENEXR}/lib)
475
476         SET(FFMPEG ${LIBDIR}/ffmpeg)
477         SET(FFMPEG_INC ${CMAKE_SOURCE_DIR}/extern/ffmpeg)
478         SET(FFMPEG_LIB avcodec avdevice avformat avutil mp3lame swscale x264 xvidcore)
479         SET(FFMPEG_LIBPATH ${FFMPEG}/lib)
480
481         SET(LIBSAMPLERATE ${LIBDIR}/samplerate)
482         SET(LIBSAMPLERATE_INC ${LIBSAMPLERATE}/include)
483         SET(LIBSAMPLERATE_LIB samplerate)
484         SET(LIBSAMPLERATE_LIBPATH ${LIBSAMPLERATE}/lib)
485
486         SET(LLIBS stdc++ SystemStubs)
487
488         SET(PLATFORM_CFLAGS "-pipe -fPIC -funsigned-char -fno-strict-aliasing")
489         SET(PLATFORM_LINKFLAGS "-fexceptions -framework CoreServices -framework Foundation -framework IOKit -framework AppKit -framework Carbon -framework AGL -framework AudioUnit -framework AudioToolbox -framework CoreAudio -framework QuickTime")
490
491         IF(WITH_OPENMP)
492                 SET(LLIBS "${LLIBS} -lgomp ")
493                 SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fopenmp ")
494                 SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fopenmp ")
495         ENDIF(WITH_OPENMP)
496
497         SET(SDL ${LIBDIR}/sdl)
498         SET(SDL_INCLUDE_DIR ${SDL}/include)
499         SET(SDL_LIBRARY SDL)
500         SET(SDL_LIBPATH ${SDL}/lib)
501
502         SET(PNG "${LIBDIR}/png")
503         SET(PNG_INC "${PNG}/include")
504         SET(PNG_LIBPATH ${PNG}/lib)
505
506         SET(JPEG "${LIBDIR}/jpeg")
507         SET(JPEG_INC "${JPEG}/include")
508         SET(JPEG_LIBPATH ${JPEG}/lib)
509
510         SET(TIFF ${LIBDIR}/tiff)
511         SET(TIFF_INC ${TIFF}/include)
512
513         SET(EXETYPE MACOSX_BUNDLE)
514 ENDIF(APPLE)
515
516 IF(CMAKE_SYSTEM_NAME MATCHES "Linux")
517         SET(BINRELOC ${CMAKE_SOURCE_DIR}/extern/binreloc)
518         SET(BINRELOC_INC ${BINRELOC}/include)
519 ENDIF(CMAKE_SYSTEM_NAME MATCHES "Linux")
520
521
522 # buildinfo
523 IF(UNIX)
524         IF(WITH_BUILDINFO)
525                 EXEC_PROGRAM("date \"+%Y-%m-%d\"" OUTPUT_VARIABLE BUILD_DATE)
526                 EXEC_PROGRAM("date \"+%H:%M:%S\"" OUTPUT_VARIABLE BUILD_TIME)  
527                 EXEC_PROGRAM("svnversion ${CMAKE_SOURCE_DIR}" OUTPUT_VARIABLE BUILD_REV)
528                 # BUILD_PLATFORM and BUILD_PLATFORM are taken from CMake
529         ENDIF(WITH_BUILDINFO)
530 ENDIF(UNIX)
531
532 #-----------------------------------------------------------------------------
533 # Common.
534
535 set(OPENJPEG ${CMAKE_SOURCE_DIR}/extern/libopenjpeg)
536 set(OPENJPEG_INC ${OPENJPEG})
537 set(OPENJPEG_LIb extern_libopenjpeg)
538
539 #-----------------------------------------------------------------------------
540 # Blender WebPlugin
541
542 IF(WITH_WEBPLUGIN) 
543         SET(GECKO_DIR "${CMAKE_SOURCE_DIR}/../gecko-sdk/" CACHE PATH "Gecko SDK path")
544         SET(WEBPLUGIN_SANDBOX_MODE "apparmor" CACHE STRING "WEB Plugin sandbox mode, can be apparmor, privsep, none")
545
546         SET(WITH_PLAYER ON)
547 ENDIF(WITH_WEBPLUGIN)
548
549
550 #-----------------------------------------------------------------------------
551 # Configure OpenGL.
552 FIND_PACKAGE(OpenGL)
553 INCLUDE_DIRECTORIES(${OPENGL_INCLUDE_DIR})
554 # UNSET(OPENGL_LIBRARIES CACHE) # not compat with older cmake 
555 # UNSET(OPENGL_xmesa_INCLUDE_DIR CACHE) # not compat with older cmake 
556
557 #-----------------------------------------------------------------------------
558 # Extra compile flags
559 SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${PLATFORM_CFLAGS} ${C_WARNINGS}")
560 SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${PLATFORM_CFLAGS} ${CXX_WARNINGS}")
561
562 # better not define flags here but this is a debugging option thats off by default.
563 IF(WITH_CXX_GUARDEDALLOC)
564         SET(CMAKE_CXX_FLAGS " -DWITH_CXX_GUARDEDALLOC -I${CMAKE_SOURCE_DIR}/intern/guardedalloc ${CMAKE_CXX_FLAGS}")
565 ENDIF(WITH_CXX_GUARDEDALLOC)
566
567 #-----------------------------------------------------------------------------
568 # Libraries
569 FILE(WRITE ${CMAKE_BINARY_DIR}/cmake_blender_libs.txt "")
570 ADD_SUBDIRECTORY(intern)
571 ADD_SUBDIRECTORY(extern)
572 ADD_SUBDIRECTORY(source)
573
574
575 #-----------------------------------------------------------------------------
576 # Blender Application
577 ADD_SUBDIRECTORY(source/creator)
578
579
580 #-----------------------------------------------------------------------------
581 # Blender Player
582 IF(WITH_PLAYER)
583         ADD_SUBDIRECTORY(source/blenderplayer)
584 ENDIF(WITH_PLAYER)
585