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