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