OSX/CMake : fix ffmpeg include path
[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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 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_WEBPLUGIN     "Enable Web Plugin (Unix only)" OFF)
74 OPTION(WITH_FFTW3         "Enable FFTW3 support" OFF)
75 OPTION(WITH_JACK          "Enable Jack Support (http://www.jackaudio.org)" OFF)
76 OPTION(WITH_SNDFILE       "Enable libsndfile Support (http://www.mega-nerd.com/libsndfile)" OFF)
77 OPTION(WITH_LZO           "Enable fast LZO compression, used for pointcache" ON)
78 OPTION(WITH_LZMA          "Enable best LZMA compression, used for pointcache" ON)
79 OPTION(WITH_CXX_GUARDEDALLOC "Enable GuardedAlloc for C++ memory allocation" OFF)
80 OPTION(WITH_BUILDINFO     "Include extra build details" ON)
81 OPTION(WITH_INSTALL       "Install accompanying scripts and language files needed to run blender" ON)
82 OPTION(WITH_OPENCOLLADA         "Enable OpenCollada Support (http://www.opencollada.org/)"      ON)
83
84 # Unix defaults to OpenMP On
85 IF(UNIX AND NOT APPLE)
86         OPTION(WITH_OPENMP        "Enable OpenMP (has to be supported by the compiler)" ON)
87 ELSE()
88         OPTION(WITH_OPENMP        "Enable OpenMP (has to be supported by the compiler)" OFF)
89 ENDIF()
90
91 OPTION(WITH_RAYOPTIMIZATION     "Enable use of SIMD (SSE) optimizations for the raytracer" OFF) 
92
93 IF (APPLE)
94         OPTION(WITH_COCOA         "Use Cocoa framework instead of deprecated Carbon" ON)
95         OPTION(USE_QTKIT          "Use QtKit instead of Carbon quicktime (needed for having partial quicktime for 64bit)" OFF)
96         OPTION(WITH_LIBS10.5  "Use 10.5 libs (needed for 64bit builds)" OFF)
97 ENDIF (APPLE)
98
99 IF(NOT WITH_GAMEENGINE AND WITH_PLAYER)
100         MESSAGE("WARNING: WITH_PLAYER needs WITH_GAMEENGINE")
101 ENDIF(NOT WITH_GAMEENGINE AND WITH_PLAYER)
102
103 # For alternate Python locations the commandline can be used to override detected/default cache settings, e.g:
104 # On Unix: 
105 #   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
106 # On Macs: 
107 #   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
108 #
109 # When changing any of this remember to update the notes in doc/blender-cmake.txt
110
111 #-----------------------------------------------------------------------------
112 # Load some macros.
113 INCLUDE(CMake/macros.cmake)
114
115 #-----------------------------------------------------------------------------
116 #Platform specifics
117
118 IF(UNIX AND NOT APPLE)
119
120
121         IF(WITH_OPENAL)
122                 FIND_PACKAGE(OpenAL)
123                 IF(OPENAL_FOUND)
124                         SET(WITH_OPENAL ON)
125                 ELSE(OPENAL_FOUND)
126                         SET(WITH_OPENAL OFF)
127                 ENDIF(OPENAL_FOUND)
128         ENDIF(WITH_OPENAL)
129
130         IF(WITH_JACK)
131                 SET(JACK /usr)
132                 SET(JACK_INC ${JACK}/include/jack)
133                 SET(JACK_LIB jack)
134                 SET(JACK_LIBPATH ${JACK}/lib)
135         ENDIF(WITH_JACK)
136
137         IF(WITH_SNDFILE)
138         SET(SNDFILE /usr)
139         SET(SNDFILE_INC ${SNDFILE}/include)
140         SET(SNDFILE_LIB sndfile)
141         SET(SNDFILE_LIBPATH ${SNDFILE}/lib)
142         ENDIF(WITH_SNDFILE)
143
144         FIND_LIBRARY(INTL_LIBRARY
145                 NAMES intl
146                 PATHS
147                 /sw/lib
148         )
149         FIND_LIBRARY(ICONV_LIBRARY
150                 NAMES iconv
151                 PATHS
152                 /sw/lib
153         )
154   
155         IF(INTL_LIBRARY AND ICONV_LIBRARY)
156                 SET(GETTEXT_LIB ${INTL_LIBRARY} ${ICONV_LIBRARY})
157         ENDIF(INTL_LIBRARY AND ICONV_LIBRARY)
158
159         FIND_PACKAGE(Freetype)
160         # UNSET(FREETYPE_INCLUDE_DIRS CACHE) # cant use
161
162         # No way to set py31. remove for now.
163         # FIND_PACKAGE(PythonLibs)
164         SET(PYTHON /usr)
165         SET(PYTHON_VERSION 3.1)
166         SET(PYTHON_INC "${PYTHON}/include/python${PYTHON_VERSION}" CACHE STRING "")
167         # SET(PYTHON_BINARY python) # not used yet
168         SET(PYTHON_LIB python${PYTHON_VERSION} CACHE STRING "")
169         SET(PYTHON_LIBPATH ${PYTHON}/lib CACHE STRING "")
170   
171         # FIND_PACKAGE(PythonInterp) # not used yet
172         # SET(PYTHON_BINARY ${PYTHON_EXECUTABLE} CACHE STRING "")
173   
174         SET(PYTHON_LINKFLAGS "-Xlinker -export-dynamic")
175
176         IF(WITH_SDL)
177                 FIND_PACKAGE(SDL)
178                 # UNSET(SDLMAIN_LIBRARY CACHE)
179                 IF(NOT SDL_FOUND)
180                         SET(WITH_SDL OFF)
181                 ENDIF(NOT SDL_FOUND)
182         ENDIF(WITH_SDL)
183
184         FIND_PATH(OPENEXR_INC
185                 ImfXdr.h
186                 PATHS
187                 /usr/local/include/OpenEXR
188                 /usr/include/OpenEXR
189                 /sw/include/OpenEXR
190                 /opt/local/include/OpenEXR
191                 /opt/csw/include/OpenEXR
192                 /opt/include/OpenEXR
193         )
194         SET(OPENEXR_LIB Half IlmImf Iex Imath)
195
196         SET(FFMPEG /usr)
197         SET(FFMPEG_INC ${FFMPEG}/include)
198         SET(FFMPEG_LIB avformat avcodec avutil avdevice swscale)
199         SET(FFMPEG_LIBPATH ${FFMPEG}/lib)
200   
201         IF(WITH_FFTW3)
202                 SET(FFTW3 /usr)
203                 SET(FFTW3_INC ${FFTW3}/include)
204                 SET(FFTW3_LIB fftw3)
205                 SET(FFTW3_LIBPATH ${FFTW3}/lib)
206         ENDIF(WITH_FFTW3)
207
208         SET(LIBSAMPLERATE /usr)
209         SET(LIBSAMPLERATE_INC ${LIBSAMPLERATE}/include)
210         SET(LIBSAMPLERATE_LIB samplerate)
211         SET(LIBSAMPLERATE_LIBPATH ${LIBSAMPLERATE}/lib)
212
213         FIND_PACKAGE(JPEG REQUIRED)
214
215         FIND_PACKAGE(PNG REQUIRED)
216
217         FIND_PACKAGE(ZLIB REQUIRED)
218
219         IF (WITH_OPENCOLLADA)
220                 SET(OPENCOLLADA /usr/local/opencollada CACHE FILEPATH "OpenCollada Directory")
221                 SET(OPENCOLLADA_LIBPATH ${OPENCOLLADA}/lib)
222                 SET(OPENCOLLADA_LIB OpenCOLLADAStreamWriter OpenCOLLADASaxFrameworkLoader OpenCOLLADAFramework OpenCOLLADABaseUtils GeneratedSaxParser UTF MathMLSolver pcre ftoa buffer)
223                 SET(OPENCOLLADA_INC ${OPENCOLLADA})
224                 SET(PCRE /usr CACHE FILEPATH "PCRE Directory")
225                 SET(PCRE_LIBPATH ${PCRE}/lib)
226                 SET(PCRE_LIB pcre)
227                 SET(EXPAT /usr CACHE FILEPATH "Expat Directory")
228                 SET(EXPAT_LIBPATH ${EXPAT}/lib)
229                 SET(EXPAT_LIB expat)
230         ENDIF (WITH_OPENCOLLADA)
231
232
233         # Could use ${X11_Xinput_LIB} ${X11_X11_LIB} too
234         SET(LLIBS "-lXi -lutil -lc -lm -lpthread -lstdc++ -lX11")
235
236         IF(CMAKE_SYSTEM_NAME MATCHES "Linux")
237                 # BSD's dont use libdl.so
238                 SET(LLIBS "${LLIBS} -ldl")
239         ENDIF(CMAKE_SYSTEM_NAME MATCHES "Linux")
240
241         IF(WITH_OPENMP)
242                 SET(LLIBS "${LLIBS} -lgomp")
243                 SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fopenmp")
244                 SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fopenmp")
245         ENDIF(WITH_OPENMP)
246
247
248         SET(PLATFORM_CFLAGS "-pipe -fPIC -funsigned-char -fno-strict-aliasing -Wno-char-subscripts")
249
250         SET(PLATFORM_LINKFLAGS "-pthread")
251
252         # Better warnings
253         SET(C_WARNINGS "-Wall -Wno-char-subscripts -Wpointer-arith -Wcast-align -Wdeclaration-after-statement -Wno-unknown-pragmas")
254         SET(CXX_WARNINGS "-Wall -Wno-invalid-offsetof -Wno-sign-compare")
255
256         INCLUDE_DIRECTORIES(${JPEG_INCLUDE_DIR} ${PNG_INCLUDE_DIR} ${ZLIB_INCLUDE_DIR} )
257 ENDIF(UNIX AND NOT APPLE)
258
259 IF(WIN32)
260
261         # this file is included anyway when building under Windows with cl.exe
262         #  INCLUDE(${CMAKE_ROOT}/Modules/Platform/Windows-cl.cmake)
263   
264         SET(LIBDIR ${CMAKE_SOURCE_DIR}/../lib/windows)
265
266         # Setup 64bit and 64bit windows systems
267         IF(CMAKE_CL_64)
268                 message("64 bit compiler detected.")
269                 SET(LIBDIR ${CMAKE_SOURCE_DIR}/../lib/win64)
270         ENDIF(CMAKE_CL_64)
271
272         SET(PYTHON ${LIBDIR}/python)
273         SET(PYTHON_VERSION 3.1)
274         SET(PYTHON_INC "${PYTHON}/include/python${PYTHON_VERSION}")
275         # SET(PYTHON_BINARY python) # not used yet
276         SET(PYTHON_LIB python31)
277         SET(PYTHON_LIBPATH ${PYTHON}/lib)
278
279         IF(CMAKE_CL_64)
280                 SET(WITH_OPENAL OFF)
281         ELSE(CMAKE_CL_64)
282                 #SET(WITH_OPENAL ON)
283                 SET(OPENAL ${LIBDIR}/openal)
284                 SET(OPENAL_INCLUDE_DIR ${OPENAL}/include)
285                 SET(OPENAL_LIBRARY wrap_oal)
286                 SET(OPENAL_LIBPATH ${OPENAL}/lib)
287         ENDIF(CMAKE_CL_64)
288
289         IF(WITH_JACK)
290                 SET(JACK ${LIBDIR}/jack)
291                 SET(JACK_INC ${JACK}/include/jack ${JACK}/include)
292                 SET(JACK_LIB libjack)
293                 SET(JACK_LIBPATH ${JACK}/lib)
294         ENDIF(WITH_JACK)
295
296         IF(WITH_SNDFILE)
297                 SET(SNDFILE ${LIBDIR}/sndfile)
298                 SET(SNDFILE_INC ${SNDFILE}/include)
299                 SET(SNDFILE_LIB libsndfile-1)
300                 SET(SNDFILE_LIBPATH ${SNDFILE}/lib)
301         ENDIF(WITH_SNDFILE)
302
303         IF(CMAKE_CL_64)
304                 SET(PNG_LIBRARIES libpng)
305         ELSE(CMAKE_CL_64)
306                 SET(PNG_LIBRARIES libpng_st)
307         ENDIF(CMAKE_CL_64)
308         SET(JPEG_LIBRARY libjpeg)
309
310         SET(ZLIB ${LIBDIR}/zlib)
311         SET(ZLIB_INC ${ZLIB}/include)
312         IF(CMAKE_CL_64)
313                 SET(ZLIB_LIBRARIES libz)
314         ELSE(CMAKE_CL_64)
315                 SET(ZLIB_LIBRARIES zlib)
316         ENDIF(CMAKE_CL_64)
317         SET(ZLIB_LIBPATH ${ZLIB}/lib)
318   
319         SET(PTHREADS ${LIBDIR}/pthreads)
320         SET(PTHREADS_INC ${PTHREADS}/include)
321         SET(PTHREADS_LIB pthreadVC2)
322         SET(PTHREADS_LIBPATH ${PTHREADS}/lib)
323   
324         SET(ICONV ${LIBDIR}/iconv)
325         SET(ICONV_INC ${ICONV}/include)
326         SET(ICONV_LIB iconv)
327         SET(ICONV_LIBPATH ${ICONV}/lib)
328   
329         IF(WITH_FFTW3)
330                 SET(FFTW3 ${LIBDIR}/fftw3)
331                 SET(FFTW3_INC ${FFTW3}/include)
332                 SET(FFTW3_LIB libfftw)
333                 SET(FFTW3_LIBPATH ${FFTW3}/lib)
334         ENDIF(WITH_FFTW3)
335   
336         SET(GETTEXT ${LIBDIR}/gettext)
337         SET(GETTEXT_INC ${GETTEXT}/include)
338         IF(CMAKE_CL_64)
339                 SET(GETTEXT_LIB gettext)
340         ELSE(CMAKE_CL_64)
341                 SET(GETTEXT_LIB gnu_gettext)
342         ENDIF(CMAKE_CL_64)
343         SET(GETTEXT_LIBPATH ${GETTEXT}/lib)
344
345         SET(FREETYPE ${LIBDIR}/freetype)
346         SET(FREETYPE_INCLUDE_DIRS ${FREETYPE}/include ${FREETYPE}/include/freetype2)
347         SET(FREETYPE_LIBPATH ${FREETYPE}/lib)
348         SET(FREETYPE_LIBRARY freetype2ST)
349   
350         SET(OPENEXR ${LIBDIR}/openexr)
351         SET(OPENEXR_INC ${OPENEXR}/include ${OPENEXR}/include/IlmImf ${OPENEXR}/include/Iex ${OPENEXR}/include/Imath)
352         SET(OPENEXR_LIB Iex Half IlmImf Imath IlmThread)
353         IF (MSVC80)
354                 SET(OPENEXR_LIBPATH ${OPENEXR}/lib_vs2005)
355         ELSE (MSVC80)
356                 SET(OPENEXR_LIBPATH ${OPENEXR}/lib_msvc)
357         ENDIF(MSVC80)
358         IF (MSVC90)
359                 SET(OPENEXR_LIBPATH ${OPENEXR}/lib_vs2008)
360         ENDIF(MSVC90)
361
362   
363         SET(QUICKTIME ${LIBDIR}/QTDevWin)
364         SET(QUICKTIME_INC ${QUICKTIME}/CIncludes)
365         SET(QUICKTIME_LIB qtmlClient)
366         SET(QUICKTIME_LIBPATH ${QUICKTIME}/Libraries)
367
368         SET(FFMPEG ${LIBDIR}/ffmpeg)
369         SET(FFMPEG_INC ${FFMPEG}/include ${FFMPEG}/include/msvc)
370         SET(FFMPEG_LIB avcodec-52 avformat-52 avdevice-52 avutil-50 swscale-0)
371         SET(FFMPEG_LIBPATH ${FFMPEG}/lib)
372
373         SET(LIBSAMPLERATE ${LIBDIR}/samplerate)
374         SET(LIBSAMPLERATE_INC ${LIBSAMPLERATE}/include)
375         SET(LIBSAMPLERATE_LIB libsamplerate)
376         SET(LIBSAMPLERATE_LIBPATH ${LIBSAMPLERATE}/lib)
377
378         IF(CMAKE_CL_64)
379                 SET(LLIBS kernel32 user32 vfw32 winmm ws2_32 )
380         ELSE(CMAKE_CL_64)
381                 SET(LLIBS kernel32 user32 gdi32 comdlg32 advapi32 shell32 ole32 oleaut32 uuid ws2_32 vfw32 winmm)
382         ENDIF(CMAKE_CL_64)
383
384         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)
385         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)
386         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)
387         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)
388         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)
389         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)
390         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)
391         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)
392
393         IF(WITH_OPENMP)
394                 SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /openmp ")
395                 SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /openmp ")
396         ENDIF(WITH_OPENMP)
397
398         SET(SDL ${LIBDIR}/sdl)
399         SET(SDL_INCLUDE_DIR ${SDL}/include)
400         SET(SDL_LIBRARY SDL)
401         SET(SDL_LIBPATH ${SDL}/lib)
402
403         SET(PNG "${LIBDIR}/png")
404         SET(PNG_INC "${PNG}/include")
405         SET(PNG_LIBPATH ${PNG}/lib)
406
407         SET(JPEG "${LIBDIR}/jpeg")
408         SET(JPEG_INC "${JPEG}/include")
409         SET(JPEG_LIBPATH ${JPEG}/lib)
410
411         SET(TIFF ${LIBDIR}/tiff)
412         SET(TIFF_INC ${TIFF}/include)
413   
414         SET(WINTAB_INC ${LIBDIR}/wintab/include) 
415
416         SET(OPENCOLLADA ${LIBDIR}/opencollada)
417         SET(OPENCOLLADA_INC ${OPENCOLLADA}/include)
418         SET(OPENCOLLADA_LIBPATH ${OPENCOLLADA}/lib)
419         SET(OPENCOLLADA_LIB OpenCOLLADASaxFrameworkLoader OpenCOLLADAFramework OpenCOLLADABaseUtils OpenCOLLADAStreamWriter MathMLSolver GeneratedSaxParser UTF xml2 buffer ftoa)
420         #pcre is bundled with openCollada
421         #SET(PCRE ${LIBDIR}/pcre)
422         #SET(PCRE_LIBPATH ${PCRE}/lib)
423         SET(PCRE_LIB pcre)
424
425
426         IF(CMAKE_CL_64)
427                 SET(PLATFORM_LINKFLAGS "/MACHINE:X64 /NODEFAULTLIB:libc.lib;MSVCRT.lib ")
428         ELSE(CMAKE_CL_64)
429                 SET(PLATFORM_LINKFLAGS "/NODEFAULTLIB:libc.lib ")
430         ENDIF(CMAKE_CL_64)
431   
432         SET(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} /NODEFAULTLIB:libcmt.lib;libc.lib ")
433 ENDIF(WIN32)
434
435 IF(APPLE)
436         IF(WITH_LIBS10.5)
437                 SET(LIBDIR ${CMAKE_SOURCE_DIR}/../lib/darwin-9.x.universal)
438         ELSE(WITH_LIBS10.5)
439                 IF(CMAKE_OSX_ARCHITECTURES MATCHES i386)
440                         SET(LIBDIR ${CMAKE_SOURCE_DIR}/../lib/darwin-8.x.i386)
441                 ELSE(CMAKE_OSX_ARCHITECTURES MATCHES i386)
442                         SET(LIBDIR ${CMAKE_SOURCE_DIR}/../lib/darwin-8.0.0-powerpc)
443                 ENDIF(CMAKE_OSX_ARCHITECTURES MATCHES i386)
444         ENDIF(WITH_LIBS10.5)
445         
446
447         IF(WITH_OPENAL)
448                 FIND_PACKAGE(OpenAL)
449                 IF(OPENAL_FOUND)
450                         SET(WITH_OPENAL ON)
451                         SET(OPENAL_INCLUDE_DIR "${LIBDIR}/openal/include")
452                 ELSE(OPENAL_FOUND)
453                         SET(WITH_OPENAL OFF)
454                 ENDIF(OPENAL_FOUND)
455         ENDIF(WITH_OPENAL)
456
457         IF(WITH_JACK)
458                 SET(JACK /usr)
459                 SET(JACK_INC ${JACK}/include/jack)
460                 SET(JACK_LIB jack)
461                 SET(JACK_LIBPATH ${JACK}/lib)
462         ENDIF(WITH_JACK)
463
464         IF(WITH_SNDFILE)
465                 SET(SNDFILE ${LIBDIR}/sndfile)
466                 SET(SNDFILE_INC ${SNDFILE}/include)
467                 SET(SNDFILE_LIB sndfile)
468                 SET(SNDFILE_LIBPATH ${SNDFILE}/lib)
469         ENDIF(WITH_SNDFILE)
470
471         SET(PYTHON_VERSION 3.1)
472
473         IF(PYTHON_VERSION MATCHES 3.1)
474                 # we use precompiled libraries for py 3.1 and up by default
475
476                 SET(PYTHON ${LIBDIR}/python)
477                 SET(PYTHON_INC "${PYTHON}/include/python${PYTHON_VERSION}")
478                 # SET(PYTHON_BINARY "${PYTHON}/bin/python${PYTHON_VERSION}") # not used yet
479                 SET(PYTHON_LIB python${PYTHON_VERSION})
480                 SET(PYTHON_LIBPATH "${PYTHON}/lib/python${PYTHON_VERSION}")
481                 #    SET(PYTHON_LINKFLAGS "-u _PyMac_Error")  # won't  build with this enabled
482         ELSE(PYTHON_VERSION MATCHES 3.1)
483                 # otherwise, use custom system framework
484
485                 SET(PYTHON /System/Library/Frameworks/Python.framework/Versions/)
486                 SET(PYTHON_VERSION 2.5)
487                 SET(PYTHON_INC "${PYTHON}${PYTHON_VERSION}/include/python${PYTHON_VERSION}")
488                 # SET(PYTHON_BINARY ${PYTHON}${PYTHON_VERSION}/bin/python${PYTHON_VERSION}) # not used yet
489                 SET(PYTHON_LIB "")
490                 SET(PYTHON_LIBPATH ${PYTHON}${PYTHON_VERSION}/lib/python${PYTHON_VERSION}/config)
491                 SET(PYTHON_LINKFLAGS "-u _PyMac_Error -framework System -framework Python")
492         ENDIF(PYTHON_VERSION MATCHES 3.1)
493
494         SET(GETTEXT ${LIBDIR}/gettext)
495         SET(GETTEXT_INC "${GETTEXT}/include")
496         SET(GETTEXT_LIB intl iconv)
497         SET(GETTEXT_LIBPATH ${GETTEXT}/lib)
498   
499         IF(WITH_FFTW3)
500                 SET(FFTW3 ${LIBDIR}/fftw3)
501                 SET(FFTW3_INC ${FFTW3}/include)
502                 SET(FFTW3_LIB fftw3)
503                 SET(FFTW3_LIBPATH ${FFTW3}/lib)
504         ENDIF(WITH_FFTW3)
505
506         SET(PNG_LIBRARIES png)
507         SET(JPEG_LIBRARY jpeg)
508
509         SET(ZLIB /usr)
510         SET(ZLIB_INC "${ZLIB}/include")
511         SET(ZLIB_LIBRARIES z)
512
513         SET(FREETYPE ${LIBDIR}/freetype)
514         SET(FREETYPE_INCLUDE_DIRS ${FREETYPE}/include ${FREETYPE}/include/freetype2)
515         SET(FREETYPE_LIBPATH ${FREETYPE}/lib)
516         SET(FREETYPE_LIBRARY freetype)
517
518         SET(OPENEXR ${LIBDIR}/openexr)
519         SET(OPENEXR_INC ${OPENEXR}/include/OpenEXR ${OPENEXR}/include)
520         SET(OPENEXR_LIB Iex Half IlmImf Imath IlmThread)
521         SET(OPENEXR_LIBPATH ${OPENEXR}/lib)
522
523         SET(FFMPEG ${LIBDIR}/ffmpeg)
524         SET(FFMPEG_INC ${FFMPEG}/include)
525         SET(FFMPEG_LIB avcodec avdevice avformat avutil mp3lame swscale x264 xvidcore)
526         SET(FFMPEG_LIBPATH ${FFMPEG}/lib)
527
528         SET(LIBSAMPLERATE ${LIBDIR}/samplerate)
529         SET(LIBSAMPLERATE_INC ${LIBSAMPLERATE}/include)
530         SET(LIBSAMPLERATE_LIB samplerate)
531         SET(LIBSAMPLERATE_LIBPATH ${LIBSAMPLERATE}/lib)
532
533         SET(LLIBS stdc++ SystemStubs)
534
535         IF (WITH_COCOA)
536                 SET(PLATFORM_CFLAGS "-pipe -funsigned-char -DGHOST_COCOA")
537                 SET(PLATFORM_LINKFLAGS "-fexceptions -framework CoreServices -framework Foundation -framework IOKit -framework AppKit -framework Cocoa -framework Carbon -framework AudioUnit -framework AudioToolbox -framework CoreAudio")
538                 IF(USE_QTKIT)
539                         SET(PLATFORM_CFLAGS "${PLATFORM_CFLAGS} -DUSE_QTKIT")
540                         SET(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} -framework QTKit")
541                         IF(CMAKE_OSX_ARCHITECTURES MATCHES i386)
542                                 SET(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} -framework QuickTime")
543                                 #libSDL still needs 32bit carbon quicktime 
544                         ENDIF(CMAKE_OSX_ARCHITECTURES MATCHES i386)
545                 ELSEIF(WITH_QUICKTIME)
546                         SET(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} -framework QuickTime")
547                 ENDIF(USE_QTKIT)
548         ELSE (WITH_COCOA)
549                 SET(PLATFORM_CFLAGS "-pipe -funsigned-char")
550                 SET(PLATFORM_LINKFLAGS "-fexceptions -framework CoreServices -framework Foundation -framework IOKit -framework AppKit -framework Carbon -framework AGL -framework AudioUnit -framework AudioToolbox -framework CoreAudio -framework QuickTime")
551         ENDIF (WITH_COCOA)
552
553         IF(WITH_OPENMP)
554                 SET(LLIBS "${LLIBS} -lgomp")
555                 SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fopenmp")
556                 SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fopenmp")
557         ENDIF(WITH_OPENMP)
558
559         IF (WITH_OPENCOLLADA)
560                 SET(OPENCOLLADA ${LIBDIR}/opencollada)
561                 SET(OPENCOLLADA_INC ${OPENCOLLADA}/include)
562                 SET(OPENCOLLADA_LIBPATH ${OPENCOLLADA}/lib)
563                 SET(OPENCOLLADA_LIB "OpenCOLLADASaxFrameworkLoader -lOpenCOLLADAFramework -lOpenCOLLADABaseUtils -lOpenCOLLADAStreamWriter -lMathMLSolver -lGeneratedSaxParser -lUTF -lxml2 -lbuffer -lftoa" )
564                 #pcre is bundled with openCollada
565                 #SET(PCRE ${LIBDIR}/pcre)
566                 #SET(PCRE_LIBPATH ${PCRE}/lib)
567                 SET(PCRE_LIB pcre)
568                 #libxml2 is used
569                 #SET(EXPAT ${LIBDIR}/expat)
570                 #SET(EXPAT_LIBPATH ${EXPAT}/lib)
571                 SET(EXPAT_LIB)
572         ENDIF (WITH_OPENCOLLADA)
573
574         SET(SDL ${LIBDIR}/sdl)
575         SET(SDL_INCLUDE_DIR ${SDL}/include)
576         SET(SDL_LIBRARY SDL)
577         SET(SDL_LIBPATH ${SDL}/lib)
578
579         SET(PNG "${LIBDIR}/png")
580         SET(PNG_INC "${PNG}/include")
581         SET(PNG_LIBPATH ${PNG}/lib)
582
583         SET(JPEG "${LIBDIR}/jpeg")
584         SET(JPEG_INC "${JPEG}/include")
585         SET(JPEG_LIBPATH ${JPEG}/lib)
586
587         SET(TIFF ${LIBDIR}/tiff)
588         SET(TIFF_INC ${TIFF}/include)
589
590         SET(EXETYPE MACOSX_BUNDLE)
591
592         SET(CMAKE_C_FLAGS_DEBUG "-fno-strict-aliasing -g")
593         SET(CMAKE_CXX_FLAGS_DEBUG "-fno-strict-aliasing -g")
594         IF(CMAKE_OSX_ARCHITECTURES MATCHES "i386")
595                 SET(CMAKE_CXX_FLAGS_RELEASE "-O3 -mdynamic-no-pic -ftree-vectorize -msse -msse2 -fvariable-expansion-in-unroller")
596                 SET(CMAKE_C_FLAGS_RELEASE "-O3 -mdynamic-no-pic -ftree-vectorize -msse -msse2 -fvariable-expansion-in-unroller")
597         ELSEIF(CMAKE_OSX_ARCHITECTURES MATCHES "x86_64")
598                 SET(CMAKE_CXX_FLAGS_RELEASE "-O3 -mdynamic-no-pic -ftree-vectorize -msse -msse2 -msse3 -mssse3 -fvariable-expansion-in-unroller")
599                 SET(CMAKE_C_FLAGS_RELEASE "-O3 -mdynamic-no-pic -ftree-vectorize -msse -msse2 -msse3 -mssse3 -fvariable-expansion-in-unroller")
600         ELSE(CMAKE_OSX_ARCHITECTURES MATCHES "x86_64")
601                 SET(CMAKE_C_FLAGS_RELEASE "-mdynamic-no-pic -fno-strict-aliasing")
602                 SET(CMAKE_CXX_FLAGS_RELEASE "-mdynamic-no-pic -fno-strict-aliasing")
603         ENDIF(CMAKE_OSX_ARCHITECTURES MATCHES "i386")
604
605         # Better warnings
606         SET(C_WARNINGS "-Wall -Wno-char-subscripts -Wpointer-arith -Wcast-align -Wdeclaration-after-statement -Wno-unknown-pragmas")
607         SET(CXX_WARNINGS "-Wall -Wno-invalid-offsetof -Wno-sign-compare")
608
609 ENDIF(APPLE)
610
611 IF(CMAKE_SYSTEM_NAME MATCHES "Linux")
612         SET(BINRELOC ${CMAKE_SOURCE_DIR}/extern/binreloc)
613         SET(BINRELOC_INC ${BINRELOC}/include)
614 ENDIF(CMAKE_SYSTEM_NAME MATCHES "Linux")
615
616
617 # buildinfo
618 IF(WITH_BUILDINFO)
619         # BUILD_PLATFORM and BUILD_PLATFORM are taken from CMake
620         IF(UNIX)
621                 EXEC_PROGRAM("date \"+%Y-%m-%d\"" OUTPUT_VARIABLE BUILD_DATE)
622                 EXEC_PROGRAM("date \"+%H:%M:%S\"" OUTPUT_VARIABLE BUILD_TIME)  
623                 EXEC_PROGRAM("svnversion ${CMAKE_SOURCE_DIR}" OUTPUT_VARIABLE BUILD_REV RETURN_VALUE BUILD_REV_RETURN)
624                 IF(BUILD_REV_RETURN)
625                         SET(BUILD_REV "unknown")
626                 ENDIF(BUILD_REV_RETURN)
627         ENDIF(UNIX)
628         
629         IF(WIN32)
630                 EXEC_PROGRAM("cmd /c date /t" OUTPUT_VARIABLE BUILD_DATE)
631                 EXEC_PROGRAM("cmd /c time /t" OUTPUT_VARIABLE BUILD_TIME)  
632                 EXEC_PROGRAM("svnversion ${CMAKE_SOURCE_DIR}" OUTPUT_VARIABLE BUILD_REV RETURN_VALUE BUILD_REV_RETURN)
633                 IF(BUILD_REV_RETURN)
634                         SET(BUILD_REV "unknown")
635                 ENDIF(BUILD_REV_RETURN)
636         ENDIF(WIN32)
637 ENDIF(WITH_BUILDINFO)
638         
639 #-----------------------------------------------------------------------------
640 # Common.
641
642 set(OPENJPEG ${CMAKE_SOURCE_DIR}/extern/libopenjpeg)
643 set(OPENJPEG_INC ${OPENJPEG})
644 set(OPENJPEG_LIb extern_libopenjpeg)
645
646 #-----------------------------------------------------------------------------
647 # Blender WebPlugin
648
649 IF(WITH_WEBPLUGIN) 
650         SET(GECKO_DIR "${CMAKE_SOURCE_DIR}/../gecko-sdk/" CACHE PATH "Gecko SDK path")
651         SET(WEBPLUGIN_SANDBOX_MODE "apparmor" CACHE STRING "WEB Plugin sandbox mode, can be apparmor, privsep, none")
652
653         SET(WITH_PLAYER ON)
654 ENDIF(WITH_WEBPLUGIN)
655
656
657 #-----------------------------------------------------------------------------
658 # Configure OpenGL.
659 FIND_PACKAGE(OpenGL)
660 INCLUDE_DIRECTORIES(${OPENGL_INCLUDE_DIR})
661 # UNSET(OPENGL_LIBRARIES CACHE) # not compat with older cmake 
662 # UNSET(OPENGL_xmesa_INCLUDE_DIR CACHE) # not compat with older cmake 
663
664 #-----------------------------------------------------------------------------
665 # Extra compile flags
666 SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${PLATFORM_CFLAGS} ${C_WARNINGS}")
667 SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${PLATFORM_CFLAGS} ${CXX_WARNINGS}")
668
669 # better not define flags here but this is a debugging option thats off by default.
670 IF(WITH_CXX_GUARDEDALLOC)
671         SET(CMAKE_CXX_FLAGS " -DWITH_CXX_GUARDEDALLOC -I${CMAKE_SOURCE_DIR}/intern/guardedalloc ${CMAKE_CXX_FLAGS}")
672 ENDIF(WITH_CXX_GUARDEDALLOC)
673
674 #-----------------------------------------------------------------------------
675 # Libraries
676 FILE(WRITE ${CMAKE_BINARY_DIR}/cmake_blender_libs.txt "")
677 ADD_SUBDIRECTORY(intern)
678 ADD_SUBDIRECTORY(extern)
679 ADD_SUBDIRECTORY(source)
680
681
682 #-----------------------------------------------------------------------------
683 # Blender Application
684 ADD_SUBDIRECTORY(source/creator)
685
686
687 #-----------------------------------------------------------------------------
688 # Blender Player
689 IF(WITH_PLAYER)
690         ADD_SUBDIRECTORY(source/blenderplayer)
691 ENDIF(WITH_PLAYER)
692