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