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