disable redcode support for cmake & scons-freebsd
[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_PYTHON        "Enable Embedded Python API" ON)
70 OPTION(WITH_BUILDINFO     "Include extra build details" ON)
71 OPTION(WITH_IK_ITASC      "Enable ITASC IK solver" ON)
72 OPTION(WITH_FFTW3         "Enable FFTW3 support (Used for smoke and audio effects)" OFF)
73 OPTION(WITH_BULLET        "Enable Bullet (Physics Engine)" ON)
74 OPTION(WITH_GAMEENGINE    "Enable Game Engine" ON)
75 OPTION(WITH_PLAYER        "Build Player" OFF)
76 # (unix defaults to OpenMP On)
77 IF(UNIX AND NOT APPLE)
78         OPTION(WITH_OPENMP        "Enable OpenMP (has to be supported by the compiler)" ON)
79 ELSE()
80         OPTION(WITH_OPENMP        "Enable OpenMP (has to be supported by the compiler)" OFF)
81 ENDIF()
82
83 # Modifiers
84 OPTION(WITH_MOD_FLUID           "Enable Elbeem Modifier (Fluid Simulation)" ON)
85 OPTION(WITH_MOD_DECIMATE        "Enable Decimate Modifier" ON)
86 OPTION(WITH_MOD_BOOLEAN         "Enable Boolean Modifier" ON)
87
88 # Image format support
89 OPTION(WITH_IMAGE_OPENEXR       "Enable OpenEXR Support (http://www.openexr.com)" ON)
90 OPTION(WITH_IMAGE_OPENJPEG      "Enable OpenJpeg Support (http://www.openjpeg.org)" ON)
91 OPTION(WITH_IMAGE_TIFF          "Enable LibTIFF Support" ON)
92 OPTION(WITH_IMAGE_DDS           "Enable DDS Image Support" ON)
93 OPTION(WITH_IMAGE_CINEON        "Enable CINEON and DPX Image Support" ON)
94 OPTION(WITH_IMAGE_HDR           "Enable HDR Image Support" ON)
95 OPTION(WITH_IMAGE_REDCODE       "Enable RedCode Image Support" OFF)
96
97 # Audio/Video format support
98 OPTION(WITH_CODEC_FFMPEG        "Enable FFMPeg Support (http://ffmpeg.mplayerhq.hu)" OFF)
99 OPTION(WITH_CODEC_SNDFILE       "Enable libsndfile Support (http://www.mega-nerd.com/libsndfile)" OFF)
100 IF(APPLE OR (WIN32 AND NOT UNIX))
101         OPTION(WITH_CODEC_QUICKTIME     "Enable Quicktime Support" OFF)
102 ENDIF(APPLE OR (WIN32 AND NOT UNIX))
103
104 # 3D format support
105 # disable opencollada on non-apple unix because opencollada has no package for debian
106 IF(UNIX AND NOT APPLE)
107         OPTION(WITH_OPENCOLLADA         "Enable OpenCollada Support (http://www.opencollada.org)"       OFF)
108 ELSE()
109         OPTION(WITH_OPENCOLLADA         "Enable OpenCollada Support (http://www.opencollada.org)"       OFF)
110 ENDIF()
111
112 # Sound output
113 OPTION(WITH_SDL           "Enable SDL for sound and joystick support" ON)
114 OPTION(WITH_OPENAL        "Enable OpenAL Support (http://www.openal.org)" ON)
115 OPTION(WITH_JACK          "Enable Jack Support (http://www.jackaudio.org)" OFF)
116 OPTION(WITH_SAMPLERATE    "Enable samplerate conversion" ON)
117
118 # Compression
119 OPTION(WITH_LZO           "Enable fast LZO compression (used for pointcache)" ON)
120 OPTION(WITH_LZMA          "Enable best LZMA compression, (used for pointcache)" ON)
121
122 # Misc
123 OPTION(WITH_RAYOPTIMIZATION     "Enable use of SIMD (SSE) optimizations for the raytracer" ON) 
124 OPTION(WITH_CXX_GUARDEDALLOC "Enable GuardedAlloc for C++ memory allocation tracking" OFF)
125 OPTION(WITH_INSTALL       "Install accompanying scripts and language files needed to run blender" ON)
126 OPTION(WITH_PYTHON_INSTALL       "Copy system python into the blender install folder" ON)
127
128 IF(APPLE)
129         OPTION(WITH_COCOA         "Use Cocoa framework instead of deprecated Carbon" ON)
130         OPTION(USE_QTKIT          "Use QtKit instead of Carbon quicktime (needed for having partial quicktime for 64bit)" OFF)
131         OPTION(WITH_LIBS10.5  "Use 10.5 libs (needed for 64bit builds)" OFF)
132 ENDIF(APPLE)
133
134 # only for developers who want to make this functional
135 # OPTION(WITH_LCMS          "Enable color correction with lcms" OFF)
136
137 IF(NOT WITH_GAMEENGINE AND WITH_PLAYER)
138         MESSAGE(FATAL_ERROR "WITH_PLAYER requires WITH_GAMEENGINE")
139 ENDIF(NOT WITH_GAMEENGINE AND WITH_PLAYER)
140
141 IF(NOT WITH_INSTALL AND WITH_PYTHON_INSTALL)
142         MESSAGE("WARNING: WITH_PYTHON_INSTALL requires WITH_INSTALL")
143 ENDIF(NOT WITH_INSTALL AND WITH_PYTHON_INSTALL)
144
145 IF(NOT WITH_SAMPLERATE AND (WITH_OPENAL OR WITH_SDL OR WITH_JACK))
146         MESSAGE(FATAL_ERROR "WITH_OPENAL/WITH_SDL/WITH_JACK require WITH_SAMPLERATE")
147 ENDIF(NOT WITH_SAMPLERATE AND (WITH_OPENAL OR WITH_SDL OR WITH_JACK))
148
149 IF(NOT WITH_IMAGE_OPENJPEG AND WITH_IMAGE_REDCODE)
150         MESSAGE(FATAL_ERROR "WITH_IMAGE_REDCODE requires WITH_IMAGE_OPENJPEG")
151 ENDIF(NOT WITH_IMAGE_OPENJPEG AND WITH_IMAGE_REDCODE)
152
153 TEST_SSE_SUPPORT()
154
155 # disabled for now, not supported
156 # OPTION(WITH_WEBPLUGIN     "Enable Web Plugin (Unix only)" OFF)
157
158 # For alternate Python locations the commandline can be used to override detected/default cache settings, e.g:
159 # On Unix: 
160 #   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
161 # On Macs: 
162 #   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
163 #
164 # When changing any of this remember to update the notes in doc/build_systems/cmake.txt
165
166 #-----------------------------------------------------------------------------
167 #Platform specifics
168
169 IF(UNIX AND NOT APPLE)
170
171         IF(WITH_OPENAL)
172                 FIND_PACKAGE(OpenAL)
173                 IF(NOT OPENAL_FOUND)
174                         SET(WITH_OPENAL OFF)
175                 ENDIF(NOT OPENAL_FOUND)
176         ENDIF(WITH_OPENAL)
177
178         IF(WITH_JACK)
179                 SET(JACK /usr)
180                 SET(JACK_INC ${JACK}/include/jack)
181                 SET(JACK_LIB jack)
182                 SET(JACK_LIBPATH ${JACK}/lib)
183         ENDIF(WITH_JACK)
184
185         IF(WITH_CODEC_SNDFILE)
186                 SET(SNDFILE /usr)
187                 SET(SNDFILE_INC ${SNDFILE}/include)
188                 SET(SNDFILE_LIB sndfile)
189                 SET(SNDFILE_LIBPATH ${SNDFILE}/lib)
190         ENDIF(WITH_CODEC_SNDFILE)
191
192         IF(WITH_INTERNATIONAL)
193                 FIND_LIBRARY(INTL_LIBRARY
194                         NAMES intl
195                         PATHS
196                         /sw/lib
197                 )
198
199                 FIND_LIBRARY(ICONV_LIBRARY
200                         NAMES iconv
201                         PATHS
202                         /sw/lib
203                 )
204
205                 IF(INTL_LIBRARY AND ICONV_LIBRARY)
206                         SET(GETTEXT_LIB ${INTL_LIBRARY} ${ICONV_LIBRARY})
207                 ENDIF(INTL_LIBRARY AND ICONV_LIBRARY)
208         ENDIF(WITH_INTERNATIONAL)
209
210         FIND_PACKAGE(Freetype)
211         # UNSET(FREETYPE_INCLUDE_DIRS CACHE) # cant use
212
213
214         IF(WITH_PYTHON)
215                 # No way to set py31. remove for now.
216                 # FIND_PACKAGE(PythonLibs)
217                 SET(PYTHON /usr)
218                 SET(PYTHON_VERSION 3.1)
219                 SET(PYTHON_INC "${PYTHON}/include/python${PYTHON_VERSION}" CACHE STRING "")
220                 # SET(PYTHON_BINARY python) # not used yet
221                 SET(PYTHON_LIB python${PYTHON_VERSION} CACHE STRING "")
222                 SET(PYTHON_LIBPATH ${PYTHON}/lib CACHE STRING "")
223         
224                 # FIND_PACKAGE(PythonInterp) # not used yet
225                 # SET(PYTHON_BINARY ${PYTHON_EXECUTABLE} CACHE STRING "")
226
227                 SET(PYTHON_LINKFLAGS "-Xlinker -export-dynamic")
228         ENDIF(WITH_PYTHON)
229
230         IF(WITH_SDL)
231                 FIND_PACKAGE(SDL)
232                 # UNSET(SDLMAIN_LIBRARY CACHE)
233                 IF(NOT SDL_FOUND)
234                         SET(WITH_SDL OFF)
235                 ENDIF(NOT SDL_FOUND)
236         ENDIF(WITH_SDL)
237
238         IF(WITH_IMAGE_OPENEXR)
239                 SET(OPENEXR /usr CACHE FILEPATH "OPENEXR Directory")
240                 FIND_PATH(OPENEXR_INC
241                         ImfXdr.h
242                         PATHS
243                         ${OPENEXR}/include/OpenEXR
244                         /usr/local/include/OpenEXR
245                         /sw/include/OpenEXR
246                         /opt/local/include/OpenEXR
247                         /opt/csw/include/OpenEXR
248                         /opt/include/OpenEXR
249                 )
250                 SET(OPENEXR_LIB Half IlmImf Iex Imath)
251                 
252                 IF(NOT OPENEXR_INC)
253                         SET(WITH_IMAGE_OPENEXR OFF)
254                 ENDIF(NOT OPENEXR_INC)
255         ENDIF(WITH_IMAGE_OPENEXR)
256
257         IF(WITH_IMAGE_TIFF)
258                 FIND_PACKAGE(TIFF)
259                 IF(NOT TIFF_FOUND)
260                         SET(WITH_IMAGE_TIFF OFF)
261                 ENDIF(NOT TIFF_FOUND)
262         ENDIF(WITH_IMAGE_TIFF)
263
264         FIND_PACKAGE(JPEG REQUIRED)
265
266         FIND_PACKAGE(PNG REQUIRED)
267
268         FIND_PACKAGE(ZLIB REQUIRED)
269
270         IF(WITH_LCMS)
271                 SET(LCMS /usr CACHE FILEPATH "LCMS directory")
272                 SET(LCMS_INCLUDE_DIR ${LCMS}/include)
273                 SET(LCMS_LIBRARY lcms)
274                 SET(LCMS_LIBPATH ${LCMS}/lib)
275         ENDIF(WITH_LCMS)
276
277         IF(WITH_CODEC_FFMPEG)
278                 SET(FFMPEG /usr CACHE FILEPATH "FFMPEG Directory")
279                 SET(FFMPEG_INC ${FFMPEG}/include)
280                 SET(FFMPEG_LIB avformat avcodec avutil avdevice swscale CACHE STRING "FFMPEG Libraries")
281                 SET(FFMPEG_LIBPATH ${FFMPEG}/lib)
282                 SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D__STDC_CONSTANT_MACROS")
283         ENDIF(WITH_CODEC_FFMPEG)
284
285         IF(WITH_FFTW3)
286                 SET(FFTW3 /usr)
287                 SET(FFTW3_INC ${FFTW3}/include)
288                 SET(FFTW3_LIB fftw3)
289                 SET(FFTW3_LIBPATH ${FFTW3}/lib)
290         ENDIF(WITH_FFTW3)
291
292         IF(WITH_SAMPLERATE)
293                 SET(LIBSAMPLERATE /usr)
294                 SET(LIBSAMPLERATE_INC ${LIBSAMPLERATE}/include)
295                 SET(LIBSAMPLERATE_LIB samplerate)
296                 SET(LIBSAMPLERATE_LIBPATH ${LIBSAMPLERATE}/lib)
297         ENDIF(WITH_SAMPLERATE)
298
299         IF (WITH_OPENCOLLADA)
300                 SET(OPENCOLLADA /usr/local/opencollada CACHE FILEPATH "OpenCollada Directory")
301                 SET(OPENCOLLADA_LIBPATH ${OPENCOLLADA}/lib)
302                 SET(OPENCOLLADA_LIB OpenCOLLADAStreamWriter OpenCOLLADASaxFrameworkLoader OpenCOLLADAFramework OpenCOLLADABaseUtils GeneratedSaxParser UTF MathMLSolver pcre ftoa buffer xml2)
303                 SET(OPENCOLLADA_INC ${OPENCOLLADA})
304                 SET(PCRE /usr CACHE FILEPATH "PCRE Directory")
305                 SET(PCRE_LIBPATH ${PCRE}/lib)
306                 SET(PCRE_LIB pcre)
307                 SET(EXPAT /usr CACHE FILEPATH "Expat Directory")
308                 SET(EXPAT_LIBPATH ${EXPAT}/lib)
309                 SET(EXPAT_LIB expat)
310         ENDIF (WITH_OPENCOLLADA)
311
312         FIND_PACKAGE(X11 REQUIRED)
313
314         # OpenSuse needs lutil, ArchLinux not, for now keep, can avoid by using --as-needed
315         SET(LLIBS "-lutil -lc -lm -lpthread -lstdc++ ${X11_X11_LIB} ${X11_Xinput_LIB}")
316
317         IF(CMAKE_SYSTEM_NAME MATCHES "Linux")
318                 # BSD's dont use libdl.so
319                 LIST(APPEND LLIBS -ldl)
320
321                 # binreloc is linux only
322                 SET(BINRELOC ${CMAKE_SOURCE_DIR}/extern/binreloc)
323                 SET(BINRELOC_INC ${BINRELOC}/include)
324         ENDIF(CMAKE_SYSTEM_NAME MATCHES "Linux")
325
326         SET(PLATFORM_LINKFLAGS "-pthread")
327
328         SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE")
329         SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE")
330
331         # GNU Compiler
332         IF(CMAKE_COMPILER_IS_GNUCC)
333                 SET(PLATFORM_CFLAGS "-pipe -fPIC -funsigned-char -fno-strict-aliasing")
334         
335                 # Better warnings
336                 # note: -Wunused-parameter is added below for all GCC compilers
337                 SET(C_WARNINGS "-Wall -Wno-char-subscripts -Wpointer-arith -Wcast-align -Wdeclaration-after-statement -Wno-unknown-pragmas")
338                 SET(CXX_WARNINGS "-Wall -Wno-invalid-offsetof -Wno-sign-compare")
339
340         # Intel C++ Compiler
341         ELSEIF(CMAKE_C_COMPILER_ID MATCHES "Intel")
342                 # think these next two are broken
343                 FIND_PROGRAM(XIAR xiar) 
344                 IF(XIAR) 
345                         SET(CMAKE_AR "${XIAR}")
346                 ENDIF(XIAR) 
347                 MARK_AS_ADVANCED(XIAR)
348
349                 FIND_PROGRAM(XILD xild) 
350                 IF(XILD) 
351                         SET(CMAKE_LINKER "${XILD}")
352                 ENDIF(XILD) 
353                 MARK_AS_ADVANCED(XILD)
354
355                 SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fp-model precise -prec_div -parallel")
356                 SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fp-model precise -prec_div -parallel")
357
358                 SET(PLATFORM_CFLAGS "-pipe -fPIC -funsigned-char -fno-strict-aliasing")
359
360                 # SET(PLATFORM_CFLAGS "${PLATFORM_CFLAGS} -diag-enable sc3")
361
362                 SET(C_WARNINGS "-Wall -Wpointer-arith -Wno-unknown-pragmas")
363                 SET(CXX_WARNINGS "-Wall -Wno-invalid-offsetof -Wno-sign-compare")
364
365                 SET(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} -static-intel")
366         ENDIF(CMAKE_COMPILER_IS_GNUCC)
367
368 ELSEIF(WIN32)
369
370         # this file is included anyway when building under Windows with cl.exe
371         #  INCLUDE(${CMAKE_ROOT}/Modules/Platform/Windows-cl.cmake)
372
373         SET(LIBDIR ${CMAKE_SOURCE_DIR}/../lib/windows)
374
375         # Setup 64bit and 64bit windows systems
376         IF(CMAKE_CL_64)
377                 MESSAGE("64 bit compiler detected.")
378                 SET(LIBDIR ${CMAKE_SOURCE_DIR}/../lib/win64)
379         ENDIF(CMAKE_CL_64)
380         
381         ADD_DEFINITIONS(-DWIN32)
382
383         IF(WITH_INTERNATIONAL)
384                 SET(ICONV ${LIBDIR}/iconv)
385                 SET(ICONV_INC ${ICONV}/include)
386                 SET(ICONV_LIB iconv)
387                 SET(ICONV_LIBPATH ${ICONV}/lib)
388         ENDIF(WITH_INTERNATIONAL)
389
390         IF(WITH_SAMPLERATE)
391                 SET(LIBSAMPLERATE ${LIBDIR}/samplerate)
392                 SET(LIBSAMPLERATE_INC ${LIBSAMPLERATE}/include)
393                 SET(LIBSAMPLERATE_LIB libsamplerate)
394                 SET(LIBSAMPLERATE_LIBPATH ${LIBSAMPLERATE}/lib)
395         ENDIF(WITH_SAMPLERATE)
396
397         SET(PNG "${LIBDIR}/png")
398         SET(PNG_INC "${PNG}/include")
399         SET(PNG_LIBPATH ${PNG}/lib)
400
401         SET(JPEG "${LIBDIR}/jpeg")
402         SET(JPEG_INC "${JPEG}/include")
403         SET(JPEG_LIBPATH ${JPEG}/lib)
404
405         SET(WINTAB_INC ${LIBDIR}/wintab/include) 
406
407         IF(WITH_OPENAL)
408                 SET(OPENAL ${LIBDIR}/openal)
409                 SET(OPENAL_INCLUDE_DIR ${OPENAL}/include)
410                 SET(OPENAL_LIBRARY wrap_oal)
411                 SET(OPENAL_LIBPATH ${OPENAL}/lib)
412         ENDIF(WITH_OPENAL)
413
414         IF(WITH_CODEC_SNDFILE)
415                 SET(SNDFILE ${LIBDIR}/sndfile)
416                 SET(SNDFILE_INC ${SNDFILE}/include)
417                 SET(SNDFILE_LIB libsndfile-1)
418                 SET(SNDFILE_LIBPATH ${SNDFILE}/lib)
419         ENDIF(WITH_CODEC_SNDFILE)
420
421         IF(WITH_SDL)
422                 SET(SDL ${LIBDIR}/sdl)
423                 SET(SDL_INCLUDE_DIR ${SDL}/include)
424                 SET(SDL_LIBRARY SDL)
425                 SET(SDL_LIBPATH ${SDL}/lib)
426         ENDIF(WITH_SDL)
427
428         IF(WITH_CODEC_QUICKTIME)
429                 SET(QUICKTIME ${LIBDIR}/QTDevWin)
430                 SET(QUICKTIME_INC ${QUICKTIME}/CIncludes)
431                 SET(QUICKTIME_LIB qtmlClient)
432                 SET(QUICKTIME_LIBPATH ${QUICKTIME}/Libraries)
433         ENDIF(WITH_CODEC_QUICKTIME)
434
435         IF(WITH_RAYOPTIMIZATION AND SUPPORT_SSE_BUILD)
436                 ADD_DEFINITIONS(-D__SSE__ -D__MMX__)
437         ENDIF(WITH_RAYOPTIMIZATION AND SUPPORT_SSE_BUILD)
438
439         IF(MSVC)
440                 IF(CMAKE_CL_64)
441                         SET(LLIBS kernel32 user32 vfw32 winmm ws2_32 )
442                 ELSE(CMAKE_CL_64)
443                         SET(LLIBS kernel32 user32 gdi32 comdlg32 advapi32 shell32 ole32 oleaut32 uuid ws2_32 vfw32 winmm)
444                 ENDIF(CMAKE_CL_64)
445                 
446                 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)
447                 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)
448
449                 IF(CMAKE_CL_64)
450                         SET(CMAKE_CXX_FLAGS_DEBUG "/D_DEBUG /Od /Gm /EHsc /RTC1 /MTd /W3 /nologo /Zi /J" CACHE STRING "MSVC MT flags " FORCE)
451                 ELSE(CMAKE_CL_64)
452                         SET(CMAKE_CXX_FLAGS_DEBUG "/D_DEBUG /Od /Gm /EHsc /RTC1 /MTd /W3 /nologo /ZI /J" CACHE STRING "MSVC MT flags " FORCE)
453                 ENDIF(CMAKE_CL_64)
454                 SET(CMAKE_CXX_FLAGS_RELEASE "/O2 /Ob2 /DNDEBUG /EHsc /MT /W3 /nologo /J" CACHE STRING "MSVC MT flags " FORCE)
455                 SET(CMAKE_CXX_FLAGS_MINSIZEREL "/O1 /Ob1 /DNDEBUG /EHsc /MT /W3 /nologo /J" CACHE STRING "MSVC MT flags " FORCE)
456                 SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "/O2 /Ob1 /DNDEBUG /EHsc /MT /W3 /nologo /Zi /J" CACHE STRING "MSVC MT flags " FORCE)
457                 IF(CMAKE_CL_64)
458                         SET(CMAKE_C_FLAGS_DEBUG "/D_DEBUG /Od /Gm /EHsc /RTC1 /MTd /W3 /nologo /Zi /J" CACHE STRING "MSVC MT flags " FORCE)
459                 ELSE(CMAKE_CL_64)
460                         SET(CMAKE_C_FLAGS_DEBUG "/D_DEBUG /Od /Gm /EHsc /RTC1 /MTd /W3 /nologo /ZI /J" CACHE STRING "MSVC MT flags " FORCE)
461                 ENDIF(CMAKE_CL_64)
462                 SET(CMAKE_C_FLAGS_RELEASE "/O2 /Ob2 /DNDEBUG /EHsc /MT /W3 /nologo /J" CACHE STRING "MSVC MT flags " FORCE)
463                 SET(CMAKE_C_FLAGS_MINSIZEREL "/O1 /Ob1 /DNDEBUG /EHsc /MT /W3 /nologo /J" CACHE STRING "MSVC MT flags " FORCE)
464                 SET(CMAKE_C_FLAGS_RELWITHDEBINFO "/O2 /Ob1 /DNDEBUG /EHsc /MT /W3 /nologo /Zi /J" CACHE STRING "MSVC MT flags " FORCE)
465
466                 IF(WITH_INTERNATIONAL)
467                         SET(GETTEXT ${LIBDIR}/gettext)
468                         SET(GETTEXT_INC ${GETTEXT}/include)
469                         SET(GETTEXT_LIBPATH ${GETTEXT}/lib)
470                         IF(CMAKE_CL_64)
471                                 SET(GETTEXT_LIB gettext)
472                         ELSE(CMAKE_CL_64)
473                                 SET(GETTEXT_LIB gnu_gettext)
474                         ENDIF(CMAKE_CL_64)
475                 ENDIF(WITH_INTERNATIONAL)
476
477                 IF(CMAKE_CL_64)
478                         SET(PNG_LIBRARIES libpng)
479                 ELSE(CMAKE_CL_64)
480                         SET(PNG_LIBRARIES libpng_st)
481                 ENDIF(CMAKE_CL_64)
482                 SET(JPEG_LIBRARY libjpeg)
483
484                 SET(ZLIB ${LIBDIR}/zlib)
485                 SET(ZLIB_INC ${ZLIB}/include)
486                 SET(ZLIB_LIBPATH ${ZLIB}/lib)
487                 IF(CMAKE_CL_64)
488                         SET(ZLIB_LIBRARIES libz)
489                 ELSE(CMAKE_CL_64)
490                         SET(ZLIB_LIBRARIES zlib)
491                 ENDIF(CMAKE_CL_64)
492
493                 SET(PTHREADS ${LIBDIR}/pthreads)
494                 SET(PTHREADS_INC ${PTHREADS}/include)
495                 SET(PTHREADS_LIBPATH ${PTHREADS}/lib)
496                 SET(PTHREADS_LIB pthreadVC2)
497                 
498                 SET(FREETYPE ${LIBDIR}/freetype)
499                 SET(FREETYPE_INCLUDE_DIRS ${FREETYPE}/include ${FREETYPE}/include/freetype2)
500                 SET(FREETYPE_LIBPATH ${FREETYPE}/lib)
501                 SET(FREETYPE_LIBRARY freetype2ST)
502
503                 IF(WITH_FFTW3)
504                         SET(FFTW3 ${LIBDIR}/fftw3)
505                         SET(FFTW3_LIB libfftw)
506                         SET(FFTW3_INC ${FFTW3}/include)
507                         SET(FFTW3_LIBPATH ${FFTW3}/lib)
508                 ENDIF(WITH_FFTW3)
509
510                 IF(WITH_OPENCOLLADA)
511                         SET(OPENCOLLADA ${LIBDIR}/opencollada)
512                         SET(OPENCOLLADA_INC ${OPENCOLLADA}/include)
513                         SET(OPENCOLLADA_LIBPATH ${OPENCOLLADA}/lib)
514                         SET(OPENCOLLADA_LIB OpenCOLLADASaxFrameworkLoader OpenCOLLADAFramework OpenCOLLADABaseUtils OpenCOLLADAStreamWriter MathMLSolver GeneratedSaxParser xml2 buffer ftoa)
515                         SET(PCRE_LIB pcre)
516                 ENDIF(WITH_OPENCOLLADA)
517                 
518                 IF(WITH_LCMS)
519                         SET(LCMS ${LIBDIR}/lcms)
520                         SET(LCMS_INCLUDE_DIR ${LCMS}/include)
521                         SET(LCMS_LIBPATH ${LCMS}/lib)
522                         SET(LCMS_LIB lcms)
523                 ENDIF(WITH_LCMS)
524
525                 IF(WITH_CODEC_FFMPEG)
526                         SET(FFMPEG ${LIBDIR}/ffmpeg)
527                         SET(FFMPEG_INC ${FFMPEG}/include ${FFMPEG}/include/msvc)
528                         SET(FFMPEG_LIB avcodec-52 avformat-52 avdevice-52 avutil-50 swscale-0)
529                         SET(FFMPEG_LIBPATH ${FFMPEG}/lib)
530                 ENDIF(WITH_CODEC_FFMPEG)
531
532                 IF(WITH_IMAGE_OPENEXR)
533                         SET(OPENEXR ${LIBDIR}/openexr)
534                         SET(OPENEXR_INC ${OPENEXR}/include ${OPENEXR}/include/IlmImf ${OPENEXR}/include/Iex ${OPENEXR}/include/Imath)
535                         SET(OPENEXR_LIB Iex Half IlmImf Imath IlmThread)
536                         IF (MSVC80)
537                                 SET(OPENEXR_LIBPATH ${OPENEXR}/lib_vs2005)
538                         ELSE (MSVC80)
539                                 SET(OPENEXR_LIBPATH ${OPENEXR}/lib_msvc)
540                         ENDIF(MSVC80)
541                         IF (MSVC90)
542                                 SET(OPENEXR_LIBPATH ${OPENEXR}/lib_vs2008)
543                         ENDIF(MSVC90)
544                 ENDIF(WITH_IMAGE_OPENEXR)
545
546                 IF(WITH_IMAGE_TIFF)
547                         SET(TIFF ${LIBDIR}/tiff)
548                         SET(TIFF_LIBRARY libtiff)
549                         SET(TIFF_INCLUDE_DIR ${TIFF}/include)
550                         SET(TIFF_LIBPATH ${TIFF}/lib)
551                 ENDIF(WITH_IMAGE_TIFF)
552
553                 IF(WITH_JACK)
554                         SET(JACK ${LIBDIR}/jack)
555                         SET(JACK_INC ${JACK}/include/jack ${JACK}/include)
556                         SET(JACK_LIB libjack)
557                         SET(JACK_LIBPATH ${JACK}/lib)
558                 ENDIF(WITH_JACK)
559
560                 IF(WITH_PYTHON)
561                         SET(PYTHON ${LIBDIR}/python)
562                         SET(PYTHON_VERSION 3.1)
563                         SET(PYTHON_INC "${PYTHON}/include/python${PYTHON_VERSION}")
564                         # SET(PYTHON_BINARY python) # not used yet
565                         SET(PYTHON_LIB python31)
566                         SET(PYTHON_LIBPATH ${PYTHON}/lib)
567                 ENDIF(WITH_PYTHON)
568
569                 # MSVC only, Mingw doesnt need
570                 IF(CMAKE_CL_64)
571                         SET(PLATFORM_LINKFLAGS "/MACHINE:X64 /NODEFAULTLIB:libc.lib ")
572                 ELSE(CMAKE_CL_64)
573                         SET(PLATFORM_LINKFLAGS "/NODEFAULTLIB:libc.lib ")
574                 ENDIF(CMAKE_CL_64)
575
576                 SET(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} /NODEFAULTLIB:libcmt.lib;libc.lib ")
577
578         ELSE(MSVC)
579                 # keep GCC spesific stuff here
580                 IF(CMAKE_COMPILER_IS_GNUCC)
581                         SET(LLIBS "-lshell32 -lshfolder -lgdi32 -lmsvcrt -lwinmm -lmingw32 -lm -lws2_32 -lz -lstdc++ -lole32 -luuid")
582                         SET(PLATFORM_CFLAGS "-pipe -funsigned-char -fno-strict-aliasing")
583
584                         # Better warnings
585                         SET(C_WARNINGS "-Wall -Wno-char-subscripts -Wpointer-arith -Wcast-align -Wdeclaration-after-statement -Wno-unknown-pragmas")
586                         SET(CXX_WARNINGS "-Wall -Wno-invalid-offsetof -Wno-sign-compare")
587
588                         SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE")
589                         SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE")
590                 ENDIF(CMAKE_COMPILER_IS_GNUCC)
591
592                 ADD_DEFINITIONS(-DFREE_WINDOWS)
593
594                 SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -D_DEBUG")
595                 SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -D_DEBUG")
596
597                 IF(WITH_INTERNATIONAL)
598                         SET(GETTEXT ${LIBDIR}/gcc/gettext)
599                         SET(GETTEXT_INC ${GETTEXT}/include)
600                         SET(GETTEXT_LIBPATH ${GETTEXT}/lib)
601                         SET(GETTEXT_LIB intl)
602                 ENDIF(WITH_INTERNATIONAL)
603
604                 SET(JPEG_LIBRARY libjpeg)
605                 SET(PNG_LIBRARIES png)
606
607                 SET(ZLIB ${LIBDIR}/zlib)
608                 SET(ZLIB_INC ${ZLIB}/include)
609                 SET(ZLIB_LIBPATH ${ZLIB}/lib)
610                 SET(ZLIB_LIBRARIES z)
611
612                 SET(PTHREADS ${LIBDIR}/pthreads)
613                 SET(PTHREADS_INC ${PTHREADS}/include)
614                 SET(PTHREADS_LIBPATH ${PTHREADS}/lib)
615                 SET(PTHREADS_LIB pthreadGC2)
616                 
617                 SET(FREETYPE ${LIBDIR}/gcc/freetype)
618                 SET(FREETYPE_INCLUDE_DIRS ${FREETYPE}/include ${FREETYPE}/include/freetype2)
619                 SET(FREETYPE_LIBPATH ${FREETYPE}/lib)
620                 SET(FREETYPE_LIBRARY freetype)
621
622                 IF(WITH_FFTW3)
623                         SET(FFTW3 ${LIBDIR}/gcc/fftw3)
624                         SET(FFTW3_LIB fftw3)
625                         SET(FFTW3_INC ${FFTW3}/include)
626                         SET(FFTW3_LIBPATH ${FFTW3}/lib)
627                 ENDIF(WITH_FFTW3)
628
629                 IF(WITH_OPENCOLLADA)
630                         SET(OPENCOLLADA ${LIBDIR}/gcc/opencollada)
631                         SET(OPENCOLLADA_INC ${OPENCOLLADA}/include)
632                         SET(OPENCOLLADA_LIBPATH ${OPENCOLLADA}/lib ${OPENCOLLADA}/lib)
633                         SET(OPENCOLLADA_LIB OpenCOLLADAStreamWriter OpenCOLLADASaxFrameworkLoader OpenCOLLADAFramework OpenCOLLADABaseUtils GeneratedSaxParser UTF MathMLSolver expat pcre buffer ftoa)
634                         SET(PCRE_LIB pcre)
635                 ENDIF(WITH_OPENCOLLADA)
636                 
637                 IF(WITH_CODEC_FFMPEG)
638                         SET(FFMPEG ${LIBDIR}/ffmpeg)
639                         SET(FFMPEG_INC ${FFMPEG}/include ${FFMPEG}/include)
640                         SET(FFMPEG_LIB avcodec-52 avformat-52 avdevice-52 avutil-50 swscale-0)
641                         SET(FFMPEG_LIBPATH ${FFMPEG}/lib)
642                 ENDIF(WITH_CODEC_FFMPEG)
643
644                 IF(WITH_IMAGE_OPENEXR)
645                         SET(OPENEXR ${LIBDIR}/gcc/openexr)
646                         SET(OPENEXR_INC ${OPENEXR}/include ${OPENEXR}/include/OpenEXR)
647                         SET(OPENEXR_LIB Half IlmImf Imath IlmThread)
648                         SET(OPENEXR_LIBPATH ${OPENEXR}/lib)
649
650                         # TODO, gives linking errors, force off
651                         SET(WITH_IMAGE_OPENEXR OFF)
652                 ENDIF(WITH_IMAGE_OPENEXR)
653
654                 IF(WITH_IMAGE_TIFF)
655                         SET(TIFF ${LIBDIR}/gcc/tiff)
656                         SET(TIFF_LIBRARY tiff)
657                         SET(TIFF_INCLUDE_DIR ${TIFF}/include)
658                         SET(TIFF_LIBPATH ${TIFF}/lib)
659                 ENDIF(WITH_IMAGE_TIFF)
660
661                 IF(WITH_JACK)
662                         SET(JACK ${LIBDIR}/jack)
663                         SET(JACK_INC ${JACK}/include/jack ${JACK}/include)
664                         SET(JACK_LIB jack)
665                         SET(JACK_LIBPATH ${JACK}/lib)
666                         
667                         # TODO, gives linking errors, force off
668                         SET(WITH_JACK OFF)
669                 ENDIF(WITH_JACK)
670
671                 IF(WITH_PYTHON)
672                         SET(PYTHON ${LIBDIR}/python)
673                         SET(PYTHON_VERSION 3.1)
674                         SET(PYTHON_INC "${PYTHON}/include/python${PYTHON_VERSION}")
675                         # SET(PYTHON_BINARY python) # not used yet
676                         SET(PYTHON_LIB python31mw)
677                         SET(PYTHON_LIBPATH ${PYTHON}/lib)
678                 ENDIF(WITH_PYTHON)
679
680         ENDIF(MSVC)
681
682         # used in many places so include globally, like OpenGL
683         INCLUDE_DIRECTORIES(${PTHREADS_INC})
684
685 ELSEIF(APPLE)
686
687         IF(WITH_LIBS10.5)
688                 SET(LIBDIR ${CMAKE_SOURCE_DIR}/../lib/darwin-9.x.universal)
689         ELSE(WITH_LIBS10.5)
690                 IF(CMAKE_OSX_ARCHITECTURES MATCHES i386)
691                         SET(LIBDIR ${CMAKE_SOURCE_DIR}/../lib/darwin-8.x.i386)
692                 ELSE(CMAKE_OSX_ARCHITECTURES MATCHES i386)
693                         SET(LIBDIR ${CMAKE_SOURCE_DIR}/../lib/darwin-8.0.0-powerpc)
694                 ENDIF(CMAKE_OSX_ARCHITECTURES MATCHES i386)
695         ENDIF(WITH_LIBS10.5)
696         
697
698         IF(WITH_OPENAL)
699                 FIND_PACKAGE(OpenAL)
700                 IF(OPENAL_FOUND)
701                         SET(WITH_OPENAL ON)
702                         SET(OPENAL_INCLUDE_DIR "${LIBDIR}/openal/include")
703                 ELSE(OPENAL_FOUND)
704                         SET(WITH_OPENAL OFF)
705                 ENDIF(OPENAL_FOUND)
706         ENDIF(WITH_OPENAL)
707
708         IF(WITH_JACK)
709                 SET(JACK /usr)
710                 SET(JACK_INC ${JACK}/include/jack)
711                 SET(JACK_LIB jack)
712                 SET(JACK_LIBPATH ${JACK}/lib)
713         ENDIF(WITH_JACK)
714
715         IF(WITH_CODEC_SNDFILE)
716                 SET(SNDFILE ${LIBDIR}/sndfile)
717                 SET(SNDFILE_INC ${SNDFILE}/include)
718                 SET(SNDFILE_LIB sndfile FLAC ogg vorbis vorbisenc)
719                 SET(SNDFILE_LIBPATH ${SNDFILE}/lib ${FFMPEG}/lib)
720         ENDIF(WITH_CODEC_SNDFILE)
721
722         SET(PYTHON_VERSION 3.1)
723
724         IF(PYTHON_VERSION MATCHES 3.1)
725                 # we use precompiled libraries for py 3.1 and up by default
726
727                 SET(PYTHON ${LIBDIR}/python)
728                 SET(PYTHON_INC "${PYTHON}/include/python${PYTHON_VERSION}")
729                 # SET(PYTHON_BINARY "${PYTHON}/bin/python${PYTHON_VERSION}") # not used yet
730                 SET(PYTHON_LIB python${PYTHON_VERSION})
731                 SET(PYTHON_LIBPATH "${PYTHON}/lib/python${PYTHON_VERSION}")
732                 # SET(PYTHON_LINKFLAGS "-u _PyMac_Error")  # won't  build with this enabled
733         ELSE(PYTHON_VERSION MATCHES 3.1)
734                 # otherwise, use custom system framework
735
736                 SET(PYTHON /System/Library/Frameworks/Python.framework/Versions/)
737                 SET(PYTHON_VERSION 3.1)
738                 SET(PYTHON_INC "${PYTHON}${PYTHON_VERSION}/include/python${PYTHON_VERSION}")
739                 # SET(PYTHON_BINARY ${PYTHON}${PYTHON_VERSION}/bin/python${PYTHON_VERSION}) # not used yet
740                 SET(PYTHON_LIB "")
741                 SET(PYTHON_LIBPATH ${PYTHON}${PYTHON_VERSION}/lib/python${PYTHON_VERSION}/config)
742                 SET(PYTHON_LINKFLAGS "-u _PyMac_Error -framework System -framework Python")
743         ENDIF(PYTHON_VERSION MATCHES 3.1)
744
745         IF(WITH_INTERNATIONAL)
746                 SET(GETTEXT ${LIBDIR}/gettext)
747                 SET(GETTEXT_INC "${GETTEXT}/include")
748                 SET(GETTEXT_LIB intl iconv)
749                 SET(GETTEXT_LIBPATH ${GETTEXT}/lib)
750         ENDIF(WITH_INTERNATIONAL)
751   
752         IF(WITH_FFTW3)
753                 SET(FFTW3 ${LIBDIR}/fftw3)
754                 SET(FFTW3_INC ${FFTW3}/include)
755                 SET(FFTW3_LIB fftw3)
756                 SET(FFTW3_LIBPATH ${FFTW3}/lib)
757         ENDIF(WITH_FFTW3)
758
759         SET(PNG_LIBRARIES png)
760         SET(JPEG_LIBRARY jpeg)
761
762         SET(ZLIB /usr)
763         SET(ZLIB_INC "${ZLIB}/include")
764         SET(ZLIB_LIBRARIES z bz2)
765
766         SET(FREETYPE ${LIBDIR}/freetype)
767         SET(FREETYPE_INCLUDE_DIRS ${FREETYPE}/include ${FREETYPE}/include/freetype2)
768         SET(FREETYPE_LIBPATH ${FREETYPE}/lib)
769         SET(FREETYPE_LIBRARY freetype)
770
771         IF(WITH_IMAGE_OPENEXR)
772                 SET(OPENEXR ${LIBDIR}/openexr)
773                 SET(OPENEXR_INC ${OPENEXR}/include/OpenEXR ${OPENEXR}/include)
774                 SET(OPENEXR_LIB Iex Half IlmImf Imath IlmThread)
775                 SET(OPENEXR_LIBPATH ${OPENEXR}/lib)
776         ENDIF(WITH_IMAGE_OPENEXR)
777
778         IF(WITH_LCMS)
779                 SET(LCMS ${LIBDIR}/lcms)
780                 SET(LCMS_INCLUDE_DIR ${LCMS}/include)
781                 SET(LCMS_LIBRARY lcms)
782                 SET(LCMS_LIBPATH ${LCMS}/lib)
783         ENDIF(WITH_LCMS)
784
785         IF(WITH_CODEC_FFMPEG)
786                 SET(FFMPEG ${LIBDIR}/ffmpeg)
787                 SET(FFMPEG_INC ${FFMPEG}/include)
788                 SET(FFMPEG_LIB avcodec avdevice avformat avutil mp3lame swscale x264 xvidcore theora theoradec theoraenc vorbis vorbisenc vorbisfile ogg)
789                 SET(FFMPEG_LIBPATH ${FFMPEG}/lib)
790                 SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D__STDC_CONSTANT_MACROS")
791         ENDIF(WITH_CODEC_FFMPEG)
792
793         IF(WITH_SAMPLERATE)
794                 SET(LIBSAMPLERATE ${LIBDIR}/samplerate)
795                 SET(LIBSAMPLERATE_INC ${LIBSAMPLERATE}/include)
796                 SET(LIBSAMPLERATE_LIB samplerate)
797                 SET(LIBSAMPLERATE_LIBPATH ${LIBSAMPLERATE}/lib)
798         ENDIF(WITH_SAMPLERATE)
799
800         SET(LLIBS stdc++ SystemStubs)
801
802         IF (WITH_COCOA)
803                 SET(PLATFORM_CFLAGS "-pipe -funsigned-char -DGHOST_COCOA")
804                 SET(PLATFORM_LINKFLAGS "-fexceptions -framework CoreServices -framework Foundation -framework IOKit -framework AppKit -framework Cocoa -framework Carbon -framework AudioUnit -framework AudioToolbox -framework CoreAudio")
805                 IF(USE_QTKIT)
806                         SET(PLATFORM_CFLAGS "${PLATFORM_CFLAGS} -DUSE_QTKIT")
807                         SET(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} -framework QTKit")
808                         IF(CMAKE_OSX_ARCHITECTURES MATCHES i386)
809                                 SET(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} -framework QuickTime")
810                                 #libSDL still needs 32bit carbon quicktime 
811                         ENDIF(CMAKE_OSX_ARCHITECTURES MATCHES i386)
812                 ELSEIF(WITH_CODEC_QUICKTIME)
813                         SET(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} -framework QuickTime")
814                 ENDIF(USE_QTKIT)
815         ELSE (WITH_COCOA)
816                 SET(PLATFORM_CFLAGS "-pipe -funsigned-char")
817                 SET(PLATFORM_LINKFLAGS "-fexceptions -framework CoreServices -framework Foundation -framework IOKit -framework AppKit -framework Carbon -framework AGL -framework AudioUnit -framework AudioToolbox -framework CoreAudio -framework QuickTime")
818         ENDIF (WITH_COCOA)
819
820         IF (WITH_OPENCOLLADA)
821                 SET(OPENCOLLADA ${LIBDIR}/opencollada)
822                 SET(OPENCOLLADA_INC ${OPENCOLLADA}/include)
823                 SET(OPENCOLLADA_LIBPATH ${OPENCOLLADA}/lib)
824                 SET(OPENCOLLADA_LIB "OpenCOLLADASaxFrameworkLoader -lOpenCOLLADAFramework -lOpenCOLLADABaseUtils -lOpenCOLLADAStreamWriter -lMathMLSolver -lGeneratedSaxParser -lUTF -lxml2 -lbuffer -lftoa" )
825                 #pcre is bundled with openCollada
826                 #SET(PCRE ${LIBDIR}/pcre)
827                 #SET(PCRE_LIBPATH ${PCRE}/lib)
828                 SET(PCRE_LIB pcre)
829                 #libxml2 is used
830                 #SET(EXPAT ${LIBDIR}/expat)
831                 #SET(EXPAT_LIBPATH ${EXPAT}/lib)
832                 SET(EXPAT_LIB)
833         ENDIF (WITH_OPENCOLLADA)
834
835         IF(WITH_SDL)
836                 SET(SDL ${LIBDIR}/sdl)
837                 SET(SDL_INCLUDE_DIR ${SDL}/include)
838                 SET(SDL_LIBRARY SDL)
839                 SET(SDL_LIBPATH ${SDL}/lib)
840         ENDIF(WITH_SDL)
841
842         SET(PNG "${LIBDIR}/png")
843         SET(PNG_INC "${PNG}/include")
844         SET(PNG_LIBPATH ${PNG}/lib)
845
846         SET(JPEG "${LIBDIR}/jpeg")
847         SET(JPEG_INC "${JPEG}/include")
848         SET(JPEG_LIBPATH ${JPEG}/lib)
849
850         IF(WITH_IMAGE_TIFF)
851                 SET(TIFF ${LIBDIR}/tiff)
852                 SET(TIFF_INCLUDE_DIR ${TIFF}/include)
853                 SET(TIFF_LIBRARY tiff)
854                 SET(TIFF_LIBPATH ${TIFF}/lib)
855         ENDIF(WITH_IMAGE_TIFF)
856
857         SET(EXETYPE MACOSX_BUNDLE)
858
859         SET(CMAKE_C_FLAGS_DEBUG "-fno-strict-aliasing -g")
860         SET(CMAKE_CXX_FLAGS_DEBUG "-fno-strict-aliasing -g")
861         IF(CMAKE_OSX_ARCHITECTURES MATCHES "i386")
862                 SET(CMAKE_CXX_FLAGS_RELEASE "-O3 -mdynamic-no-pic -ftree-vectorize -msse -msse2 -fvariable-expansion-in-unroller")
863                 SET(CMAKE_C_FLAGS_RELEASE "-O3 -mdynamic-no-pic -ftree-vectorize -msse -msse2 -fvariable-expansion-in-unroller")
864         ELSEIF(CMAKE_OSX_ARCHITECTURES MATCHES "x86_64")
865                 SET(CMAKE_CXX_FLAGS_RELEASE "-O3 -mdynamic-no-pic -ftree-vectorize -msse -msse2 -msse3 -mssse3 -fvariable-expansion-in-unroller")
866                 SET(CMAKE_C_FLAGS_RELEASE "-O3 -mdynamic-no-pic -ftree-vectorize -msse -msse2 -msse3 -mssse3 -fvariable-expansion-in-unroller")
867         ELSE(CMAKE_OSX_ARCHITECTURES MATCHES "x86_64")
868                 SET(CMAKE_C_FLAGS_RELEASE "-mdynamic-no-pic -fno-strict-aliasing")
869                 SET(CMAKE_CXX_FLAGS_RELEASE "-mdynamic-no-pic -fno-strict-aliasing")
870         ENDIF(CMAKE_OSX_ARCHITECTURES MATCHES "i386")
871
872         # Better warnings
873         SET(C_WARNINGS "-Wall -Wno-char-subscripts -Wpointer-arith -Wcast-align -Wdeclaration-after-statement -Wno-unknown-pragmas")
874         SET(CXX_WARNINGS "-Wall -Wno-invalid-offsetof -Wno-sign-compare")
875
876 ENDIF(UNIX AND NOT APPLE)
877
878
879 # buildinfo
880 IF(WITH_BUILDINFO)
881         # BUILD_PLATFORM and BUILD_PLATFORM are taken from CMake
882         IF(UNIX)
883                 EXEC_PROGRAM("date \"+%Y-%m-%d\"" OUTPUT_VARIABLE BUILD_DATE)
884                 EXEC_PROGRAM("date \"+%H:%M:%S\"" OUTPUT_VARIABLE BUILD_TIME)  
885                 EXEC_PROGRAM("svnversion ${CMAKE_SOURCE_DIR}" OUTPUT_VARIABLE BUILD_REV RETURN_VALUE BUILD_REV_RETURN)
886                 IF(BUILD_REV_RETURN)
887                         SET(BUILD_REV "unknown")
888                 ENDIF(BUILD_REV_RETURN)
889         ENDIF(UNIX)
890         
891         IF(WIN32)
892                 EXEC_PROGRAM("cmd /c date /t" OUTPUT_VARIABLE BUILD_DATE)
893                 EXEC_PROGRAM("cmd /c time /t" OUTPUT_VARIABLE BUILD_TIME)  
894                 EXEC_PROGRAM("svnversion ${CMAKE_SOURCE_DIR}" OUTPUT_VARIABLE BUILD_REV RETURN_VALUE BUILD_REV_RETURN)
895                 IF(BUILD_REV_RETURN)
896                         SET(BUILD_REV "unknown")
897                 ENDIF(BUILD_REV_RETURN)
898         ENDIF(WIN32)
899 ENDIF(WITH_BUILDINFO)
900 #-----------------------------------------------------------------------------
901 # Common.
902
903 IF(WITH_RAYOPTIMIZATION)
904         IF(CMAKE_COMPILER_IS_GNUCC)
905                 IF(SUPPORT_SSE_BUILD)
906                         SET(PLATFORM_CFLAGS " -msse ${PLATFORM_CFLAGS}")
907                         ADD_DEFINITIONS(-D__SSE__ -D__MMX__)
908                 ENDIF(SUPPORT_SSE_BUILD)
909                 IF(SUPPORT_SSE2_BUILD)
910                         SET(PLATFORM_CFLAGS " -msse2 ${PLATFORM_CFLAGS}")
911                         ADD_DEFINITIONS(-D__SSE2__)
912                         IF(NOT SUPPORT_SSE_BUILD) # dont double up
913                                 ADD_DEFINITIONS(-D__MMX__)
914                         ENDIF(NOT SUPPORT_SSE_BUILD)
915                 ENDIF(SUPPORT_SSE2_BUILD)
916         ENDIF(CMAKE_COMPILER_IS_GNUCC)
917 ENDIF(WITH_RAYOPTIMIZATION)
918
919 IF(WITH_IMAGE_OPENJPEG)
920         set(OPENJPEG ${CMAKE_SOURCE_DIR}/extern/libopenjpeg)
921         set(OPENJPEG_INC ${OPENJPEG})
922 ENDIF(WITH_IMAGE_OPENJPEG)
923
924 IF(WITH_IMAGE_REDCODE)
925         set(REDCODE ${CMAKE_SOURCE_DIR}/extern)
926         set(REDCODE_INC ${REDCODE})
927 ENDIF(WITH_IMAGE_REDCODE)
928
929 #-----------------------------------------------------------------------------
930 # Blender WebPlugin
931
932 IF(WITH_WEBPLUGIN) 
933         SET(GECKO_DIR "${CMAKE_SOURCE_DIR}/../gecko-sdk/" CACHE PATH "Gecko SDK path")
934         SET(WEBPLUGIN_SANDBOX_MODE "apparmor" CACHE STRING "WEB Plugin sandbox mode, can be apparmor, privsep, none")
935
936         SET(WITH_PLAYER ON)
937 ENDIF(WITH_WEBPLUGIN)
938
939
940 #-----------------------------------------------------------------------------
941 # Configure OpenGL.
942 FIND_PACKAGE(OpenGL)
943 INCLUDE_DIRECTORIES(${OPENGL_INCLUDE_DIR})
944 # UNSET(OPENGL_LIBRARIES CACHE) # not compat with older cmake 
945 # UNSET(OPENGL_xmesa_INCLUDE_DIR CACHE) # not compat with older cmake 
946
947 #-----------------------------------------------------------------------------
948 # Configure OpenMP.
949 IF(WITH_OPENMP)
950         FIND_PACKAGE(OpenMP)    
951         IF(OPENMP_FOUND)
952                 SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
953                 SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
954
955                 IF(APPLE AND ${CMAKE_GENERATOR} MATCHES "Xcode")
956                         SET(CMAKE_XCODE_ATTRIBUTE_ENABLE_OPENMP_SUPPORT "YES")
957                 ENDIF(APPLE AND ${CMAKE_GENERATOR} MATCHES "Xcode")
958         ELSE(OPENMP_FOUND)
959                 SET(WITH_OPENMP OFF)
960         ENDIF(OPENMP_FOUND)
961 ENDIF(WITH_OPENMP) 
962
963 #-----------------------------------------------------------------------------
964 # Extra compile flags
965
966 IF((NOT WIN32) AND (NOT MSVC))
967         # used for internal debug checks
968         SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DDEBUG")
969         SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DDEBUG")
970         
971         # assert() checks for this.
972         SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -DNDEBUG")
973         SET(CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS_MINSIZEREL} -DNDEBUG")
974         SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -DNDEBUG")
975
976         SET(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -DNDEBUG")
977         SET(CMAKE_C_FLAGS_MINSIZEREL "${CMAKE_C_FLAGS_MINSIZEREL} -DNDEBUG")
978         SET(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO} -DNDEBUG")
979 ENDIF((NOT WIN32) AND (NOT MSVC))
980
981 IF(CMAKE_COMPILER_IS_GNUCC)
982         SET(C_WARNINGS "${C_WARNINGS} -Wunused-parameter -Werror=declaration-after-statement -Werror=implicit-function-declaration -Werror=return-type")
983 ENDIF(CMAKE_COMPILER_IS_GNUCC)
984
985 SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${PLATFORM_CFLAGS} ${C_WARNINGS}")
986 SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${PLATFORM_CFLAGS} ${CXX_WARNINGS}")
987
988 # better not define flags here but this is a debugging option thats off by default.
989 IF(WITH_CXX_GUARDEDALLOC)
990         SET(CMAKE_CXX_FLAGS " -DWITH_CXX_GUARDEDALLOC -I${CMAKE_SOURCE_DIR}/intern/guardedalloc ${CMAKE_CXX_FLAGS}")
991 ENDIF(WITH_CXX_GUARDEDALLOC)
992
993 #-----------------------------------------------------------------------------
994 # Libraries
995 FILE(WRITE ${CMAKE_BINARY_DIR}/cmake_blender_libs.txt "")
996 ADD_SUBDIRECTORY(source)
997 ADD_SUBDIRECTORY(intern)
998 ADD_SUBDIRECTORY(extern)
999
1000
1001 #-----------------------------------------------------------------------------
1002 # Blender Application
1003 ADD_SUBDIRECTORY(source/creator)
1004
1005
1006 #-----------------------------------------------------------------------------
1007 # Blender Player
1008 IF(WITH_PLAYER)
1009         ADD_SUBDIRECTORY(source/blenderplayer)
1010 ENDIF(WITH_PLAYER)