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