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