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