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