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