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