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