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