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