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