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