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