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