Merge branch 'master' into blender2.8
[blender.git] / build_files / cmake / platform / platform_apple.cmake
1 # ***** BEGIN GPL LICENSE BLOCK *****
2 #
3 # This program is free software; you can redistribute it and/or
4 # modify it under the terms of the GNU General Public License
5 # as published by the Free Software Foundation; either version 2
6 # of the License, or (at your option) any later version.
7 #
8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11 # GNU General Public License for more details.
12 #
13 # You should have received a copy of the GNU General Public License
14 # along with this program; if not, write to the Free Software Foundation,
15 # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16 #
17 # The Original Code is Copyright (C) 2016, Blender Foundation
18 # All rights reserved.
19 #
20 # Contributor(s): Sergey Sharybin.
21 #
22 # ***** END GPL LICENSE BLOCK *****
23
24 # Libraries configuration for Apple.
25
26 set(MACOSX_DEPLOYMENT_TARGET "10.9")
27
28 macro(find_package_wrapper)
29 # do nothing, just satisfy the macro
30 endmacro()
31
32 if(NOT DEFINED LIBDIR)
33         if(WITH_CXX11)
34                 set(LIBDIR ${CMAKE_SOURCE_DIR}/../lib/darwin)
35         else()
36                 set(LIBDIR ${CMAKE_SOURCE_DIR}/../lib/darwin-9.x.universal)
37         endif()
38 else()
39         message(STATUS "Using pre-compiled LIBDIR: ${LIBDIR}")
40 endif()
41 if(NOT EXISTS "${LIBDIR}/")
42         message(FATAL_ERROR "Mac OSX requires pre-compiled libs at: '${LIBDIR}'")
43 endif()
44
45 if(WITH_OPENAL)
46         find_package(OpenAL)
47         if(OPENAL_FOUND)
48                 set(WITH_OPENAL ON)
49                 set(OPENAL_INCLUDE_DIR "${LIBDIR}/openal/include")
50         else()
51                 set(WITH_OPENAL OFF)
52         endif()
53 endif()
54
55 if(WITH_ALEMBIC)
56         set(ALEMBIC ${LIBDIR}/alembic)
57         set(ALEMBIC_INCLUDE_DIR ${ALEMBIC}/include)
58         set(ALEMBIC_INCLUDE_DIRS ${ALEMBIC_INCLUDE_DIR})
59         set(ALEMBIC_LIBPATH ${ALEMBIC}/lib)
60         set(ALEMBIC_LIBRARIES Alembic)
61         set(ALEMBIC_FOUND ON)
62 endif()
63
64 if(WITH_OPENSUBDIV OR WITH_CYCLES_OPENSUBDIV)
65         set(OPENSUBDIV ${LIBDIR}/opensubdiv)
66         set(OPENSUBDIV_LIBPATH ${OPENSUBDIV}/lib)
67         find_library(OSD_LIB_CPU NAMES osdCPU PATHS ${OPENSUBDIV_LIBPATH})
68         find_library(OSD_LIB_GPU NAMES osdGPU PATHS ${OPENSUBDIV_LIBPATH})
69         set(OPENSUBDIV_INCLUDE_DIR ${OPENSUBDIV}/include)
70         set(OPENSUBDIV_INCLUDE_DIRS ${OPENSUBDIV_INCLUDE_DIR})
71         list(APPEND OPENSUBDIV_LIBRARIES ${OSD_LIB_CPU} ${OSD_LIB_GPU})
72 endif()
73
74 if(WITH_JACK)
75         find_library(JACK_FRAMEWORK
76                 NAMES jackmp
77         )
78         set(JACK_INCLUDE_DIRS ${JACK_FRAMEWORK}/headers)
79         if(NOT JACK_FRAMEWORK)
80                 set(WITH_JACK OFF)
81         endif()
82 endif()
83
84 if(WITH_CODEC_SNDFILE)
85         set(SNDFILE ${LIBDIR}/sndfile)
86         set(SNDFILE_INCLUDE_DIRS ${SNDFILE}/include)
87         set(SNDFILE_LIBRARIES sndfile FLAC ogg vorbis vorbisenc)
88         set(SNDFILE_LIBPATH ${SNDFILE}/lib ${LIBDIR}/ffmpeg/lib)  # TODO, deprecate
89 endif()
90
91 if(WITH_PYTHON)
92         # we use precompiled libraries for py 3.5 and up by default
93         set(PYTHON_VERSION 3.5)
94         if(NOT WITH_PYTHON_MODULE AND NOT WITH_PYTHON_FRAMEWORK)
95                 # normally cached but not since we include them with blender
96                 set(PYTHON_INCLUDE_DIR "${LIBDIR}/python/include/python${PYTHON_VERSION}m")
97                 set(PYTHON_EXECUTABLE "${LIBDIR}/python/bin/python${PYTHON_VERSION}m")
98                 if(WITH_CXX11)
99                         set(PYTHON_LIBRARY ${LIBDIR}/python/lib/libpython${PYTHON_VERSION}m.a)
100                 else()
101                         set(PYTHON_LIBRARY python${PYTHON_VERSION}m)
102                 endif()
103                 set(PYTHON_LIBPATH "${LIBDIR}/python/lib/python${PYTHON_VERSION}")
104                 # set(PYTHON_LINKFLAGS "-u _PyMac_Error")  # won't  build with this enabled
105         else()
106                 # module must be compiled against Python framework
107                 set(_py_framework "/Library/Frameworks/Python.framework/Versions/${PYTHON_VERSION}")
108
109                 set(PYTHON_INCLUDE_DIR "${_py_framework}/include/python${PYTHON_VERSION}m")
110                 set(PYTHON_EXECUTABLE "${_py_framework}/bin/python${PYTHON_VERSION}m")
111                 set(PYTHON_LIBPATH "${_py_framework}/lib/python${PYTHON_VERSION}/config-${PYTHON_VERSION}m")
112                 #set(PYTHON_LIBRARY python${PYTHON_VERSION})
113                 #set(PYTHON_LINKFLAGS "-u _PyMac_Error -framework Python")  # won't  build with this enabled
114
115                 unset(_py_framework)
116         endif()
117
118         # uncached vars
119         set(PYTHON_INCLUDE_DIRS "${PYTHON_INCLUDE_DIR}")
120         set(PYTHON_LIBRARIES  "${PYTHON_LIBRARY}")
121
122         # needed for Audaspace, numpy is installed into python site-packages
123         set(NUMPY_INCLUDE_DIRS "${PYTHON_LIBPATH}/site-packages/numpy/core/include")
124
125         if(NOT EXISTS "${PYTHON_EXECUTABLE}")
126                 message(FATAL_ERROR "Python executable missing: ${PYTHON_EXECUTABLE}")
127         endif()
128 endif()
129
130 if(WITH_FFTW3)
131         set(FFTW3 ${LIBDIR}/fftw3)
132         set(FFTW3_INCLUDE_DIRS ${FFTW3}/include)
133         set(FFTW3_LIBRARIES fftw3)
134         set(FFTW3_LIBPATH ${FFTW3}/lib)
135 endif()
136
137 set(PNG_LIBRARIES png)
138 set(JPEG_LIBRARIES jpeg)
139
140 set(ZLIB /usr)
141 set(ZLIB_INCLUDE_DIRS "${ZLIB}/include")
142 set(ZLIB_LIBRARIES z bz2)
143
144 set(FREETYPE ${LIBDIR}/freetype)
145 set(FREETYPE_INCLUDE_DIRS ${FREETYPE}/include ${FREETYPE}/include/freetype2)
146 set(FREETYPE_LIBPATH ${FREETYPE}/lib)
147 set(FREETYPE_LIBRARY freetype)
148
149 if(WITH_IMAGE_OPENEXR)
150         set(OPENEXR ${LIBDIR}/openexr)
151         set(OPENEXR_INCLUDE_DIR ${OPENEXR}/include)
152         set(OPENEXR_INCLUDE_DIRS ${OPENEXR_INCLUDE_DIR} ${OPENEXR}/include/OpenEXR)
153         if(WITH_CXX11)
154                 set(OPENEXR_POSTFIX -2_2)
155         else()
156                 set(OPENEXR_POSTFIX)
157         endif()
158         set(OPENEXR_LIBRARIES
159                 Iex${OPENEXR_POSTFIX}
160                 Half
161                 IlmImf${OPENEXR_POSTFIX}
162                 Imath${OPENEXR_POSTFIX}
163                 IlmThread${OPENEXR_POSTFIX})
164         set(OPENEXR_LIBPATH ${OPENEXR}/lib)
165 endif()
166
167 if(WITH_CODEC_FFMPEG)
168         set(FFMPEG ${LIBDIR}/ffmpeg)
169         set(FFMPEG_INCLUDE_DIRS ${FFMPEG}/include)
170         set(FFMPEG_LIBRARIES
171                 avcodec avdevice avformat avutil
172                 mp3lame swscale x264 xvidcore theora theoradec theoraenc vorbis vorbisenc vorbisfile ogg
173         )
174         if(WITH_CXX11)
175                 set(FFMPEG_LIBRARIES ${FFMPEG_LIBRARIES} schroedinger orc vpx webp swresample)
176         endif()
177         set(FFMPEG_LIBPATH ${FFMPEG}/lib)
178 endif()
179
180 if(WITH_OPENJPEG OR WITH_CODEC_FFMPEG)
181         # use openjpeg from libdir that is linked into ffmpeg
182         if(WITH_CXX11)
183                 set(OPENJPEG ${LIBDIR}/openjpeg)
184                 set(WITH_SYSTEM_OPENJPEG ON)
185                 set(OPENJPEG_INCLUDE_DIRS ${OPENJPEG}/include)
186                 set(OPENJPEG_LIBRARIES ${OPENJPEG}/lib/libopenjpeg.a)
187         endif()
188 endif()
189
190 find_library(SYSTEMSTUBS_LIBRARY
191         NAMES
192         SystemStubs
193         PATHS
194 )
195 mark_as_advanced(SYSTEMSTUBS_LIBRARY)
196 if(SYSTEMSTUBS_LIBRARY)
197         list(APPEND PLATFORM_LINKLIBS SystemStubs)
198 endif()
199
200 set(PLATFORM_CFLAGS "-pipe -funsigned-char")
201 set(PLATFORM_LINKFLAGS
202         "-fexceptions -framework CoreServices -framework Foundation -framework IOKit -framework AppKit -framework Cocoa -framework Carbon -framework AudioUnit -framework AudioToolbox -framework CoreAudio"
203 )
204 if(WITH_CODEC_QUICKTIME)
205         set(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} -framework QTKit")
206         if(CMAKE_OSX_ARCHITECTURES MATCHES i386)
207                 set(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} -framework QuickTime")
208                 # libSDL still needs 32bit carbon quicktime
209         endif()
210 endif()
211
212 if(WITH_CXX11)
213         list(APPEND PLATFORM_LINKLIBS c++)
214 else()
215         list(APPEND PLATFORM_LINKLIBS stdc++)
216 endif()
217
218 if(WITH_JACK)
219         set(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} -F/Library/Frameworks -weak_framework jackmp")
220 endif()
221
222 if(WITH_PYTHON_MODULE OR WITH_PYTHON_FRAMEWORK)
223         # force cmake to link right framework
224         set(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} /Library/Frameworks/Python.framework/Versions/${PYTHON_VERSION}/Python")
225 endif()
226
227 if(WITH_OPENCOLLADA)
228         set(OPENCOLLADA ${LIBDIR}/opencollada)
229
230         set(OPENCOLLADA_INCLUDE_DIRS
231                 ${LIBDIR}/opencollada/include/COLLADAStreamWriter
232                 ${LIBDIR}/opencollada/include/COLLADABaseUtils
233                 ${LIBDIR}/opencollada/include/COLLADAFramework
234                 ${LIBDIR}/opencollada/include/COLLADASaxFrameworkLoader
235                 ${LIBDIR}/opencollada/include/GeneratedSaxParser
236         )
237
238         set(OPENCOLLADA_LIBPATH ${OPENCOLLADA}/lib)
239         set(OPENCOLLADA_LIBRARIES
240                 OpenCOLLADASaxFrameworkLoader
241                 -lOpenCOLLADAFramework
242                 -lOpenCOLLADABaseUtils
243                 -lOpenCOLLADAStreamWriter
244                 -lMathMLSolver
245                 -lGeneratedSaxParser
246                 -lxml2 -lbuffer -lftoa
247         )
248         # Use UTF functions from collada if LLVM is not enabled
249         if(NOT WITH_LLVM)
250                 list(APPEND OPENCOLLADA_LIBRARIES -lUTF)
251         endif()
252         # pcre is bundled with openCollada
253         #set(PCRE ${LIBDIR}/pcre)
254         #set(PCRE_LIBPATH ${PCRE}/lib)
255         set(PCRE_LIBRARIES pcre)
256         #libxml2 is used
257         #set(EXPAT ${LIBDIR}/expat)
258         #set(EXPAT_LIBPATH ${EXPAT}/lib)
259         set(EXPAT_LIB)
260 endif()
261
262 if(WITH_SDL)
263         set(SDL ${LIBDIR}/sdl)
264         set(SDL_INCLUDE_DIR ${SDL}/include)
265         set(SDL_LIBRARY SDL2)
266         set(SDL_LIBPATH ${SDL}/lib)
267         if(WITH_CXX11)
268                 set(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} -framework ForceFeedback")
269         else()
270                 set(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} -lazy_framework ForceFeedback")
271         endif()
272 endif()
273
274 set(PNG "${LIBDIR}/png")
275 set(PNG_INCLUDE_DIRS "${PNG}/include")
276 set(PNG_LIBPATH ${PNG}/lib)
277
278 set(JPEG "${LIBDIR}/jpeg")
279 set(JPEG_INCLUDE_DIR "${JPEG}/include")
280 set(JPEG_LIBPATH ${JPEG}/lib)
281
282 if(WITH_IMAGE_TIFF)
283         set(TIFF ${LIBDIR}/tiff)
284         set(TIFF_INCLUDE_DIR ${TIFF}/include)
285         set(TIFF_LIBRARY tiff)
286         set(TIFF_LIBPATH ${TIFF}/lib)
287 endif()
288
289 if(WITH_BOOST)
290         set(BOOST ${LIBDIR}/boost)
291         set(BOOST_INCLUDE_DIR ${BOOST}/include)
292         if(WITH_CXX11)
293                 set(BOOST_POSTFIX)
294         else()
295                 set(BOOST_POSTFIX -mt)
296         endif()
297         set(BOOST_LIBRARIES
298                 boost_date_time${BOOST_POSTFIX}
299                 boost_filesystem${BOOST_POSTFIX}
300                 boost_regex${BOOST_POSTFIX}
301                 boost_system${BOOST_POSTFIX}
302                 boost_thread${BOOST_POSTFIX}
303                 boost_wave${BOOST_POSTFIX}
304         )
305         if(WITH_INTERNATIONAL)
306                 list(APPEND BOOST_LIBRARIES boost_locale${BOOST_POSTFIX})
307         endif()
308         if(WITH_CYCLES_NETWORK)
309                 list(APPEND BOOST_LIBRARIES boost_serialization${BOOST_POSTFIX})
310         endif()
311         if(WITH_OPENVDB)
312                 list(APPEND BOOST_LIBRARIES boost_iostreams${BOOST_POSTFIX})
313         endif()
314         set(BOOST_LIBPATH ${BOOST}/lib)
315         set(BOOST_DEFINITIONS)
316 endif()
317
318 if(WITH_INTERNATIONAL OR WITH_CODEC_FFMPEG)
319         set(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} -liconv") # boost_locale and ffmpeg needs it !
320 endif()
321
322 if(WITH_OPENIMAGEIO)
323         set(OPENIMAGEIO ${LIBDIR}/openimageio)
324         set(OPENIMAGEIO_INCLUDE_DIRS ${OPENIMAGEIO}/include)
325         set(OPENIMAGEIO_LIBRARIES
326                 ${OPENIMAGEIO}/lib/libOpenImageIO.a
327                 ${PNG_LIBRARIES}
328                 ${JPEG_LIBRARIES}
329                 ${TIFF_LIBRARY}
330                 ${OPENEXR_LIBRARIES}
331                 ${ZLIB_LIBRARIES}
332         )
333         if(WITH_CXX11)
334                 set(OPENIMAGEIO_LIBRARIES ${OPENIMAGEIO_LIBRARIES} ${LIBDIR}/ffmpeg/lib/libwebp.a)
335         endif()
336         set(OPENIMAGEIO_LIBPATH
337                 ${OPENIMAGEIO}/lib
338                 ${JPEG_LIBPATH}
339                 ${PNG_LIBPATH}
340                 ${TIFF_LIBPATH}
341                 ${OPENEXR_LIBPATH}
342                 ${ZLIB_LIBPATH}
343         )
344         set(OPENIMAGEIO_DEFINITIONS "-DOIIO_STATIC_BUILD")
345         set(OPENIMAGEIO_IDIFF "${LIBDIR}/openimageio/bin/idiff")
346 endif()
347
348 if(WITH_OPENCOLORIO)
349         set(OPENCOLORIO ${LIBDIR}/opencolorio)
350         set(OPENCOLORIO_INCLUDE_DIRS ${OPENCOLORIO}/include)
351         set(OPENCOLORIO_LIBRARIES OpenColorIO tinyxml yaml-cpp)
352         set(OPENCOLORIO_LIBPATH ${OPENCOLORIO}/lib)
353 endif()
354
355 if(WITH_OPENVDB)
356         set(OPENVDB ${LIBDIR}/openvdb)
357         set(OPENVDB_INCLUDE_DIRS ${OPENVDB}/include)
358         set(TBB_INCLUDE_DIRS ${LIBDIR}/tbb/include)
359         set(TBB_LIBRARIES ${LIBDIR}/tbb/lib/libtbb.a)
360         set(OPENVDB_LIBRARIES openvdb blosc ${TBB_LIBRARIES})
361         set(OPENVDB_LIBPATH ${LIBDIR}/openvdb/lib)
362         set(OPENVDB_DEFINITIONS)
363 endif()
364
365 if(WITH_LLVM)
366         set(LLVM_ROOT_DIR ${LIBDIR}/llvm CACHE PATH     "Path to the LLVM installation")
367         set(LLVM_VERSION "3.4" CACHE STRING     "Version of LLVM to use")
368         if(EXISTS "${LLVM_ROOT_DIR}/bin/llvm-config")
369                 set(LLVM_CONFIG "${LLVM_ROOT_DIR}/bin/llvm-config")
370         else()
371                 set(LLVM_CONFIG llvm-config)
372         endif()
373         execute_process(COMMAND ${LLVM_CONFIG} --version
374                         OUTPUT_VARIABLE LLVM_VERSION
375                         OUTPUT_STRIP_TRAILING_WHITESPACE)
376         execute_process(COMMAND ${LLVM_CONFIG} --prefix
377                         OUTPUT_VARIABLE LLVM_ROOT_DIR
378                         OUTPUT_STRIP_TRAILING_WHITESPACE)
379         execute_process(COMMAND ${LLVM_CONFIG} --libdir
380                         OUTPUT_VARIABLE LLVM_LIBPATH
381                         OUTPUT_STRIP_TRAILING_WHITESPACE)
382         find_library(LLVM_LIBRARY
383                       NAMES LLVMAnalysis # first of a whole bunch of libs to get
384                       PATHS ${LLVM_LIBPATH})
385
386         if(LLVM_LIBRARY AND LLVM_ROOT_DIR AND LLVM_LIBPATH)
387                 if(LLVM_STATIC)
388                         # if static LLVM libraries were requested, use llvm-config to generate
389                         # the list of what libraries we need, and substitute that in the right
390                         # way for LLVM_LIBRARY.
391                         execute_process(COMMAND ${LLVM_CONFIG} --libfiles
392                                         OUTPUT_VARIABLE LLVM_LIBRARY
393                                         OUTPUT_STRIP_TRAILING_WHITESPACE)
394                         string(REPLACE " " ";" LLVM_LIBRARY ${LLVM_LIBRARY})
395                 else()
396                         set(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} -lLLVM-3.4")
397                 endif()
398         else()
399                 message(FATAL_ERROR "LLVM not found.")
400         endif()
401 endif()
402
403 if(WITH_CYCLES_OSL)
404         set(CYCLES_OSL ${LIBDIR}/osl CACHE PATH "Path to OpenShadingLanguage installation")
405
406         find_library(OSL_LIB_EXEC NAMES oslexec PATHS ${CYCLES_OSL}/lib)
407         find_library(OSL_LIB_COMP NAMES oslcomp PATHS ${CYCLES_OSL}/lib)
408         find_library(OSL_LIB_QUERY NAMES oslquery PATHS ${CYCLES_OSL}/lib)
409         # WARNING! depends on correct order of OSL libs linking
410         list(APPEND OSL_LIBRARIES ${OSL_LIB_COMP} -force_load ${OSL_LIB_EXEC} ${OSL_LIB_QUERY})
411         find_path(OSL_INCLUDE_DIR OSL/oslclosure.h PATHS ${CYCLES_OSL}/include)
412         find_program(OSL_COMPILER NAMES oslc PATHS ${CYCLES_OSL}/bin)
413
414         if(OSL_INCLUDE_DIR AND OSL_LIBRARIES AND OSL_COMPILER)
415                 set(OSL_FOUND TRUE)
416         else()
417                 message(STATUS "OSL not found")
418                 set(WITH_CYCLES_OSL OFF)
419         endif()
420 endif()
421
422 if(WITH_OPENMP)
423         execute_process(COMMAND ${CMAKE_C_COMPILER} --version OUTPUT_VARIABLE COMPILER_VENDOR)
424         string(SUBSTRING "${COMPILER_VENDOR}" 0 5 VENDOR_NAME) # truncate output
425         if(${VENDOR_NAME} MATCHES "Apple") # Apple does not support OpenMP reliable with gcc and not with clang
426                 set(WITH_OPENMP OFF)
427         else() # vanilla gcc or clang_omp support OpenMP
428                 message(STATUS "Using special OpenMP enabled compiler !") # letting find_package(OpenMP) module work for gcc
429                 if(CMAKE_C_COMPILER_ID MATCHES "Clang") # clang-omp in darwin libs
430                         set(OPENMP_FOUND ON)
431                         set(OpenMP_C_FLAGS "-fopenmp" CACHE STRING "C compiler flags for OpenMP parallization" FORCE)
432                         set(OpenMP_CXX_FLAGS "-fopenmp" CACHE STRING "C++ compiler flags for OpenMP parallization" FORCE)
433                         include_directories(${LIBDIR}/openmp/include)
434                         link_directories(${LIBDIR}/openmp/lib)
435                         # This is a workaround for our helperbinaries ( datatoc, masgfmt, ... ),
436                         # They are linked also to omp lib, so we need it in builddir for runtime exexcution,
437                         # TODO: remove all unneeded dependencies from these
438
439                         # for intermediate binaries, in respect to lib ID
440                         execute_process(
441                                 COMMAND ditto -arch ${CMAKE_OSX_ARCHITECTURES}
442                                 ${LIBDIR}/openmp/lib/libiomp5.dylib
443                                 ${CMAKE_BINARY_DIR}/Resources/lib/libiomp5.dylib)
444                 endif()
445         endif()
446 endif()
447
448 set(EXETYPE MACOSX_BUNDLE)
449
450 set(CMAKE_C_FLAGS_DEBUG "-fno-strict-aliasing -g")
451 set(CMAKE_CXX_FLAGS_DEBUG "-fno-strict-aliasing -g")
452 if(CMAKE_OSX_ARCHITECTURES MATCHES "x86_64" OR CMAKE_OSX_ARCHITECTURES MATCHES "i386")
453         set(CMAKE_CXX_FLAGS_RELEASE "-O2 -mdynamic-no-pic -msse -msse2 -msse3 -mssse3")
454         set(CMAKE_C_FLAGS_RELEASE "-O2 -mdynamic-no-pic  -msse -msse2 -msse3 -mssse3")
455         if(NOT CMAKE_C_COMPILER_ID MATCHES "Clang")
456                 set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -ftree-vectorize  -fvariable-expansion-in-unroller")
457                 set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -ftree-vectorize  -fvariable-expansion-in-unroller")
458         endif()
459 else()
460         set(CMAKE_C_FLAGS_RELEASE "-mdynamic-no-pic -fno-strict-aliasing")
461         set(CMAKE_CXX_FLAGS_RELEASE "-mdynamic-no-pic -fno-strict-aliasing")
462 endif()
463
464 if(${XCODE_VERSION} VERSION_EQUAL 5 OR ${XCODE_VERSION} VERSION_GREATER 5)
465         # Xcode 5 is always using CLANG, which has too low template depth of 128 for libmv
466         set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -ftemplate-depth=1024")
467 endif()
468 # Get rid of eventually clashes, we export some symbols explicite as local
469 set(PLATFORM_LINKFLAGS
470         "${PLATFORM_LINKFLAGS} -Xlinker -unexported_symbols_list -Xlinker ${CMAKE_SOURCE_DIR}/source/creator/osx_locals.map"
471 )
472
473 if(WITH_CXX11)
474         set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++")
475         set(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} -stdlib=libc++")
476 endif()
477
478 # Suppress ranlib "has no symbols" warnings (workaround for T48250)
479 set(CMAKE_C_ARCHIVE_CREATE   "<CMAKE_AR> Scr <TARGET> <LINK_FLAGS> <OBJECTS>")
480 set(CMAKE_CXX_ARCHIVE_CREATE "<CMAKE_AR> Scr <TARGET> <LINK_FLAGS> <OBJECTS>")
481 set(CMAKE_C_ARCHIVE_FINISH   "<CMAKE_RANLIB> -no_warning_for_no_symbols -c <TARGET>")
482 set(CMAKE_CXX_ARCHIVE_FINISH "<CMAKE_RANLIB> -no_warning_for_no_symbols -c <TARGET>")