CMake option 'WITH_HEADLESS' to build blender in headless mode (no x11/xlib) with...
[blender.git] / CMakeLists.txt
1 # -*- mode: cmake; indent-tabs-mode: t; -*-
2 # $Id$
3 # ***** BEGIN GPL LICENSE BLOCK *****
4 #
5 # This program is free software; you can redistribute it and/or
6 # modify it under the terms of the GNU General Public License
7 # as published by the Free Software Foundation; either version 2
8 # of the License, or (at your option) any later version.
9 #
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 # GNU General Public License for more details.
14 #
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write to the Free Software Foundation,
17 # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 #
19 # The Original Code is Copyright (C) 2006, Blender Foundation
20 # All rights reserved.
21 #
22 # The Original Code is: all of this file.
23 #
24 # Contributor(s): Jacques Beaurain.
25 #
26 # ***** END GPL LICENSE BLOCK *****
27
28 #-----------------------------------------------------------------------------
29 # We don't allow in-source builds. This causes no end of troubles because 
30 # all out-of-source builds will use the CMakeCache.txt file there and even 
31 # build the libs and objects in it.
32
33 if(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR})
34         if(NOT DEFINED WITH_IN_SOURCE_BUILD)
35                 message(FATAL_ERROR
36                         "CMake generation for blender is not allowed within the source directory!"
37                         "\n Remove the CMakeCache.txt file and try again from another folder, e.g.:"
38                         "\n "
39                         "\n rm CMakeCache.txt"
40                         "\n cd .."
41                         "\n mkdir cmake-make"
42                         "\n cd cmake-make"
43                         "\n cmake ../blender"
44                         "\n "
45                         "\n Alternately define WITH_IN_SOURCE_BUILD to force this option (not recommended!)"
46                 )
47         endif()
48 endif()
49
50 cmake_minimum_required(VERSION 2.8)
51
52 # this starts out unset
53 set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/build_files/cmake/Modules/")
54
55 # quiet output for Makefiles, 'make -s' helps too
56 # set_property(GLOBAL PROPERTY RULE_MESSAGES OFF)
57
58 #-----------------------------------------------------------------------------
59 # Load some macros.
60 include(build_files/cmake/macros.cmake)
61
62
63 #-----------------------------------------------------------------------------
64 # Initialize project.
65
66 blender_project_hack_pre()
67
68 project(Blender)
69
70 blender_project_hack_post()
71
72 enable_testing()
73
74 #-----------------------------------------------------------------------------
75 # Redirect output files
76
77 set(EXECUTABLE_OUTPUT_PATH ${CMAKE_BINARY_DIR}/bin CACHE INTERNAL "" FORCE )
78 set(LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR}/lib CACHE INTERNAL "" FORCE )
79
80 #-----------------------------------------------------------------------------
81 # Set default config options
82
83 get_blender_version()
84
85 # Blender internal features
86 option(WITH_INTERNATIONAL "Enable I18N (International fonts and text)" ON)
87
88 option(WITH_PYTHON        "Enable Embedded Python API  (only disable for development)" ON)
89 option(WITH_PYTHON_SECURITY "Disables execution of scripts within blend files by default (recommend to leave off)" OFF)
90 mark_as_advanced(WITH_PYTHON)  # dont want people disabling this unless they really know what they are doing.
91 mark_as_advanced(WITH_PYTHON_SECURITY)  # some distrobutions see this as a security issue, rather than have them patch it, make a build option.
92
93 option(WITH_PYTHON_SAFETY "Enable internal API error checking to track invalid data to prevent crash on access (at the expense of some effeciency, only enable for development)." OFF)
94 option(WITH_PYTHON_MODULE "Enable building as a python module (experemental, only enable for development)" OFF)
95 option(WITH_BUILDINFO     "Include extra build details (only disable for development & faster builds)" ON)
96 option(WITH_IK_ITASC      "Enable ITASC IK solver (only disable for development & for incompatible C++ compilers)" ON)
97 option(WITH_FFTW3         "Enable FFTW3 support (Used for smoke and audio effects)" OFF)
98 option(WITH_BULLET        "Enable Bullet (Physics Engine)" ON)
99 option(WITH_GAMEENGINE    "Enable Game Engine" ON)
100 option(WITH_PLAYER        "Build Player" OFF)
101
102 option(WITH_HEADLESS      "Build without graphical support (renderfarm, server mode only)" OFF)
103 mark_as_advanced(WITH_HEADLESS)
104
105 # (unix defaults to OpenMP On)
106 if(UNIX AND NOT APPLE)
107         option(WITH_OPENMP        "Enable OpenMP (has to be supported by the compiler)" ON)
108 else()
109         option(WITH_OPENMP        "Enable OpenMP (has to be supported by the compiler)" OFF)
110 endif()
111
112 if(UNIX AND NOT APPLE)
113         option(WITH_X11_XINPUT "Enable X11 Xinput (tablet support)"     ON)
114         option(WITH_BUILTIN_GLEW "Use GLEW OpenGL wrapper library bundled with blender" ON)
115 else()
116         # not an option for other OS's
117         set(WITH_BUILTIN_GLEW ON)
118 endif()
119
120 # Modifiers
121 option(WITH_MOD_FLUID           "Enable Elbeem Modifier (Fluid Simulation)" ON)
122 option(WITH_MOD_DECIMATE        "Enable Decimate Modifier" ON)
123 option(WITH_MOD_BOOLEAN         "Enable Boolean Modifier" ON)
124 option(WITH_MOD_CLOTH_ELTOPO    "Enable Experemental cloth solver" OFF)
125 mark_as_advanced(WITH_MOD_CLOTH_ELTOPO)
126
127 # Image format support
128 option(WITH_IMAGE_OPENEXR       "Enable OpenEXR Support (http://www.openexr.com)" ON)
129 option(WITH_IMAGE_OPENJPEG      "Enable OpenJpeg Support (http://www.openjpeg.org)" ON)
130 option(WITH_IMAGE_TIFF          "Enable LibTIFF Support" ON)
131 option(WITH_IMAGE_DDS           "Enable DDS Image Support" ON)
132 option(WITH_IMAGE_CINEON        "Enable CINEON and DPX Image Support" ON)
133 option(WITH_IMAGE_HDR           "Enable HDR Image Support" ON)
134 option(WITH_IMAGE_REDCODE       "Enable RedCode Image Support" OFF)
135
136 # Audio/Video format support
137 option(WITH_CODEC_FFMPEG        "Enable FFMPeg Support (http://ffmpeg.mplayerhq.hu)" OFF)
138 option(WITH_CODEC_SNDFILE       "Enable libsndfile Support (http://www.mega-nerd.com/libsndfile)" OFF)
139 if(APPLE OR (WIN32 AND NOT UNIX))
140         option(WITH_CODEC_QUICKTIME     "Enable Quicktime Support" OFF)
141 endif()
142
143 # 3D format support
144 # disable opencollada on non-apple unix because opencollada has no package for debian
145 option(WITH_OPENCOLLADA         "Enable OpenCollada Support (http://www.opencollada.org)"       OFF)
146
147 # Sound output
148 option(WITH_SDL           "Enable SDL for sound and joystick support" ON)
149 option(WITH_OPENAL        "Enable OpenAL Support (http://www.openal.org)" ON)
150 option(WITH_JACK          "Enable Jack Support (http://www.jackaudio.org)" OFF)
151 option(WITH_SAMPLERATE    "Enable samplerate conversion" ON)
152
153 # Compression
154 option(WITH_LZO           "Enable fast LZO compression (used for pointcache)" ON)
155 option(WITH_LZMA          "Enable best LZMA compression, (used for pointcache)" ON)
156
157 # Misc
158 option(WITH_RAYOPTIMIZATION     "Enable use of SIMD (SSE) optimizations for the raytracer" ON) 
159 if(UNIX AND NOT APPLE)
160         option(WITH_INSTALL_PORTABLE "Install redistributeable runtime, otherwise install into CMAKE_INSTALL_PREFIX" ON)
161 endif()
162 option(WITH_PYTHON_INSTALL       "Copy system python into the blender install folder" ON)
163
164 # disable for now, but plan to support on all platforms eventually
165 option(WITH_MEM_JEMALLOC   "Enable malloc replacement (http://www.canonware.com/jemalloc)" OFF)
166 mark_as_advanced(WITH_MEM_JEMALLOC)
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 if(NOT WITH_GAMEENGINE AND WITH_PLAYER)
192         message(FATAL_ERROR "WITH_PLAYER requires WITH_GAMEENGINE")
193 endif()
194
195 if(NOT WITH_SAMPLERATE AND (WITH_OPENAL OR WITH_SDL OR WITH_JACK))
196         message(FATAL_ERROR "WITH_OPENAL/WITH_SDL/WITH_JACK require WITH_SAMPLERATE")
197 endif()
198
199 if(NOT WITH_IMAGE_OPENJPEG AND WITH_IMAGE_REDCODE)
200         message(FATAL_ERROR "WITH_IMAGE_REDCODE requires WITH_IMAGE_OPENJPEG")
201 endif()
202
203 # python module, needs some different options
204 if(WITH_PYTHON_MODULE AND WITH_PLAYER)
205         message(FATAL_ERROR "WITH_PYTHON_MODULE requires WITH_PLAYER to be OFF")
206 endif()
207
208 if(WITH_PYTHON_MODULE AND WITH_PYTHON_INSTALL)
209         message(FATAL_ERROR "WITH_PYTHON_MODULE requires WITH_PYTHON_INSTALL to be OFF")
210 endif()
211
212 # may as well build python module without a UI
213 if(WITH_PYTHON_MODULE)
214         set(WITH_HEADLESS ON)
215 endif()
216
217 # remove old vars
218 unset(WITH_INSTALL CACHE)
219
220 TEST_SSE_SUPPORT()
221
222 #-----------------------------------------------------------------------------
223 # Initialize un-cached vars, avoid unused warning
224
225 # linux only, not cached
226 set(WITH_BINRELOC OFF)
227
228 # these are added to later on.
229 set(C_WARNINGS "")
230 set(CXX_WARNINGS "")
231
232
233 # disabled for now, not supported
234 # option(WITH_WEBPLUGIN     "Enable Web Plugin (Unix only)" OFF)
235
236 # For alternate Python locations the commandline can be used to override detected/default cache settings, e.g:
237 # On Unix: 
238 #   cmake ../blender \
239 #         -D PYTHON_VERSION=3.2 \
240 #         -D PYTHON_INCLUDE_DIRS=/opt/py32/include/python3.2d \
241 #         -D PYTHON_LIBPATH=/opt/py32/lib \
242 #         -D PYTHON_LIBRARY=python3.2d
243 #
244 # On Macs: 
245 #   cmake ../blender \
246 #         -D PYTHON_INCLUDE_DIRS=/System/Library/Frameworks/Python.framework/Versions/3.2/include/python3.2 \
247 #         -D PYTHON_LIBPATH=/System/Library/Frameworks/Python.framework/Versions/3.2/lib/python3.2/config \
248 #         -G Xcode
249 #
250 # When changing any of this remember to update the notes in doc/build_systems/cmake.txt
251
252 #-----------------------------------------------------------------------------
253 #Platform specifics
254
255 if(UNIX AND NOT APPLE)
256         
257         # needed for ubuntu 11.04
258         if(EXISTS "/usr/lib/x86_64-linux-gnu")
259                 set(CMAKE_LIBRARY_PATH "/usr/lib/x86_64-linux-gnu;${CMAKE_LIBRARY_PATH}")
260         endif()
261
262         if(WITH_OPENAL)
263                 find_package(OpenAL)
264                 if(NOT OPENAL_FOUND)
265                         set(WITH_OPENAL OFF)
266                 endif()
267         endif()
268
269         if(WITH_JACK)
270                 set(JACK /usr)
271                 set(JACK_INC ${JACK}/include/jack)
272                 set(JACK_LIB jack)
273                 set(JACK_LIBPATH ${JACK}/lib)
274         endif()
275
276         if(WITH_CODEC_SNDFILE)
277                 set(SNDFILE /usr)
278                 set(SNDFILE_INC ${SNDFILE}/include)
279                 set(SNDFILE_LIB sndfile)
280                 set(SNDFILE_LIBPATH ${SNDFILE}/lib)
281         endif()
282
283         if(WITH_INTERNATIONAL)
284                 find_library(INTL_LIBRARY
285                         NAMES intl
286                         PATHS
287                         /sw/lib
288                 )
289
290                 find_library(ICONV_LIBRARY
291                         NAMES iconv
292                         PATHS
293                         /sw/lib
294                 )
295                 mark_as_advanced(ICONV_LIBRARY)
296                 mark_as_advanced(INTL_LIBRARY)
297
298                 if(INTL_LIBRARY AND ICONV_LIBRARY)
299                         set(GETTEXT_LIB ${INTL_LIBRARY} ${ICONV_LIBRARY})
300                 endif()
301         endif()
302
303         find_package(Freetype)
304         # unset(FREETYPE_INCLUDE_DIRS CACHE) # cant use
305
306
307         if(WITH_PYTHON)
308                 # No way to set py32. remove for now.
309                 # find_package(PythonLibs)
310
311                 # defines...
312                 
313                 #  PYTHON_VERSION
314                 #  PYTHON_INCLUDE_DIRS
315                 #  PYTHON_LIBRARY
316                 #  PYTHON_LIBPATH
317                 #  PYTHON_LINKFLAGS
318
319                 include(build_files/cmake/FindPythonLibsUnix.cmake)
320
321         endif()
322
323         if(WITH_SDL)
324                 find_package(SDL)
325                 mark_as_advanced(SDLMAIN_LIBRARY)
326                 mark_as_advanced(SDL_INCLUDE_DIR)
327                 mark_as_advanced(SDL_LIBRARY)
328                 mark_as_advanced(SDL_LIBRARY_TEMP)
329                 # unset(SDLMAIN_LIBRARY CACHE)
330                 if(NOT SDL_FOUND)
331                         set(WITH_SDL OFF)
332                 endif()
333         endif()
334
335         if(WITH_IMAGE_OPENEXR)
336                 set(OPENEXR /usr CACHE FILEPATH "OPENEXR Directory")
337                 mark_as_advanced(OPENEXR)
338                 find_path(OPENEXR_INC
339                         ImfXdr.h
340                         PATHS
341                         ${OPENEXR}/include/OpenEXR
342                         /usr/local/include/OpenEXR
343                         /sw/include/OpenEXR
344                         /opt/local/include/OpenEXR
345                         /opt/csw/include/OpenEXR
346                         /opt/include/OpenEXR
347                 )
348                 mark_as_advanced(OPENEXR_INC)
349
350                 set(OPENEXR_LIB Half IlmImf Iex Imath)
351                 
352                 if(NOT OPENEXR_INC)
353                         set(WITH_IMAGE_OPENEXR OFF)
354                 endif()
355         endif()
356
357         if(WITH_IMAGE_TIFF)
358                 find_package(TIFF)
359                 if(NOT TIFF_FOUND)
360                         set(WITH_IMAGE_TIFF OFF)
361                 endif()
362         endif()
363
364         find_package(JPEG REQUIRED)
365
366         find_package(PNG REQUIRED)
367
368         find_package(ZLIB REQUIRED)
369
370         if(WITH_CODEC_FFMPEG)
371                 set(FFMPEG /usr CACHE FILEPATH "FFMPEG Directory")
372                 mark_as_advanced(FFMPEG)
373                 set(FFMPEG_INC ${FFMPEG}/include)
374                 set(FFMPEG_LIB avformat avcodec avutil avdevice swscale CACHE STRING "FFMPEG Libraries")
375                 mark_as_advanced(FFMPEG_LIB)
376                 set(FFMPEG_LIBPATH ${FFMPEG}/lib)
377                 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D__STDC_CONSTANT_MACROS")
378         endif()
379
380         if(WITH_FFTW3)
381                 set(FFTW3 /usr)
382                 set(FFTW3_INC ${FFTW3}/include)
383                 set(FFTW3_LIB fftw3)
384                 set(FFTW3_LIBPATH ${FFTW3}/lib)
385         endif()
386
387         if(WITH_SAMPLERATE)
388                 set(LIBSAMPLERATE /usr)
389                 set(LIBSAMPLERATE_INC ${LIBSAMPLERATE}/include)
390                 set(LIBSAMPLERATE_LIB samplerate)
391                 set(LIBSAMPLERATE_LIBPATH ${LIBSAMPLERATE}/lib)
392         endif()
393
394         if(WITH_OPENCOLLADA)
395                 set(OPENCOLLADA /usr/local/opencollada CACHE FILEPATH "OpenCollada Directory")
396                 mark_as_advanced(OPENCOLLADA)
397                 set(OPENCOLLADA_LIBPATH ${OPENCOLLADA}/lib)
398                 set(OPENCOLLADA_LIB OpenCOLLADAStreamWriter OpenCOLLADASaxFrameworkLoader OpenCOLLADAFramework OpenCOLLADABaseUtils GeneratedSaxParser UTF MathMLSolver pcre ftoa buffer xml2)
399                 set(OPENCOLLADA_INC ${OPENCOLLADA})
400
401                 set(PCRE /usr CACHE FILEPATH "PCRE Directory")
402                 mark_as_advanced(PCRE)
403                 set(PCRE_LIBPATH ${PCRE}/lib)
404                 set(PCRE_LIB pcre)
405
406                 set(EXPAT /usr CACHE FILEPATH "Expat Directory")
407                 mark_as_advanced(EXPAT)
408                 set(EXPAT_LIBPATH ${EXPAT}/lib)
409                 set(EXPAT_LIB expat)
410         endif()
411
412         if(WITH_MEM_JEMALLOC)
413                 set(JEMALLOC /usr)
414                 set(JEMALLOC_LIBRARY jemalloc CACHE STRING "JeMalloc library")
415                 set(JEMALLOC_LIBPATH ${JEMALLOC}/lib  CACHE FILEPATH "JeMalloc library path")
416                 # no use for this yet.
417                 # set(JEMALLOC_INCLUDE_DIR ${JEMALLOC}/include  CACHE FILEPATH "JeMalloc include path")
418                 unset(JEMALLOC)
419         endif()
420
421         # OpenSuse needs lutil, ArchLinux not, for now keep, can avoid by using --as-needed
422         set(LLIBS "-lutil -lc -lm -lpthread -lstdc++")
423
424         if(NOT WITH_HEADLESS)
425                 find_package(X11 REQUIRED)
426                 find_path(X11_XF86keysym_INCLUDE_PATH X11/XF86keysym.h ${X11_INC_SEARCH_PATH})
427                 mark_as_advanced(X11_XF86keysym_INCLUDE_PATH)
428
429                 list(APPEND LLIBS ${X11_X11_LIB})
430
431                 if(WITH_X11_XINPUT)
432                         list(APPEND LLIBS ${X11_Xinput_LIB})
433                 endif()
434         endif()
435
436         if(CMAKE_SYSTEM_NAME MATCHES "Linux")
437                 if(NOT WITH_PYTHON_MODULE)
438                         # BSD's dont use libdl.so
439                         list(APPEND LLIBS -ldl)
440
441                         # binreloc is linux only
442                         set(BINRELOC ${CMAKE_SOURCE_DIR}/extern/binreloc)
443                         set(BINRELOC_INC ${BINRELOC}/include)
444                         set(WITH_BINRELOC ON)
445                 endif()
446         endif()
447
448         set(PLATFORM_LINKFLAGS "-pthread")
449
450         set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE")
451         set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE")
452
453         # GNU Compiler
454         if(CMAKE_COMPILER_IS_GNUCC)
455                 set(PLATFORM_CFLAGS "-pipe -fPIC -funsigned-char -fno-strict-aliasing")
456         # Intel C++ Compiler
457         elseif(CMAKE_C_COMPILER_ID MATCHES "Intel")
458                 # think these next two are broken
459                 find_program(XIAR xiar) 
460                 if(XIAR) 
461                         set(CMAKE_AR "${XIAR}")
462                 endif() 
463                 mark_as_advanced(XIAR)
464
465                 find_program(XILD xild) 
466                 if(XILD) 
467                         set(CMAKE_LINKER "${XILD}")
468                 endif() 
469                 mark_as_advanced(XILD)
470
471                 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fp-model precise -prec_div -parallel")
472                 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fp-model precise -prec_div -parallel")
473
474                 # set(PLATFORM_CFLAGS "${PLATFORM_CFLAGS} -diag-enable sc3")
475                 set(PLATFORM_CFLAGS "-pipe -fPIC -funsigned-char -fno-strict-aliasing")
476                 set(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} -static-intel")
477         endif()
478
479 elseif(WIN32)
480
481         # this file is included anyway when building under Windows with cl.exe
482         #  include(${CMAKE_ROOT}/Modules/Platform/Windows-cl.cmake)
483
484         set(LIBDIR ${CMAKE_SOURCE_DIR}/../lib/windows)
485
486         # Setup 64bit and 64bit windows systems
487         if(CMAKE_CL_64)
488                 message("64 bit compiler detected.")
489                 set(LIBDIR ${CMAKE_SOURCE_DIR}/../lib/win64)
490         endif()
491         
492         add_definitions(-DWIN32)
493
494         if(WITH_INTERNATIONAL)
495                 set(ICONV ${LIBDIR}/iconv)
496                 set(ICONV_INC ${ICONV}/include)
497                 set(ICONV_LIB iconv)
498                 set(ICONV_LIBPATH ${ICONV}/lib)
499         endif()
500
501         if(WITH_SAMPLERATE)
502                 set(LIBSAMPLERATE ${LIBDIR}/samplerate)
503                 set(LIBSAMPLERATE_INC ${LIBSAMPLERATE}/include)
504                 set(LIBSAMPLERATE_LIB libsamplerate)
505                 set(LIBSAMPLERATE_LIBPATH ${LIBSAMPLERATE}/lib)
506         endif()
507
508         set(PNG "${LIBDIR}/png")
509         set(PNG_INCLUDE_DIR "${PNG}/include")
510         set(PNG_LIBPATH ${PNG}/lib) # not cmake defined
511
512         set(JPEG "${LIBDIR}/jpeg")
513         set(JPEG_INCLUDE_DIR "${JPEG}/include")
514         set(JPEG_LIBPATH ${JPEG}/lib) # not cmake defined
515
516         set(WINTAB_INC ${LIBDIR}/wintab/include) 
517
518         if(WITH_OPENAL)
519                 set(OPENAL ${LIBDIR}/openal)
520                 set(OPENAL_INCLUDE_DIR ${OPENAL}/include)
521                 set(OPENAL_LIBRARY wrap_oal)
522                 set(OPENAL_LIBPATH ${OPENAL}/lib)
523         endif()
524
525         if(WITH_CODEC_SNDFILE)
526                 set(SNDFILE ${LIBDIR}/sndfile)
527                 set(SNDFILE_INC ${SNDFILE}/include)
528                 set(SNDFILE_LIB libsndfile-1)
529                 set(SNDFILE_LIBPATH ${SNDFILE}/lib)
530         endif()
531
532         if(WITH_SDL)
533                 set(SDL ${LIBDIR}/sdl)
534                 set(SDL_INCLUDE_DIR ${SDL}/include)
535                 set(SDL_LIBRARY SDL)
536                 set(SDL_LIBPATH ${SDL}/lib)
537         endif()
538
539         if(WITH_CODEC_QUICKTIME)
540                 set(QUICKTIME ${LIBDIR}/QTDevWin)
541                 set(QUICKTIME_INC ${QUICKTIME}/CIncludes)
542                 set(QUICKTIME_LIB qtmlClient)
543                 set(QUICKTIME_LIBPATH ${QUICKTIME}/Libraries)
544         endif()
545
546         if(WITH_RAYOPTIMIZATION AND SUPPORT_SSE_BUILD)
547                 add_definitions(-D__SSE__ -D__MMX__)
548         endif()
549
550         if(MSVC)
551                 if(CMAKE_CL_64)
552                         set(LLIBS ws2_32 vfw32 winmm kernel32 user32 gdi32 comdlg32 advapi32 shfolder shell32 ole32 oleaut32 uuid )
553                 else()
554                         set(LLIBS kernel32 user32 gdi32 comdlg32 advapi32 shell32 ole32 oleaut32 uuid ws2_32 vfw32 winmm)
555                 endif()
556                 
557                 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)
558                 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)
559
560                 if(CMAKE_CL_64)
561                         set(CMAKE_CXX_FLAGS_DEBUG "/D_DEBUG /Od /Gm /EHsc /RTC1 /MTd /W3 /nologo /Zi /J" CACHE STRING "MSVC MT flags " FORCE)
562                 else()
563                         set(CMAKE_CXX_FLAGS_DEBUG "/D_DEBUG /Od /Gm /EHsc /RTC1 /MTd /W3 /nologo /ZI /J" CACHE STRING "MSVC MT flags " FORCE)
564                 endif()
565                 set(CMAKE_CXX_FLAGS_RELEASE "/O2 /Ob2 /DNDEBUG /EHsc /MT /W3 /nologo /J" CACHE STRING "MSVC MT flags " FORCE)
566                 set(CMAKE_CXX_FLAGS_MINSIZEREL "/O1 /Ob1 /DNDEBUG /EHsc /MT /W3 /nologo /J" CACHE STRING "MSVC MT flags " FORCE)
567                 set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "/O2 /Ob1 /DNDEBUG /EHsc /MT /W3 /nologo /Zi /J" CACHE STRING "MSVC MT flags " FORCE)
568                 if(CMAKE_CL_64)
569                         set(CMAKE_C_FLAGS_DEBUG "/D_DEBUG /Od /Gm /EHsc /RTC1 /MTd /W3 /nologo /Zi /J" CACHE STRING "MSVC MT flags " FORCE)
570                 else()
571                         set(CMAKE_C_FLAGS_DEBUG "/D_DEBUG /Od /Gm /EHsc /RTC1 /MTd /W3 /nologo /ZI /J" CACHE STRING "MSVC MT flags " FORCE)
572                 endif()
573                 set(CMAKE_C_FLAGS_RELEASE "/O2 /Ob2 /DNDEBUG /EHsc /MT /W3 /nologo /J" CACHE STRING "MSVC MT flags " FORCE)
574                 set(CMAKE_C_FLAGS_MINSIZEREL "/O1 /Ob1 /DNDEBUG /EHsc /MT /W3 /nologo /J" CACHE STRING "MSVC MT flags " FORCE)
575                 set(CMAKE_C_FLAGS_RELWITHDEBINFO "/O2 /Ob1 /DNDEBUG /EHsc /MT /W3 /nologo /Zi /J" CACHE STRING "MSVC MT flags " FORCE)
576
577                 if(WITH_INTERNATIONAL)
578                         set(GETTEXT ${LIBDIR}/gettext)
579                         set(GETTEXT_INC ${GETTEXT}/include)
580                         set(GETTEXT_LIBPATH ${GETTEXT}/lib)
581                         if(CMAKE_CL_64)
582                                 set(GETTEXT_LIB gettext)
583                         else()
584                                 set(GETTEXT_LIB gnu_gettext)
585                         endif()
586                 endif()
587
588                 if(CMAKE_CL_64)
589                         set(PNG_LIBRARIES libpng)
590                 else()
591                         set(PNG_LIBRARIES libpng_st)
592                 endif()
593                 set(JPEG_LIBRARIES libjpeg)
594
595                 set(ZLIB ${LIBDIR}/zlib)
596                 set(ZLIB_INCLUDE_DIRS ${ZLIB}/include)
597                 set(ZLIB_LIBPATH ${ZLIB}/lib)
598                 if(CMAKE_CL_64)
599                         set(ZLIB_LIBRARIES libz)
600                 else()
601                         set(ZLIB_LIBRARIES zlib)
602                 endif()
603
604                 set(PTHREADS ${LIBDIR}/pthreads)
605                 set(PTHREADS_INC ${PTHREADS}/include)
606                 set(PTHREADS_LIBPATH ${PTHREADS}/lib)
607                 set(PTHREADS_LIB pthreadVC2)
608                 
609                 set(FREETYPE ${LIBDIR}/freetype)
610                 set(FREETYPE_INCLUDE_DIRS ${FREETYPE}/include ${FREETYPE}/include/freetype2)
611                 set(FREETYPE_LIBPATH ${FREETYPE}/lib)
612                 set(FREETYPE_LIBRARY freetype2ST)
613
614                 if(WITH_FFTW3)
615                         set(FFTW3 ${LIBDIR}/fftw3)
616                         set(FFTW3_LIB libfftw)
617                         set(FFTW3_INC ${FFTW3}/include)
618                         set(FFTW3_LIBPATH ${FFTW3}/lib)
619                 endif()
620
621                 if(WITH_OPENCOLLADA)
622                         set(OPENCOLLADA ${LIBDIR}/opencollada)
623                         set(OPENCOLLADA_INC ${OPENCOLLADA}/include)
624                         set(OPENCOLLADA_LIBPATH ${OPENCOLLADA}/lib)
625                         set(OPENCOLLADA_LIB OpenCOLLADASaxFrameworkLoader OpenCOLLADAFramework OpenCOLLADABaseUtils OpenCOLLADAStreamWriter MathMLSolver GeneratedSaxParser xml2 buffer ftoa UTF)
626                         set(PCRE_LIB pcre)
627                 endif()
628         
629                 if(WITH_CODEC_FFMPEG)
630                         set(FFMPEG ${LIBDIR}/ffmpeg)
631                         set(FFMPEG_INC ${FFMPEG}/include ${FFMPEG}/include/msvc)
632                         set(FFMPEG_LIB avcodec-52 avformat-52 avdevice-52 avutil-50 swscale-0)
633                         set(FFMPEG_LIBPATH ${FFMPEG}/lib)
634                 endif()
635
636                 if(WITH_IMAGE_OPENEXR)
637                         if(MSVC80)
638                                 set(MSVC_LIB _vs2005)
639                                 set(MSVC_INC)
640                         elseif(MSVC90)
641                                 set(MSVC_LIB _vs2008)
642                                 set(MSVC_INC)
643                         elseif(MSVC10)
644                                 set(MSVC_LIB _vs2010)
645                                 set(MSVC_INC _vs2010)
646                         else()
647                                 set(MSVC_LIB msvc)
648                                 set(MSVC_INC)
649                         endif()
650                         set(OPENEXR ${LIBDIR}/openexr)                  
651                         set(OPENEXR_LIB Iex Half IlmImf Imath IlmThread)
652                         set(OPENEXR_LIBPATH ${OPENEXR}/lib${MSVC_LIB})
653                         set(OPENEXR_INCUDE ${OPENEXR}/include${MSVC_INC})
654                         set(OPENEXR_INC ${OPENEXR_INCUDE}/ ${OPENEXR_INCUDE}/IlmImf ${OPENEXR_INCUDE}/Iex ${OPENEXR_INCUDE}/Imath)
655                 endif()
656
657                 if(WITH_IMAGE_TIFF)
658                         set(TIFF ${LIBDIR}/tiff)
659                         set(TIFF_LIBRARY libtiff)
660                         set(TIFF_INCLUDE_DIR ${TIFF}/include)
661                         set(TIFF_LIBPATH ${TIFF}/lib)
662                 endif()
663
664                 if(WITH_JACK)
665                         set(JACK ${LIBDIR}/jack)
666                         set(JACK_INC ${JACK}/include/jack ${JACK}/include)
667                         set(JACK_LIB libjack)
668                         set(JACK_LIBPATH ${JACK}/lib)
669                 endif()
670
671                 if(WITH_PYTHON)
672                         set(PYTHON ${LIBDIR}/python)
673                         set(PYTHON_VERSION 3.2)
674                         set(PYTHON_INCLUDE_DIRS "${PYTHON}/include/python${PYTHON_VERSION}")
675                         # set(PYTHON_BINARY python) # not used yet
676                         set(PYTHON_LIBRARY python32)
677                         set(PYTHON_LIBPATH ${PYTHON}/lib)
678                 endif()
679
680                 # MSVC only, Mingw doesnt need
681                 if(CMAKE_CL_64)
682                         set(PLATFORM_LINKFLAGS "/MACHINE:X64 /NODEFAULTLIB:libc.lib /STACK:2097152 ")
683                 else()
684                         set(PLATFORM_LINKFLAGS "/NODEFAULTLIB:libc.lib /STACK:2097152 ")
685                 endif()
686
687                 set(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} /NODEFAULTLIB:libcmt.lib;libc.lib ")
688
689         else()
690                 # keep GCC spesific stuff here
691                 if(CMAKE_COMPILER_IS_GNUCC)
692                         set(LLIBS "-lshell32 -lshfolder -lgdi32 -lmsvcrt -lwinmm -lmingw32 -lm -lws2_32 -lz -lstdc++ -lole32 -luuid")
693                         set(PLATFORM_CFLAGS "-pipe -funsigned-char -fno-strict-aliasing")
694
695                         set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE")
696                         set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE")
697                 endif()
698
699                 add_definitions(-DFREE_WINDOWS)
700
701                 set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -D_DEBUG")
702                 set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -D_DEBUG")
703
704                 if(WITH_INTERNATIONAL)
705                         set(GETTEXT ${LIBDIR}/gcc/gettext)
706                         set(GETTEXT_INC ${GETTEXT}/include)
707                         set(GETTEXT_LIBPATH ${GETTEXT}/lib)
708                         set(GETTEXT_LIB intl)
709                 endif()
710
711                 set(JPEG_LIBRARIES libjpeg)
712                 set(PNG_LIBRARIES png)
713
714                 set(ZLIB ${LIBDIR}/zlib)
715                 set(ZLIB_INCLUDE_DIRS ${ZLIB}/include)
716                 set(ZLIB_LIBPATH ${ZLIB}/lib)
717                 set(ZLIB_LIBRARIES z)
718
719                 set(PTHREADS ${LIBDIR}/pthreads)
720                 set(PTHREADS_INC ${PTHREADS}/include)
721                 set(PTHREADS_LIBPATH ${PTHREADS}/lib)
722                 set(PTHREADS_LIB pthreadGC2)
723                 
724                 set(FREETYPE ${LIBDIR}/gcc/freetype)
725                 set(FREETYPE_INCLUDE_DIRS ${FREETYPE}/include ${FREETYPE}/include/freetype2)
726                 set(FREETYPE_LIBPATH ${FREETYPE}/lib)
727                 set(FREETYPE_LIBRARY freetype)
728
729                 if(WITH_FFTW3)
730                         set(FFTW3 ${LIBDIR}/gcc/fftw3)
731                         set(FFTW3_LIB fftw3)
732                         set(FFTW3_INC ${FFTW3}/include)
733                         set(FFTW3_LIBPATH ${FFTW3}/lib)
734                 endif()
735
736                 if(WITH_OPENCOLLADA)
737                         set(OPENCOLLADA ${LIBDIR}/gcc/opencollada)
738                         set(OPENCOLLADA_INC ${OPENCOLLADA}/include)
739                         set(OPENCOLLADA_LIBPATH ${OPENCOLLADA}/lib ${OPENCOLLADA}/lib)
740                         set(OPENCOLLADA_LIB OpenCOLLADAStreamWriter OpenCOLLADASaxFrameworkLoader OpenCOLLADAFramework OpenCOLLADABaseUtils GeneratedSaxParser UTF MathMLSolver expat pcre buffer ftoa)
741                         set(PCRE_LIB pcre)
742                 endif()
743                 
744                 if(WITH_CODEC_FFMPEG)
745                         set(FFMPEG ${LIBDIR}/ffmpeg)
746                         set(FFMPEG_INC ${FFMPEG}/include ${FFMPEG}/include)
747                         set(FFMPEG_LIB avcodec-52 avformat-52 avdevice-52 avutil-50 swscale-0)
748                         set(FFMPEG_LIBPATH ${FFMPEG}/lib)
749                 endif()
750
751                 if(WITH_IMAGE_OPENEXR)
752                         set(OPENEXR ${LIBDIR}/gcc/openexr)
753                         set(OPENEXR_INC ${OPENEXR}/include ${OPENEXR}/include/OpenEXR)
754                         set(OPENEXR_LIB Half IlmImf Imath IlmThread)
755                         set(OPENEXR_LIBPATH ${OPENEXR}/lib)
756
757                         # TODO, gives linking errors, force off
758                         set(WITH_IMAGE_OPENEXR OFF)
759                 endif()
760
761                 if(WITH_IMAGE_TIFF)
762                         set(TIFF ${LIBDIR}/gcc/tiff)
763                         set(TIFF_LIBRARY tiff)
764                         set(TIFF_INCLUDE_DIR ${TIFF}/include)
765                         set(TIFF_LIBPATH ${TIFF}/lib)
766                 endif()
767
768                 if(WITH_JACK)
769                         set(JACK ${LIBDIR}/jack)
770                         set(JACK_INC ${JACK}/include/jack ${JACK}/include)
771                         set(JACK_LIB jack)
772                         set(JACK_LIBPATH ${JACK}/lib)
773                         
774                         # TODO, gives linking errors, force off
775                         set(WITH_JACK OFF)
776                 endif()
777
778                 if(WITH_PYTHON)
779                         set(PYTHON ${LIBDIR}/python)
780                         set(PYTHON_VERSION 3.2)
781                         set(PYTHON_INCLUDE_DIRS "${PYTHON}/include/python${PYTHON_VERSION}")
782                         # set(PYTHON_BINARY python) # not used yet
783                         set(PYTHON_LIBRARY python32mw)
784                         set(PYTHON_LIBPATH ${PYTHON}/lib)
785                 endif()
786
787                 set(PLATFORM_LINKFLAGS "--stack,2097152")
788
789         endif()
790
791         # used in many places so include globally, like OpenGL
792         blender_include_dirs("${PTHREADS_INC}")
793
794 elseif(APPLE)
795
796         if (${CMAKE_OSX_DEPLOYMENT_TARGET} STREQUAL "10.5")
797                 set(WITH_LIBS10.5 ON CACHE BOOL "Use 10.5 libs" FORCE)
798         endif()
799
800         if(WITH_LIBS10.5)
801                 set(LIBDIR ${CMAKE_SOURCE_DIR}/../lib/darwin-9.x.universal)
802         else()
803                 if(CMAKE_OSX_ARCHITECTURES MATCHES i386)
804                         set(LIBDIR ${CMAKE_SOURCE_DIR}/../lib/darwin-8.x.i386)
805                 else()
806                         set(LIBDIR ${CMAKE_SOURCE_DIR}/../lib/darwin-8.0.0-powerpc)
807                 endif()
808         endif()
809         
810
811         if(WITH_OPENAL)
812                 find_package(OpenAL)
813                 if(OPENAL_FOUND)
814                         set(WITH_OPENAL ON)
815                         set(OPENAL_INCLUDE_DIR "${LIBDIR}/openal/include")
816                 else()
817                         set(WITH_OPENAL OFF)
818                 endif()
819         endif()
820
821         if(WITH_JACK)
822                 set(JACK /usr)
823                 set(JACK_INC ${JACK}/include/jack)
824                 set(JACK_LIB jack)
825                 set(JACK_LIBPATH ${JACK}/lib)
826         endif()
827
828         if(WITH_CODEC_SNDFILE)
829                 set(SNDFILE ${LIBDIR}/sndfile)
830                 set(SNDFILE_INC ${SNDFILE}/include)
831                 set(SNDFILE_LIB sndfile FLAC ogg vorbis vorbisenc)
832                 set(SNDFILE_LIBPATH ${SNDFILE}/lib ${FFMPEG}/lib)
833         endif()
834
835         set(PYTHON_VERSION 3.2)
836
837         if(PYTHON_VERSION MATCHES 3.2)
838                 # we use precompiled libraries for py 3.2 and up by default
839
840                 set(PYTHON ${LIBDIR}/python)
841                 set(PYTHON_INCLUDE_DIRS "${PYTHON}/include/python${PYTHON_VERSION}")
842                 # set(PYTHON_BINARY "${PYTHON}/bin/python${PYTHON_VERSION}") # not used yet
843                 set(PYTHON_LIBRARY python${PYTHON_VERSION})
844                 set(PYTHON_LIBPATH "${PYTHON}/lib/python${PYTHON_VERSION}")
845                 # set(PYTHON_LINKFLAGS "-u _PyMac_Error")  # won't  build with this enabled
846         else()
847                 # otherwise, use custom system framework
848
849                 set(PYTHON /System/Library/Frameworks/Python.framework/Versions/)
850                 set(PYTHON_VERSION 3.2)
851                 set(PYTHON_INCLUDE_DIRS "${PYTHON}${PYTHON_VERSION}/include/python${PYTHON_VERSION}")
852                 # set(PYTHON_BINARY ${PYTHON}${PYTHON_VERSION}/bin/python${PYTHON_VERSION}) # not used yet
853                 set(PYTHON_LIBRARY "")
854                 set(PYTHON_LIBPATH ${PYTHON}${PYTHON_VERSION}/lib/python${PYTHON_VERSION}/config)
855                 set(PYTHON_LINKFLAGS "-u _PyMac_Error -framework System -framework Python")
856         endif()
857
858         if(WITH_INTERNATIONAL)
859                 set(GETTEXT ${LIBDIR}/gettext)
860                 set(GETTEXT_INC "${GETTEXT}/include")
861                 set(GETTEXT_LIB intl iconv)
862                 set(GETTEXT_LIBPATH ${GETTEXT}/lib)
863         endif()
864
865         if(WITH_FFTW3)
866                 set(FFTW3 ${LIBDIR}/fftw3)
867                 set(FFTW3_INC ${FFTW3}/include)
868                 set(FFTW3_LIB fftw3)
869                 set(FFTW3_LIBPATH ${FFTW3}/lib)
870         endif()
871
872         set(PNG_LIBRARIES png)
873         set(JPEG_LIBRARIES jpeg)
874
875         set(ZLIB /usr)
876         set(ZLIB_INCLUDE_DIRS "${ZLIB}/include")
877         set(ZLIB_LIBRARIES z bz2)
878
879         set(FREETYPE ${LIBDIR}/freetype)
880         set(FREETYPE_INCLUDE_DIRS ${FREETYPE}/include ${FREETYPE}/include/freetype2)
881         set(FREETYPE_LIBPATH ${FREETYPE}/lib)
882         set(FREETYPE_LIBRARY freetype)
883
884         if(WITH_IMAGE_OPENEXR)
885                 set(OPENEXR ${LIBDIR}/openexr)
886                 set(OPENEXR_INC ${OPENEXR}/include/OpenEXR ${OPENEXR}/include)
887                 set(OPENEXR_LIB Iex Half IlmImf Imath IlmThread)
888                 set(OPENEXR_LIBPATH ${OPENEXR}/lib)
889         endif()
890
891         if(WITH_CODEC_FFMPEG)
892                 set(FFMPEG ${LIBDIR}/ffmpeg)
893                 set(FFMPEG_INC ${FFMPEG}/include)
894                 set(FFMPEG_LIB avcodec avdevice avformat avutil mp3lame swscale x264 xvidcore theora theoradec theoraenc vorbis vorbisenc vorbisfile ogg)
895                 set(FFMPEG_LIBPATH ${FFMPEG}/lib)
896                 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D__STDC_CONSTANT_MACROS")
897         endif()
898
899         if(WITH_SAMPLERATE)
900                 set(LIBSAMPLERATE ${LIBDIR}/samplerate)
901                 set(LIBSAMPLERATE_INC ${LIBSAMPLERATE}/include)
902                 set(LIBSAMPLERATE_LIB samplerate)
903                 set(LIBSAMPLERATE_LIBPATH ${LIBSAMPLERATE}/lib)
904         endif()
905
906         set(LLIBS stdc++ SystemStubs)
907
908         if(WITH_COCOA)
909                 set(PLATFORM_CFLAGS "-pipe -funsigned-char -DGHOST_COCOA")
910                 set(PLATFORM_LINKFLAGS "-fexceptions -framework CoreServices -framework Foundation -framework IOKit -framework AppKit -framework Cocoa -framework Carbon -framework AudioUnit -framework AudioToolbox -framework CoreAudio")
911                 if(USE_QTKIT)
912                         set(PLATFORM_CFLAGS "${PLATFORM_CFLAGS} -DUSE_QTKIT")
913                         set(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} -framework QTKit")
914                         if(CMAKE_OSX_ARCHITECTURES MATCHES i386)
915                                 set(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} -framework QuickTime")
916                                 #libSDL still needs 32bit carbon quicktime 
917                         endif()
918                 elseif(WITH_CODEC_QUICKTIME)
919                         set(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} -framework QuickTime")
920                 endif()
921         else()
922                 set(PLATFORM_CFLAGS "-pipe -funsigned-char")
923                 set(PLATFORM_LINKFLAGS "-fexceptions -framework CoreServices -framework Foundation -framework IOKit -framework AppKit -framework Carbon -framework AGL -framework AudioUnit -framework AudioToolbox -framework CoreAudio -framework QuickTime")
924         endif()
925
926         if(WITH_OPENCOLLADA)
927                 set(OPENCOLLADA ${LIBDIR}/opencollada)
928                 set(OPENCOLLADA_INC ${OPENCOLLADA}/include)
929                 set(OPENCOLLADA_LIBPATH ${OPENCOLLADA}/lib)
930                 set(OPENCOLLADA_LIB "OpenCOLLADASaxFrameworkLoader -lOpenCOLLADAFramework -lOpenCOLLADABaseUtils -lOpenCOLLADAStreamWriter -lMathMLSolver -lGeneratedSaxParser -lUTF -lxml2 -lbuffer -lftoa" )
931                 #pcre is bundled with openCollada
932                 #set(PCRE ${LIBDIR}/pcre)
933                 #set(PCRE_LIBPATH ${PCRE}/lib)
934                 set(PCRE_LIB pcre)
935                 #libxml2 is used
936                 #set(EXPAT ${LIBDIR}/expat)
937                 #set(EXPAT_LIBPATH ${EXPAT}/lib)
938                 set(EXPAT_LIB)
939         endif()
940
941         if(WITH_SDL)
942                 set(SDL ${LIBDIR}/sdl)
943                 set(SDL_INCLUDE_DIR ${SDL}/include)
944                 set(SDL_LIBRARY SDL)
945                 set(SDL_LIBPATH ${SDL}/lib)
946         endif()
947
948         set(PNG "${LIBDIR}/png")
949         set(PNG_INCLUDE_DIR "${PNG}/include")
950         set(PNG_LIBPATH ${PNG}/lib)
951
952         set(JPEG "${LIBDIR}/jpeg")
953         set(JPEG_INCLUDE_DIR "${JPEG}/include")
954         set(JPEG_LIBPATH ${JPEG}/lib)
955
956         if(WITH_IMAGE_TIFF)
957                 set(TIFF ${LIBDIR}/tiff)
958                 set(TIFF_INCLUDE_DIR ${TIFF}/include)
959                 set(TIFF_LIBRARY tiff)
960                 set(TIFF_LIBPATH ${TIFF}/lib)
961         endif()
962
963         set(EXETYPE MACOSX_BUNDLE)
964
965         set(CMAKE_C_FLAGS_DEBUG "-fno-strict-aliasing -g")
966         set(CMAKE_CXX_FLAGS_DEBUG "-fno-strict-aliasing -g")
967         if(CMAKE_OSX_ARCHITECTURES MATCHES "i386")
968                 set(CMAKE_CXX_FLAGS_RELEASE "-O3 -mdynamic-no-pic -ftree-vectorize -msse -msse2 -fvariable-expansion-in-unroller")
969                 set(CMAKE_C_FLAGS_RELEASE "-O3 -mdynamic-no-pic -ftree-vectorize -msse -msse2 -fvariable-expansion-in-unroller")
970         elseif(CMAKE_OSX_ARCHITECTURES MATCHES "x86_64")
971                 set(CMAKE_CXX_FLAGS_RELEASE "-O3 -mdynamic-no-pic -ftree-vectorize -msse -msse2 -msse3 -mssse3 -fvariable-expansion-in-unroller")
972                 set(CMAKE_C_FLAGS_RELEASE "-O3 -mdynamic-no-pic -ftree-vectorize -msse -msse2 -msse3 -mssse3 -fvariable-expansion-in-unroller")
973         else()
974                 set(CMAKE_C_FLAGS_RELEASE "-mdynamic-no-pic -fno-strict-aliasing")
975                 set(CMAKE_CXX_FLAGS_RELEASE "-mdynamic-no-pic -fno-strict-aliasing")
976         endif()
977 endif()
978
979 #-----------------------------------------------------------------------------
980 # Common.
981
982 if(APPLE OR WIN32)
983         if(NOT IS_DIRECTORY "${LIBDIR}")
984                 message(FATAL_ERROR "Apple and Windows require pre-compiled libs at: '${LIBDIR}'")
985         endif()
986 endif()
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 set includes here but this debugging option is off by default.
1149 if(WITH_CXX_GUARDEDALLOC)
1150         include_directories(${CMAKE_SOURCE_DIR}/intern/guardedalloc)
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)