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