enable building the game engine without bullet for scons & cmake
[blender.git] / CMakeLists.txt
1 # $Id$
2 # ***** BEGIN GPL LICENSE BLOCK *****
3 #
4 # This program is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU General Public License
6 # as published by the Free Software Foundation; either version 2
7 # of the License, or (at your option) any later version.
8 #
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 # GNU General Public License for more details.
13 #
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software Foundation,
16 # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 #
18 # The Original Code is Copyright (C) 2006, Blender Foundation
19 # All rights reserved.
20 #
21 # The Original Code is: all of this file.
22 #
23 # Contributor(s): Jacques Beaurain.
24 #
25 # ***** END GPL LICENSE BLOCK *****
26
27 #-----------------------------------------------------------------------------
28 # We don't allow in-source builds. This causes no end of troubles because 
29 # all out-of-source builds will use the CMakeCache.txt file there and even 
30 # build the libs and objects in it. It will also conflict with the current 
31 # Makefile system for Blender
32
33 IF(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR})
34 MESSAGE(FATAL_ERROR "CMake generation for blender is not allowed within the source directory! 
35 Remove the CMakeCache.txt file and try again from another folder, e.g.: 
36
37         rm CMakeCache.txt 
38         cd ..
39         mkdir cmake-make 
40         cd cmake-make
41         cmake -G \"Unix Makefiles\" ../blender
42 ")
43 ENDIF(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR})
44
45 CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
46
47 # quiet output for Makefiles, 'make -s' helps too
48 # SET_PROPERTY(GLOBAL PROPERTY RULE_MESSAGES OFF)
49
50 PROJECT(Blender)
51
52 #-----------------------------------------------------------------------------
53 # Redirect output files
54
55 SET(EXECUTABLE_OUTPUT_PATH ${CMAKE_BINARY_DIR}/bin)
56 SET(LIBRARY_OUTPUT_PATH  ${CMAKE_BINARY_DIR}/lib)
57
58 #-----------------------------------------------------------------------------
59 # Load some macros.
60 INCLUDE(build_files/cmake/macros.cmake)
61
62 #-----------------------------------------------------------------------------
63 # Set default config options
64
65 GET_BLENDER_VERSION()
66
67 # Blender internal features
68 OPTION(WITH_INTERNATIONAL "Enable I18N   (International fonts and text)" ON)
69 OPTION(WITH_LCMS          "Enable color correction with lcms" OFF)
70 OPTION(WITH_PYTHON        "Enable Embedded Python API" ON)
71 OPTION(WITH_BUILDINFO     "Include extra build details" ON)
72 OPTION(WITH_FLUID        "Enable Elbeem (Fluid Simulation)" ON)
73 OPTION(WITH_IK_ITASC      "Enable ITASC IK solver" ON)
74 OPTION(WITH_FFTW3         "Enable FFTW3 support (Used for smoke and audio effects)" OFF)
75 OPTION(WITH_BULLET        "Enable Bullet (Physics Engine)" ON)
76 OPTION(WITH_GAMEENGINE    "Enable Game Engine" ON)
77 OPTION(WITH_PLAYER        "Build Player" OFF)
78 # (unix defaults to OpenMP On)
79 IF(UNIX AND NOT APPLE)
80         OPTION(WITH_OPENMP        "Enable OpenMP (has to be supported by the compiler)" ON)
81 ELSE()
82         OPTION(WITH_OPENMP        "Enable OpenMP (has to be supported by the compiler)" OFF)
83 ENDIF()
84
85 # Image format support
86 OPTION(WITH_IMAGE_OPENEXR       "Enable OpenEXR Support (http://www.openexr.com)" ON)
87 OPTION(WITH_IMAGE_OPENJPEG      "Enable OpenJpeg Support (http://www.openjpeg.org/)" OFF)
88 OPTION(WITH_IMAGE_TIFF          "Enable LibTIFF Support" ON)
89 OPTION(WITH_IMAGE_DDS           "Enable DDS Image Support" ON)
90 OPTION(WITH_IMAGE_CINEON        "Enable CINEON and DPX Image Support" ON)
91 OPTION(WITH_IMAGE_HDR           "Enable HDR Image Support" ON)
92
93 # Audio format support
94 OPTION(WITH_FFMPEG        "Enable FFMPeg Support (http://ffmpeg.mplayerhq.hu/)" OFF)
95 OPTION(WITH_SNDFILE       "Enable libsndfile Support (http://www.mega-nerd.com/libsndfile)" OFF)
96 IF(APPLE OR WIN32)
97         OPTION(WITH_QUICKTIME     "Enable Quicktime Support" OFF)
98 ENDIF(APPLE OR WIN32)
99
100 # 3D format support
101 # disable opencollada on non-apple unix because opencollada has no package for debian
102 IF(UNIX AND NOT APPLE)
103         OPTION(WITH_OPENCOLLADA         "Enable OpenCollada Support (http://www.opencollada.org/)"      OFF)
104 ELSE()
105         OPTION(WITH_OPENCOLLADA         "Enable OpenCollada Support (http://www.opencollada.org/)"      OFF)
106 ENDIF()
107
108 # Sound output
109 OPTION(WITH_SDL           "Enable SDL for sound and joystick support" ON)
110 OPTION(WITH_OPENAL        "Enable OpenAL Support (http://www.openal.org)" ON)
111 OPTION(WITH_JACK          "Enable Jack Support (http://www.jackaudio.org)" OFF)
112
113 # Compression
114 OPTION(WITH_LZO           "Enable fast LZO compression (used for pointcache)" ON)
115 OPTION(WITH_LZMA          "Enable best LZMA compression, (used for pointcache)" ON)
116
117 # Misc
118 OPTION(WITH_RAYOPTIMIZATION     "Enable use of SIMD (SSE) optimizations for the raytracer" ON) 
119 OPTION(WITH_CXX_GUARDEDALLOC "Enable GuardedAlloc for C++ memory allocation tracking" OFF)
120 OPTION(WITH_INSTALL       "Install accompanying scripts and language files needed to run blender" ON)
121 OPTION(WITH_PYTHON_INSTALL       "Copy system python into the blender install folder" ON)
122
123 IF(APPLE)
124         OPTION(WITH_COCOA         "Use Cocoa framework instead of deprecated Carbon" ON)
125         OPTION(USE_QTKIT          "Use QtKit instead of Carbon quicktime (needed for having partial quicktime for 64bit)" OFF)
126         OPTION(WITH_LIBS10.5  "Use 10.5 libs (needed for 64bit builds)" OFF)
127 ENDIF(APPLE)
128
129
130 IF(NOT WITH_GAMEENGINE AND WITH_PLAYER)
131         MESSAGE("WARNING: WITH_PLAYER needs WITH_GAMEENGINE")
132 ENDIF(NOT WITH_GAMEENGINE AND WITH_PLAYER)
133
134 IF(NOT WITH_INSTALL AND WITH_PYTHON_INSTALL)
135         MESSAGE("WARNING: WITH_PYTHON_INSTALL needs WITH_INSTALL")
136 ENDIF(NOT WITH_INSTALL AND WITH_PYTHON_INSTALL)
137
138 TEST_SSE_SUPPORT()
139
140 # disabled for now, not supported
141 # OPTION(WITH_WEBPLUGIN     "Enable Web Plugin (Unix only)" OFF)
142
143 # For alternate Python locations the commandline can be used to override detected/default cache settings, e.g:
144 # On Unix: 
145 #   cmake -D PYTHON_LIB=/usr/local/lib/python3.1/config/libpython3.1.so -D PYTHON_INC=/usr/local/include/python3.1 -G "Unix Makefiles" ../blender
146 # On Macs: 
147 #   cmake -D PYTHON_INC=/System/Library/Frameworks/Python.framework/Versions/3.1/include/python3.1 -D PYTHON_LIBPATH=/System/Library/Frameworks/Python.framework/Versions/3.1/lib/python3.1/config -G Xcode ../blender
148 #
149 # When changing any of this remember to update the notes in doc/blender-cmake.txt
150
151 #-----------------------------------------------------------------------------
152 #Platform specifics
153
154 IF(UNIX AND NOT APPLE)
155
156         IF(WITH_OPENAL)
157                 FIND_PACKAGE(OpenAL)
158                 IF(NOT OPENAL_FOUND)
159                         SET(WITH_OPENAL OFF)
160                 ENDIF(NOT OPENAL_FOUND)
161         ENDIF(WITH_OPENAL)
162
163         IF(WITH_JACK)
164                 SET(JACK /usr)
165                 SET(JACK_INC ${JACK}/include/jack)
166                 SET(JACK_LIB jack)
167                 SET(JACK_LIBPATH ${JACK}/lib)
168         ENDIF(WITH_JACK)
169
170         IF(WITH_SNDFILE)
171         SET(SNDFILE /usr)
172         SET(SNDFILE_INC ${SNDFILE}/include)
173         SET(SNDFILE_LIB sndfile)
174         SET(SNDFILE_LIBPATH ${SNDFILE}/lib)
175         ENDIF(WITH_SNDFILE)
176
177         IF(WITH_INTERNATIONAL)
178                 FIND_LIBRARY(INTL_LIBRARY
179                         NAMES intl
180                         PATHS
181                         /sw/lib
182                 )
183
184                 FIND_LIBRARY(ICONV_LIBRARY
185                         NAMES iconv
186                         PATHS
187                         /sw/lib
188                 )
189
190                 IF(INTL_LIBRARY AND ICONV_LIBRARY)
191                         SET(GETTEXT_LIB ${INTL_LIBRARY} ${ICONV_LIBRARY})
192                 ENDIF(INTL_LIBRARY AND ICONV_LIBRARY)
193         ENDIF(WITH_INTERNATIONAL)
194
195         FIND_PACKAGE(Freetype)
196         # UNSET(FREETYPE_INCLUDE_DIRS CACHE) # cant use
197
198
199         IF(WITH_PYTHON)
200                 # No way to set py31. remove for now.
201                 # FIND_PACKAGE(PythonLibs)
202                 SET(PYTHON /usr)
203                 SET(PYTHON_VERSION 3.1)
204                 SET(PYTHON_INC "${PYTHON}/include/python${PYTHON_VERSION}" CACHE STRING "")
205                 # SET(PYTHON_BINARY python) # not used yet
206                 SET(PYTHON_LIB python${PYTHON_VERSION} CACHE STRING "")
207                 SET(PYTHON_LIBPATH ${PYTHON}/lib CACHE STRING "")
208         
209                 # FIND_PACKAGE(PythonInterp) # not used yet
210                 # SET(PYTHON_BINARY ${PYTHON_EXECUTABLE} CACHE STRING "")
211
212                 SET(PYTHON_LINKFLAGS "-Xlinker -export-dynamic")
213         ENDIF(WITH_PYTHON)
214
215         IF(WITH_SDL)
216                 FIND_PACKAGE(SDL)
217                 # UNSET(SDLMAIN_LIBRARY CACHE)
218                 IF(NOT SDL_FOUND)
219                         SET(WITH_SDL OFF)
220                 ENDIF(NOT SDL_FOUND)
221         ENDIF(WITH_SDL)
222
223         IF(WITH_IMAGE_OPENEXR)
224                 SET(OPENEXR /usr CACHE FILEPATH "OPENEXR Directory")
225                 FIND_PATH(OPENEXR_INC
226                         ImfXdr.h
227                         PATHS
228                         ${OPENEXR}/include/OpenEXR
229                         /usr/local/include/OpenEXR
230                         /sw/include/OpenEXR
231                         /opt/local/include/OpenEXR
232                         /opt/csw/include/OpenEXR
233                         /opt/include/OpenEXR
234                 )
235                 SET(OPENEXR_LIB Half IlmImf Iex Imath)
236                 
237                 IF(NOT OPENEXR_INC)
238                         SET(WITH_IMAGE_OPENEXR OFF)
239                 ENDIF(NOT OPENEXR_INC)
240         ENDIF(WITH_IMAGE_OPENEXR)
241
242         IF(WITH_IMAGE_TIFF)
243                 FIND_PACKAGE(TIFF)
244                 IF(NOT TIFF_FOUND)
245                         SET(WITH_IMAGE_TIFF OFF)
246                 ENDIF(NOT TIFF_FOUND)
247         ENDIF(WITH_IMAGE_TIFF)
248
249         FIND_PACKAGE(JPEG REQUIRED)
250
251         FIND_PACKAGE(PNG REQUIRED)
252
253         FIND_PACKAGE(ZLIB REQUIRED)
254
255         IF(WITH_LCMS)
256                 SET(LCMS /usr CACHE FILEPATH "LCMS directory")
257                 SET(LCMS_INCLUDE_DIR ${LCMS}/include)
258                 SET(LCMS_LIBRARY lcms)
259                 SET(LCMS_LIBPATH ${LCMS}/lib)
260         ENDIF(WITH_LCMS)
261
262         IF(WITH_FFMPEG)
263                 SET(FFMPEG /usr CACHE FILEPATH "FFMPEG Directory")
264                 SET(FFMPEG_INC ${FFMPEG}/include)
265                 SET(FFMPEG_LIB avformat avcodec avutil avdevice swscale CACHE STRING "FFMPEG Libraries")
266                 SET(FFMPEG_LIBPATH ${FFMPEG}/lib)
267                 SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D__STDC_CONSTANT_MACROS")
268         ENDIF(WITH_FFMPEG)
269
270         IF(WITH_FFTW3)
271                 SET(FFTW3 /usr)
272                 SET(FFTW3_INC ${FFTW3}/include)
273                 SET(FFTW3_LIB fftw3)
274                 SET(FFTW3_LIBPATH ${FFTW3}/lib)
275         ENDIF(WITH_FFTW3)
276
277         SET(LIBSAMPLERATE /usr)
278         SET(LIBSAMPLERATE_INC ${LIBSAMPLERATE}/include)
279         SET(LIBSAMPLERATE_LIB samplerate)
280         SET(LIBSAMPLERATE_LIBPATH ${LIBSAMPLERATE}/lib)
281
282         IF (WITH_OPENCOLLADA)
283                 SET(OPENCOLLADA /usr/local/opencollada CACHE FILEPATH "OpenCollada Directory")
284                 SET(OPENCOLLADA_LIBPATH ${OPENCOLLADA}/lib)
285                 SET(OPENCOLLADA_LIB OpenCOLLADAStreamWriter OpenCOLLADASaxFrameworkLoader OpenCOLLADAFramework OpenCOLLADABaseUtils GeneratedSaxParser UTF MathMLSolver pcre ftoa buffer)
286                 SET(OPENCOLLADA_INC ${OPENCOLLADA})
287                 SET(PCRE /usr CACHE FILEPATH "PCRE Directory")
288                 SET(PCRE_LIBPATH ${PCRE}/lib)
289                 SET(PCRE_LIB pcre)
290                 SET(EXPAT /usr CACHE FILEPATH "Expat Directory")
291                 SET(EXPAT_LIBPATH ${EXPAT}/lib)
292                 SET(EXPAT_LIB expat)
293         ENDIF (WITH_OPENCOLLADA)
294
295         FIND_PACKAGE(X11 REQUIRED)
296
297         # OpenSuse needs lutil, ArchLinux not, for now keep, can avoid by using --as-needed
298         SET(LLIBS "-lutil -lc -lm -lpthread -lstdc++ ${X11_X11_LIB} ${X11_Xinput_LIB}")
299
300         IF(CMAKE_SYSTEM_NAME MATCHES "Linux")
301                 # BSD's dont use libdl.so
302                 LIST(APPEND LLIBS -ldl)
303
304                 # binreloc is linux only
305                 SET(BINRELOC ${CMAKE_SOURCE_DIR}/extern/binreloc)
306                 SET(BINRELOC_INC ${BINRELOC}/include)
307         ENDIF(CMAKE_SYSTEM_NAME MATCHES "Linux")
308
309         IF(WITH_OPENMP)
310                 LIST(APPEND LLIBS -lgomp)
311                 SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fopenmp")
312                 SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fopenmp")
313         ENDIF(WITH_OPENMP)
314
315
316         SET(PLATFORM_CFLAGS "-pipe -fPIC -funsigned-char -fno-strict-aliasing")
317
318         SET(PLATFORM_LINKFLAGS "-pthread")
319
320         # Better warnings
321         SET(C_WARNINGS "-Wall -Wno-char-subscripts -Wpointer-arith -Wcast-align -Wdeclaration-after-statement -Wno-unknown-pragmas")
322         SET(CXX_WARNINGS "-Wall -Wno-invalid-offsetof -Wno-sign-compare")
323
324         INCLUDE_DIRECTORIES(${JPEG_INCLUDE_DIR} ${PNG_INCLUDE_DIR} ${ZLIB_INCLUDE_DIR} )
325 ENDIF(UNIX AND NOT APPLE)
326
327
328 IF(WIN32)
329
330         # this file is included anyway when building under Windows with cl.exe
331         #  INCLUDE(${CMAKE_ROOT}/Modules/Platform/Windows-cl.cmake)
332   
333         SET(LIBDIR ${CMAKE_SOURCE_DIR}/../lib/windows)
334
335         # Setup 64bit and 64bit windows systems
336         IF(CMAKE_CL_64)
337                 message("64 bit compiler detected.")
338                 SET(LIBDIR ${CMAKE_SOURCE_DIR}/../lib/win64)
339         ENDIF(CMAKE_CL_64)
340         
341         ADD_DEFINITIONS(-DWIN32)
342
343         IF(WITH_INTERNATIONAL)
344                 SET(ICONV ${LIBDIR}/iconv)
345                 SET(ICONV_INC ${ICONV}/include)
346                 SET(ICONV_LIB iconv)
347                 SET(ICONV_LIBPATH ${ICONV}/lib)
348         ENDIF(WITH_INTERNATIONAL)
349
350         SET(LIBSAMPLERATE ${LIBDIR}/samplerate)
351         SET(LIBSAMPLERATE_INC ${LIBSAMPLERATE}/include)
352         SET(LIBSAMPLERATE_LIB libsamplerate)
353         SET(LIBSAMPLERATE_LIBPATH ${LIBSAMPLERATE}/lib)
354
355         SET(PNG "${LIBDIR}/png")
356         SET(PNG_INC "${PNG}/include")
357         SET(PNG_LIBPATH ${PNG}/lib)
358
359         SET(JPEG "${LIBDIR}/jpeg")
360         SET(JPEG_INC "${JPEG}/include")
361         SET(JPEG_LIBPATH ${JPEG}/lib)
362
363         SET(WINTAB_INC ${LIBDIR}/wintab/include) 
364
365         IF(WITH_OPENAL)
366                 SET(OPENAL ${LIBDIR}/openal)
367                 SET(OPENAL_INCLUDE_DIR ${OPENAL}/include)
368                 SET(OPENAL_LIBRARY wrap_oal)
369                 SET(OPENAL_LIBPATH ${OPENAL}/lib)
370         ENDIF(WITH_OPENAL)
371
372         IF(WITH_SNDFILE)
373                 SET(SNDFILE ${LIBDIR}/sndfile)
374                 SET(SNDFILE_INC ${SNDFILE}/include)
375                 SET(SNDFILE_LIB libsndfile-1)
376                 SET(SNDFILE_LIBPATH ${SNDFILE}/lib)
377         ENDIF(WITH_SNDFILE)
378
379         IF(WITH_SDL)
380                 SET(SDL ${LIBDIR}/sdl)
381                 SET(SDL_INCLUDE_DIR ${SDL}/include)
382                 SET(SDL_LIBRARY SDL)
383                 SET(SDL_LIBPATH ${SDL}/lib)
384         ENDIF(WITH_SDL)
385
386         IF(WITH_QUICKTIME)
387                 SET(QUICKTIME ${LIBDIR}/QTDevWin)
388                 SET(QUICKTIME_INC ${QUICKTIME}/CIncludes)
389                 SET(QUICKTIME_LIB qtmlClient)
390                 SET(QUICKTIME_LIBPATH ${QUICKTIME}/Libraries)
391         ENDIF(WITH_QUICKTIME)
392
393         IF(WITH_RAYOPTIMIZATION AND SUPPORT_SSE_BUILD)
394                 ADD_DEFINITIONS(-D__SSE__ -D__MMX__)
395         ENDIF(WITH_RAYOPTIMIZATION AND SUPPORT_SSE_BUILD)
396
397         IF(MSVC)
398                 IF(CMAKE_CL_64)
399                         SET(LLIBS kernel32 user32 vfw32 winmm ws2_32 )
400                 ELSE(CMAKE_CL_64)
401                         SET(LLIBS kernel32 user32 gdi32 comdlg32 advapi32 shell32 ole32 oleaut32 uuid ws2_32 vfw32 winmm)
402                 ENDIF(CMAKE_CL_64)
403                 
404                 SET(CMAKE_CXX_FLAGS "/D_CRT_NONSTDC_NO_DEPRECATE /D_CRT_SECURE_NO_DEPRECATE /D_SCL_SECURE_NO_DEPRECATE /wd4800 /wd4244 /wd4305" CACHE STRING "MSVC MT C++ flags " FORCE)
405                 SET(CMAKE_C_FLAGS   "/D_CRT_NONSTDC_NO_DEPRECATE /D_CRT_SECURE_NO_DEPRECATE /D_SCL_SECURE_NO_DEPRECATE /wd4800 /wd4244 /wd4305" CACHE STRING "MSVC MT C++ flags " FORCE)
406
407                 IF(CMAKE_CL_64)
408                         SET(CMAKE_CXX_FLAGS_DEBUG "/D_DEBUG /Od /Gm /EHsc /RTC1 /MTd /W3 /nologo /Zi /J" CACHE STRING "MSVC MT flags " FORCE)
409                 ELSE(CMAKE_CL_64)
410                         SET(CMAKE_CXX_FLAGS_DEBUG "/D_DEBUG /Od /Gm /EHsc /RTC1 /MTd /W3 /nologo /ZI /J" CACHE STRING "MSVC MT flags " FORCE)
411                 ENDIF(CMAKE_CL_64)
412                 SET(CMAKE_CXX_FLAGS_RELEASE "/O2 /Ob2 /DNDEBUG /EHsc /MT /W3 /nologo /J" CACHE STRING "MSVC MT flags " FORCE)
413                 SET(CMAKE_CXX_FLAGS_MINSIZEREL "/O1 /Ob1 /DNDEBUG /EHsc /MT /W3 /nologo /J" CACHE STRING "MSVC MT flags " FORCE)
414                 SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "/O2 /Ob1 /DNDEBUG /EHsc /MT /W3 /nologo /Zi /J" CACHE STRING "MSVC MT flags " FORCE)
415                 IF(CMAKE_CL_64)
416                         SET(CMAKE_C_FLAGS_DEBUG "/D_DEBUG /Od /Gm /EHsc /RTC1 /MTd /W3 /nologo /Zi /J" CACHE STRING "MSVC MT flags " FORCE)
417                 ELSE(CMAKE_CL_64)
418                         SET(CMAKE_C_FLAGS_DEBUG "/D_DEBUG /Od /Gm /EHsc /RTC1 /MTd /W3 /nologo /ZI /J" CACHE STRING "MSVC MT flags " FORCE)
419                 ENDIF(CMAKE_CL_64)
420                 SET(CMAKE_C_FLAGS_RELEASE "/O2 /Ob2 /DNDEBUG /EHsc /MT /W3 /nologo /J" CACHE STRING "MSVC MT flags " FORCE)
421                 SET(CMAKE_C_FLAGS_MINSIZEREL "/O1 /Ob1 /DNDEBUG /EHsc /MT /W3 /nologo /J" CACHE STRING "MSVC MT flags " FORCE)
422                 SET(CMAKE_C_FLAGS_RELWITHDEBINFO "/O2 /Ob1 /DNDEBUG /EHsc /MT /W3 /nologo /Zi /J" CACHE STRING "MSVC MT flags " FORCE)
423                 
424                 IF(WITH_OPENMP)
425                         SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /openmp ")
426                         SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /openmp ")
427                 ENDIF(WITH_OPENMP)
428                 
429                 IF(WITH_INTERNATIONAL)
430                         SET(GETTEXT ${LIBDIR}/gettext)
431                         SET(GETTEXT_INC ${GETTEXT}/include)
432                         SET(GETTEXT_LIBPATH ${GETTEXT}/lib)
433                         IF(CMAKE_CL_64)
434                                 SET(GETTEXT_LIB gettext)
435                         ELSE(CMAKE_CL_64)
436                                 SET(GETTEXT_LIB gnu_gettext)
437                         ENDIF(CMAKE_CL_64)
438                 ENDIF(WITH_INTERNATIONAL)
439
440                 IF(CMAKE_CL_64)
441                         SET(PNG_LIBRARIES libpng)
442                 ELSE(CMAKE_CL_64)
443                         SET(PNG_LIBRARIES libpng_st)
444                 ENDIF(CMAKE_CL_64)
445                 SET(JPEG_LIBRARY libjpeg)
446
447                 SET(ZLIB ${LIBDIR}/zlib)
448                 SET(ZLIB_INC ${ZLIB}/include)
449                 SET(ZLIB_LIBPATH ${ZLIB}/lib)
450                 IF(CMAKE_CL_64)
451                         SET(ZLIB_LIBRARIES libz)
452                 ELSE(CMAKE_CL_64)
453                         SET(ZLIB_LIBRARIES zlib)
454                 ENDIF(CMAKE_CL_64)
455
456                 SET(PTHREADS ${LIBDIR}/pthreads)
457                 SET(PTHREADS_INC ${PTHREADS}/include)
458                 SET(PTHREADS_LIBPATH ${PTHREADS}/lib)
459                 SET(PTHREADS_LIB pthreadVC2)
460                 
461                 SET(FREETYPE ${LIBDIR}/freetype)
462                 SET(FREETYPE_INCLUDE_DIRS ${FREETYPE}/include ${FREETYPE}/include/freetype2)
463                 SET(FREETYPE_LIBPATH ${FREETYPE}/lib)
464                 SET(FREETYPE_LIBRARY freetype2ST)
465
466                 IF(WITH_FFTW3)
467                         SET(FFTW3 ${LIBDIR}/fftw3)
468                         SET(FFTW3_LIB libfftw)
469                         SET(FFTW3_INC ${FFTW3}/include)
470                         SET(FFTW3_LIBPATH ${FFTW3}/lib)
471                 ENDIF(WITH_FFTW3)
472
473                 IF(WITH_OPENCOLLADA)
474                         SET(OPENCOLLADA ${LIBDIR}/opencollada)
475                         SET(OPENCOLLADA_INC ${OPENCOLLADA}/include)
476                         SET(OPENCOLLADA_LIBPATH ${OPENCOLLADA}/lib)
477                         SET(OPENCOLLADA_LIB OpenCOLLADASaxFrameworkLoader OpenCOLLADAFramework OpenCOLLADABaseUtils OpenCOLLADAStreamWriter MathMLSolver GeneratedSaxParser xml2 buffer ftoa)
478                         SET(PCRE_LIB pcre)
479                 ENDIF(WITH_OPENCOLLADA)
480                 
481                 IF(WITH_LCMS)
482                         SET(LCMS ${LIBDIR}/lcms)
483                         SET(LCMS_INCLUDE_DIR ${LCMS}/include)
484                         SET(LCMS_LIBPATH ${LCMS}/lib)
485                         SET(LCMS_LIB lcms)
486                 ENDIF(WITH_LCMS)
487         
488                 IF(WITH_FFMPEG)
489                         SET(FFMPEG ${LIBDIR}/ffmpeg)
490                         SET(FFMPEG_INC ${FFMPEG}/include ${FFMPEG}/include/msvc)
491                         SET(FFMPEG_LIB avcodec-52 avformat-52 avdevice-52 avutil-50 swscale-0)
492                         SET(FFMPEG_LIBPATH ${FFMPEG}/lib)
493                 ENDIF(WITH_FFMPEG)
494
495                 IF(WITH_IMAGE_OPENEXR)
496                         SET(OPENEXR ${LIBDIR}/openexr)
497                         SET(OPENEXR_INC ${OPENEXR}/include ${OPENEXR}/include/IlmImf ${OPENEXR}/include/Iex ${OPENEXR}/include/Imath)
498                         SET(OPENEXR_LIB Iex Half IlmImf Imath IlmThread)
499                         IF (MSVC80)
500                                 SET(OPENEXR_LIBPATH ${OPENEXR}/lib_vs2005)
501                         ELSE (MSVC80)
502                                 SET(OPENEXR_LIBPATH ${OPENEXR}/lib_msvc)
503                         ENDIF(MSVC80)
504                         IF (MSVC90)
505                                 SET(OPENEXR_LIBPATH ${OPENEXR}/lib_vs2008)
506                         ENDIF(MSVC90)
507                 ENDIF(WITH_IMAGE_OPENEXR)
508
509                 IF(WITH_IMAGE_TIFF)
510                         SET(TIFF ${LIBDIR}/tiff)
511                         SET(TIFF_LIBRARY libtiff)
512                         SET(TIFF_INCLUDE_DIR ${TIFF}/include)
513                         SET(TIFF_LIBPATH ${TIFF}/lib)
514                 ENDIF(WITH_IMAGE_TIFF)
515
516                 IF(WITH_JACK)
517                         SET(JACK ${LIBDIR}/jack)
518                         SET(JACK_INC ${JACK}/include/jack ${JACK}/include)
519                         SET(JACK_LIB libjack)
520                         SET(JACK_LIBPATH ${JACK}/lib)
521                 ENDIF(WITH_JACK)
522
523                 IF(WITH_PYTHON)
524                         SET(PYTHON ${LIBDIR}/python)
525                         SET(PYTHON_VERSION 3.1)
526                         SET(PYTHON_INC "${PYTHON}/include/python${PYTHON_VERSION}")
527                         # SET(PYTHON_BINARY python) # not used yet
528                         SET(PYTHON_LIB python31)
529                         SET(PYTHON_LIBPATH ${PYTHON}/lib)
530                 ENDIF(WITH_PYTHON)
531
532                 # MSVC only, Mingw doesnt need
533                 IF(CMAKE_CL_64)
534                         SET(PLATFORM_LINKFLAGS "/MACHINE:X64 /NODEFAULTLIB:libc.lib;MSVCRT.lib ")
535                 ELSE(CMAKE_CL_64)
536                         SET(PLATFORM_LINKFLAGS "/NODEFAULTLIB:libc.lib ")
537                 ENDIF(CMAKE_CL_64)
538           
539                 SET(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} /NODEFAULTLIB:libcmt.lib;libc.lib ")
540
541         ELSE(MSVC) # MINGW
542                 SET(LLIBS "-lshell32 -lshfolder -lgdi32 -lmsvcrt -lwinmm -lmingw32 -lm -lws2_32 -lz -lstdc++ -lole32 -luuid")
543                 SET(PLATFORM_CFLAGS "-pipe -funsigned-char -fno-strict-aliasing")
544
545                 # Better warnings
546                 SET(C_WARNINGS "-Wall -Wno-char-subscripts -Wpointer-arith -Wcast-align -Wdeclaration-after-statement -Wno-unknown-pragmas")
547                 SET(CXX_WARNINGS "-Wall -Wno-invalid-offsetof -Wno-sign-compare")
548
549                 ADD_DEFINITIONS(-DFREE_WINDOWS)
550
551                 SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -D_DEBUG")
552                 SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -D_DEBUG")
553
554
555                 SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -DNDEBUG")
556                 SET(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -DNDEBUG")
557
558                 SET(CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS_MINSIZEREL} -DNDEBUG")
559                 SET(CMAKE_C_FLAGS_MINSIZEREL "${CMAKE_C_FLAGS_MINSIZEREL} -DNDEBUG")
560
561                 SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -DNDEBUG")
562                 SET(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO} -DNDEBUG")
563
564
565                 IF(WITH_OPENMP)
566                         SET(LLIBS "${LLIBS} -lgomp")
567                         SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fopenmp")
568                         SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fopenmp")
569                 ENDIF(WITH_OPENMP)
570
571                 IF(WITH_INTERNATIONAL)
572                         SET(GETTEXT ${LIBDIR}/gcc/gettext)
573                         SET(GETTEXT_INC ${GETTEXT}/include)
574                         SET(GETTEXT_LIBPATH ${GETTEXT}/lib)
575                         SET(GETTEXT_LIB intl)
576                 ENDIF(WITH_INTERNATIONAL)
577
578                 SET(JPEG_LIBRARY libjpeg)
579                 SET(PNG_LIBRARIES png)
580
581                 SET(ZLIB ${LIBDIR}/zlib)
582                 SET(ZLIB_INC ${ZLIB}/include)
583                 SET(ZLIB_LIBPATH ${ZLIB}/lib)
584                 SET(ZLIB_LIBRARIES z)
585
586                 SET(PTHREADS ${LIBDIR}/pthreads)
587                 SET(PTHREADS_INC ${PTHREADS}/include)
588                 SET(PTHREADS_LIBPATH ${PTHREADS}/lib)
589                 SET(PTHREADS_LIB pthreadGC2)
590                 
591                 SET(FREETYPE ${LIBDIR}/gcc/freetype)
592                 SET(FREETYPE_INCLUDE_DIRS ${FREETYPE}/include ${FREETYPE}/include/freetype2)
593                 SET(FREETYPE_LIBPATH ${FREETYPE}/lib)
594                 SET(FREETYPE_LIBRARY freetype)
595
596                 IF(WITH_FFTW3)
597                         SET(FFTW3 ${LIBDIR}/gcc/fftw3)
598                         SET(FFTW3_LIB fftw3)
599                         SET(FFTW3_INC ${FFTW3}/include)
600                         SET(FFTW3_LIBPATH ${FFTW3}/lib)
601                 ENDIF(WITH_FFTW3)
602
603                 IF(WITH_OPENCOLLADA)
604                         SET(OPENCOLLADA ${LIBDIR}/gcc/opencollada)
605                         SET(OPENCOLLADA_INC ${OPENCOLLADA}/include)
606                         SET(OPENCOLLADA_LIBPATH ${OPENCOLLADA}/lib ${OPENCOLLADA}/lib)
607                         SET(OPENCOLLADA_LIB OpenCOLLADAStreamWriter OpenCOLLADASaxFrameworkLoader OpenCOLLADAFramework OpenCOLLADABaseUtils GeneratedSaxParser UTF MathMLSolver expat pcre buffer ftoa)
608                         SET(PCRE_LIB pcre)
609                 ENDIF(WITH_OPENCOLLADA)
610                 
611                 IF(WITH_FFMPEG)
612                         SET(FFMPEG ${LIBDIR}/ffmpeg)
613                         SET(FFMPEG_INC ${FFMPEG}/include ${FFMPEG}/include)
614                         SET(FFMPEG_LIB avcodec-52 avformat-52 avdevice-52 avutil-50 swscale-0)
615                         SET(FFMPEG_LIBPATH ${FFMPEG}/lib)
616                 ENDIF(WITH_FFMPEG)
617
618                 IF(WITH_IMAGE_OPENEXR)
619                         SET(OPENEXR ${LIBDIR}/gcc/openexr)
620                         SET(OPENEXR_INC ${OPENEXR}/include ${OPENEXR}/include/OpenEXR)
621                         SET(OPENEXR_LIB Half IlmImf Imath IlmThread)
622                         SET(OPENEXR_LIBPATH ${OPENEXR}/lib)
623
624                         # TODO, gives linking errors, force off
625                         SET(WITH_IMAGE_OPENEXR OFF)
626                 ENDIF(WITH_IMAGE_OPENEXR)
627
628                 IF(WITH_IMAGE_TIFF)
629                         SET(TIFF ${LIBDIR}/gcc/tiff)
630                         SET(TIFF_LIBRARY tiff)
631                         SET(TIFF_INCLUDE_DIR ${TIFF}/include)
632                         SET(TIFF_LIBPATH ${TIFF}/lib)
633                 ENDIF(WITH_IMAGE_TIFF)
634
635                 IF(WITH_JACK)
636                         SET(JACK ${LIBDIR}/jack)
637                         SET(JACK_INC ${JACK}/include/jack ${JACK}/include)
638                         SET(JACK_LIB jack)
639                         SET(JACK_LIBPATH ${JACK}/lib)
640                         
641                         # TODO, gives linking errors, force off
642                         SET(WITH_JACK OFF)
643                 ENDIF(WITH_JACK)
644
645                 IF(WITH_PYTHON)
646                         SET(PYTHON ${LIBDIR}/python)
647                         SET(PYTHON_VERSION 3.1)
648                         SET(PYTHON_INC "${PYTHON}/include/python${PYTHON_VERSION}")
649                         # SET(PYTHON_BINARY python) # not used yet
650                         SET(PYTHON_LIB python31mw)
651                         SET(PYTHON_LIBPATH ${PYTHON}/lib)
652                 ENDIF(WITH_PYTHON)
653
654         ENDIF(MSVC)
655
656 ENDIF(WIN32)
657
658
659 IF(APPLE)
660         IF(WITH_LIBS10.5)
661                 SET(LIBDIR ${CMAKE_SOURCE_DIR}/../lib/darwin-9.x.universal)
662         ELSE(WITH_LIBS10.5)
663                 IF(CMAKE_OSX_ARCHITECTURES MATCHES i386)
664                         SET(LIBDIR ${CMAKE_SOURCE_DIR}/../lib/darwin-8.x.i386)
665                 ELSE(CMAKE_OSX_ARCHITECTURES MATCHES i386)
666                         SET(LIBDIR ${CMAKE_SOURCE_DIR}/../lib/darwin-8.0.0-powerpc)
667                 ENDIF(CMAKE_OSX_ARCHITECTURES MATCHES i386)
668         ENDIF(WITH_LIBS10.5)
669         
670
671         IF(WITH_OPENAL)
672                 FIND_PACKAGE(OpenAL)
673                 IF(OPENAL_FOUND)
674                         SET(WITH_OPENAL ON)
675                         SET(OPENAL_INCLUDE_DIR "${LIBDIR}/openal/include")
676                 ELSE(OPENAL_FOUND)
677                         SET(WITH_OPENAL OFF)
678                 ENDIF(OPENAL_FOUND)
679         ENDIF(WITH_OPENAL)
680
681         IF(WITH_JACK)
682                 SET(JACK /usr)
683                 SET(JACK_INC ${JACK}/include/jack)
684                 SET(JACK_LIB jack)
685                 SET(JACK_LIBPATH ${JACK}/lib)
686         ENDIF(WITH_JACK)
687
688         IF(WITH_SNDFILE)
689                 SET(SNDFILE ${LIBDIR}/sndfile)
690                 SET(SNDFILE_INC ${SNDFILE}/include)
691                 SET(SNDFILE_LIB sndfile FLAC ogg vorbis vorbisenc)
692                 SET(SNDFILE_LIBPATH ${SNDFILE}/lib ${FFMPEG}/lib)
693         ENDIF(WITH_SNDFILE)
694
695         SET(PYTHON_VERSION 3.1)
696
697         IF(PYTHON_VERSION MATCHES 3.1)
698                 # we use precompiled libraries for py 3.1 and up by default
699
700                 SET(PYTHON ${LIBDIR}/python)
701                 SET(PYTHON_INC "${PYTHON}/include/python${PYTHON_VERSION}")
702                 # SET(PYTHON_BINARY "${PYTHON}/bin/python${PYTHON_VERSION}") # not used yet
703                 SET(PYTHON_LIB python${PYTHON_VERSION})
704                 SET(PYTHON_LIBPATH "${PYTHON}/lib/python${PYTHON_VERSION}")
705                 # SET(PYTHON_LINKFLAGS "-u _PyMac_Error")  # won't  build with this enabled
706         ELSE(PYTHON_VERSION MATCHES 3.1)
707                 # otherwise, use custom system framework
708
709                 SET(PYTHON /System/Library/Frameworks/Python.framework/Versions/)
710                 SET(PYTHON_VERSION 3.1)
711                 SET(PYTHON_INC "${PYTHON}${PYTHON_VERSION}/include/python${PYTHON_VERSION}")
712                 # SET(PYTHON_BINARY ${PYTHON}${PYTHON_VERSION}/bin/python${PYTHON_VERSION}) # not used yet
713                 SET(PYTHON_LIB "")
714                 SET(PYTHON_LIBPATH ${PYTHON}${PYTHON_VERSION}/lib/python${PYTHON_VERSION}/config)
715                 SET(PYTHON_LINKFLAGS "-u _PyMac_Error -framework System -framework Python")
716         ENDIF(PYTHON_VERSION MATCHES 3.1)
717
718         IF(WITH_INTERNATIONAL)
719                 SET(GETTEXT ${LIBDIR}/gettext)
720                 SET(GETTEXT_INC "${GETTEXT}/include")
721                 SET(GETTEXT_LIB intl iconv)
722                 SET(GETTEXT_LIBPATH ${GETTEXT}/lib)
723         ENDIF(WITH_INTERNATIONAL)
724   
725         IF(WITH_FFTW3)
726                 SET(FFTW3 ${LIBDIR}/fftw3)
727                 SET(FFTW3_INC ${FFTW3}/include)
728                 SET(FFTW3_LIB fftw3)
729                 SET(FFTW3_LIBPATH ${FFTW3}/lib)
730         ENDIF(WITH_FFTW3)
731
732         SET(PNG_LIBRARIES png)
733         SET(JPEG_LIBRARY jpeg)
734
735         SET(ZLIB /usr)
736         SET(ZLIB_INC "${ZLIB}/include")
737         SET(ZLIB_LIBRARIES z bz2)
738
739         SET(FREETYPE ${LIBDIR}/freetype)
740         SET(FREETYPE_INCLUDE_DIRS ${FREETYPE}/include ${FREETYPE}/include/freetype2)
741         SET(FREETYPE_LIBPATH ${FREETYPE}/lib)
742         SET(FREETYPE_LIBRARY freetype)
743
744         IF(WITH_IMAGE_OPENEXR)
745                 SET(OPENEXR ${LIBDIR}/openexr)
746                 SET(OPENEXR_INC ${OPENEXR}/include/OpenEXR ${OPENEXR}/include)
747                 SET(OPENEXR_LIB Iex Half IlmImf Imath IlmThread)
748                 SET(OPENEXR_LIBPATH ${OPENEXR}/lib)
749         ENDIF(WITH_IMAGE_OPENEXR)
750
751         IF(WITH_LCMS)
752                 SET(LCMS ${LIBDIR}/lcms)
753                 SET(LCMS_INCLUDE_DIR ${LCMS}/include)
754                 SET(LCMS_LIBRARY lcms)
755                 SET(LCMS_LIBPATH ${LCMS}/lib)
756         ENDIF(WITH_LCMS)
757
758         IF(WITH_FFMPEG)
759                 SET(FFMPEG ${LIBDIR}/ffmpeg)
760                 SET(FFMPEG_INC ${FFMPEG}/include)
761                 SET(FFMPEG_LIB avcodec avdevice avformat avutil mp3lame swscale x264 xvidcore theora theoradec theoraenc vorbis vorbisenc vorbisfile ogg)
762                 SET(FFMPEG_LIBPATH ${FFMPEG}/lib)
763                 SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D__STDC_CONSTANT_MACROS")
764         ENDIF(WITH_FFMPEG)
765
766         SET(LIBSAMPLERATE ${LIBDIR}/samplerate)
767         SET(LIBSAMPLERATE_INC ${LIBSAMPLERATE}/include)
768         SET(LIBSAMPLERATE_LIB samplerate)
769         SET(LIBSAMPLERATE_LIBPATH ${LIBSAMPLERATE}/lib)
770
771         SET(LLIBS stdc++ SystemStubs)
772
773         IF (WITH_COCOA)
774                 SET(PLATFORM_CFLAGS "-pipe -funsigned-char -DGHOST_COCOA")
775                 SET(PLATFORM_LINKFLAGS "-fexceptions -framework CoreServices -framework Foundation -framework IOKit -framework AppKit -framework Cocoa -framework Carbon -framework AudioUnit -framework AudioToolbox -framework CoreAudio")
776                 IF(USE_QTKIT)
777                         SET(PLATFORM_CFLAGS "${PLATFORM_CFLAGS} -DUSE_QTKIT")
778                         SET(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} -framework QTKit")
779                         IF(CMAKE_OSX_ARCHITECTURES MATCHES i386)
780                                 SET(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} -framework QuickTime")
781                                 #libSDL still needs 32bit carbon quicktime 
782                         ENDIF(CMAKE_OSX_ARCHITECTURES MATCHES i386)
783                 ELSEIF(WITH_QUICKTIME)
784                         SET(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} -framework QuickTime")
785                 ENDIF(USE_QTKIT)
786         ELSE (WITH_COCOA)
787                 SET(PLATFORM_CFLAGS "-pipe -funsigned-char")
788                 SET(PLATFORM_LINKFLAGS "-fexceptions -framework CoreServices -framework Foundation -framework IOKit -framework AppKit -framework Carbon -framework AGL -framework AudioUnit -framework AudioToolbox -framework CoreAudio -framework QuickTime")
789         ENDIF (WITH_COCOA)
790
791         IF(WITH_OPENMP)
792                 SET(LLIBS "${LLIBS} -lgomp")
793                 SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fopenmp")
794                 SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fopenmp")
795         ENDIF(WITH_OPENMP)
796
797         IF (WITH_OPENCOLLADA)
798                 SET(OPENCOLLADA ${LIBDIR}/opencollada)
799                 SET(OPENCOLLADA_INC ${OPENCOLLADA}/include)
800                 SET(OPENCOLLADA_LIBPATH ${OPENCOLLADA}/lib)
801                 SET(OPENCOLLADA_LIB "OpenCOLLADASaxFrameworkLoader -lOpenCOLLADAFramework -lOpenCOLLADABaseUtils -lOpenCOLLADAStreamWriter -lMathMLSolver -lGeneratedSaxParser -lUTF -lxml2 -lbuffer -lftoa" )
802                 #pcre is bundled with openCollada
803                 #SET(PCRE ${LIBDIR}/pcre)
804                 #SET(PCRE_LIBPATH ${PCRE}/lib)
805                 SET(PCRE_LIB pcre)
806                 #libxml2 is used
807                 #SET(EXPAT ${LIBDIR}/expat)
808                 #SET(EXPAT_LIBPATH ${EXPAT}/lib)
809                 SET(EXPAT_LIB)
810         ENDIF (WITH_OPENCOLLADA)
811
812         IF(WITH_SDL)
813                 SET(SDL ${LIBDIR}/sdl)
814                 SET(SDL_INCLUDE_DIR ${SDL}/include)
815                 SET(SDL_LIBRARY SDL)
816                 SET(SDL_LIBPATH ${SDL}/lib)
817         ENDIF(WITH_SDL)
818
819         SET(PNG "${LIBDIR}/png")
820         SET(PNG_INC "${PNG}/include")
821         SET(PNG_LIBPATH ${PNG}/lib)
822
823         SET(JPEG "${LIBDIR}/jpeg")
824         SET(JPEG_INC "${JPEG}/include")
825         SET(JPEG_LIBPATH ${JPEG}/lib)
826
827         IF(WITH_IMAGE_TIFF)
828                 SET(TIFF ${LIBDIR}/tiff)
829                 SET(TIFF_INCLUDE_DIR ${TIFF}/include)
830                 SET(TIFF_LIBRARY tiff)
831                 SET(TIFF_LIBPATH ${TIFF}/lib)
832         ENDIF(WITH_IMAGE_TIFF)
833
834         SET(EXETYPE MACOSX_BUNDLE)
835
836         SET(CMAKE_C_FLAGS_DEBUG "-fno-strict-aliasing -g")
837         SET(CMAKE_CXX_FLAGS_DEBUG "-fno-strict-aliasing -g")
838         IF(CMAKE_OSX_ARCHITECTURES MATCHES "i386")
839                 SET(CMAKE_CXX_FLAGS_RELEASE "-O3 -mdynamic-no-pic -ftree-vectorize -msse -msse2 -fvariable-expansion-in-unroller")
840                 SET(CMAKE_C_FLAGS_RELEASE "-O3 -mdynamic-no-pic -ftree-vectorize -msse -msse2 -fvariable-expansion-in-unroller")
841         ELSEIF(CMAKE_OSX_ARCHITECTURES MATCHES "x86_64")
842                 SET(CMAKE_CXX_FLAGS_RELEASE "-O3 -mdynamic-no-pic -ftree-vectorize -msse -msse2 -msse3 -mssse3 -fvariable-expansion-in-unroller")
843                 SET(CMAKE_C_FLAGS_RELEASE "-O3 -mdynamic-no-pic -ftree-vectorize -msse -msse2 -msse3 -mssse3 -fvariable-expansion-in-unroller")
844         ELSE(CMAKE_OSX_ARCHITECTURES MATCHES "x86_64")
845                 SET(CMAKE_C_FLAGS_RELEASE "-mdynamic-no-pic -fno-strict-aliasing")
846                 SET(CMAKE_CXX_FLAGS_RELEASE "-mdynamic-no-pic -fno-strict-aliasing")
847         ENDIF(CMAKE_OSX_ARCHITECTURES MATCHES "i386")
848
849         # Better warnings
850         SET(C_WARNINGS "-Wall -Wno-char-subscripts -Wpointer-arith -Wcast-align -Wdeclaration-after-statement -Wno-unknown-pragmas")
851         SET(CXX_WARNINGS "-Wall -Wno-invalid-offsetof -Wno-sign-compare")
852
853 ENDIF(APPLE)
854
855
856 # buildinfo
857 IF(WITH_BUILDINFO)
858         # BUILD_PLATFORM and BUILD_PLATFORM are taken from CMake
859         IF(UNIX)
860                 EXEC_PROGRAM("date \"+%Y-%m-%d\"" OUTPUT_VARIABLE BUILD_DATE)
861                 EXEC_PROGRAM("date \"+%H:%M:%S\"" OUTPUT_VARIABLE BUILD_TIME)  
862                 EXEC_PROGRAM("svnversion ${CMAKE_SOURCE_DIR}" OUTPUT_VARIABLE BUILD_REV RETURN_VALUE BUILD_REV_RETURN)
863                 IF(BUILD_REV_RETURN)
864                         SET(BUILD_REV "unknown")
865                 ENDIF(BUILD_REV_RETURN)
866         ENDIF(UNIX)
867         
868         IF(WIN32)
869                 EXEC_PROGRAM("cmd /c date /t" OUTPUT_VARIABLE BUILD_DATE)
870                 EXEC_PROGRAM("cmd /c time /t" OUTPUT_VARIABLE BUILD_TIME)  
871                 EXEC_PROGRAM("svnversion ${CMAKE_SOURCE_DIR}" OUTPUT_VARIABLE BUILD_REV RETURN_VALUE BUILD_REV_RETURN)
872                 IF(BUILD_REV_RETURN)
873                         SET(BUILD_REV "unknown")
874                 ENDIF(BUILD_REV_RETURN)
875         ENDIF(WIN32)
876 ENDIF(WITH_BUILDINFO)
877 #-----------------------------------------------------------------------------
878 # Common.
879
880 IF(WITH_RAYOPTIMIZATION)
881         IF(CMAKE_COMPILER_IS_GNUCC)
882                 IF(SUPPORT_SSE_BUILD)
883                         SET(PLATFORM_CFLAGS " -msse ${PLATFORM_CFLAGS}")
884                         ADD_DEFINITIONS(-D__SSE__ -D__MMX__)
885                 ENDIF(SUPPORT_SSE_BUILD)
886                 IF(SUPPORT_SSE2_BUILD)
887                         SET(PLATFORM_CFLAGS " -msse2 ${PLATFORM_CFLAGS}")
888                         ADD_DEFINITIONS(-D__SSE2__)
889                         IF(NOT SUPPORT_SSE_BUILD) # dont double up
890                                 ADD_DEFINITIONS(-D__MMX__)
891                         ENDIF(NOT SUPPORT_SSE_BUILD)
892                 ENDIF(SUPPORT_SSE2_BUILD)
893         ENDIF(CMAKE_COMPILER_IS_GNUCC)
894 ENDIF(WITH_RAYOPTIMIZATION)
895
896 IF(WITH_IMAGE_OPENJPEG)
897         set(OPENJPEG ${CMAKE_SOURCE_DIR}/extern/libopenjpeg)
898         set(OPENJPEG_INC ${OPENJPEG})
899         set(OPENJPEG_LIb extern_openjpeg)
900 ENDIF(WITH_IMAGE_OPENJPEG)
901
902 #-----------------------------------------------------------------------------
903 # Blender WebPlugin
904
905 IF(WITH_WEBPLUGIN) 
906         SET(GECKO_DIR "${CMAKE_SOURCE_DIR}/../gecko-sdk/" CACHE PATH "Gecko SDK path")
907         SET(WEBPLUGIN_SANDBOX_MODE "apparmor" CACHE STRING "WEB Plugin sandbox mode, can be apparmor, privsep, none")
908
909         SET(WITH_PLAYER ON)
910 ENDIF(WITH_WEBPLUGIN)
911
912
913 #-----------------------------------------------------------------------------
914 # Configure OpenGL.
915 FIND_PACKAGE(OpenGL)
916 INCLUDE_DIRECTORIES(${OPENGL_INCLUDE_DIR})
917 # UNSET(OPENGL_LIBRARIES CACHE) # not compat with older cmake 
918 # UNSET(OPENGL_xmesa_INCLUDE_DIR CACHE) # not compat with older cmake 
919
920 #-----------------------------------------------------------------------------
921 # Extra compile flags
922 SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${PLATFORM_CFLAGS} ${C_WARNINGS}")
923 SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${PLATFORM_CFLAGS} ${CXX_WARNINGS}")
924
925 # better not define flags here but this is a debugging option thats off by default.
926 IF(WITH_CXX_GUARDEDALLOC)
927         SET(CMAKE_CXX_FLAGS " -DWITH_CXX_GUARDEDALLOC -I${CMAKE_SOURCE_DIR}/intern/guardedalloc ${CMAKE_CXX_FLAGS}")
928 ENDIF(WITH_CXX_GUARDEDALLOC)
929
930 #-----------------------------------------------------------------------------
931 # Libraries
932 FILE(WRITE ${CMAKE_BINARY_DIR}/cmake_blender_libs.txt "")
933 ADD_SUBDIRECTORY(intern)
934 ADD_SUBDIRECTORY(extern)
935 ADD_SUBDIRECTORY(source)
936
937
938 #-----------------------------------------------------------------------------
939 # Blender Application
940 ADD_SUBDIRECTORY(source/creator)
941
942
943 #-----------------------------------------------------------------------------
944 # Blender Player
945 IF(WITH_PLAYER)
946         ADD_SUBDIRECTORY(source/blenderplayer)
947 ENDIF(WITH_PLAYER)