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