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