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