* Library path fixes for win64
[blender.git] / CMakeLists.txt
1 # $Id$
2 # ***** BEGIN GPL LICENSE BLOCK *****
3 #
4 # This program is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU General Public License
6 # as published by the Free Software Foundation; either version 2
7 # of the License, or (at your option) any later version.
8 #
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 # GNU General Public License for more details.
13 #
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software Foundation,
16 # Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
17 #
18 # The Original Code is Copyright (C) 2006, Blender Foundation
19 # All rights reserved.
20 #
21 # The Original Code is: all of this file.
22 #
23 # Contributor(s): Jacques Beaurain.
24 #
25 # ***** END GPL LICENSE BLOCK *****
26
27 #-----------------------------------------------------------------------------
28 # We don't allow in-source builds. This causes no end of troubles because 
29 # all out-of-source builds will use the CMakeCache.txt file there and even 
30 # build the libs and objects in it. It will also conflict with the current 
31 # Makefile system for Blender
32
33 IF(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR})
34 MESSAGE(FATAL_ERROR "CMake generation for blender is not allowed within the source directory! 
35 Remove the CMakeCache.txt file and try again from another folder, e.g.: 
36
37    rm CMakeCache.txt 
38    cd ..
39    mkdir cmake-make 
40    cd cmake-make
41    cmake -G \"Unix Makefiles\" ../blender
42 ")
43 ENDIF(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR})
44
45 CMAKE_MINIMUM_REQUIRED(VERSION 2.4)
46 PROJECT(Blender)
47
48 #-----------------------------------------------------------------------------
49 # Redirect output files
50
51 SET(EXECUTABLE_OUTPUT_PATH ${CMAKE_BINARY_DIR}/bin)
52 SET(LIBRARY_OUTPUT_PATH  ${CMAKE_BINARY_DIR}/lib)
53
54 #-----------------------------------------------------------------------------
55 # Set default config options
56 OPTION(WITH_PLAYER        "Build Player" OFF)
57 OPTION(WITH_GAMEENGINE    "Enable Game Engine" ON)
58 OPTION(WITH_BULLET        "Enable Bullet (Physics Engine)" ON)
59 OPTION(WITH_INTERNATIONAL "Enable I18N   (International fonts and text)" ON)
60 OPTION(WITH_ELBEEM        "Enable Elbeem (Fluid Simulation)" ON)
61 OPTION(WITH_QUICKTIME     "Enable Quicktime Support" OFF)
62 OPTION(WITH_OPENEXR       "Enable OpenEXR Support (http://www.openexr.com)" ON)
63 OPTION(WITH_DDS           "Enable DDS Support" ON)
64 OPTION(WITH_FFMPEG        "Enable FFMPeg Support (http://ffmpeg.mplayerhq.hu/)" OFF)
65 OPTION(WITH_PYTHON        "Enable Embedded Python API" ON)
66 OPTION(WITH_SDL           "Enable SDL for sound and joystick support" ON)
67 OPTION(WITH_OPENJPEG      "Enable OpenJpeg Support (http://www.openjpeg.org/)" OFF)
68 OPTION(WITH_OPENAL        "Enable OpenAL Support (http://www.openal.org)" ON)
69 OPTION(WITH_OPENMP        "Enable OpenMP (has to be supported by the compiler)" OFF)
70 OPTION(WITH_WEBPLUGIN     "Enable Web Plugin (Unix only)" OFF)
71 OPTION(WITH_FFTW3         "Enable FFTW3 support" OFF)
72 OPTION(WITH_JACK          "Enable Jack Support (http://www.jackaudio.org)" OFF)
73 OPTION(WITH_CXX_GUARDEDALLOC "Enable GuardedAlloc for C++ memory allocation" OFF)
74 OPTION(WITH_INSTALL       "Install accompanying scripts and language files needed to run blender" ON)
75
76 IF(NOT WITH_GAMEENGINE AND WITH_PLAYER)
77   MESSAGE("WARNING: WITH_PLAYER needs WITH_GAMEENGINE")
78 ENDIF(NOT WITH_GAMEENGINE AND WITH_PLAYER)
79
80 # For alternate Python locations the commandline can be used to override detected/default cache settings, e.g:
81 # On Unix: 
82 #   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
83 # On Macs: 
84 #   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
85 #
86 # When changing any of this remember to update the notes in doc/blender-cmake.txt
87
88 #-----------------------------------------------------------------------------
89 # Load some macros.
90 INCLUDE(CMake/macros.cmake)
91
92 #-----------------------------------------------------------------------------
93 #Platform specifics
94
95 IF(UNIX AND NOT APPLE)
96   IF(WITH_OPENAL)
97     FIND_PACKAGE(OpenAL)
98     IF(OPENAL_FOUND)
99       SET(WITH_OPENAL ON)
100     ELSE(OPENAL_FOUND)
101       SET(WITH_OPENAL OFF)
102     ENDIF(OPENAL_FOUND)
103   ENDIF(WITH_OPENAL)
104
105   IF(WITH_JACK)
106     SET(JACK /usr)
107     SET(JACK_INC ${JACK}/include/jack)
108     SET(JACK_LIB jack)
109     SET(JACK_LIBPATH ${JACK}/lib)
110   ENDIF(WITH_JACK)
111
112   FIND_LIBRARY(INTL_LIBRARY
113     NAMES intl
114     PATHS
115     /sw/lib
116   )
117   FIND_LIBRARY(ICONV_LIBRARY
118     NAMES iconv
119     PATHS
120     /sw/lib
121   )
122   
123   IF(INTL_LIBRARY AND ICONV_LIBRARY)
124     SET(GETTEXT_LIB ${INTL_LIBRARY} ${ICONV_LIBRARY})
125   ENDIF(INTL_LIBRARY AND ICONV_LIBRARY)
126
127   FIND_PACKAGE(Freetype)
128   # UNSET(FREETYPE_INCLUDE_DIRS CACHE) # cant use
129
130   # No way to set py31. remove for now.
131   # FIND_PACKAGE(PythonLibs)
132   SET(PYTHON /usr)
133   SET(PYTHON_VERSION 3.1)
134   SET(PYTHON_INC "${PYTHON}/include/python${PYTHON_VERSION}" CACHE STRING "")
135   # SET(PYTHON_BINARY python) # not used yet
136   SET(PYTHON_LIB python${PYTHON_VERSION} CACHE STRING "")
137   SET(PYTHON_LIBPATH ${PYTHON}/lib CACHE STRING "")
138   
139   # FIND_PACKAGE(PythonInterp) # not used yet
140   # SET(PYTHON_BINARY ${PYTHON_EXECUTABLE} CACHE STRING "")
141   
142   SET(PYTHON_LINKFLAGS "-Xlinker -export-dynamic")
143
144   IF(WITH_SDL)
145     FIND_PACKAGE(SDL)
146     # UNSET(SDLMAIN_LIBRARY CACHE)
147     IF(NOT SDL_FOUND)
148       SET(WITH_SDL OFF)
149     ENDIF(NOT SDL_FOUND)
150   ENDIF(WITH_SDL)
151
152   FIND_PATH(OPENEXR_INC
153     ImfXdr.h
154     PATHS
155     /usr/local/include/OpenEXR
156     /usr/include/OpenEXR
157     /sw/include/OpenEXR
158     /opt/local/include/OpenEXR
159     /opt/csw/include/OpenEXR
160     /opt/include/OpenEXR
161   )
162   SET(OPENEXR_LIB Half IlmImf Iex Imath)
163
164   SET(FFMPEG /usr)
165   SET(FFMPEG_INC ${FFMPEG}/include)
166   SET(FFMPEG_LIB avformat avcodec avutil avdevice swscale)
167   SET(FFMPEG_LIBPATH ${FFMPEG}/lib)
168   
169   IF(WITH_FFTW3)
170     SET(FFTW3 /usr)
171     SET(FFTW3_INC ${FFTW3}/include)
172     SET(FFTW3_LIB fftw3)
173     SET(FFTW3_LIBPATH ${FFTW3}/lib)
174   ENDIF(WITH_FFTW3)
175
176   SET(LIBSAMPLERATE /usr)
177   SET(LIBSAMPLERATE_INC ${LIBSAMPLERATE}/include)
178   SET(LIBSAMPLERATE_LIB samplerate)
179   SET(LIBSAMPLERATE_LIBPATH ${LIBSAMPLERATE}/lib)
180
181   FIND_PACKAGE(JPEG REQUIRED)
182
183   FIND_PACKAGE(PNG REQUIRED)
184
185   FIND_PACKAGE(ZLIB REQUIRED)
186
187   # Could use ${X11_Xinput_LIB} ${X11_X11_LIB} too
188   SET(LLIBS "-lXi -lutil -lc -lm -lpthread -lstdc++ -lX11")
189
190   IF(CMAKE_SYSTEM_NAME MATCHES "Linux")
191     # BSD's dont use libdl.so
192     SET(LLIBS "${LLIBS} -ldl")
193   ENDIF(CMAKE_SYSTEM_NAME MATCHES "Linux")
194
195   IF(WITH_OPENMP)
196     SET(LLIBS "${LLIBS} -lgomp")
197     SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fopenmp")
198     SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fopenmp")
199   ENDIF(WITH_OPENMP)
200
201
202   SET(PLATFORM_CFLAGS "-pipe -fPIC -funsigned-char -fno-strict-aliasing -DXP_UNIX -Wno-char-subscripts")
203
204   SET(PLATFORM_LINKFLAGS "-pthread")
205
206   # Better warnings
207   SET(C_WARNINGS "-Wall -Wno-char-subscripts -Wpointer-arith -Wcast-align -Wnested-externs -Wdeclaration-after-statement")
208   SET(CXX_WARNINGS "-Wall -Wno-invalid-offsetof -Wno-sign-compare")
209
210   INCLUDE_DIRECTORIES(${JPEG_INCLUDE_DIR} ${PNG_INCLUDE_DIR} ${ZLIB_INCLUDE_DIR} )
211 ENDIF(UNIX AND NOT APPLE)
212
213 IF(WIN32)
214
215   # this file is included anyway when building under Windows with cl.exe
216   #  INCLUDE(${CMAKE_ROOT}/Modules/Platform/Windows-cl.cmake)
217   
218   SET(LIBDIR ${CMAKE_SOURCE_DIR}/../lib/windows)
219
220   # Setup 64bit and 64bit windows systems
221   IF(CMAKE_CL_64)
222     message("64 bit compiler detected.")
223     SET(LIBDIR ${CMAKE_SOURCE_DIR}/../lib/win64)
224   ENDIF(CMAKE_CL_64)
225
226   SET(PYTHON ${LIBDIR}/python)
227   SET(PYTHON_VERSION 3.1)
228   SET(PYTHON_INC "${PYTHON}/include/python${PYTHON_VERSION}")
229   # SET(PYTHON_BINARY python) # not used yet
230   SET(PYTHON_LIB python31)
231   SET(PYTHON_LIBPATH ${PYTHON}/lib)
232
233   IF(CMAKE_CL_64)
234     SET(WITH_OPENAL OFF)
235   ELSE(CMAKE_CL_64)
236     #SET(WITH_OPENAL ON)
237     SET(OPENAL ${LIBDIR}/openal)
238     SET(OPENAL_INCLUDE_DIR ${OPENAL}/include)
239     SET(OPENAL_LIBRARY wrap_oal)
240     SET(OPENAL_LIBPATH ${OPENAL}/lib)
241   ENDIF(CMAKE_CL_64)
242
243   IF(WITH_JACK)
244     SET(JACK ${LIBDIR}/jack)
245     SET(JACK_INC ${JACK}/include/jack)
246     SET(JACK_LIB jack)
247     SET(JACK_LIBPATH ${JACK}/lib)
248   ENDIF(WITH_JACK)
249
250   IF(CMAKE_CL_64)
251     SET(PNG_LIBRARIES libpng)
252   ELSE(CMAKE_CL_64)
253     SET(PNG_LIBRARIES libpng_st)
254   ENDIF(CMAKE_CL_64)
255   SET(JPEG_LIBRARY libjpeg)
256
257   SET(ZLIB ${LIBDIR}/zlib)
258   SET(ZLIB_INC ${ZLIB}/include)
259   IF(CMAKE_CL_64)
260     SET(ZLIB_LIBRARIES libz)
261   ELSE(CMAKE_CL_64)
262     SET(ZLIB_LIBRARIES zlib)
263   ENDIF(CMAKE_CL_64)
264   SET(ZLIB_LIBPATH ${ZLIB}/lib)
265   
266   SET(PTHREADS ${LIBDIR}/pthreads)
267   SET(PTHREADS_INC ${PTHREADS}/include)
268   SET(PTHREADS_LIB pthreadVC2)
269   SET(PTHREADS_LIBPATH ${PTHREADS}/lib)
270   
271   SET(ICONV ${LIBDIR}/iconv)
272   SET(ICONV_INC ${ICONV}/include)
273   SET(ICONV_LIB iconv)
274   SET(ICONV_LIBPATH ${ICONV}/lib)
275   
276   IF(WITH_FFTW3)
277     SET(FFTW3 ${LIBDIR}/fftw3)
278     SET(FFTW3_INC ${FFTW3}/include)
279     SET(FFTW3_LIB libfftw)
280     SET(FFTW3_LIBPATH ${FFTW3}/lib)
281   ENDIF(WITH_FFTW3)
282   
283   SET(GETTEXT ${LIBDIR}/gettext)
284   SET(GETTEXT_INC ${GETTEXT}/include)
285   IF(CMAKE_CL_64)
286     SET(GETTEXT_LIB gettext)
287   ELSE(CMAKE_CL_64)
288     SET(GETTEXT_LIB gnu_gettext)
289   ENDIF(CMAKE_CL_64)
290   SET(GETTEXT_LIBPATH ${GETTEXT}/lib)
291
292   SET(FREETYPE ${LIBDIR}/freetype)
293   SET(FREETYPE_INCLUDE_DIRS ${FREETYPE}/include ${FREETYPE}/include/freetype2)
294   SET(FREETYPE_LIBPATH ${FREETYPE}/lib)
295   SET(FREETYPE_LIBRARY freetype2ST)
296   
297   SET(OPENEXR ${LIBDIR}/openexr)
298   SET(OPENEXR_INC ${OPENEXR}/include ${OPENEXR}/include/IlmImf ${OPENEXR}/include/Iex ${OPENEXR}/include/Imath)
299   SET(OPENEXR_LIB Iex Half IlmImf Imath IlmThread)
300   IF (MSVC80)
301     SET(OPENEXR_LIBPATH ${OPENEXR}/lib_vs2005)
302   ELSE (MSVC80)
303     SET(OPENEXR_LIBPATH ${OPENEXR}/lib_msvc)
304   ENDIF(MSVC80)
305   IF (MSVC90)
306     SET(OPENEXR_LIBPATH ${OPENEXR}/lib_vs2008)
307   ENDIF(MSVC90)
308
309   
310   SET(QUICKTIME ${LIBDIR}/QTDevWin)
311   SET(QUICKTIME_INC ${QUICKTIME}/CIncludes)
312   SET(QUICKTIME_LIB qtmlClient)
313   SET(QUICKTIME_LIBPATH ${QUICKTIME}/Libraries)
314
315   SET(FFMPEG ${LIBDIR}/ffmpeg)
316   SET(FFMPEG_INC ${FFMPEG}/include)
317   SET(FFMPEG_LIB avcodec-52 avformat-52 avdevice-52 avutil-50 swscale-0)
318   SET(FFMPEG_LIBPATH ${FFMPEG}/lib)
319
320   SET(LIBSAMPLERATE ${LIBDIR}/samplerate)
321   SET(LIBSAMPLERATE_INC ${LIBSAMPLERATE}/include)
322   SET(LIBSAMPLERATE_LIB libsamplerate)
323   SET(LIBSAMPLERATE_LIBPATH ${LIBSAMPLERATE}/lib)
324
325   IF(CMAKE_CL_64)
326     SET(LLIBS kernel32 user32 vfw32 winmm ws2_32 )
327   ELSE(CMAKE_CL_64)
328     SET(LLIBS kernel32 user32 gdi32 comdlg32 advapi32 shell32 ole32 oleaut32 uuid ws2_32 vfw32 winmm)
329   ENDIF(CMAKE_CL_64)
330
331   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)
332   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)
333   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)
334   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)
335   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)
336   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)
337   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)
338   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)
339
340   IF(WITH_OPENMP)
341     SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /openmp ")
342     SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /openmp ")
343   ENDIF(WITH_OPENMP)
344
345   SET(SDL ${LIBDIR}/sdl)
346   SET(SDL_INCLUDE_DIR ${SDL}/include)
347   SET(SDL_LIBRARY SDL)
348   SET(SDL_LIBPATH ${SDL}/lib)
349
350   SET(PNG "${LIBDIR}/png")
351   SET(PNG_INC "${PNG}/include")
352   SET(PNG_LIBPATH ${PNG}/lib)
353
354   SET(JPEG "${LIBDIR}/jpeg")
355   SET(JPEG_INC "${JPEG}/include")
356   SET(JPEG_LIBPATH ${JPEG}/lib)
357
358   SET(TIFF ${LIBDIR}/tiff)
359   SET(TIFF_INC ${TIFF}/include)
360   
361   SET(WINTAB_INC ${LIBDIR}/wintab/include) 
362
363   IF(CMAKE_CL_64)
364     SET(PLATFORM_LINKFLAGS "/MANIFEST:NO /MANIFESTUAC:NO /MACHINE:X64 /NODEFAULTLIB:libc.lib;MSVCRT.lib ")
365   ELSE(CMAKE_CL_64)
366     SET(PLATFORM_LINKFLAGS "/NODEFAULTLIB:libc.lib ")
367   ENDIF(CMAKE_CL_64)
368   
369   SET(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} /NODEFAULTLIB:libcmt.lib;libc.lib ")
370 ENDIF(WIN32)
371
372 IF(APPLE)
373   IF(CMAKE_OSX_ARCHITECTURES MATCHES i386)
374     SET(LIBDIR ${CMAKE_SOURCE_DIR}/../lib/darwin-8.x.i386)
375   ELSE(CMAKE_OSX_ARCHITECTURES MATCHES i386)
376     SET(LIBDIR ${CMAKE_SOURCE_DIR}/../lib/darwin-6.1-powerpc)
377   ENDIF(CMAKE_OSX_ARCHITECTURES MATCHES i386)
378
379   IF(WITH_OPENAL)
380     FIND_PACKAGE(OpenAL)
381     IF(OPENAL_FOUND)
382       SET(WITH_OPENAL ON)
383     ELSE(OPENAL_FOUND)
384       SET(WITH_OPENAL OFF)
385     ENDIF(OPENAL_FOUND)
386   ENDIF(WITH_OPENAL)
387
388   IF(WITH_JACK)
389     SET(JACK /usr)
390     SET(JACK_INC ${JACK}/include/jack)
391     SET(JACK_LIB jack)
392     SET(JACK_LIBPATH ${JACK}/lib)
393   ENDIF(WITH_JACK)
394
395   SET(PYTHON_VERSION 3.1)
396
397   IF(PYTHON_VERSION MATCHES 3.1)
398     # we use precompiled libraries for py 3.1 and up by default
399
400     SET(PYTHON ${LIBDIR}/python)
401     SET(PYTHON_INC "${PYTHON}/include/python${PYTHON_VERSION}" CACHE STRING "")
402     # SET(PYTHON_BINARY "${PYTHON}/bin/python${PYTHON_VERSION}" CACHE STRING "") # not used yet
403     SET(PYTHON_LIB python${PYTHON_VERSION})
404     SET(PYTHON_LIBPATH "${PYTHON}/lib/python${PYTHON_VERSION}" CACHE STRING "")
405     #    SET(PYTHON_LINKFLAGS "-u _PyMac_Error")  # won't  build with this enabled
406   ELSE(PYTHON_VERSION MATCHES 3.1)
407     # otherwise, use custom system framework
408
409     SET(PYTHON /System/Library/Frameworks/Python.framework/Versions/)
410     SET(PYTHON_VERSION 2.5)
411     SET(PYTHON_INC "${PYTHON}${PYTHON_VERSION}/include/python${PYTHON_VERSION}" CACHE STRING "")
412     # SET(PYTHON_BINARY ${PYTHON}${PYTHON_VERSION}/bin/python${PYTHON_VERSION} CACHE STRING "") # not used yet
413     SET(PYTHON_LIB "")
414     SET(PYTHON_LIBPATH ${PYTHON}${PYTHON_VERSION}/lib/python${PYTHON_VERSION}/config CACHE STRING "")
415     SET(PYTHON_LINKFLAGS "-u _PyMac_Error -framework System -framework Python")
416   ENDIF(PYTHON_VERSION MATCHES 3.1)
417
418   SET(GETTEXT ${LIBDIR}/gettext)
419   SET(GETTEXT_INC "${GETTEXT}/include")
420   SET(GETTEXT_LIB intl iconv)
421   SET(GETTEXT_LIBPATH ${GETTEXT}/lib)
422   
423   IF(WITH_FFTW3)
424     SET(FFTW3 ${LIBDIR}/fftw3)
425     SET(FFTW3_INC ${FFTW3}/include)
426     SET(FFTW3_LIB libfftw)
427     SET(FFTW3_LIBPATH ${FFTW3}/lib)
428   ENDIF(WITH_FFTW3)
429
430   SET(PNG_LIBRARIES png)
431   SET(JPEG_LIBRARY jpeg)
432
433   SET(ZLIB /usr)
434   SET(ZLIB_INC "${ZLIB}/include")
435   SET(ZLIB_LIBRARIES z)
436
437   SET(FREETYPE ${LIBDIR}/freetype)
438   SET(FREETYPE_INCLUDE_DIRS ${FREETYPE}/include ${FREETYPE}/include/freetype2)
439   SET(FREETYPE_LIBPATH ${FREETYPE}/lib)
440   SET(FREETYPE_LIBRARY freetype)
441
442   SET(OPENEXR ${LIBDIR}/openexr)
443   SET(OPENEXR_INC ${OPENEXR}/include/OpenEXR ${OPENEXR}/include)
444   SET(OPENEXR_LIB Iex Half IlmImf Imath IlmThread)
445   SET(OPENEXR_LIBPATH ${OPENEXR}/lib)
446
447   SET(FFMPEG ${LIBDIR}/ffmpeg)
448   SET(FFMPEG_INC ${CMAKE_SOURCE_DIR}/extern/ffmpeg)
449   SET(FFMPEG_LIB avcodec avdevice avformat avutil mp3lame swscale x264 xvidcore)
450   SET(FFMPEG_LIBPATH ${FFMPEG}/lib)
451
452   SET(LIBSAMPLERATE ${LIBDIR}/samplerate)
453   SET(LIBSAMPLERATE_INC ${LIBSAMPLERATE}/include)
454   SET(LIBSAMPLERATE_LIB samplerate)
455   SET(LIBSAMPLERATE_LIBPATH ${LIBSAMPLERATE}/lib)
456
457   SET(LLIBS stdc++ SystemStubs)
458
459   SET(PLATFORM_CFLAGS "-pipe -fPIC -funsigned-char -fno-strict-aliasing")
460   SET(PLATFORM_LINKFLAGS "-fexceptions -framework CoreServices -framework Foundation -framework IOKit -framework AppKit -framework Carbon -framework AGL -framework AudioUnit -framework AudioToolbox -framework CoreAudio -framework QuickTime")
461
462   IF(WITH_OPENMP)
463     SET(LLIBS "${LLIBS} -lgomp ")
464     SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fopenmp ")
465     SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fopenmp ")
466   ENDIF(WITH_OPENMP)
467
468   SET(SDL ${LIBDIR}/sdl)
469   SET(SDL_INCLUDE_DIR ${SDL}/include)
470   SET(SDL_LIBRARY SDL)
471   SET(SDL_LIBPATH ${SDL}/lib)
472
473   SET(PNG "${LIBDIR}/png")
474   SET(PNG_INC "${PNG}/include")
475   SET(PNG_LIBPATH ${PNG}/lib)
476
477   SET(JPEG "${LIBDIR}/jpeg")
478   SET(JPEG_INC "${JPEG}/include")
479   SET(JPEG_LIBPATH ${JPEG}/lib)
480
481   SET(TIFF ${LIBDIR}/tiff)
482   SET(TIFF_INC ${TIFF}/include)
483
484   SET(EXETYPE MACOSX_BUNDLE)
485 ENDIF(APPLE)
486
487 IF(CMAKE_SYSTEM_NAME MATCHES "Linux")
488   SET(BINRELOC ${CMAKE_SOURCE_DIR}/extern/binreloc)
489   SET(BINRELOC_INC ${BINRELOC}/include)
490 ENDIF(CMAKE_SYSTEM_NAME MATCHES "Linux")
491
492 #-----------------------------------------------------------------------------
493 # Common.
494
495 set(OPENJPEG ${CMAKE_SOURCE_DIR}/extern/libopenjpeg)
496 set(OPENJPEG_INC ${OPENJPEG})
497 set(OPENJPEG_LIb extern_libopenjpeg)
498
499 #-----------------------------------------------------------------------------
500 # Blender WebPlugin
501
502 IF(WITH_WEBPLUGIN) 
503   SET(GECKO_DIR "${CMAKE_SOURCE_DIR}/../gecko-sdk/" CACHE PATH "Gecko SDK path")
504   SET(WEBPLUGIN_SANDBOX_MODE "apparmor" CACHE STRING "WEB Plugin sandbox mode, can be apparmor, privsep, none")
505
506   SET(WITH_PLAYER ON)
507 ENDIF(WITH_WEBPLUGIN)
508
509
510 #-----------------------------------------------------------------------------
511 # Configure OpenGL.
512 FIND_PACKAGE(OpenGL)
513 INCLUDE_DIRECTORIES(${OPENGL_INCLUDE_DIR})
514 # UNSET(OPENGL_LIBRARIES CACHE) # not compat with older cmake 
515 # UNSET(OPENGL_xmesa_INCLUDE_DIR CACHE) # not compat with older cmake 
516
517 #-----------------------------------------------------------------------------
518 # Extra compile flags
519 SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${PLATFORM_CFLAGS} ${C_WARNINGS}")
520 SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${PLATFORM_CFLAGS} ${CXX_WARNINGS}")
521
522 # better not define flags here but this is a debugging option thats off by default.
523 IF(WITH_CXX_GUARDEDALLOC)
524   SET(CMAKE_CXX_FLAGS " -DWITH_CXX_GUARDEDALLOC -I${CMAKE_SOURCE_DIR}/intern/guardedalloc ${CMAKE_CXX_FLAGS}")
525 ENDIF(WITH_CXX_GUARDEDALLOC)
526
527 #-----------------------------------------------------------------------------
528 # Libraries
529 FILE(WRITE ${CMAKE_BINARY_DIR}/cmake_blender_libs.txt "")
530 ADD_SUBDIRECTORY(intern)
531 ADD_SUBDIRECTORY(extern)
532 ADD_SUBDIRECTORY(source)
533
534
535 #-----------------------------------------------------------------------------
536 # Blender Application
537 ADD_SUBDIRECTORY(source/creator)
538
539
540 #-----------------------------------------------------------------------------
541 # Blender Player
542 IF(WITH_PLAYER)
543   ADD_SUBDIRECTORY(blenderplayer)
544 ENDIF(WITH_PLAYER)
545