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