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