Fix [#23569] Convex hull bounds crash Blender
[blender-staging.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         FIND_PACKAGE(X11 REQUIRED)
298
299         SET(LLIBS "-lutil -lc -lm -lpthread -lstdc++ ${X11_X11_LIB} ${X11_Xinput_LIB}")
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         SET(PLATFORM_LINKFLAGS "-pthread")
320
321         # Better warnings
322         SET(C_WARNINGS "-Wall -Wno-char-subscripts -Wpointer-arith -Wcast-align -Wdeclaration-after-statement -Wno-unknown-pragmas")
323         SET(CXX_WARNINGS "-Wall -Wno-invalid-offsetof -Wno-sign-compare")
324
325         INCLUDE_DIRECTORIES(${JPEG_INCLUDE_DIR} ${PNG_INCLUDE_DIR} ${ZLIB_INCLUDE_DIR} )
326 ENDIF(UNIX AND NOT APPLE)
327
328
329 IF(WIN32)
330
331         # this file is included anyway when building under Windows with cl.exe
332         #  INCLUDE(${CMAKE_ROOT}/Modules/Platform/Windows-cl.cmake)
333   
334         SET(LIBDIR ${CMAKE_SOURCE_DIR}/../lib/windows)
335
336         # Setup 64bit and 64bit windows systems
337         IF(CMAKE_CL_64)
338                 message("64 bit compiler detected.")
339                 SET(LIBDIR ${CMAKE_SOURCE_DIR}/../lib/win64)
340         ENDIF(CMAKE_CL_64)
341         
342         ADD_DEFINITIONS(-DWIN32)
343
344         IF(WITH_INTERNATIONAL)
345                 SET(ICONV ${LIBDIR}/iconv)
346                 SET(ICONV_INC ${ICONV}/include)
347                 SET(ICONV_LIB iconv)
348                 SET(ICONV_LIBPATH ${ICONV}/lib)
349         ENDIF(WITH_INTERNATIONAL)
350
351         SET(LIBSAMPLERATE ${LIBDIR}/samplerate)
352         SET(LIBSAMPLERATE_INC ${LIBSAMPLERATE}/include)
353         SET(LIBSAMPLERATE_LIB libsamplerate)
354         SET(LIBSAMPLERATE_LIBPATH ${LIBSAMPLERATE}/lib)
355
356         SET(PNG "${LIBDIR}/png")
357         SET(PNG_INC "${PNG}/include")
358         SET(PNG_LIBPATH ${PNG}/lib)
359
360         SET(JPEG "${LIBDIR}/jpeg")
361         SET(JPEG_INC "${JPEG}/include")
362         SET(JPEG_LIBPATH ${JPEG}/lib)
363
364         SET(WINTAB_INC ${LIBDIR}/wintab/include) 
365
366         IF(WITH_PYTHON)
367                 SET(PYTHON ${LIBDIR}/python)
368                 SET(PYTHON_VERSION 3.1)
369                 SET(PYTHON_INC "${PYTHON}/include/python${PYTHON_VERSION}")
370                 # SET(PYTHON_BINARY python) # not used yet
371                 SET(PYTHON_LIB python31)
372                 SET(PYTHON_LIBPATH ${PYTHON}/lib)
373         ENDIF(WITH_PYTHON)
374
375         IF(WITH_OPENAL)
376                 SET(OPENAL ${LIBDIR}/openal)
377                 SET(OPENAL_INCLUDE_DIR ${OPENAL}/include)
378                 SET(OPENAL_LIBRARY wrap_oal)
379                 SET(OPENAL_LIBPATH ${OPENAL}/lib)
380         ENDIF(WITH_OPENAL)
381
382         IF(WITH_SNDFILE)
383                 SET(SNDFILE ${LIBDIR}/sndfile)
384                 SET(SNDFILE_INC ${SNDFILE}/include)
385                 SET(SNDFILE_LIB libsndfile-1)
386                 SET(SNDFILE_LIBPATH ${SNDFILE}/lib)
387         ENDIF(WITH_SNDFILE)
388
389         IF(WITH_SDL)
390                 SET(SDL ${LIBDIR}/sdl)
391                 SET(SDL_INCLUDE_DIR ${SDL}/include)
392                 SET(SDL_LIBRARY SDL)
393                 SET(SDL_LIBPATH ${SDL}/lib)
394         ENDIF(WITH_SDL)
395
396         IF(WITH_QUICKTIME)
397                 SET(QUICKTIME ${LIBDIR}/QTDevWin)
398                 SET(QUICKTIME_INC ${QUICKTIME}/CIncludes)
399                 SET(QUICKTIME_LIB qtmlClient)
400                 SET(QUICKTIME_LIBPATH ${QUICKTIME}/Libraries)
401         ENDIF(WITH_QUICKTIME)
402
403         IF(WITH_RAYOPTIMIZATION AND SUPPORT_SSE_BUILD)
404                 ADD_DEFINITIONS(-D__SSE__)
405                 ADD_DEFINITIONS(-D__MMX__)
406         ENDIF(WITH_RAYOPTIMIZATION AND SUPPORT_SSE_BUILD)
407
408         IF(MSVC)
409                 IF(CMAKE_CL_64)
410                         SET(LLIBS kernel32 user32 vfw32 winmm ws2_32 )
411                 ELSE(CMAKE_CL_64)
412                         SET(LLIBS kernel32 user32 gdi32 comdlg32 advapi32 shell32 ole32 oleaut32 uuid ws2_32 vfw32 winmm)
413                 ENDIF(CMAKE_CL_64)
414                 
415                 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)
416                 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)
417
418                 IF(CMAKE_CL_64)
419                         SET(CMAKE_CXX_FLAGS_DEBUG "/D_DEBUG /Od /Gm /EHsc /RTC1 /MTd /W3 /nologo /Zi /J" CACHE STRING "MSVC MT flags " FORCE)
420                 ELSE(CMAKE_CL_64)
421                         SET(CMAKE_CXX_FLAGS_DEBUG "/D_DEBUG /Od /Gm /EHsc /RTC1 /MTd /W3 /nologo /ZI /J" CACHE STRING "MSVC MT flags " FORCE)
422                 ENDIF(CMAKE_CL_64)
423                 SET(CMAKE_CXX_FLAGS_RELEASE "/O2 /Ob2 /DNDEBUG /EHsc /MT /W3 /nologo /J" CACHE STRING "MSVC MT flags " FORCE)
424                 SET(CMAKE_CXX_FLAGS_MINSIZEREL "/O1 /Ob1 /DNDEBUG /EHsc /MT /W3 /nologo /J" CACHE STRING "MSVC MT flags " FORCE)
425                 SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "/O2 /Ob1 /DNDEBUG /EHsc /MT /W3 /nologo /Zi /J" CACHE STRING "MSVC MT flags " FORCE)
426                 IF(CMAKE_CL_64)
427                         SET(CMAKE_C_FLAGS_DEBUG "/D_DEBUG /Od /Gm /EHsc /RTC1 /MTd /W3 /nologo /Zi /J" CACHE STRING "MSVC MT flags " FORCE)
428                 ELSE(CMAKE_CL_64)
429                         SET(CMAKE_C_FLAGS_DEBUG "/D_DEBUG /Od /Gm /EHsc /RTC1 /MTd /W3 /nologo /ZI /J" CACHE STRING "MSVC MT flags " FORCE)
430                 ENDIF(CMAKE_CL_64)
431                 SET(CMAKE_C_FLAGS_RELEASE "/O2 /Ob2 /DNDEBUG /EHsc /MT /W3 /nologo /J" CACHE STRING "MSVC MT flags " FORCE)
432                 SET(CMAKE_C_FLAGS_MINSIZEREL "/O1 /Ob1 /DNDEBUG /EHsc /MT /W3 /nologo /J" CACHE STRING "MSVC MT flags " FORCE)
433                 SET(CMAKE_C_FLAGS_RELWITHDEBINFO "/O2 /Ob1 /DNDEBUG /EHsc /MT /W3 /nologo /Zi /J" CACHE STRING "MSVC MT flags " FORCE)
434                 
435                 IF(WITH_OPENMP)
436                         SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /openmp ")
437                         SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /openmp ")
438                 ENDIF(WITH_OPENMP)
439                 
440                 IF(WITH_INTERNATIONAL)
441                         SET(GETTEXT ${LIBDIR}/gettext)
442                         SET(GETTEXT_INC ${GETTEXT}/include)
443                         SET(GETTEXT_LIBPATH ${GETTEXT}/lib)
444                         IF(CMAKE_CL_64)
445                                 SET(GETTEXT_LIB gettext)
446                         ELSE(CMAKE_CL_64)
447                                 SET(GETTEXT_LIB gnu_gettext)
448                         ENDIF(CMAKE_CL_64)
449                 ENDIF(WITH_INTERNATIONAL)
450
451                 IF(CMAKE_CL_64)
452                         SET(PNG_LIBRARIES libpng)
453                 ELSE(CMAKE_CL_64)
454                         SET(PNG_LIBRARIES libpng_st)
455                 ENDIF(CMAKE_CL_64)
456                 SET(JPEG_LIBRARY libjpeg)
457
458                 SET(ZLIB ${LIBDIR}/zlib)
459                 SET(ZLIB_INC ${ZLIB}/include)
460                 SET(ZLIB_LIBPATH ${ZLIB}/lib)
461                 IF(CMAKE_CL_64)
462                         SET(ZLIB_LIBRARIES libz)
463                 ELSE(CMAKE_CL_64)
464                         SET(ZLIB_LIBRARIES zlib)
465                 ENDIF(CMAKE_CL_64)
466
467                 SET(PTHREADS ${LIBDIR}/pthreads)
468                 SET(PTHREADS_INC ${PTHREADS}/include)
469                 SET(PTHREADS_LIBPATH ${PTHREADS}/lib)
470                 SET(PTHREADS_LIB pthreadVC2)
471                 
472                 SET(FREETYPE ${LIBDIR}/freetype)
473                 SET(FREETYPE_INCLUDE_DIRS ${FREETYPE}/include ${FREETYPE}/include/freetype2)
474                 SET(FREETYPE_LIBPATH ${FREETYPE}/lib)
475                 SET(FREETYPE_LIBRARY freetype2ST)
476
477                 IF(WITH_FFTW3)
478                         SET(FFTW3 ${LIBDIR}/fftw3)
479                         SET(FFTW3_LIB libfftw)
480                         SET(FFTW3_INC ${FFTW3}/include)
481                         SET(FFTW3_LIBPATH ${FFTW3}/lib)
482                 ENDIF(WITH_FFTW3)
483
484                 IF(WITH_OPENCOLLADA)
485                         SET(OPENCOLLADA ${LIBDIR}/opencollada)
486                         SET(OPENCOLLADA_INC ${OPENCOLLADA}/include)
487                         SET(OPENCOLLADA_LIBPATH ${OPENCOLLADA}/lib)
488                         SET(OPENCOLLADA_LIB OpenCOLLADASaxFrameworkLoader OpenCOLLADAFramework OpenCOLLADABaseUtils OpenCOLLADAStreamWriter MathMLSolver GeneratedSaxParser xml2 buffer ftoa)
489                         #pcre is bundled with openCollada
490                         #SET(PCRE ${LIBDIR}/pcre)
491                         #SET(PCRE_LIBPATH ${PCRE}/lib)
492                         SET(PCRE_LIB pcre)
493                 ENDIF(WITH_OPENCOLLADA)
494                 
495                 # TODO: IF(WITH_LCMS)
496         
497                 IF(WITH_FFMPEG)
498                         SET(FFMPEG ${LIBDIR}/ffmpeg)
499                         SET(FFMPEG_INC ${FFMPEG}/include ${FFMPEG}/include/msvc)
500                         SET(FFMPEG_LIB avcodec-52 avformat-52 avdevice-52 avutil-50 swscale-0)
501                         SET(FFMPEG_LIBPATH ${FFMPEG}/lib)
502                 ENDIF(WITH_FFMPEG)
503
504                 IF(WITH_IMAGE_OPENEXR)
505                         SET(OPENEXR ${LIBDIR}/openexr)
506                         SET(OPENEXR_INC ${OPENEXR}/include ${OPENEXR}/include/IlmImf ${OPENEXR}/include/Iex ${OPENEXR}/include/Imath)
507                         SET(OPENEXR_LIB Iex Half IlmImf Imath IlmThread)
508                         IF (MSVC80)
509                                 SET(OPENEXR_LIBPATH ${OPENEXR}/lib_vs2005)
510                         ELSE (MSVC80)
511                                 SET(OPENEXR_LIBPATH ${OPENEXR}/lib_msvc)
512                         ENDIF(MSVC80)
513                         IF (MSVC90)
514                                 SET(OPENEXR_LIBPATH ${OPENEXR}/lib_vs2008)
515                         ENDIF(MSVC90)
516                 ENDIF(WITH_IMAGE_OPENEXR)
517
518                 IF(WITH_IMAGE_TIFF)
519                         SET(TIFF ${LIBDIR}/tiff)
520                         SET(TIFF_LIBRARY libtiff)
521                         SET(TIFF_INCLUDE_DIR ${TIFF}/include)
522                         SET(TIFF_LIBPATH ${TIFF}/lib)
523                 ENDIF(WITH_IMAGE_TIFF)
524
525                 IF(WITH_JACK)
526                         SET(JACK ${LIBDIR}/jack)
527                         SET(JACK_INC ${JACK}/include/jack ${JACK}/include)
528                         SET(JACK_LIB libjack)
529                         SET(JACK_LIBPATH ${JACK}/lib)
530                 ENDIF(WITH_JACK)
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
544                 SET(CMAKE_CXX_FLAGS                "-pipe -funsigned-char -fno-strict-aliasing" CACHE STRING "Mingw C++ flags ")
545                 SET(CMAKE_C_FLAGS                  "-pipe -funsigned-char -fno-strict-aliasing" CACHE STRING "Mingw C flags ")
546
547                 SET(CMAKE_CXX_FLAGS_DEBUG          "-O0 -g" CACHE STRING "Mingw debug C++ flags ")
548                 SET(CMAKE_CXX_FLAGS_RELEASE        "   -O2" CACHE STRING "Mingw release C++ flags ")
549                 SET(CMAKE_CXX_FLAGS_MINSIZEREL     "   -Os" CACHE STRING "Mingw minsize release C++ flags ")
550                 SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O2 -g" CACHE STRING "Mingw release, debug C++ flags ")
551
552                 SET(CMAKE_C_FLAGS_DEBUG            "-O0 -g" CACHE STRING "Mingw debug C flags ")
553                 SET(CMAKE_C_FLAGS_RELEASE          "-O2"    CACHE STRING "Mingw release C flags ")
554                 SET(CMAKE_C_FLAGS_MINSIZEREL       "-Os"    CACHE STRING "Mingw minsize release C flags ")
555                 SET(CMAKE_C_FLAGS_RELWITHDEBINFO   "-O2 -g" CACHE STRING "Mingw release, debug C++ flags ")
556                 ADD_DEFINITIONS(-DFREE_WINDOWS)
557                 
558                 IF(WITH_OPENMP)
559                         SET(LLIBS "${LLIBS} -lgomp")
560                         SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fopenmp")
561                         SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fopenmp")
562                 ENDIF(WITH_OPENMP)
563
564                 IF(WITH_INTERNATIONAL)
565                         SET(GETTEXT ${LIBDIR}/gcc/gettext)
566                         SET(GETTEXT_INC ${GETTEXT}/include)
567                         SET(GETTEXT_LIBPATH ${GETTEXT}/lib)
568                         SET(GETTEXT_LIB intl)
569                 ENDIF(WITH_INTERNATIONAL)
570
571                 SET(JPEG_LIBRARY libjpeg)
572                 SET(PNG_LIBRARIES png)
573
574                 SET(ZLIB ${LIBDIR}/zlib)
575                 SET(ZLIB_INC ${ZLIB}/include)
576                 SET(ZLIB_LIBPATH ${ZLIB}/lib)
577                 SET(ZLIB_LIBRARIES z)
578
579                 SET(PTHREADS ${LIBDIR}/pthreads)
580                 SET(PTHREADS_INC ${PTHREADS}/include)
581                 SET(PTHREADS_LIBPATH ${PTHREADS}/lib)
582                 SET(PTHREADS_LIB pthreadGC2)
583                 
584                 SET(FREETYPE ${LIBDIR}/gcc/freetype)
585                 SET(FREETYPE_INCLUDE_DIRS ${FREETYPE}/include ${FREETYPE}/include/freetype2)
586                 SET(FREETYPE_LIBPATH ${FREETYPE}/lib)
587                 SET(FREETYPE_LIBRARY freetype)
588
589                 IF(WITH_FFTW3)
590                         SET(FFTW3 ${LIBDIR}/gcc/fftw3)
591                         SET(FFTW3_LIB fftw3)
592                         SET(FFTW3_INC ${FFTW3}/include)
593                         SET(FFTW3_LIBPATH ${FFTW3}/lib)
594                 ENDIF(WITH_FFTW3)
595
596                 IF(WITH_OPENCOLLADA)
597                         SET(OPENCOLLADA ${LIBDIR}/gcc/opencollada)
598                         SET(OPENCOLLADA_INC ${OPENCOLLADA}/include)
599                         SET(OPENCOLLADA_LIBPATH ${OPENCOLLADA}/lib ${OPENCOLLADA}/lib)
600                         SET(OPENCOLLADA_LIB OpenCOLLADAStreamWriter OpenCOLLADASaxFrameworkLoader OpenCOLLADAFramework OpenCOLLADABaseUtils GeneratedSaxParser UTF MathMLSolver expat pcre buffer ftoa)
601                         #pcre is bundled with openCollada
602                         #SET(PCRE ${LIBDIR}/pcre)
603                         #SET(PCRE_LIBPATH ${PCRE}/lib)
604                         SET(PCRE_LIB pcre)
605                 ENDIF(WITH_OPENCOLLADA)
606                 
607                 IF(WITH_FFMPEG)
608                         SET(FFMPEG ${LIBDIR}/ffmpeg)
609                         SET(FFMPEG_INC ${FFMPEG}/include ${FFMPEG}/include)
610                         SET(FFMPEG_LIB avcodec-52 avformat-52 avdevice-52 avutil-50 swscale-0)
611                         SET(FFMPEG_LIBPATH ${FFMPEG}/lib)
612                 ENDIF(WITH_FFMPEG)
613
614                 IF(WITH_IMAGE_OPENEXR)
615                         SET(OPENEXR ${LIBDIR}/gcc/openexr)
616                         SET(OPENEXR_INC ${OPENEXR}/include ${OPENEXR}/include/OpenEXR)
617                         SET(OPENEXR_LIB Half IlmImf Imath IlmThread)
618                         SET(OPENEXR_LIBPATH ${OPENEXR}/lib)
619                 ENDIF(WITH_IMAGE_OPENEXR)
620
621                 IF(WITH_IMAGE_TIFF)
622                         SET(TIFF ${LIBDIR}/gcc/tiff)
623                         SET(TIFF_LIBRARY tiff)
624                         SET(TIFF_INCLUDE_DIR ${TIFF}/include)
625                         SET(TIFF_LIBPATH ${TIFF}/lib)
626                 ENDIF(WITH_IMAGE_TIFF)
627
628                 IF(WITH_JACK)
629                         SET(JACK ${LIBDIR}/jack)
630                         SET(JACK_INC ${JACK}/include/jack ${JACK}/include)
631                         SET(JACK_LIB jack)
632                         SET(JACK_LIBPATH ${JACK}/lib)
633                         
634                         # TODO, gives linking errors, force off
635                         SET(WITH_JACK OFF)
636                 ENDIF(WITH_JACK)
637
638         ENDIF(MSVC)
639
640 ENDIF(WIN32)
641
642
643 IF(APPLE)
644         IF(WITH_LIBS10.5)
645                 SET(LIBDIR ${CMAKE_SOURCE_DIR}/../lib/darwin-9.x.universal)
646         ELSE(WITH_LIBS10.5)
647                 IF(CMAKE_OSX_ARCHITECTURES MATCHES i386)
648                         SET(LIBDIR ${CMAKE_SOURCE_DIR}/../lib/darwin-8.x.i386)
649                 ELSE(CMAKE_OSX_ARCHITECTURES MATCHES i386)
650                         SET(LIBDIR ${CMAKE_SOURCE_DIR}/../lib/darwin-8.0.0-powerpc)
651                 ENDIF(CMAKE_OSX_ARCHITECTURES MATCHES i386)
652         ENDIF(WITH_LIBS10.5)
653         
654
655         IF(WITH_OPENAL)
656                 FIND_PACKAGE(OpenAL)
657                 IF(OPENAL_FOUND)
658                         SET(WITH_OPENAL ON)
659                         SET(OPENAL_INCLUDE_DIR "${LIBDIR}/openal/include")
660                 ELSE(OPENAL_FOUND)
661                         SET(WITH_OPENAL OFF)
662                 ENDIF(OPENAL_FOUND)
663         ENDIF(WITH_OPENAL)
664
665         IF(WITH_JACK)
666                 SET(JACK /usr)
667                 SET(JACK_INC ${JACK}/include/jack)
668                 SET(JACK_LIB jack)
669                 SET(JACK_LIBPATH ${JACK}/lib)
670         ENDIF(WITH_JACK)
671
672         IF(WITH_SNDFILE)
673                 SET(SNDFILE ${LIBDIR}/sndfile)
674                 SET(SNDFILE_INC ${SNDFILE}/include)
675                 SET(SNDFILE_LIB sndfile FLAC ogg vorbis vorbisenc)
676                 SET(SNDFILE_LIBPATH ${SNDFILE}/lib ${FFMPEG}/lib)
677         ENDIF(WITH_SNDFILE)
678
679         SET(PYTHON_VERSION 3.1)
680
681         IF(PYTHON_VERSION MATCHES 3.1)
682                 # we use precompiled libraries for py 3.1 and up by default
683
684                 SET(PYTHON ${LIBDIR}/python)
685                 SET(PYTHON_INC "${PYTHON}/include/python${PYTHON_VERSION}")
686                 # SET(PYTHON_BINARY "${PYTHON}/bin/python${PYTHON_VERSION}") # not used yet
687                 SET(PYTHON_LIB python${PYTHON_VERSION})
688                 SET(PYTHON_LIBPATH "${PYTHON}/lib/python${PYTHON_VERSION}")
689                 # SET(PYTHON_LINKFLAGS "-u _PyMac_Error")  # won't  build with this enabled
690         ELSE(PYTHON_VERSION MATCHES 3.1)
691                 # otherwise, use custom system framework
692
693                 SET(PYTHON /System/Library/Frameworks/Python.framework/Versions/)
694                 SET(PYTHON_VERSION 3.1)
695                 SET(PYTHON_INC "${PYTHON}${PYTHON_VERSION}/include/python${PYTHON_VERSION}")
696                 # SET(PYTHON_BINARY ${PYTHON}${PYTHON_VERSION}/bin/python${PYTHON_VERSION}) # not used yet
697                 SET(PYTHON_LIB "")
698                 SET(PYTHON_LIBPATH ${PYTHON}${PYTHON_VERSION}/lib/python${PYTHON_VERSION}/config)
699                 SET(PYTHON_LINKFLAGS "-u _PyMac_Error -framework System -framework Python")
700         ENDIF(PYTHON_VERSION MATCHES 3.1)
701
702         IF(WITH_INTERNATIONAL)
703                 SET(GETTEXT ${LIBDIR}/gettext)
704                 SET(GETTEXT_INC "${GETTEXT}/include")
705                 SET(GETTEXT_LIB intl iconv)
706                 SET(GETTEXT_LIBPATH ${GETTEXT}/lib)
707         ENDIF(WITH_INTERNATIONAL)
708   
709         IF(WITH_FFTW3)
710                 SET(FFTW3 ${LIBDIR}/fftw3)
711                 SET(FFTW3_INC ${FFTW3}/include)
712                 SET(FFTW3_LIB fftw3)
713                 SET(FFTW3_LIBPATH ${FFTW3}/lib)
714         ENDIF(WITH_FFTW3)
715
716         SET(PNG_LIBRARIES png)
717         SET(JPEG_LIBRARY jpeg)
718
719         SET(ZLIB /usr)
720         SET(ZLIB_INC "${ZLIB}/include")
721         SET(ZLIB_LIBRARIES z bz2)
722
723         SET(FREETYPE ${LIBDIR}/freetype)
724         SET(FREETYPE_INCLUDE_DIRS ${FREETYPE}/include ${FREETYPE}/include/freetype2)
725         SET(FREETYPE_LIBPATH ${FREETYPE}/lib)
726         SET(FREETYPE_LIBRARY freetype)
727
728         IF(WITH_IMAGE_OPENEXR)
729                 SET(OPENEXR ${LIBDIR}/openexr)
730                 SET(OPENEXR_INC ${OPENEXR}/include/OpenEXR ${OPENEXR}/include)
731                 SET(OPENEXR_LIB Iex Half IlmImf Imath IlmThread)
732                 SET(OPENEXR_LIBPATH ${OPENEXR}/lib)
733         ENDIF(WITH_IMAGE_OPENEXR)
734
735         IF(WITH_LCMS)
736                 SET(LCMS ${LIBDIR}/lcms)
737                 SET(LCMS_INCLUDE_DIR ${LCMS}/include)
738                 SET(LCMS_LIBRARY lcms)
739                 SET(LCMS_LIBPATH ${LCMS}/lib)
740         ENDIF(WITH_LCMS)
741
742         IF(WITH_FFMPEG)
743                 SET(FFMPEG ${LIBDIR}/ffmpeg)
744                 SET(FFMPEG_INC ${FFMPEG}/include)
745                 SET(FFMPEG_LIB avcodec avdevice avformat avutil mp3lame swscale x264 xvidcore theora theoradec theoraenc vorbis vorbisenc vorbisfile ogg)
746                 SET(FFMPEG_LIBPATH ${FFMPEG}/lib)
747                 SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D__STDC_CONSTANT_MACROS")
748         ENDIF(WITH_FFMPEG)
749
750         SET(LIBSAMPLERATE ${LIBDIR}/samplerate)
751         SET(LIBSAMPLERATE_INC ${LIBSAMPLERATE}/include)
752         SET(LIBSAMPLERATE_LIB samplerate)
753         SET(LIBSAMPLERATE_LIBPATH ${LIBSAMPLERATE}/lib)
754
755         SET(LLIBS stdc++ SystemStubs)
756
757         IF (WITH_COCOA)
758                 SET(PLATFORM_CFLAGS "-pipe -funsigned-char -DGHOST_COCOA")
759                 SET(PLATFORM_LINKFLAGS "-fexceptions -framework CoreServices -framework Foundation -framework IOKit -framework AppKit -framework Cocoa -framework Carbon -framework AudioUnit -framework AudioToolbox -framework CoreAudio")
760                 IF(USE_QTKIT)
761                         SET(PLATFORM_CFLAGS "${PLATFORM_CFLAGS} -DUSE_QTKIT")
762                         SET(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} -framework QTKit")
763                         IF(CMAKE_OSX_ARCHITECTURES MATCHES i386)
764                                 SET(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} -framework QuickTime")
765                                 #libSDL still needs 32bit carbon quicktime 
766                         ENDIF(CMAKE_OSX_ARCHITECTURES MATCHES i386)
767                 ELSEIF(WITH_QUICKTIME)
768                         SET(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} -framework QuickTime")
769                 ENDIF(USE_QTKIT)
770         ELSE (WITH_COCOA)
771                 SET(PLATFORM_CFLAGS "-pipe -funsigned-char")
772                 SET(PLATFORM_LINKFLAGS "-fexceptions -framework CoreServices -framework Foundation -framework IOKit -framework AppKit -framework Carbon -framework AGL -framework AudioUnit -framework AudioToolbox -framework CoreAudio -framework QuickTime")
773         ENDIF (WITH_COCOA)
774
775         IF(WITH_OPENMP)
776                 SET(LLIBS "${LLIBS} -lgomp")
777                 SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fopenmp")
778                 SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fopenmp")
779         ENDIF(WITH_OPENMP)
780
781         IF (WITH_OPENCOLLADA)
782                 SET(OPENCOLLADA ${LIBDIR}/opencollada)
783                 SET(OPENCOLLADA_INC ${OPENCOLLADA}/include)
784                 SET(OPENCOLLADA_LIBPATH ${OPENCOLLADA}/lib)
785                 SET(OPENCOLLADA_LIB "OpenCOLLADASaxFrameworkLoader -lOpenCOLLADAFramework -lOpenCOLLADABaseUtils -lOpenCOLLADAStreamWriter -lMathMLSolver -lGeneratedSaxParser -lUTF -lxml2 -lbuffer -lftoa" )
786                 #pcre is bundled with openCollada
787                 #SET(PCRE ${LIBDIR}/pcre)
788                 #SET(PCRE_LIBPATH ${PCRE}/lib)
789                 SET(PCRE_LIB pcre)
790                 #libxml2 is used
791                 #SET(EXPAT ${LIBDIR}/expat)
792                 #SET(EXPAT_LIBPATH ${EXPAT}/lib)
793                 SET(EXPAT_LIB)
794         ENDIF (WITH_OPENCOLLADA)
795
796         IF(WITH_SDL)
797                 SET(SDL ${LIBDIR}/sdl)
798                 SET(SDL_INCLUDE_DIR ${SDL}/include)
799                 SET(SDL_LIBRARY SDL)
800                 SET(SDL_LIBPATH ${SDL}/lib)
801         ENDIF(WITH_SDL)
802
803         SET(PNG "${LIBDIR}/png")
804         SET(PNG_INC "${PNG}/include")
805         SET(PNG_LIBPATH ${PNG}/lib)
806
807         SET(JPEG "${LIBDIR}/jpeg")
808         SET(JPEG_INC "${JPEG}/include")
809         SET(JPEG_LIBPATH ${JPEG}/lib)
810
811         IF(WITH_IMAGE_TIFF)
812                 SET(TIFF ${LIBDIR}/tiff)
813                 SET(TIFF_INCLUDE_DIR ${TIFF}/include)
814                 SET(TIFF_LIBRARY tiff)
815                 SET(TIFF_LIBPATH ${TIFF}/lib)
816         ENDIF(WITH_IMAGE_TIFF)
817
818         SET(EXETYPE MACOSX_BUNDLE)
819
820         SET(CMAKE_C_FLAGS_DEBUG "-fno-strict-aliasing -g")
821         SET(CMAKE_CXX_FLAGS_DEBUG "-fno-strict-aliasing -g")
822         IF(CMAKE_OSX_ARCHITECTURES MATCHES "i386")
823                 SET(CMAKE_CXX_FLAGS_RELEASE "-O3 -mdynamic-no-pic -ftree-vectorize -msse -msse2 -fvariable-expansion-in-unroller")
824                 SET(CMAKE_C_FLAGS_RELEASE "-O3 -mdynamic-no-pic -ftree-vectorize -msse -msse2 -fvariable-expansion-in-unroller")
825         ELSEIF(CMAKE_OSX_ARCHITECTURES MATCHES "x86_64")
826                 SET(CMAKE_CXX_FLAGS_RELEASE "-O3 -mdynamic-no-pic -ftree-vectorize -msse -msse2 -msse3 -mssse3 -fvariable-expansion-in-unroller")
827                 SET(CMAKE_C_FLAGS_RELEASE "-O3 -mdynamic-no-pic -ftree-vectorize -msse -msse2 -msse3 -mssse3 -fvariable-expansion-in-unroller")
828         ELSE(CMAKE_OSX_ARCHITECTURES MATCHES "x86_64")
829                 SET(CMAKE_C_FLAGS_RELEASE "-mdynamic-no-pic -fno-strict-aliasing")
830                 SET(CMAKE_CXX_FLAGS_RELEASE "-mdynamic-no-pic -fno-strict-aliasing")
831         ENDIF(CMAKE_OSX_ARCHITECTURES MATCHES "i386")
832
833         # Better warnings
834         SET(C_WARNINGS "-Wall -Wno-char-subscripts -Wpointer-arith -Wcast-align -Wdeclaration-after-statement -Wno-unknown-pragmas")
835         SET(CXX_WARNINGS "-Wall -Wno-invalid-offsetof -Wno-sign-compare")
836
837 ENDIF(APPLE)
838
839
840 # buildinfo
841 IF(WITH_BUILDINFO)
842         # BUILD_PLATFORM and BUILD_PLATFORM are taken from CMake
843         IF(UNIX)
844                 EXEC_PROGRAM("date \"+%Y-%m-%d\"" OUTPUT_VARIABLE BUILD_DATE)
845                 EXEC_PROGRAM("date \"+%H:%M:%S\"" OUTPUT_VARIABLE BUILD_TIME)  
846                 EXEC_PROGRAM("svnversion ${CMAKE_SOURCE_DIR}" OUTPUT_VARIABLE BUILD_REV RETURN_VALUE BUILD_REV_RETURN)
847                 IF(BUILD_REV_RETURN)
848                         SET(BUILD_REV "unknown")
849                 ENDIF(BUILD_REV_RETURN)
850         ENDIF(UNIX)
851         
852         IF(WIN32)
853                 EXEC_PROGRAM("cmd /c date /t" OUTPUT_VARIABLE BUILD_DATE)
854                 EXEC_PROGRAM("cmd /c time /t" OUTPUT_VARIABLE BUILD_TIME)  
855                 EXEC_PROGRAM("svnversion ${CMAKE_SOURCE_DIR}" OUTPUT_VARIABLE BUILD_REV RETURN_VALUE BUILD_REV_RETURN)
856                 IF(BUILD_REV_RETURN)
857                         SET(BUILD_REV "unknown")
858                 ENDIF(BUILD_REV_RETURN)
859         ENDIF(WIN32)
860 ENDIF(WITH_BUILDINFO)
861 #-----------------------------------------------------------------------------
862 # Common.
863
864 IF(WITH_RAYOPTIMIZATION)
865         IF(CMAKE_COMPILER_IS_GNUCC)
866                 IF(SUPPORT_SSE_BUILD)
867                         SET(PLATFORM_CFLAGS " -msse ${PLATFORM_CFLAGS}")
868                         ADD_DEFINITIONS(-D__SSE__)
869                         ADD_DEFINITIONS(-D__MMX__)
870                 ENDIF(SUPPORT_SSE_BUILD)
871                 IF(SUPPORT_SSE2_BUILD)
872                         SET(PLATFORM_CFLAGS " -msse2 ${PLATFORM_CFLAGS}")
873                         ADD_DEFINITIONS(-D__SSE2__)
874                         IF(NOT SUPPORT_SSE_BUILD) # dont double up
875                                 ADD_DEFINITIONS(-D__MMX__)
876                         ENDIF(NOT SUPPORT_SSE_BUILD)
877                 ENDIF(SUPPORT_SSE2_BUILD)
878         ENDIF(CMAKE_COMPILER_IS_GNUCC)
879 ENDIF(WITH_RAYOPTIMIZATION)
880
881 IF(WITH_IMAGE_OPENJPEG)
882         set(OPENJPEG ${CMAKE_SOURCE_DIR}/extern/libopenjpeg)
883         set(OPENJPEG_INC ${OPENJPEG})
884         set(OPENJPEG_LIb extern_openjpeg)
885 ENDIF(WITH_IMAGE_OPENJPEG)
886
887 #-----------------------------------------------------------------------------
888 # Blender WebPlugin
889
890 IF(WITH_WEBPLUGIN) 
891         SET(GECKO_DIR "${CMAKE_SOURCE_DIR}/../gecko-sdk/" CACHE PATH "Gecko SDK path")
892         SET(WEBPLUGIN_SANDBOX_MODE "apparmor" CACHE STRING "WEB Plugin sandbox mode, can be apparmor, privsep, none")
893
894         SET(WITH_PLAYER ON)
895 ENDIF(WITH_WEBPLUGIN)
896
897
898 #-----------------------------------------------------------------------------
899 # Configure OpenGL.
900 FIND_PACKAGE(OpenGL)
901 INCLUDE_DIRECTORIES(${OPENGL_INCLUDE_DIR})
902 # UNSET(OPENGL_LIBRARIES CACHE) # not compat with older cmake 
903 # UNSET(OPENGL_xmesa_INCLUDE_DIR CACHE) # not compat with older cmake 
904
905 #-----------------------------------------------------------------------------
906 # Extra compile flags
907 SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${PLATFORM_CFLAGS} ${C_WARNINGS}")
908 SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${PLATFORM_CFLAGS} ${CXX_WARNINGS}")
909
910 # better not define flags here but this is a debugging option thats off by default.
911 IF(WITH_CXX_GUARDEDALLOC)
912         SET(CMAKE_CXX_FLAGS " -DWITH_CXX_GUARDEDALLOC -I${CMAKE_SOURCE_DIR}/intern/guardedalloc ${CMAKE_CXX_FLAGS}")
913 ENDIF(WITH_CXX_GUARDEDALLOC)
914
915 #-----------------------------------------------------------------------------
916 # Libraries
917 FILE(WRITE ${CMAKE_BINARY_DIR}/cmake_blender_libs.txt "")
918 ADD_SUBDIRECTORY(intern)
919 ADD_SUBDIRECTORY(extern)
920 ADD_SUBDIRECTORY(source)
921
922
923 #-----------------------------------------------------------------------------
924 # Blender Application
925 ADD_SUBDIRECTORY(source/creator)
926
927
928 #-----------------------------------------------------------------------------
929 # Blender Player
930 IF(WITH_PLAYER)
931         ADD_SUBDIRECTORY(source/blenderplayer)
932 ENDIF(WITH_PLAYER)