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