e249f25230051717ab8e481674eea0683e0a4e14
[blender.git] / CMakeLists.txt
1 # $Id$
2 # ***** BEGIN GPL LICENSE BLOCK *****
3 #
4 # This program is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU General Public License
6 # as published by the Free Software Foundation; either version 2
7 # of the License, or (at your option) any later version.
8 #
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 # GNU General Public License for more details.
13 #
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software Foundation,
16 # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 #
18 # The Original Code is Copyright (C) 2006, Blender Foundation
19 # All rights reserved.
20 #
21 # The Original Code is: all of this file.
22 #
23 # Contributor(s): Jacques Beaurain.
24 #
25 # ***** END GPL LICENSE BLOCK *****
26
27 #-----------------------------------------------------------------------------
28 # We don't allow in-source builds. This causes no end of troubles because 
29 # all out-of-source builds will use the CMakeCache.txt file there and even 
30 # build the libs and objects in it. It will also conflict with the current 
31 # Makefile system for Blender
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 -G \"Unix Makefiles\" ../blender
42 ")
43 ENDIF(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR})
44
45 CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
46
47 # quiet output for Makefiles, 'make -s' helps too
48 # SET_PROPERTY(GLOBAL PROPERTY RULE_MESSAGES OFF)
49
50 PROJECT(Blender)
51
52 #-----------------------------------------------------------------------------
53 # Redirect output files
54
55 SET(EXECUTABLE_OUTPUT_PATH ${CMAKE_BINARY_DIR}/bin)
56 SET(LIBRARY_OUTPUT_PATH  ${CMAKE_BINARY_DIR}/lib)
57
58 #-----------------------------------------------------------------------------
59 # Load some macros.
60 INCLUDE(build_files/cmake/macros.cmake)
61
62 #-----------------------------------------------------------------------------
63 # Set default config options
64
65 GET_BLENDER_VERSION()
66
67 # Blender internal features
68 OPTION(WITH_INTERNATIONAL "Enable I18N   (International fonts and text)" ON)
69 OPTION(WITH_LCMS          "Enable color correction with lcms" OFF)
70 OPTION(WITH_PYTHON        "Enable Embedded Python API" ON)
71 OPTION(WITH_BUILDINFO     "Include extra build details" ON)
72 OPTION(WITH_ELBEEM        "Enable Elbeem (Fluid Simulation)" ON)
73 OPTION(WITH_FFTW3         "Enable FFTW3 support (Used for smoke and audio effects)" OFF)
74 OPTION(WITH_BULLET        "Enable Bullet (Physics Engine)" ON)
75 OPTION(WITH_GAMEENGINE    "Enable Game Engine" ON)
76 OPTION(WITH_PLAYER        "Build Player" OFF)
77 # (unix defaults to OpenMP On)
78 IF(UNIX AND NOT APPLE)
79         OPTION(WITH_OPENMP        "Enable OpenMP (has to be supported by the compiler)" ON)
80 ELSE()
81         OPTION(WITH_OPENMP        "Enable OpenMP (has to be supported by the compiler)" OFF)
82 ENDIF()
83
84 # Image format support
85 OPTION(WITH_OPENEXR       "Enable OpenEXR Support (http://www.openexr.com)" ON)
86 OPTION(WITH_OPENJPEG      "Enable OpenJpeg Support (http://www.openjpeg.org/)" OFF)
87 OPTION(WITH_TIFF          "Enable LibTIFF Support" ON)
88 OPTION(WITH_DDS           "Enable DDS Support" ON)
89
90 # Audio format support
91 OPTION(WITH_FFMPEG        "Enable FFMPeg Support (http://ffmpeg.mplayerhq.hu/)" OFF)
92 OPTION(WITH_SNDFILE       "Enable libsndfile Support (http://www.mega-nerd.com/libsndfile)" OFF)
93 IF(APPLE OR WIN32)
94         OPTION(WITH_QUICKTIME     "Enable Quicktime Support" OFF)
95 ENDIF(APPLE OR WIN32)
96
97 # 3D format support
98 # disable opencollada on non-apple unix because opencollada has no package for debian
99 IF(UNIX AND NOT APPLE)
100         OPTION(WITH_OPENCOLLADA         "Enable OpenCollada Support (http://www.opencollada.org/)"      OFF)
101 ELSE()
102         OPTION(WITH_OPENCOLLADA         "Enable OpenCollada Support (http://www.opencollada.org/)"      OFF)
103 ENDIF()
104
105 # Sound output
106 OPTION(WITH_SDL           "Enable SDL for sound and joystick support" ON)
107 OPTION(WITH_OPENAL        "Enable OpenAL Support (http://www.openal.org)" ON)
108 OPTION(WITH_JACK          "Enable Jack Support (http://www.jackaudio.org)" OFF)
109
110 # Compression
111 OPTION(WITH_LZO           "Enable fast LZO compression (used for pointcache)" ON)
112 OPTION(WITH_LZMA          "Enable best LZMA compression, (used for pointcache)" ON)
113
114 # Misc
115 OPTION(WITH_RAYOPTIMIZATION     "Enable use of SIMD (SSE) optimizations for the raytracer" ON) 
116 OPTION(WITH_CXX_GUARDEDALLOC "Enable GuardedAlloc for C++ memory allocation tracking" OFF)
117 OPTION(WITH_INSTALL       "Install accompanying scripts and language files needed to run blender" ON)
118 OPTION(WITH_PYTHON_INSTALL       "Copy system python into the blender install folder" ON)
119
120 IF(APPLE)
121         OPTION(WITH_COCOA         "Use Cocoa framework instead of deprecated Carbon" ON)
122         OPTION(USE_QTKIT          "Use QtKit instead of Carbon quicktime (needed for having partial quicktime for 64bit)" OFF)
123         OPTION(WITH_LIBS10.5  "Use 10.5 libs (needed for 64bit builds)" OFF)
124 ENDIF(APPLE)
125
126 IF(NOT WITH_BULLET AND WITH_GAMEENGINE)
127         MESSAGE("WARNING: WITH_GAMEENGINE needs WITH_BULLET")
128 ENDIF(NOT WITH_BULLET AND WITH_GAMEENGINE)
129
130 IF(NOT WITH_GAMEENGINE AND WITH_PLAYER)
131         MESSAGE("WARNING: WITH_PLAYER needs WITH_GAMEENGINE")
132 ENDIF(NOT WITH_GAMEENGINE AND WITH_PLAYER)
133
134 IF(NOT WITH_INSTALL AND WITH_PYTHON_INSTALL)
135         MESSAGE("WARNING: WITH_PYTHON_INSTALL needs WITH_INSTALL")
136 ENDIF(NOT WITH_INSTALL AND WITH_PYTHON_INSTALL)
137
138 TEST_SSE_SUPPORT()
139
140 # disabled for now, not supported
141 # OPTION(WITH_WEBPLUGIN     "Enable Web Plugin (Unix only)" OFF)
142
143 # For alternate Python locations the commandline can be used to override detected/default cache settings, e.g:
144 # On Unix: 
145 #   cmake -D PYTHON_LIB=/usr/local/lib/python3.1/config/libpython3.1.so -D PYTHON_INC=/usr/local/include/python3.1 -G "Unix Makefiles" ../blender
146 # On Macs: 
147 #   cmake -D PYTHON_INC=/System/Library/Frameworks/Python.framework/Versions/3.1/include/python3.1 -D PYTHON_LIBPATH=/System/Library/Frameworks/Python.framework/Versions/3.1/lib/python3.1/config -G Xcode ../blender
148 #
149 # When changing any of this remember to update the notes in doc/blender-cmake.txt
150
151 #-----------------------------------------------------------------------------
152 #Platform specifics
153
154 IF(UNIX AND NOT APPLE)
155
156         IF(WITH_OPENAL)
157                 FIND_PACKAGE(OpenAL)
158                 IF(NOT OPENAL_FOUND)
159                         SET(WITH_OPENAL OFF)
160                 ENDIF(NOT OPENAL_FOUND)
161         ENDIF(WITH_OPENAL)
162
163         IF(WITH_JACK)
164                 SET(JACK /usr)
165                 SET(JACK_INC ${JACK}/include/jack)
166                 SET(JACK_LIB jack)
167                 SET(JACK_LIBPATH ${JACK}/lib)
168         ENDIF(WITH_JACK)
169
170         IF(WITH_SNDFILE)
171         SET(SNDFILE /usr)
172         SET(SNDFILE_INC ${SNDFILE}/include)
173         SET(SNDFILE_LIB sndfile)
174         SET(SNDFILE_LIBPATH ${SNDFILE}/lib)
175         ENDIF(WITH_SNDFILE)
176
177         IF(WITH_INTERNATIONAL)
178                 FIND_LIBRARY(INTL_LIBRARY
179                         NAMES intl
180                         PATHS
181                         /sw/lib
182                 )
183
184                 FIND_LIBRARY(ICONV_LIBRARY
185                         NAMES iconv
186                         PATHS
187                         /sw/lib
188                 )
189
190                 IF(INTL_LIBRARY AND ICONV_LIBRARY)
191                         SET(GETTEXT_LIB ${INTL_LIBRARY} ${ICONV_LIBRARY})
192                 ENDIF(INTL_LIBRARY AND ICONV_LIBRARY)
193         ENDIF(WITH_INTERNATIONAL)
194
195         FIND_PACKAGE(Freetype)
196         # UNSET(FREETYPE_INCLUDE_DIRS CACHE) # cant use
197
198
199         IF(WITH_PYTHON)
200                 # No way to set py31. remove for now.
201                 # FIND_PACKAGE(PythonLibs)
202                 SET(PYTHON /usr)
203                 SET(PYTHON_VERSION 3.1)
204                 SET(PYTHON_INC "${PYTHON}/include/python${PYTHON_VERSION}" CACHE STRING "")
205                 # SET(PYTHON_BINARY python) # not used yet
206                 SET(PYTHON_LIB python${PYTHON_VERSION} CACHE STRING "")
207                 SET(PYTHON_LIBPATH ${PYTHON}/lib CACHE STRING "")
208         
209                 # FIND_PACKAGE(PythonInterp) # not used yet
210                 # SET(PYTHON_BINARY ${PYTHON_EXECUTABLE} CACHE STRING "")
211
212                 SET(PYTHON_LINKFLAGS "-Xlinker -export-dynamic")
213         ENDIF(WITH_PYTHON)
214
215         IF(WITH_SDL)
216                 FIND_PACKAGE(SDL)
217                 # UNSET(SDLMAIN_LIBRARY CACHE)
218                 IF(NOT SDL_FOUND)
219                         SET(WITH_SDL OFF)
220                 ENDIF(NOT SDL_FOUND)
221         ENDIF(WITH_SDL)
222
223         IF(WITH_OPENEXR)
224                 SET(OPENEXR /usr CACHE FILEPATH "OPENEXR Directory")
225                 FIND_PATH(OPENEXR_INC
226                         ImfXdr.h
227                         PATHS
228                         ${OPENEXR}/include/OpenEXR
229                         /usr/local/include/OpenEXR
230                         /sw/include/OpenEXR
231                         /opt/local/include/OpenEXR
232                         /opt/csw/include/OpenEXR
233                         /opt/include/OpenEXR
234                 )
235                 SET(OPENEXR_LIB Half IlmImf Iex Imath)
236                 
237                 IF(NOT OPENEXR_INC)
238                         SET(WITH_OPENEXR OFF)
239                 ENDIF(NOT OPENEXR_INC)
240         ENDIF(WITH_OPENEXR)
241
242         IF(WITH_TIFF)
243                 FIND_PACKAGE(TIFF)
244                 IF(NOT TIFF_FOUND)
245                         SET(WITH_TIFF OFF)
246                 ENDIF(NOT TIFF_FOUND)
247         ENDIF(WITH_TIFF)
248
249         FIND_PACKAGE(JPEG REQUIRED)
250
251         FIND_PACKAGE(PNG REQUIRED)
252
253         FIND_PACKAGE(ZLIB REQUIRED)
254
255         IF(WITH_LCMS)
256                 SET(LCMS /usr CACHE FILEPATH "LCMS directory")
257                 SET(LCMS_INCLUDE_DIR ${LCMS}/include)
258                 SET(LCMS_LIBRARY lcms)
259                 SET(LCMS_LIBPATH ${LCMS}/lib)
260         ENDIF(WITH_LCMS)
261
262         IF(WITH_FFMPEG)
263                 SET(FFMPEG /usr CACHE FILEPATH "FFMPEG Directory")
264                 SET(FFMPEG_INC ${FFMPEG}/include)
265                 SET(FFMPEG_LIB avformat avcodec avutil avdevice swscale CACHE STRING "FFMPEG Libraries")
266                 SET(FFMPEG_LIBPATH ${FFMPEG}/lib)
267                 SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D__STDC_CONSTANT_MACROS")
268         ENDIF(WITH_FFMPEG)
269
270         IF(WITH_FFTW3)
271                 SET(FFTW3 /usr)
272                 SET(FFTW3_INC ${FFTW3}/include)
273                 SET(FFTW3_LIB fftw3)
274                 SET(FFTW3_LIBPATH ${FFTW3}/lib)
275         ENDIF(WITH_FFTW3)
276
277         SET(LIBSAMPLERATE /usr)
278         SET(LIBSAMPLERATE_INC ${LIBSAMPLERATE}/include)
279         SET(LIBSAMPLERATE_LIB samplerate)
280         SET(LIBSAMPLERATE_LIBPATH ${LIBSAMPLERATE}/lib)
281
282         IF (WITH_OPENCOLLADA)
283                 SET(OPENCOLLADA /usr/local/opencollada CACHE FILEPATH "OpenCollada Directory")
284                 SET(OPENCOLLADA_LIBPATH ${OPENCOLLADA}/lib)
285                 SET(OPENCOLLADA_LIB OpenCOLLADAStreamWriter OpenCOLLADASaxFrameworkLoader OpenCOLLADAFramework OpenCOLLADABaseUtils GeneratedSaxParser UTF MathMLSolver pcre ftoa buffer)
286                 SET(OPENCOLLADA_INC ${OPENCOLLADA})
287                 SET(PCRE /usr CACHE FILEPATH "PCRE Directory")
288                 SET(PCRE_LIBPATH ${PCRE}/lib)
289                 SET(PCRE_LIB pcre)
290                 SET(EXPAT /usr CACHE FILEPATH "Expat Directory")
291                 SET(EXPAT_LIBPATH ${EXPAT}/lib)
292                 SET(EXPAT_LIB expat)
293         ENDIF (WITH_OPENCOLLADA)
294
295
296         # Could use ${X11_Xinput_LIB} ${X11_X11_LIB} too
297         SET(LLIBS "-lXi -lutil -lc -lm -lpthread -lstdc++ -lX11")
298
299         IF(CMAKE_SYSTEM_NAME MATCHES "Linux")
300                 # BSD's dont use libdl.so
301                 SET(LLIBS "${LLIBS} -ldl")
302
303                 # binreloc is linux only
304                 SET(BINRELOC ${CMAKE_SOURCE_DIR}/extern/binreloc)
305                 SET(BINRELOC_INC ${BINRELOC}/include)
306         ENDIF(CMAKE_SYSTEM_NAME MATCHES "Linux")
307
308         IF(WITH_OPENMP)
309                 SET(LLIBS "${LLIBS} -lgomp")
310                 SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fopenmp")
311                 SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fopenmp")
312         ENDIF(WITH_OPENMP)
313
314
315         SET(PLATFORM_CFLAGS "-pipe -fPIC -funsigned-char -fno-strict-aliasing -Wno-char-subscripts")
316
317         IF(WITH_RAYOPTIMIZATION AND SUPPORT_SSE_BUILD)
318                 SET(PLATFORM_CFLAGS " -msse -msse2 ${PLATFORM_CFLAGS}")
319                 ADD_DEFINITIONS(-D__SSE__)
320                 ADD_DEFINITIONS(-D__MMX__)
321         ENDIF(WITH_RAYOPTIMIZATION AND SUPPORT_SSE_BUILD)
322
323         SET(PLATFORM_LINKFLAGS "-pthread")
324
325         # Better warnings
326         SET(C_WARNINGS "-Wall -Wextra -Winit-self -Wno-unused-parameter -Wno-ignored-qualifiers -Wno-sign-compare -Wno-missing-field-initializers -Wno-char-subscripts -Wpointer-arith -Wcast-align -Wdeclaration-after-statement -Wno-unknown-pragmas")
327         SET(CXX_WARNINGS "-Wall -Wextra -Winit-self -Wno-unused-parameter -Wno-ignored-qualifiers -Wno-sign-compare -Wno-missing-field-initializers -Wno-invalid-offsetof -Wno-sign-compare")
328
329         INCLUDE_DIRECTORIES(${JPEG_INCLUDE_DIR} ${PNG_INCLUDE_DIR} ${ZLIB_INCLUDE_DIR} )
330 ENDIF(UNIX AND NOT APPLE)
331
332
333 IF(WIN32)
334
335         # this file is included anyway when building under Windows with cl.exe
336         #  INCLUDE(${CMAKE_ROOT}/Modules/Platform/Windows-cl.cmake)
337   
338         SET(LIBDIR ${CMAKE_SOURCE_DIR}/../lib/windows)
339
340         # Setup 64bit and 64bit windows systems
341         IF(CMAKE_CL_64)
342                 message("64 bit compiler detected.")
343                 SET(LIBDIR ${CMAKE_SOURCE_DIR}/../lib/win64)
344         ENDIF(CMAKE_CL_64)
345         
346         ADD_DEFINITIONS(-DWIN32)
347
348         IF(WITH_INTERNATIONAL)
349                 SET(ICONV ${LIBDIR}/iconv)
350                 SET(ICONV_INC ${ICONV}/include)
351                 SET(ICONV_LIB iconv)
352                 SET(ICONV_LIBPATH ${ICONV}/lib)
353         ENDIF(WITH_INTERNATIONAL)
354
355         SET(LIBSAMPLERATE ${LIBDIR}/samplerate)
356         SET(LIBSAMPLERATE_INC ${LIBSAMPLERATE}/include)
357         SET(LIBSAMPLERATE_LIB libsamplerate)
358         SET(LIBSAMPLERATE_LIBPATH ${LIBSAMPLERATE}/lib)
359
360         SET(PNG "${LIBDIR}/png")
361         SET(PNG_INC "${PNG}/include")
362         SET(PNG_LIBPATH ${PNG}/lib)
363
364         SET(JPEG "${LIBDIR}/jpeg")
365         SET(JPEG_INC "${JPEG}/include")
366         SET(JPEG_LIBPATH ${JPEG}/lib)
367
368         SET(WINTAB_INC ${LIBDIR}/wintab/include) 
369
370         IF(WITH_PYTHON)
371                 SET(PYTHON ${LIBDIR}/python)
372                 SET(PYTHON_VERSION 3.1)
373                 SET(PYTHON_INC "${PYTHON}/include/python${PYTHON_VERSION}")
374                 # SET(PYTHON_BINARY python) # not used yet
375                 SET(PYTHON_LIB python31)
376                 SET(PYTHON_LIBPATH ${PYTHON}/lib)
377         ENDIF(WITH_PYTHON)
378
379         IF(WITH_OPENAL)
380                 SET(OPENAL ${LIBDIR}/openal)
381                 SET(OPENAL_INCLUDE_DIR ${OPENAL}/include)
382                 SET(OPENAL_LIBRARY wrap_oal)
383                 SET(OPENAL_LIBPATH ${OPENAL}/lib)
384         ENDIF(WITH_OPENAL)
385
386         IF(WITH_SNDFILE)
387                 SET(SNDFILE ${LIBDIR}/sndfile)
388                 SET(SNDFILE_INC ${SNDFILE}/include)
389                 SET(SNDFILE_LIB libsndfile-1)
390                 SET(SNDFILE_LIBPATH ${SNDFILE}/lib)
391         ENDIF(WITH_SNDFILE)
392
393         IF(WITH_SDL)
394                 SET(SDL ${LIBDIR}/sdl)
395                 SET(SDL_INCLUDE_DIR ${SDL}/include)
396                 SET(SDL_LIBRARY SDL)
397                 SET(SDL_LIBPATH ${SDL}/lib)
398         ENDIF(WITH_SDL)
399
400         IF(WITH_QUICKTIME)
401                 SET(QUICKTIME ${LIBDIR}/QTDevWin)
402                 SET(QUICKTIME_INC ${QUICKTIME}/CIncludes)
403                 SET(QUICKTIME_LIB qtmlClient)
404                 SET(QUICKTIME_LIBPATH ${QUICKTIME}/Libraries)
405         ENDIF(WITH_QUICKTIME)
406
407         IF(WITH_RAYOPTIMIZATION AND SUPPORT_SSE_BUILD)
408                 ADD_DEFINITIONS(-D__SSE__)
409                 ADD_DEFINITIONS(-D__MMX__)
410         ENDIF(WITH_RAYOPTIMIZATION AND SUPPORT_SSE_BUILD)
411
412         IF(MSVC)
413                 IF(CMAKE_CL_64)
414                         SET(LLIBS kernel32 user32 vfw32 winmm ws2_32 )
415                 ELSE(CMAKE_CL_64)
416                         SET(LLIBS kernel32 user32 gdi32 comdlg32 advapi32 shell32 ole32 oleaut32 uuid ws2_32 vfw32 winmm)
417                 ENDIF(CMAKE_CL_64)
418                 
419                 SET(CMAKE_CXX_FLAGS "/D_CRT_NONSTDC_NO_DEPRECATE /D_CRT_SECURE_NO_DEPRECATE /D_SCL_SECURE_NO_DEPRECATE /wd4800 /wd4244 /wd4305" CACHE STRING "MSVC MT C++ flags " FORCE)
420                 SET(CMAKE_C_FLAGS   "/D_CRT_NONSTDC_NO_DEPRECATE /D_CRT_SECURE_NO_DEPRECATE /D_SCL_SECURE_NO_DEPRECATE /wd4800 /wd4244 /wd4305" CACHE STRING "MSVC MT C++ flags " FORCE)
421
422                 SET(CMAKE_CXX_FLAGS_DEBUG "/D_DEBUG /Od /Gm /EHsc /RTC1 /MTd /W3 /nologo /ZI /J" CACHE STRING "MSVC MT flags " FORCE)
423                 SET(CMAKE_CXX_FLAGS_RELEASE "/O2 /Ob2 /DNDEBUG /EHsc /MT /W3 /nologo /J" CACHE STRING "MSVC MT flags " FORCE)
424                 SET(CMAKE_CXX_FLAGS_MINSIZEREL "/O1 /Ob1 /DNDEBUG /EHsc /MT /W3 /nologo /J" CACHE STRING "MSVC MT flags " FORCE)
425                 SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "/O2 /Ob1 /DNDEBUG /EHsc /MT /W3 /nologo /Zi /J" CACHE STRING "MSVC MT flags " FORCE)
426                 SET(CMAKE_C_FLAGS_DEBUG "/D_DEBUG /Od /Gm /EHsc /RTC1 /MTd /W3 /nologo /ZI /J" CACHE STRING "MSVC MT flags " FORCE)
427                 SET(CMAKE_C_FLAGS_RELEASE "/O2 /Ob2 /DNDEBUG /EHsc /MT /W3 /nologo /J" CACHE STRING "MSVC MT flags " FORCE)
428                 SET(CMAKE_C_FLAGS_MINSIZEREL "/O1 /Ob1 /DNDEBUG /EHsc /MT /W3 /nologo /J" CACHE STRING "MSVC MT flags " FORCE)
429                 SET(CMAKE_C_FLAGS_RELWITHDEBINFO "/O2 /Ob1 /DNDEBUG /EHsc /MT /W3 /nologo /Zi /J" CACHE STRING "MSVC MT flags " FORCE)
430                 
431                 IF(WITH_OPENMP)
432                         SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /openmp ")
433                         SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /openmp ")
434                 ENDIF(WITH_OPENMP)
435                 
436                 IF(WITH_INTERNATIONAL)
437                         SET(GETTEXT ${LIBDIR}/gettext)
438                         SET(GETTEXT_INC ${GETTEXT}/include)
439                         SET(GETTEXT_LIBPATH ${GETTEXT}/lib)
440                         IF(CMAKE_CL_64)
441                                 SET(GETTEXT_LIB gettext)
442                         ELSE(CMAKE_CL_64)
443                                 SET(GETTEXT_LIB gnu_gettext)
444                         ENDIF(CMAKE_CL_64)
445                 ENDIF(WITH_INTERNATIONAL)
446
447                 IF(CMAKE_CL_64)
448                         SET(PNG_LIBRARIES libpng)
449                 ELSE(CMAKE_CL_64)
450                         SET(PNG_LIBRARIES libpng_st)
451                 ENDIF(CMAKE_CL_64)
452                 SET(JPEG_LIBRARY libjpeg)
453
454                 SET(ZLIB ${LIBDIR}/zlib)
455                 SET(ZLIB_INC ${ZLIB}/include)
456                 SET(ZLIB_LIBPATH ${ZLIB}/lib)
457                 IF(CMAKE_CL_64)
458                         SET(ZLIB_LIBRARIES libz)
459                 ELSE(CMAKE_CL_64)
460                         SET(ZLIB_LIBRARIES zlib)
461                 ENDIF(CMAKE_CL_64)
462
463                 SET(PTHREADS ${LIBDIR}/pthreads)
464                 SET(PTHREADS_INC ${PTHREADS}/include)
465                 SET(PTHREADS_LIBPATH ${PTHREADS}/lib)
466                 SET(PTHREADS_LIB pthreadVC2)
467                 
468                 SET(FREETYPE ${LIBDIR}/freetype)
469                 SET(FREETYPE_INCLUDE_DIRS ${FREETYPE}/include ${FREETYPE}/include/freetype2)
470                 SET(FREETYPE_LIBPATH ${FREETYPE}/lib)
471                 SET(FREETYPE_LIBRARY freetype2ST)
472
473                 IF(WITH_FFTW3)
474                         SET(FFTW3 ${LIBDIR}/fftw3)
475                         SET(FFTW3_LIB libfftw)
476                         SET(FFTW3_INC ${FFTW3}/include)
477                         SET(FFTW3_LIBPATH ${FFTW3}/lib)
478                 ENDIF(WITH_FFTW3)
479
480                 IF(WITH_OPENCOLLADA)
481                         SET(OPENCOLLADA ${LIBDIR}/opencollada)
482                         SET(OPENCOLLADA_INC ${OPENCOLLADA}/include)
483                         SET(OPENCOLLADA_LIBPATH ${OPENCOLLADA}/lib)
484                         SET(OPENCOLLADA_LIB OpenCOLLADASaxFrameworkLoader OpenCOLLADAFramework OpenCOLLADABaseUtils OpenCOLLADAStreamWriter MathMLSolver GeneratedSaxParser xml2 buffer ftoa)
485                         #pcre is bundled with openCollada
486                         #SET(PCRE ${LIBDIR}/pcre)
487                         #SET(PCRE_LIBPATH ${PCRE}/lib)
488                         SET(PCRE_LIB pcre)
489                 ENDIF(WITH_OPENCOLLADA)
490                 
491                 # TODO: IF(WITH_LCMS)
492         
493                 IF(WITH_FFMPEG)
494                         SET(FFMPEG ${LIBDIR}/ffmpeg)
495                         SET(FFMPEG_INC ${FFMPEG}/include ${FFMPEG}/include/msvc)
496                         SET(FFMPEG_LIB avcodec-52 avformat-52 avdevice-52 avutil-50 swscale-0)
497                         SET(FFMPEG_LIBPATH ${FFMPEG}/lib)
498                 ENDIF(WITH_FFMPEG)
499
500                 IF(WITH_OPENEXR)
501                         SET(OPENEXR ${LIBDIR}/openexr)
502                         SET(OPENEXR_INC ${OPENEXR}/include ${OPENEXR}/include/IlmImf ${OPENEXR}/include/Iex ${OPENEXR}/include/Imath)
503                         SET(OPENEXR_LIB Iex Half IlmImf Imath IlmThread)
504                         IF (MSVC80)
505                                 SET(OPENEXR_LIBPATH ${OPENEXR}/lib_vs2005)
506                         ELSE (MSVC80)
507                                 SET(OPENEXR_LIBPATH ${OPENEXR}/lib_msvc)
508                         ENDIF(MSVC80)
509                         IF (MSVC90)
510                                 SET(OPENEXR_LIBPATH ${OPENEXR}/lib_vs2008)
511                         ENDIF(MSVC90)
512                 ENDIF(WITH_OPENEXR)
513
514                 IF(WITH_TIFF)
515                         SET(TIFF ${LIBDIR}/tiff)
516                         SET(TIFF_LIBRARY libtiff)
517                         SET(TIFF_INCLUDE_DIR ${TIFF}/include)
518                         SET(TIFF_LIBPATH ${TIFF}/lib)
519                 ENDIF(WITH_TIFF)
520
521                 IF(WITH_JACK)
522                         SET(JACK ${LIBDIR}/jack)
523                         SET(JACK_INC ${JACK}/include/jack ${JACK}/include)
524                         SET(JACK_LIB libjack)
525                         SET(JACK_LIBPATH ${JACK}/lib)
526                 ENDIF(WITH_JACK)
527
528                 # MSVC only, Mingw doesnt need
529                 IF(CMAKE_CL_64)
530                         SET(PLATFORM_LINKFLAGS "/MACHINE:X64 /NODEFAULTLIB:libc.lib;MSVCRT.lib ")
531                 ELSE(CMAKE_CL_64)
532                         SET(PLATFORM_LINKFLAGS "/NODEFAULTLIB:libc.lib ")
533                 ENDIF(CMAKE_CL_64)
534           
535                 SET(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} /NODEFAULTLIB:libcmt.lib;libc.lib ")
536
537         ELSE(MSVC) # MINGW
538                 SET(LLIBS "-lshell32 -lshfolder -lgdi32 -lmsvcrt -lwinmm -lmingw32 -lm -lws2_32 -lz -lstdc++ -lole32 -luuid")
539
540                 SET(CMAKE_CXX_FLAGS                "-pipe -funsigned-char -fno-strict-aliasing" CACHE STRING "Mingw C++ flags ")
541                 SET(CMAKE_C_FLAGS                  "-pipe -funsigned-char -fno-strict-aliasing" CACHE STRING "Mingw C flags ")
542
543                 SET(CMAKE_CXX_FLAGS_DEBUG          "-O0 -g" CACHE STRING "Mingw debug C++ flags ")
544                 SET(CMAKE_CXX_FLAGS_RELEASE        "   -O2" CACHE STRING "Mingw release C++ flags ")
545                 SET(CMAKE_CXX_FLAGS_MINSIZEREL     "   -Os" CACHE STRING "Mingw minsize release C++ flags ")
546                 SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O2 -g" CACHE STRING "Mingw release, debug C++ flags ")
547
548                 SET(CMAKE_C_FLAGS_DEBUG            "-O0 -g" CACHE STRING "Mingw debug C flags ")
549                 SET(CMAKE_C_FLAGS_RELEASE          "-O2"    CACHE STRING "Mingw release C flags ")
550                 SET(CMAKE_C_FLAGS_MINSIZEREL       "-Os"    CACHE STRING "Mingw minsize release C flags ")
551                 SET(CMAKE_C_FLAGS_RELWITHDEBINFO   "-O2 -g" CACHE STRING "Mingw release, debug C++ flags ")
552                 ADD_DEFINITIONS(-DFREE_WINDOWS)
553                 
554                 IF(WITH_OPENMP)
555                         SET(LLIBS "${LLIBS} -lgomp")
556                         SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fopenmp")
557                         SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fopenmp")
558                 ENDIF(WITH_OPENMP)
559
560                 IF(WITH_INTERNATIONAL)
561                         SET(GETTEXT ${LIBDIR}/gcc/gettext)
562                         SET(GETTEXT_INC ${GETTEXT}/include)
563                         SET(GETTEXT_LIBPATH ${GETTEXT}/lib)
564                         SET(GETTEXT_LIB intl)
565                 ENDIF(WITH_INTERNATIONAL)
566
567                 SET(JPEG_LIBRARY libjpeg)
568                 SET(PNG_LIBRARIES png)
569
570                 SET(ZLIB ${LIBDIR}/zlib)
571                 SET(ZLIB_INC ${ZLIB}/include)
572                 SET(ZLIB_LIBPATH ${ZLIB}/lib)
573                 SET(ZLIB_LIBRARIES z)
574
575                 SET(PTHREADS ${LIBDIR}/pthreads)
576                 SET(PTHREADS_INC ${PTHREADS}/include)
577                 SET(PTHREADS_LIBPATH ${PTHREADS}/lib)
578                 SET(PTHREADS_LIB pthreadGC2)
579                 
580                 SET(FREETYPE ${LIBDIR}/gcc/freetype)
581                 SET(FREETYPE_INCLUDE_DIRS ${FREETYPE}/include ${FREETYPE}/include/freetype2)
582                 SET(FREETYPE_LIBPATH ${FREETYPE}/lib)
583                 SET(FREETYPE_LIBRARY freetype)
584
585                 IF(WITH_FFTW3)
586                         SET(FFTW3 ${LIBDIR}/gcc/fftw3)
587                         SET(FFTW3_LIB fftw3)
588                         SET(FFTW3_INC ${FFTW3}/include)
589                         SET(FFTW3_LIBPATH ${FFTW3}/lib)
590                 ENDIF(WITH_FFTW3)
591
592                 IF(WITH_OPENCOLLADA)
593                         SET(OPENCOLLADA ${LIBDIR}/gcc/opencollada)
594                         SET(OPENCOLLADA_INC ${OPENCOLLADA}/include)
595                         SET(OPENCOLLADA_LIBPATH ${OPENCOLLADA}/lib ${OPENCOLLADA}/lib)
596                         SET(OPENCOLLADA_LIB OpenCOLLADAStreamWriter OpenCOLLADASaxFrameworkLoader OpenCOLLADAFramework OpenCOLLADABaseUtils GeneratedSaxParser UTF MathMLSolver expat pcre buffer ftoa)
597                         #pcre is bundled with openCollada
598                         #SET(PCRE ${LIBDIR}/pcre)
599                         #SET(PCRE_LIBPATH ${PCRE}/lib)
600                         SET(PCRE_LIB pcre)
601                 ENDIF(WITH_OPENCOLLADA)
602                 
603                 IF(WITH_FFMPEG)
604                         SET(FFMPEG ${LIBDIR}/ffmpeg)
605                         SET(FFMPEG_INC ${FFMPEG}/include ${FFMPEG}/include)
606                         SET(FFMPEG_LIB avcodec-52 avformat-52 avdevice-52 avutil-50 swscale-0)
607                         SET(FFMPEG_LIBPATH ${FFMPEG}/lib)
608                 ENDIF(WITH_FFMPEG)
609
610                 IF(WITH_OPENEXR)
611                         SET(OPENEXR ${LIBDIR}/gcc/openexr)
612                         SET(OPENEXR_INC ${OPENEXR}/include ${OPENEXR}/include/OpenEXR)
613                         SET(OPENEXR_LIB Half IlmImf Imath IlmThread)
614                         SET(OPENEXR_LIBPATH ${OPENEXR}/lib)
615                 ENDIF(WITH_OPENEXR)
616
617                 IF(WITH_TIFF)
618                         SET(TIFF ${LIBDIR}/gcc/tiff)
619                         SET(TIFF_LIBRARY tiff)
620                         SET(TIFF_INCLUDE_DIR ${TIFF}/include)
621                         SET(TIFF_LIBPATH ${TIFF}/lib)
622                 ENDIF(WITH_TIFF)
623
624                 IF(WITH_JACK)
625                         SET(JACK ${LIBDIR}/jack)
626                         SET(JACK_INC ${JACK}/include/jack ${JACK}/include)
627                         SET(JACK_LIB jack)
628                         SET(JACK_LIBPATH ${JACK}/lib)
629                         
630                         # TODO, gives linking errors, force off
631                         SET(WITH_JACK OFF)
632                 ENDIF(WITH_JACK)
633
634                 IF(WITH_RAYOPTIMIZATION AND SUPPORT_SSE_BUILD)
635                         SET(PLATFORM_CFLAGS " -msse -msse2 ${PLATFORM_CFLAGS}")
636                         ADD_DEFINITIONS(-D__SSE__)
637                         ADD_DEFINITIONS(-D__MMX__)
638                 ENDIF(WITH_RAYOPTIMIZATION AND SUPPORT_SSE_BUILD)
639
640         ENDIF(MSVC)
641
642 ENDIF(WIN32)
643
644
645 IF(APPLE)
646         IF(WITH_LIBS10.5)
647                 SET(LIBDIR ${CMAKE_SOURCE_DIR}/../lib/darwin-9.x.universal)
648         ELSE(WITH_LIBS10.5)
649                 IF(CMAKE_OSX_ARCHITECTURES MATCHES i386)
650                         SET(LIBDIR ${CMAKE_SOURCE_DIR}/../lib/darwin-8.x.i386)
651                 ELSE(CMAKE_OSX_ARCHITECTURES MATCHES i386)
652                         SET(LIBDIR ${CMAKE_SOURCE_DIR}/../lib/darwin-8.0.0-powerpc)
653                 ENDIF(CMAKE_OSX_ARCHITECTURES MATCHES i386)
654         ENDIF(WITH_LIBS10.5)
655         
656
657         IF(WITH_OPENAL)
658                 FIND_PACKAGE(OpenAL)
659                 IF(OPENAL_FOUND)
660                         SET(WITH_OPENAL ON)
661                         SET(OPENAL_INCLUDE_DIR "${LIBDIR}/openal/include")
662                 ELSE(OPENAL_FOUND)
663                         SET(WITH_OPENAL OFF)
664                 ENDIF(OPENAL_FOUND)
665         ENDIF(WITH_OPENAL)
666
667         IF(WITH_JACK)
668                 SET(JACK /usr)
669                 SET(JACK_INC ${JACK}/include/jack)
670                 SET(JACK_LIB jack)
671                 SET(JACK_LIBPATH ${JACK}/lib)
672         ENDIF(WITH_JACK)
673
674         IF(WITH_SNDFILE)
675                 SET(SNDFILE ${LIBDIR}/sndfile)
676                 SET(SNDFILE_INC ${SNDFILE}/include)
677                 SET(SNDFILE_LIB sndfile FLAC ogg vorbis vorbisenc)
678                 SET(SNDFILE_LIBPATH ${SNDFILE}/lib ${FFMPEG}/lib)
679         ENDIF(WITH_SNDFILE)
680
681         SET(PYTHON_VERSION 3.1)
682
683         IF(PYTHON_VERSION MATCHES 3.1)
684                 # we use precompiled libraries for py 3.1 and up by default
685
686                 SET(PYTHON ${LIBDIR}/python)
687                 SET(PYTHON_INC "${PYTHON}/include/python${PYTHON_VERSION}")
688                 # SET(PYTHON_BINARY "${PYTHON}/bin/python${PYTHON_VERSION}") # not used yet
689                 SET(PYTHON_LIB python${PYTHON_VERSION})
690                 SET(PYTHON_LIBPATH "${PYTHON}/lib/python${PYTHON_VERSION}")
691                 # SET(PYTHON_LINKFLAGS "-u _PyMac_Error")  # won't  build with this enabled
692         ELSE(PYTHON_VERSION MATCHES 3.1)
693                 # otherwise, use custom system framework
694
695                 SET(PYTHON /System/Library/Frameworks/Python.framework/Versions/)
696                 SET(PYTHON_VERSION 3.1)
697                 SET(PYTHON_INC "${PYTHON}${PYTHON_VERSION}/include/python${PYTHON_VERSION}")
698                 # SET(PYTHON_BINARY ${PYTHON}${PYTHON_VERSION}/bin/python${PYTHON_VERSION}) # not used yet
699                 SET(PYTHON_LIB "")
700                 SET(PYTHON_LIBPATH ${PYTHON}${PYTHON_VERSION}/lib/python${PYTHON_VERSION}/config)
701                 SET(PYTHON_LINKFLAGS "-u _PyMac_Error -framework System -framework Python")
702         ENDIF(PYTHON_VERSION MATCHES 3.1)
703
704         IF(WITH_INTERNATIONAL)
705                 SET(GETTEXT ${LIBDIR}/gettext)
706                 SET(GETTEXT_INC "${GETTEXT}/include")
707                 SET(GETTEXT_LIB intl iconv)
708                 SET(GETTEXT_LIBPATH ${GETTEXT}/lib)
709         ENDIF(WITH_INTERNATIONAL)
710   
711         IF(WITH_FFTW3)
712                 SET(FFTW3 ${LIBDIR}/fftw3)
713                 SET(FFTW3_INC ${FFTW3}/include)
714                 SET(FFTW3_LIB fftw3)
715                 SET(FFTW3_LIBPATH ${FFTW3}/lib)
716         ENDIF(WITH_FFTW3)
717
718         SET(PNG_LIBRARIES png)
719         SET(JPEG_LIBRARY jpeg)
720
721         SET(ZLIB /usr)
722         SET(ZLIB_INC "${ZLIB}/include")
723         SET(ZLIB_LIBRARIES z bz2)
724
725         SET(FREETYPE ${LIBDIR}/freetype)
726         SET(FREETYPE_INCLUDE_DIRS ${FREETYPE}/include ${FREETYPE}/include/freetype2)
727         SET(FREETYPE_LIBPATH ${FREETYPE}/lib)
728         SET(FREETYPE_LIBRARY freetype)
729
730         IF(WITH_OPENEXR)
731                 SET(OPENEXR ${LIBDIR}/openexr)
732                 SET(OPENEXR_INC ${OPENEXR}/include/OpenEXR ${OPENEXR}/include)
733                 SET(OPENEXR_LIB Iex Half IlmImf Imath IlmThread)
734                 SET(OPENEXR_LIBPATH ${OPENEXR}/lib)
735         ENDIF(WITH_OPENEXR)
736
737         IF(WITH_LCMS)
738                 SET(LCMS ${LIBDIR}/lcms)
739                 SET(LCMS_INCLUDE_DIR ${LCMS}/include)
740                 SET(LCMS_LIBRARY lcms)
741                 SET(LCMS_LIBPATH ${LCMS}/lib)
742         ENDIF(WITH_LCMS)
743
744         IF(WITH_FFMPEG)
745                 SET(FFMPEG ${LIBDIR}/ffmpeg)
746                 SET(FFMPEG_INC ${FFMPEG}/include)
747                 SET(FFMPEG_LIB avcodec avdevice avformat avutil mp3lame swscale x264 xvidcore theora theoradec theoraenc vorbis vorbisenc vorbisfile ogg)
748                 SET(FFMPEG_LIBPATH ${FFMPEG}/lib)
749                 SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D__STDC_CONSTANT_MACROS")
750         ENDIF(WITH_FFMPEG)
751
752         SET(LIBSAMPLERATE ${LIBDIR}/samplerate)
753         SET(LIBSAMPLERATE_INC ${LIBSAMPLERATE}/include)
754         SET(LIBSAMPLERATE_LIB samplerate)
755         SET(LIBSAMPLERATE_LIBPATH ${LIBSAMPLERATE}/lib)
756
757         SET(LLIBS stdc++ SystemStubs)
758
759         IF (WITH_COCOA)
760                 SET(PLATFORM_CFLAGS "-pipe -funsigned-char -DGHOST_COCOA")
761                 SET(PLATFORM_LINKFLAGS "-fexceptions -framework CoreServices -framework Foundation -framework IOKit -framework AppKit -framework Cocoa -framework Carbon -framework AudioUnit -framework AudioToolbox -framework CoreAudio")
762                 IF(USE_QTKIT)
763                         SET(PLATFORM_CFLAGS "${PLATFORM_CFLAGS} -DUSE_QTKIT")
764                         SET(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} -framework QTKit")
765                         IF(CMAKE_OSX_ARCHITECTURES MATCHES i386)
766                                 SET(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} -framework QuickTime")
767                                 #libSDL still needs 32bit carbon quicktime 
768                         ENDIF(CMAKE_OSX_ARCHITECTURES MATCHES i386)
769                 ELSEIF(WITH_QUICKTIME)
770                         SET(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} -framework QuickTime")
771                 ENDIF(USE_QTKIT)
772         ELSE (WITH_COCOA)
773                 SET(PLATFORM_CFLAGS "-pipe -funsigned-char")
774                 SET(PLATFORM_LINKFLAGS "-fexceptions -framework CoreServices -framework Foundation -framework IOKit -framework AppKit -framework Carbon -framework AGL -framework AudioUnit -framework AudioToolbox -framework CoreAudio -framework QuickTime")
775         ENDIF (WITH_COCOA)
776
777         IF(WITH_OPENMP)
778                 SET(LLIBS "${LLIBS} -lgomp")
779                 SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fopenmp")
780                 SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fopenmp")
781         ENDIF(WITH_OPENMP)
782
783         IF (WITH_OPENCOLLADA)
784                 SET(OPENCOLLADA ${LIBDIR}/opencollada)
785                 SET(OPENCOLLADA_INC ${OPENCOLLADA}/include)
786                 SET(OPENCOLLADA_LIBPATH ${OPENCOLLADA}/lib)
787                 SET(OPENCOLLADA_LIB "OpenCOLLADASaxFrameworkLoader -lOpenCOLLADAFramework -lOpenCOLLADABaseUtils -lOpenCOLLADAStreamWriter -lMathMLSolver -lGeneratedSaxParser -lUTF -lxml2 -lbuffer -lftoa" )
788                 #pcre is bundled with openCollada
789                 #SET(PCRE ${LIBDIR}/pcre)
790                 #SET(PCRE_LIBPATH ${PCRE}/lib)
791                 SET(PCRE_LIB pcre)
792                 #libxml2 is used
793                 #SET(EXPAT ${LIBDIR}/expat)
794                 #SET(EXPAT_LIBPATH ${EXPAT}/lib)
795                 SET(EXPAT_LIB)
796         ENDIF (WITH_OPENCOLLADA)
797
798         IF(WITH_SDL)
799                 SET(SDL ${LIBDIR}/sdl)
800                 SET(SDL_INCLUDE_DIR ${SDL}/include)
801                 SET(SDL_LIBRARY SDL)
802                 SET(SDL_LIBPATH ${SDL}/lib)
803         ENDIF(WITH_SDL)
804
805         SET(PNG "${LIBDIR}/png")
806         SET(PNG_INC "${PNG}/include")
807         SET(PNG_LIBPATH ${PNG}/lib)
808
809         SET(JPEG "${LIBDIR}/jpeg")
810         SET(JPEG_INC "${JPEG}/include")
811         SET(JPEG_LIBPATH ${JPEG}/lib)
812
813         IF(WITH_TIFF)
814                 SET(TIFF ${LIBDIR}/tiff)
815                 SET(TIFF_INCLUDE_DIR ${TIFF}/include)
816                 SET(TIFF_LIBRARY tiff)
817                 SET(TIFF_LIBPATH ${TIFF}/lib)
818         ENDIF(WITH_TIFF)
819
820         IF(WITH_RAYOPTIMIZATION AND SUPPORT_SSE_BUILD)
821                 SET(PLATFORM_CFLAGS " -msse -msse2 ${PLATFORM_CFLAGS}")
822                 ADD_DEFINITIONS(-D__SSE__)
823                 ADD_DEFINITIONS(-D__MMX__)
824         ENDIF(WITH_RAYOPTIMIZATION AND SUPPORT_SSE_BUILD)
825
826         SET(EXETYPE MACOSX_BUNDLE)
827
828         SET(CMAKE_C_FLAGS_DEBUG "-fno-strict-aliasing -g")
829         SET(CMAKE_CXX_FLAGS_DEBUG "-fno-strict-aliasing -g")
830         IF(CMAKE_OSX_ARCHITECTURES MATCHES "i386")
831                 SET(CMAKE_CXX_FLAGS_RELEASE "-O3 -mdynamic-no-pic -ftree-vectorize -msse -msse2 -fvariable-expansion-in-unroller")
832                 SET(CMAKE_C_FLAGS_RELEASE "-O3 -mdynamic-no-pic -ftree-vectorize -msse -msse2 -fvariable-expansion-in-unroller")
833         ELSEIF(CMAKE_OSX_ARCHITECTURES MATCHES "x86_64")
834                 SET(CMAKE_CXX_FLAGS_RELEASE "-O3 -mdynamic-no-pic -ftree-vectorize -msse -msse2 -msse3 -mssse3 -fvariable-expansion-in-unroller")
835                 SET(CMAKE_C_FLAGS_RELEASE "-O3 -mdynamic-no-pic -ftree-vectorize -msse -msse2 -msse3 -mssse3 -fvariable-expansion-in-unroller")
836         ELSE(CMAKE_OSX_ARCHITECTURES MATCHES "x86_64")
837                 SET(CMAKE_C_FLAGS_RELEASE "-mdynamic-no-pic -fno-strict-aliasing")
838                 SET(CMAKE_CXX_FLAGS_RELEASE "-mdynamic-no-pic -fno-strict-aliasing")
839         ENDIF(CMAKE_OSX_ARCHITECTURES MATCHES "i386")
840
841         # Better warnings
842         SET(C_WARNINGS "-Wall -Wno-char-subscripts -Wpointer-arith -Wcast-align -Wdeclaration-after-statement -Wno-unknown-pragmas")
843         SET(CXX_WARNINGS "-Wall -Wno-invalid-offsetof -Wno-sign-compare")
844
845 ENDIF(APPLE)
846
847
848 # buildinfo
849 IF(WITH_BUILDINFO)
850         # BUILD_PLATFORM and BUILD_PLATFORM are taken from CMake
851         IF(UNIX)
852                 EXEC_PROGRAM("date \"+%Y-%m-%d\"" OUTPUT_VARIABLE BUILD_DATE)
853                 EXEC_PROGRAM("date \"+%H:%M:%S\"" OUTPUT_VARIABLE BUILD_TIME)  
854                 EXEC_PROGRAM("svnversion ${CMAKE_SOURCE_DIR}" OUTPUT_VARIABLE BUILD_REV RETURN_VALUE BUILD_REV_RETURN)
855                 IF(BUILD_REV_RETURN)
856                         SET(BUILD_REV "unknown")
857                 ENDIF(BUILD_REV_RETURN)
858         ENDIF(UNIX)
859         
860         IF(WIN32)
861                 EXEC_PROGRAM("cmd /c date /t" OUTPUT_VARIABLE BUILD_DATE)
862                 EXEC_PROGRAM("cmd /c time /t" OUTPUT_VARIABLE BUILD_TIME)  
863                 EXEC_PROGRAM("svnversion ${CMAKE_SOURCE_DIR}" OUTPUT_VARIABLE BUILD_REV RETURN_VALUE BUILD_REV_RETURN)
864                 IF(BUILD_REV_RETURN)
865                         SET(BUILD_REV "unknown")
866                 ENDIF(BUILD_REV_RETURN)
867         ENDIF(WIN32)
868 ENDIF(WITH_BUILDINFO)
869         
870 #-----------------------------------------------------------------------------
871 # Common.
872 IF(WITH_OPENJPEG)
873         set(OPENJPEG ${CMAKE_SOURCE_DIR}/extern/libopenjpeg)
874         set(OPENJPEG_INC ${OPENJPEG})
875         set(OPENJPEG_LIb extern_libopenjpeg)
876 ENDIF(WITH_OPENJPEG)
877
878 #-----------------------------------------------------------------------------
879 # Blender WebPlugin
880
881 IF(WITH_WEBPLUGIN) 
882         SET(GECKO_DIR "${CMAKE_SOURCE_DIR}/../gecko-sdk/" CACHE PATH "Gecko SDK path")
883         SET(WEBPLUGIN_SANDBOX_MODE "apparmor" CACHE STRING "WEB Plugin sandbox mode, can be apparmor, privsep, none")
884
885         SET(WITH_PLAYER ON)
886 ENDIF(WITH_WEBPLUGIN)
887
888
889 #-----------------------------------------------------------------------------
890 # Configure OpenGL.
891 FIND_PACKAGE(OpenGL)
892 INCLUDE_DIRECTORIES(${OPENGL_INCLUDE_DIR})
893 # UNSET(OPENGL_LIBRARIES CACHE) # not compat with older cmake 
894 # UNSET(OPENGL_xmesa_INCLUDE_DIR CACHE) # not compat with older cmake 
895
896 #-----------------------------------------------------------------------------
897 # Extra compile flags
898 SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${PLATFORM_CFLAGS} ${C_WARNINGS}")
899 SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${PLATFORM_CFLAGS} ${CXX_WARNINGS}")
900
901 # better not define flags here but this is a debugging option thats off by default.
902 IF(WITH_CXX_GUARDEDALLOC)
903         SET(CMAKE_CXX_FLAGS " -DWITH_CXX_GUARDEDALLOC -I${CMAKE_SOURCE_DIR}/intern/guardedalloc ${CMAKE_CXX_FLAGS}")
904 ENDIF(WITH_CXX_GUARDEDALLOC)
905
906 #-----------------------------------------------------------------------------
907 # Libraries
908 FILE(WRITE ${CMAKE_BINARY_DIR}/cmake_blender_libs.txt "")
909 ADD_SUBDIRECTORY(intern)
910 ADD_SUBDIRECTORY(extern)
911 ADD_SUBDIRECTORY(source)
912
913
914 #-----------------------------------------------------------------------------
915 # Blender Application
916 ADD_SUBDIRECTORY(source/creator)
917
918
919 #-----------------------------------------------------------------------------
920 # Blender Player
921 IF(WITH_PLAYER)
922         ADD_SUBDIRECTORY(source/blenderplayer)
923 ENDIF(WITH_PLAYER)