enable warning for unused args with gcc: -Wunused-parameter
[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
130 IF(NOT WITH_GAMEENGINE AND WITH_PLAYER)
131         MESSAGE(FATAL_ERROR "WITH_PLAYER needs WITH_GAMEENGINE")
132 ENDIF(NOT WITH_GAMEENGINE AND WITH_PLAYER)
133
134 IF(NOT WITH_INSTALL AND WITH_PYTHON_INSTALL)
135         MESSAGE("WARNING: WITH_PYTHON_INSTALL needs WITH_INSTALL")
136 ENDIF(NOT WITH_INSTALL AND WITH_PYTHON_INSTALL)
137
138 TEST_SSE_SUPPORT()
139
140 # disabled for now, not supported
141 # OPTION(WITH_WEBPLUGIN     "Enable Web Plugin (Unix only)" OFF)
142
143 # For alternate Python locations the commandline can be used to override detected/default cache settings, e.g:
144 # On Unix: 
145 #   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
146 # On Macs: 
147 #   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
148 #
149 # When changing any of this remember to update the notes in doc/build_systems/cmake.txt
150
151 #-----------------------------------------------------------------------------
152 #Platform specifics
153
154 IF(UNIX AND NOT APPLE)
155
156         IF(WITH_OPENAL)
157                 FIND_PACKAGE(OpenAL)
158                 IF(NOT OPENAL_FOUND)
159                         SET(WITH_OPENAL OFF)
160                 ENDIF(NOT OPENAL_FOUND)
161         ENDIF(WITH_OPENAL)
162
163         IF(WITH_JACK)
164                 SET(JACK /usr)
165                 SET(JACK_INC ${JACK}/include/jack)
166                 SET(JACK_LIB jack)
167                 SET(JACK_LIBPATH ${JACK}/lib)
168         ENDIF(WITH_JACK)
169
170         IF(WITH_SNDFILE)
171         SET(SNDFILE /usr)
172         SET(SNDFILE_INC ${SNDFILE}/include)
173         SET(SNDFILE_LIB sndfile)
174         SET(SNDFILE_LIBPATH ${SNDFILE}/lib)
175         ENDIF(WITH_SNDFILE)
176
177         IF(WITH_INTERNATIONAL)
178                 FIND_LIBRARY(INTL_LIBRARY
179                         NAMES intl
180                         PATHS
181                         /sw/lib
182                 )
183
184                 FIND_LIBRARY(ICONV_LIBRARY
185                         NAMES iconv
186                         PATHS
187                         /sw/lib
188                 )
189
190                 IF(INTL_LIBRARY AND ICONV_LIBRARY)
191                         SET(GETTEXT_LIB ${INTL_LIBRARY} ${ICONV_LIBRARY})
192                 ENDIF(INTL_LIBRARY AND ICONV_LIBRARY)
193         ENDIF(WITH_INTERNATIONAL)
194
195         FIND_PACKAGE(Freetype)
196         # UNSET(FREETYPE_INCLUDE_DIRS CACHE) # cant use
197
198
199         IF(WITH_PYTHON)
200                 # No way to set py31. remove for now.
201                 # FIND_PACKAGE(PythonLibs)
202                 SET(PYTHON /usr)
203                 SET(PYTHON_VERSION 3.1)
204                 SET(PYTHON_INC "${PYTHON}/include/python${PYTHON_VERSION}" CACHE STRING "")
205                 # SET(PYTHON_BINARY python) # not used yet
206                 SET(PYTHON_LIB python${PYTHON_VERSION} CACHE STRING "")
207                 SET(PYTHON_LIBPATH ${PYTHON}/lib CACHE STRING "")
208         
209                 # FIND_PACKAGE(PythonInterp) # not used yet
210                 # SET(PYTHON_BINARY ${PYTHON_EXECUTABLE} CACHE STRING "")
211
212                 SET(PYTHON_LINKFLAGS "-Xlinker -export-dynamic")
213         ENDIF(WITH_PYTHON)
214
215         IF(WITH_SDL)
216                 FIND_PACKAGE(SDL)
217                 # UNSET(SDLMAIN_LIBRARY CACHE)
218                 IF(NOT SDL_FOUND)
219                         SET(WITH_SDL OFF)
220                 ENDIF(NOT SDL_FOUND)
221         ENDIF(WITH_SDL)
222
223         IF(WITH_IMAGE_OPENEXR)
224                 SET(OPENEXR /usr CACHE FILEPATH "OPENEXR Directory")
225                 FIND_PATH(OPENEXR_INC
226                         ImfXdr.h
227                         PATHS
228                         ${OPENEXR}/include/OpenEXR
229                         /usr/local/include/OpenEXR
230                         /sw/include/OpenEXR
231                         /opt/local/include/OpenEXR
232                         /opt/csw/include/OpenEXR
233                         /opt/include/OpenEXR
234                 )
235                 SET(OPENEXR_LIB Half IlmImf Iex Imath)
236                 
237                 IF(NOT OPENEXR_INC)
238                         SET(WITH_IMAGE_OPENEXR OFF)
239                 ENDIF(NOT OPENEXR_INC)
240         ENDIF(WITH_IMAGE_OPENEXR)
241
242         IF(WITH_IMAGE_TIFF)
243                 FIND_PACKAGE(TIFF)
244                 IF(NOT TIFF_FOUND)
245                         SET(WITH_IMAGE_TIFF OFF)
246                 ENDIF(NOT TIFF_FOUND)
247         ENDIF(WITH_IMAGE_TIFF)
248
249         FIND_PACKAGE(JPEG REQUIRED)
250
251         FIND_PACKAGE(PNG REQUIRED)
252
253         FIND_PACKAGE(ZLIB REQUIRED)
254
255         IF(WITH_LCMS)
256                 SET(LCMS /usr CACHE FILEPATH "LCMS directory")
257                 SET(LCMS_INCLUDE_DIR ${LCMS}/include)
258                 SET(LCMS_LIBRARY lcms)
259                 SET(LCMS_LIBPATH ${LCMS}/lib)
260         ENDIF(WITH_LCMS)
261
262         IF(WITH_FFMPEG)
263                 SET(FFMPEG /usr CACHE FILEPATH "FFMPEG Directory")
264                 SET(FFMPEG_INC ${FFMPEG}/include)
265                 SET(FFMPEG_LIB avformat avcodec avutil avdevice swscale CACHE STRING "FFMPEG Libraries")
266                 SET(FFMPEG_LIBPATH ${FFMPEG}/lib)
267                 SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D__STDC_CONSTANT_MACROS")
268         ENDIF(WITH_FFMPEG)
269
270         IF(WITH_FFTW3)
271                 SET(FFTW3 /usr)
272                 SET(FFTW3_INC ${FFTW3}/include)
273                 SET(FFTW3_LIB fftw3)
274                 SET(FFTW3_LIBPATH ${FFTW3}/lib)
275         ENDIF(WITH_FFTW3)
276
277         SET(LIBSAMPLERATE /usr)
278         SET(LIBSAMPLERATE_INC ${LIBSAMPLERATE}/include)
279         SET(LIBSAMPLERATE_LIB samplerate)
280         SET(LIBSAMPLERATE_LIBPATH ${LIBSAMPLERATE}/lib)
281
282         IF (WITH_OPENCOLLADA)
283                 SET(OPENCOLLADA /usr/local/opencollada CACHE FILEPATH "OpenCollada Directory")
284                 SET(OPENCOLLADA_LIBPATH ${OPENCOLLADA}/lib)
285                 SET(OPENCOLLADA_LIB OpenCOLLADAStreamWriter OpenCOLLADASaxFrameworkLoader OpenCOLLADAFramework OpenCOLLADABaseUtils GeneratedSaxParser UTF MathMLSolver pcre ftoa buffer)
286                 SET(OPENCOLLADA_INC ${OPENCOLLADA})
287                 SET(PCRE /usr CACHE FILEPATH "PCRE Directory")
288                 SET(PCRE_LIBPATH ${PCRE}/lib)
289                 SET(PCRE_LIB pcre)
290                 SET(EXPAT /usr CACHE FILEPATH "Expat Directory")
291                 SET(EXPAT_LIBPATH ${EXPAT}/lib)
292                 SET(EXPAT_LIB expat)
293         ENDIF (WITH_OPENCOLLADA)
294
295         FIND_PACKAGE(X11 REQUIRED)
296
297         # OpenSuse needs lutil, ArchLinux not, for now keep, can avoid by using --as-needed
298         SET(LLIBS "-lutil -lc -lm -lpthread -lstdc++ ${X11_X11_LIB} ${X11_Xinput_LIB}")
299
300         IF(CMAKE_SYSTEM_NAME MATCHES "Linux")
301                 # BSD's dont use libdl.so
302                 LIST(APPEND LLIBS -ldl)
303
304                 # binreloc is linux only
305                 SET(BINRELOC ${CMAKE_SOURCE_DIR}/extern/binreloc)
306                 SET(BINRELOC_INC ${BINRELOC}/include)
307         ENDIF(CMAKE_SYSTEM_NAME MATCHES "Linux")
308
309         IF(WITH_OPENMP)
310                 LIST(APPEND LLIBS -lgomp)
311                 SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fopenmp")
312                 SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fopenmp")
313         ENDIF(WITH_OPENMP)
314
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 should be added but for now only apply to ./source/blender
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
556                 SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -DNDEBUG")
557                 SET(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -DNDEBUG")
558
559                 SET(CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS_MINSIZEREL} -DNDEBUG")
560                 SET(CMAKE_C_FLAGS_MINSIZEREL "${CMAKE_C_FLAGS_MINSIZEREL} -DNDEBUG")
561
562                 SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -DNDEBUG")
563                 SET(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO} -DNDEBUG")
564
565
566                 IF(WITH_OPENMP)
567                         SET(LLIBS "${LLIBS} -lgomp")
568                         SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fopenmp")
569                         SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fopenmp")
570                 ENDIF(WITH_OPENMP)
571
572                 IF(WITH_INTERNATIONAL)
573                         SET(GETTEXT ${LIBDIR}/gcc/gettext)
574                         SET(GETTEXT_INC ${GETTEXT}/include)
575                         SET(GETTEXT_LIBPATH ${GETTEXT}/lib)
576                         SET(GETTEXT_LIB intl)
577                 ENDIF(WITH_INTERNATIONAL)
578
579                 SET(JPEG_LIBRARY libjpeg)
580                 SET(PNG_LIBRARIES png)
581
582                 SET(ZLIB ${LIBDIR}/zlib)
583                 SET(ZLIB_INC ${ZLIB}/include)
584                 SET(ZLIB_LIBPATH ${ZLIB}/lib)
585                 SET(ZLIB_LIBRARIES z)
586
587                 SET(PTHREADS ${LIBDIR}/pthreads)
588                 SET(PTHREADS_INC ${PTHREADS}/include)
589                 SET(PTHREADS_LIBPATH ${PTHREADS}/lib)
590                 SET(PTHREADS_LIB pthreadGC2)
591                 
592                 SET(FREETYPE ${LIBDIR}/gcc/freetype)
593                 SET(FREETYPE_INCLUDE_DIRS ${FREETYPE}/include ${FREETYPE}/include/freetype2)
594                 SET(FREETYPE_LIBPATH ${FREETYPE}/lib)
595                 SET(FREETYPE_LIBRARY freetype)
596
597                 IF(WITH_FFTW3)
598                         SET(FFTW3 ${LIBDIR}/gcc/fftw3)
599                         SET(FFTW3_LIB fftw3)
600                         SET(FFTW3_INC ${FFTW3}/include)
601                         SET(FFTW3_LIBPATH ${FFTW3}/lib)
602                 ENDIF(WITH_FFTW3)
603
604                 IF(WITH_OPENCOLLADA)
605                         SET(OPENCOLLADA ${LIBDIR}/gcc/opencollada)
606                         SET(OPENCOLLADA_INC ${OPENCOLLADA}/include)
607                         SET(OPENCOLLADA_LIBPATH ${OPENCOLLADA}/lib ${OPENCOLLADA}/lib)
608                         SET(OPENCOLLADA_LIB OpenCOLLADAStreamWriter OpenCOLLADASaxFrameworkLoader OpenCOLLADAFramework OpenCOLLADABaseUtils GeneratedSaxParser UTF MathMLSolver expat pcre buffer ftoa)
609                         SET(PCRE_LIB pcre)
610                 ENDIF(WITH_OPENCOLLADA)
611                 
612                 IF(WITH_FFMPEG)
613                         SET(FFMPEG ${LIBDIR}/ffmpeg)
614                         SET(FFMPEG_INC ${FFMPEG}/include ${FFMPEG}/include)
615                         SET(FFMPEG_LIB avcodec-52 avformat-52 avdevice-52 avutil-50 swscale-0)
616                         SET(FFMPEG_LIBPATH ${FFMPEG}/lib)
617                 ENDIF(WITH_FFMPEG)
618
619                 IF(WITH_IMAGE_OPENEXR)
620                         SET(OPENEXR ${LIBDIR}/gcc/openexr)
621                         SET(OPENEXR_INC ${OPENEXR}/include ${OPENEXR}/include/OpenEXR)
622                         SET(OPENEXR_LIB Half IlmImf Imath IlmThread)
623                         SET(OPENEXR_LIBPATH ${OPENEXR}/lib)
624
625                         # TODO, gives linking errors, force off
626                         SET(WITH_IMAGE_OPENEXR OFF)
627                 ENDIF(WITH_IMAGE_OPENEXR)
628
629                 IF(WITH_IMAGE_TIFF)
630                         SET(TIFF ${LIBDIR}/gcc/tiff)
631                         SET(TIFF_LIBRARY tiff)
632                         SET(TIFF_INCLUDE_DIR ${TIFF}/include)
633                         SET(TIFF_LIBPATH ${TIFF}/lib)
634                 ENDIF(WITH_IMAGE_TIFF)
635
636                 IF(WITH_JACK)
637                         SET(JACK ${LIBDIR}/jack)
638                         SET(JACK_INC ${JACK}/include/jack ${JACK}/include)
639                         SET(JACK_LIB jack)
640                         SET(JACK_LIBPATH ${JACK}/lib)
641                         
642                         # TODO, gives linking errors, force off
643                         SET(WITH_JACK OFF)
644                 ENDIF(WITH_JACK)
645
646                 IF(WITH_PYTHON)
647                         SET(PYTHON ${LIBDIR}/python)
648                         SET(PYTHON_VERSION 3.1)
649                         SET(PYTHON_INC "${PYTHON}/include/python${PYTHON_VERSION}")
650                         # SET(PYTHON_BINARY python) # not used yet
651                         SET(PYTHON_LIB python31mw)
652                         SET(PYTHON_LIBPATH ${PYTHON}/lib)
653                 ENDIF(WITH_PYTHON)
654
655         ENDIF(MSVC)
656
657 ENDIF(WIN32)
658
659
660 IF(APPLE)
661         IF(WITH_LIBS10.5)
662                 SET(LIBDIR ${CMAKE_SOURCE_DIR}/../lib/darwin-9.x.universal)
663         ELSE(WITH_LIBS10.5)
664                 IF(CMAKE_OSX_ARCHITECTURES MATCHES i386)
665                         SET(LIBDIR ${CMAKE_SOURCE_DIR}/../lib/darwin-8.x.i386)
666                 ELSE(CMAKE_OSX_ARCHITECTURES MATCHES i386)
667                         SET(LIBDIR ${CMAKE_SOURCE_DIR}/../lib/darwin-8.0.0-powerpc)
668                 ENDIF(CMAKE_OSX_ARCHITECTURES MATCHES i386)
669         ENDIF(WITH_LIBS10.5)
670         
671
672         IF(WITH_OPENAL)
673                 FIND_PACKAGE(OpenAL)
674                 IF(OPENAL_FOUND)
675                         SET(WITH_OPENAL ON)
676                         SET(OPENAL_INCLUDE_DIR "${LIBDIR}/openal/include")
677                 ELSE(OPENAL_FOUND)
678                         SET(WITH_OPENAL OFF)
679                 ENDIF(OPENAL_FOUND)
680         ENDIF(WITH_OPENAL)
681
682         IF(WITH_JACK)
683                 SET(JACK /usr)
684                 SET(JACK_INC ${JACK}/include/jack)
685                 SET(JACK_LIB jack)
686                 SET(JACK_LIBPATH ${JACK}/lib)
687         ENDIF(WITH_JACK)
688
689         IF(WITH_SNDFILE)
690                 SET(SNDFILE ${LIBDIR}/sndfile)
691                 SET(SNDFILE_INC ${SNDFILE}/include)
692                 SET(SNDFILE_LIB sndfile FLAC ogg vorbis vorbisenc)
693                 SET(SNDFILE_LIBPATH ${SNDFILE}/lib ${FFMPEG}/lib)
694         ENDIF(WITH_SNDFILE)
695
696         SET(PYTHON_VERSION 3.1)
697
698         IF(PYTHON_VERSION MATCHES 3.1)
699                 # we use precompiled libraries for py 3.1 and up by default
700
701                 SET(PYTHON ${LIBDIR}/python)
702                 SET(PYTHON_INC "${PYTHON}/include/python${PYTHON_VERSION}")
703                 # SET(PYTHON_BINARY "${PYTHON}/bin/python${PYTHON_VERSION}") # not used yet
704                 SET(PYTHON_LIB python${PYTHON_VERSION})
705                 SET(PYTHON_LIBPATH "${PYTHON}/lib/python${PYTHON_VERSION}")
706                 # SET(PYTHON_LINKFLAGS "-u _PyMac_Error")  # won't  build with this enabled
707         ELSE(PYTHON_VERSION MATCHES 3.1)
708                 # otherwise, use custom system framework
709
710                 SET(PYTHON /System/Library/Frameworks/Python.framework/Versions/)
711                 SET(PYTHON_VERSION 3.1)
712                 SET(PYTHON_INC "${PYTHON}${PYTHON_VERSION}/include/python${PYTHON_VERSION}")
713                 # SET(PYTHON_BINARY ${PYTHON}${PYTHON_VERSION}/bin/python${PYTHON_VERSION}) # not used yet
714                 SET(PYTHON_LIB "")
715                 SET(PYTHON_LIBPATH ${PYTHON}${PYTHON_VERSION}/lib/python${PYTHON_VERSION}/config)
716                 SET(PYTHON_LINKFLAGS "-u _PyMac_Error -framework System -framework Python")
717         ENDIF(PYTHON_VERSION MATCHES 3.1)
718
719         IF(WITH_INTERNATIONAL)
720                 SET(GETTEXT ${LIBDIR}/gettext)
721                 SET(GETTEXT_INC "${GETTEXT}/include")
722                 SET(GETTEXT_LIB intl iconv)
723                 SET(GETTEXT_LIBPATH ${GETTEXT}/lib)
724         ENDIF(WITH_INTERNATIONAL)
725   
726         IF(WITH_FFTW3)
727                 SET(FFTW3 ${LIBDIR}/fftw3)
728                 SET(FFTW3_INC ${FFTW3}/include)
729                 SET(FFTW3_LIB fftw3)
730                 SET(FFTW3_LIBPATH ${FFTW3}/lib)
731         ENDIF(WITH_FFTW3)
732
733         SET(PNG_LIBRARIES png)
734         SET(JPEG_LIBRARY jpeg)
735
736         SET(ZLIB /usr)
737         SET(ZLIB_INC "${ZLIB}/include")
738         SET(ZLIB_LIBRARIES z bz2)
739
740         SET(FREETYPE ${LIBDIR}/freetype)
741         SET(FREETYPE_INCLUDE_DIRS ${FREETYPE}/include ${FREETYPE}/include/freetype2)
742         SET(FREETYPE_LIBPATH ${FREETYPE}/lib)
743         SET(FREETYPE_LIBRARY freetype)
744
745         IF(WITH_IMAGE_OPENEXR)
746                 SET(OPENEXR ${LIBDIR}/openexr)
747                 SET(OPENEXR_INC ${OPENEXR}/include/OpenEXR ${OPENEXR}/include)
748                 SET(OPENEXR_LIB Iex Half IlmImf Imath IlmThread)
749                 SET(OPENEXR_LIBPATH ${OPENEXR}/lib)
750         ENDIF(WITH_IMAGE_OPENEXR)
751
752         IF(WITH_LCMS)
753                 SET(LCMS ${LIBDIR}/lcms)
754                 SET(LCMS_INCLUDE_DIR ${LCMS}/include)
755                 SET(LCMS_LIBRARY lcms)
756                 SET(LCMS_LIBPATH ${LCMS}/lib)
757         ENDIF(WITH_LCMS)
758
759         IF(WITH_FFMPEG)
760                 SET(FFMPEG ${LIBDIR}/ffmpeg)
761                 SET(FFMPEG_INC ${FFMPEG}/include)
762                 SET(FFMPEG_LIB avcodec avdevice avformat avutil mp3lame swscale x264 xvidcore theora theoradec theoraenc vorbis vorbisenc vorbisfile ogg)
763                 SET(FFMPEG_LIBPATH ${FFMPEG}/lib)
764                 SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D__STDC_CONSTANT_MACROS")
765         ENDIF(WITH_FFMPEG)
766
767         SET(LIBSAMPLERATE ${LIBDIR}/samplerate)
768         SET(LIBSAMPLERATE_INC ${LIBSAMPLERATE}/include)
769         SET(LIBSAMPLERATE_LIB samplerate)
770         SET(LIBSAMPLERATE_LIBPATH ${LIBSAMPLERATE}/lib)
771
772         SET(LLIBS stdc++ SystemStubs)
773
774         IF (WITH_COCOA)
775                 SET(PLATFORM_CFLAGS "-pipe -funsigned-char -DGHOST_COCOA")
776                 SET(PLATFORM_LINKFLAGS "-fexceptions -framework CoreServices -framework Foundation -framework IOKit -framework AppKit -framework Cocoa -framework Carbon -framework AudioUnit -framework AudioToolbox -framework CoreAudio")
777                 IF(USE_QTKIT)
778                         SET(PLATFORM_CFLAGS "${PLATFORM_CFLAGS} -DUSE_QTKIT")
779                         SET(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} -framework QTKit")
780                         IF(CMAKE_OSX_ARCHITECTURES MATCHES i386)
781                                 SET(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} -framework QuickTime")
782                                 #libSDL still needs 32bit carbon quicktime 
783                         ENDIF(CMAKE_OSX_ARCHITECTURES MATCHES i386)
784                 ELSEIF(WITH_QUICKTIME)
785                         SET(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} -framework QuickTime")
786                 ENDIF(USE_QTKIT)
787         ELSE (WITH_COCOA)
788                 SET(PLATFORM_CFLAGS "-pipe -funsigned-char")
789                 SET(PLATFORM_LINKFLAGS "-fexceptions -framework CoreServices -framework Foundation -framework IOKit -framework AppKit -framework Carbon -framework AGL -framework AudioUnit -framework AudioToolbox -framework CoreAudio -framework QuickTime")
790         ENDIF (WITH_COCOA)
791
792         IF(WITH_OPENMP)
793                 SET(LLIBS "${LLIBS} -lgomp")
794                 SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fopenmp")
795                 SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fopenmp")
796         ENDIF(WITH_OPENMP)
797
798         IF (WITH_OPENCOLLADA)
799                 SET(OPENCOLLADA ${LIBDIR}/opencollada)
800                 SET(OPENCOLLADA_INC ${OPENCOLLADA}/include)
801                 SET(OPENCOLLADA_LIBPATH ${OPENCOLLADA}/lib)
802                 SET(OPENCOLLADA_LIB "OpenCOLLADASaxFrameworkLoader -lOpenCOLLADAFramework -lOpenCOLLADABaseUtils -lOpenCOLLADAStreamWriter -lMathMLSolver -lGeneratedSaxParser -lUTF -lxml2 -lbuffer -lftoa" )
803                 #pcre is bundled with openCollada
804                 #SET(PCRE ${LIBDIR}/pcre)
805                 #SET(PCRE_LIBPATH ${PCRE}/lib)
806                 SET(PCRE_LIB pcre)
807                 #libxml2 is used
808                 #SET(EXPAT ${LIBDIR}/expat)
809                 #SET(EXPAT_LIBPATH ${EXPAT}/lib)
810                 SET(EXPAT_LIB)
811         ENDIF (WITH_OPENCOLLADA)
812
813         IF(WITH_SDL)
814                 SET(SDL ${LIBDIR}/sdl)
815                 SET(SDL_INCLUDE_DIR ${SDL}/include)
816                 SET(SDL_LIBRARY SDL)
817                 SET(SDL_LIBPATH ${SDL}/lib)
818         ENDIF(WITH_SDL)
819
820         SET(PNG "${LIBDIR}/png")
821         SET(PNG_INC "${PNG}/include")
822         SET(PNG_LIBPATH ${PNG}/lib)
823
824         SET(JPEG "${LIBDIR}/jpeg")
825         SET(JPEG_INC "${JPEG}/include")
826         SET(JPEG_LIBPATH ${JPEG}/lib)
827
828         IF(WITH_IMAGE_TIFF)
829                 SET(TIFF ${LIBDIR}/tiff)
830                 SET(TIFF_INCLUDE_DIR ${TIFF}/include)
831                 SET(TIFF_LIBRARY tiff)
832                 SET(TIFF_LIBPATH ${TIFF}/lib)
833         ENDIF(WITH_IMAGE_TIFF)
834
835         SET(EXETYPE MACOSX_BUNDLE)
836
837         SET(CMAKE_C_FLAGS_DEBUG "-fno-strict-aliasing -g")
838         SET(CMAKE_CXX_FLAGS_DEBUG "-fno-strict-aliasing -g")
839         IF(CMAKE_OSX_ARCHITECTURES MATCHES "i386")
840                 SET(CMAKE_CXX_FLAGS_RELEASE "-O3 -mdynamic-no-pic -ftree-vectorize -msse -msse2 -fvariable-expansion-in-unroller")
841                 SET(CMAKE_C_FLAGS_RELEASE "-O3 -mdynamic-no-pic -ftree-vectorize -msse -msse2 -fvariable-expansion-in-unroller")
842         ELSEIF(CMAKE_OSX_ARCHITECTURES MATCHES "x86_64")
843                 SET(CMAKE_CXX_FLAGS_RELEASE "-O3 -mdynamic-no-pic -ftree-vectorize -msse -msse2 -msse3 -mssse3 -fvariable-expansion-in-unroller")
844                 SET(CMAKE_C_FLAGS_RELEASE "-O3 -mdynamic-no-pic -ftree-vectorize -msse -msse2 -msse3 -mssse3 -fvariable-expansion-in-unroller")
845         ELSE(CMAKE_OSX_ARCHITECTURES MATCHES "x86_64")
846                 SET(CMAKE_C_FLAGS_RELEASE "-mdynamic-no-pic -fno-strict-aliasing")
847                 SET(CMAKE_CXX_FLAGS_RELEASE "-mdynamic-no-pic -fno-strict-aliasing")
848         ENDIF(CMAKE_OSX_ARCHITECTURES MATCHES "i386")
849
850         # Better warnings
851         SET(C_WARNINGS "-Wall -Wno-char-subscripts -Wpointer-arith -Wcast-align -Wdeclaration-after-statement -Wno-unknown-pragmas")
852         SET(CXX_WARNINGS "-Wall -Wno-invalid-offsetof -Wno-sign-compare")
853
854 ENDIF(APPLE)
855
856
857 # buildinfo
858 IF(WITH_BUILDINFO)
859         # BUILD_PLATFORM and BUILD_PLATFORM are taken from CMake
860         IF(UNIX)
861                 EXEC_PROGRAM("date \"+%Y-%m-%d\"" OUTPUT_VARIABLE BUILD_DATE)
862                 EXEC_PROGRAM("date \"+%H:%M:%S\"" OUTPUT_VARIABLE BUILD_TIME)  
863                 EXEC_PROGRAM("svnversion ${CMAKE_SOURCE_DIR}" OUTPUT_VARIABLE BUILD_REV RETURN_VALUE BUILD_REV_RETURN)
864                 IF(BUILD_REV_RETURN)
865                         SET(BUILD_REV "unknown")
866                 ENDIF(BUILD_REV_RETURN)
867         ENDIF(UNIX)
868         
869         IF(WIN32)
870                 EXEC_PROGRAM("cmd /c date /t" OUTPUT_VARIABLE BUILD_DATE)
871                 EXEC_PROGRAM("cmd /c time /t" OUTPUT_VARIABLE BUILD_TIME)  
872                 EXEC_PROGRAM("svnversion ${CMAKE_SOURCE_DIR}" OUTPUT_VARIABLE BUILD_REV RETURN_VALUE BUILD_REV_RETURN)
873                 IF(BUILD_REV_RETURN)
874                         SET(BUILD_REV "unknown")
875                 ENDIF(BUILD_REV_RETURN)
876         ENDIF(WIN32)
877 ENDIF(WITH_BUILDINFO)
878 #-----------------------------------------------------------------------------
879 # Common.
880
881 IF(WITH_RAYOPTIMIZATION)
882         IF(CMAKE_COMPILER_IS_GNUCC)
883                 IF(SUPPORT_SSE_BUILD)
884                         SET(PLATFORM_CFLAGS " -msse ${PLATFORM_CFLAGS}")
885                         ADD_DEFINITIONS(-D__SSE__ -D__MMX__)
886                 ENDIF(SUPPORT_SSE_BUILD)
887                 IF(SUPPORT_SSE2_BUILD)
888                         SET(PLATFORM_CFLAGS " -msse2 ${PLATFORM_CFLAGS}")
889                         ADD_DEFINITIONS(-D__SSE2__)
890                         IF(NOT SUPPORT_SSE_BUILD) # dont double up
891                                 ADD_DEFINITIONS(-D__MMX__)
892                         ENDIF(NOT SUPPORT_SSE_BUILD)
893                 ENDIF(SUPPORT_SSE2_BUILD)
894         ENDIF(CMAKE_COMPILER_IS_GNUCC)
895 ENDIF(WITH_RAYOPTIMIZATION)
896
897 IF(WITH_IMAGE_OPENJPEG)
898         set(OPENJPEG ${CMAKE_SOURCE_DIR}/extern/libopenjpeg)
899         set(OPENJPEG_INC ${OPENJPEG})
900         set(OPENJPEG_LIb extern_openjpeg)
901 ENDIF(WITH_IMAGE_OPENJPEG)
902
903 #-----------------------------------------------------------------------------
904 # Blender WebPlugin
905
906 IF(WITH_WEBPLUGIN) 
907         SET(GECKO_DIR "${CMAKE_SOURCE_DIR}/../gecko-sdk/" CACHE PATH "Gecko SDK path")
908         SET(WEBPLUGIN_SANDBOX_MODE "apparmor" CACHE STRING "WEB Plugin sandbox mode, can be apparmor, privsep, none")
909
910         SET(WITH_PLAYER ON)
911 ENDIF(WITH_WEBPLUGIN)
912
913
914 #-----------------------------------------------------------------------------
915 # Configure OpenGL.
916 FIND_PACKAGE(OpenGL)
917 INCLUDE_DIRECTORIES(${OPENGL_INCLUDE_DIR})
918 # UNSET(OPENGL_LIBRARIES CACHE) # not compat with older cmake 
919 # UNSET(OPENGL_xmesa_INCLUDE_DIR CACHE) # not compat with older cmake 
920
921 #-----------------------------------------------------------------------------
922 # Extra compile flags
923 SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${PLATFORM_CFLAGS} ${C_WARNINGS}")
924 SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${PLATFORM_CFLAGS} ${CXX_WARNINGS}")
925
926 # better not define flags here but this is a debugging option thats off by default.
927 IF(WITH_CXX_GUARDEDALLOC)
928         SET(CMAKE_CXX_FLAGS " -DWITH_CXX_GUARDEDALLOC -I${CMAKE_SOURCE_DIR}/intern/guardedalloc ${CMAKE_CXX_FLAGS}")
929 ENDIF(WITH_CXX_GUARDEDALLOC)
930
931 #-----------------------------------------------------------------------------
932 # Libraries
933 FILE(WRITE ${CMAKE_BINARY_DIR}/cmake_blender_libs.txt "")
934 ADD_SUBDIRECTORY(intern)
935 ADD_SUBDIRECTORY(extern)
936 ADD_SUBDIRECTORY(source)
937
938
939 #-----------------------------------------------------------------------------
940 # Blender Application
941 ADD_SUBDIRECTORY(source/creator)
942
943
944 #-----------------------------------------------------------------------------
945 # Blender Player
946 IF(WITH_PLAYER)
947         ADD_SUBDIRECTORY(source/blenderplayer)
948 ENDIF(WITH_PLAYER)