Merge branch 'master' into blender2.8
[blender.git] / build_files / cmake / platform / platform_win32.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 Windows.
25
26 add_definitions(-DWIN32)
27
28 if(NOT MSVC)
29         message(FATAL_ERROR "Compiler is unsupported")
30 endif()
31
32 # Libraries configuration for Windows when compiling with MSVC.
33
34 macro(warn_hardcoded_paths package_name
35         )
36         if(WITH_WINDOWS_FIND_MODULES)
37                 message(WARNING "Using HARDCODED ${package_name} locations")
38         endif()
39 endmacro()
40
41 macro(windows_find_package package_name
42         )
43         if(WITH_WINDOWS_FIND_MODULES)
44                 find_package(${package_name})
45         endif()
46 endmacro()
47
48 macro(find_package_wrapper)
49         if(WITH_WINDOWS_FIND_MODULES)
50                 find_package(${ARGV})
51         endif()
52 endmacro()
53
54 add_definitions(-DWIN32)
55
56 # Needed, otherwise system encoding causes utf-8 encoding to fail in some cases (C4819)
57 add_compile_options("$<$<C_COMPILER_ID:MSVC>:/utf-8>")
58 add_compile_options("$<$<CXX_COMPILER_ID:MSVC>:/utf-8>")
59
60 # Minimum MSVC Version
61 if(CMAKE_CXX_COMPILER_ID MATCHES MSVC)
62         if(MSVC_VERSION EQUAL 1800)
63                 set(_min_ver "18.0.31101")
64                 if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS ${_min_ver})
65                         message(FATAL_ERROR
66                                 "Visual Studio 2013 (Update 4, ${_min_ver}) required, "
67                                 "found (${CMAKE_CXX_COMPILER_VERSION})")
68                 endif()
69         endif()
70         if(MSVC_VERSION EQUAL 1900)
71                 set(_min_ver "19.0.24210")
72                 if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS ${_min_ver})
73                         message(FATAL_ERROR
74                                 "Visual Studio 2015 (Update 3, ${_min_ver}) required, "
75                                 "found (${CMAKE_CXX_COMPILER_VERSION})")
76                 endif()
77         endif()
78 endif()
79 unset(_min_ver)
80
81 # needed for some MSVC installations
82 set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /SAFESEH:NO")
83 set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /SAFESEH:NO")
84 set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} /SAFESEH:NO")
85
86 list(APPEND PLATFORM_LINKLIBS
87         ws2_32 vfw32 winmm kernel32 user32 gdi32 comdlg32
88         advapi32 shfolder shell32 ole32 oleaut32 uuid psapi Dbghelp
89 )
90
91 if(WITH_INPUT_IME)
92         list(APPEND PLATFORM_LINKLIBS imm32)
93 endif()
94
95 add_definitions(
96         -D_CRT_NONSTDC_NO_DEPRECATE
97         -D_CRT_SECURE_NO_DEPRECATE
98         -D_SCL_SECURE_NO_DEPRECATE
99         -D_CONSOLE
100         -D_LIB
101 )
102
103 # MSVC11 needs _ALLOW_KEYWORD_MACROS to build
104 add_definitions(-D_ALLOW_KEYWORD_MACROS)
105
106 # We want to support Vista level ABI
107 add_definitions(-D_WIN32_WINNT=0x600)
108
109 # Make cmake find the msvc redistributables
110 set(CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS_SKIP TRUE)
111 include(InstallRequiredSystemLibraries)
112
113 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /nologo /J /Gd /MP /EHsc")
114 set(CMAKE_C_FLAGS     "${CMAKE_C_FLAGS} /nologo /J /Gd /MP")
115
116 set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MTd")
117 set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} /MTd")
118 set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /MT")
119 set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} /MT")
120 set(CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS_MINSIZEREL} /MT")
121 set(CMAKE_C_FLAGS_MINSIZEREL "${CMAKE_C_FLAGS_MINSIZEREL} /MT")
122 set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} /MT")
123 set(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO} /MT")
124
125 set(PLATFORM_LINKFLAGS "/SUBSYSTEM:CONSOLE /STACK:2097152 /INCREMENTAL:NO ")
126 set(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} /NODEFAULTLIB:msvcrt.lib /NODEFAULTLIB:msvcmrt.lib /NODEFAULTLIB:msvcurt.lib /NODEFAULTLIB:msvcrtd.lib ")
127
128 # Ignore meaningless for us linker warnings.
129 set(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} /ignore:4049 /ignore:4217 /ignore:4221")
130 set(CMAKE_STATIC_LINKER_FLAGS "${CMAKE_STATIC_LINKER_FLAGS} /ignore:4221")
131
132 if(CMAKE_CL_64)
133         set(PLATFORM_LINKFLAGS "/MACHINE:X64 ${PLATFORM_LINKFLAGS}")
134 else()
135         set(PLATFORM_LINKFLAGS "/MACHINE:IX86 /LARGEADDRESSAWARE ${PLATFORM_LINKFLAGS}")
136 endif()
137
138 set(PLATFORM_LINKFLAGS_DEBUG "/IGNORE:4099 /NODEFAULTLIB:libcmt.lib /NODEFAULTLIB:libc.lib")
139
140 if(NOT DEFINED LIBDIR)
141
142         # Setup 64bit and 64bit windows systems
143         if(CMAKE_CL_64)
144                 message(STATUS "64 bit compiler detected.")
145                 set(LIBDIR_BASE "win64")
146         else()
147                 message(STATUS "32 bit compiler detected.")
148                 set(LIBDIR_BASE "windows")
149         endif()
150         # Can be 1910..1912
151         if(MSVC_VERSION GREATER 1909)
152                 message(STATUS "Visual Studio 2017 detected.")
153                 set(LIBDIR ${CMAKE_SOURCE_DIR}/../lib/${LIBDIR_BASE}_vc14)
154         elseif(MSVC_VERSION EQUAL 1900)
155                 message(STATUS "Visual Studio 2015 detected.")
156                 set(LIBDIR ${CMAKE_SOURCE_DIR}/../lib/${LIBDIR_BASE}_vc14)
157         else()
158                 message(STATUS "Visual Studio 2013 detected.")
159                 set(LIBDIR ${CMAKE_SOURCE_DIR}/../lib/${LIBDIR_BASE}_vc12)
160         endif()
161 else()
162         message(STATUS "Using pre-compiled LIBDIR: ${LIBDIR}")
163 endif()
164 if(NOT EXISTS "${LIBDIR}/")
165         message(FATAL_ERROR "Windows requires pre-compiled libs at: '${LIBDIR}'")
166 endif()
167
168 # Add each of our libraries to our cmake_prefix_path so find_package() could work
169 file(GLOB children RELATIVE ${LIBDIR} ${LIBDIR}/*)
170 foreach(child ${children})
171         if(IS_DIRECTORY ${LIBDIR}/${child})
172                 list(APPEND CMAKE_PREFIX_PATH  ${LIBDIR}/${child})
173         endif()
174 endforeach()
175
176 set(ZLIB_INCLUDE_DIRS ${LIBDIR}/zlib/include)
177 set(ZLIB_LIBRARIES ${LIBDIR}/zlib/lib/libz_st.lib)
178 set(ZLIB_INCLUDE_DIR ${LIBDIR}/zlib/include)
179 set(ZLIB_LIBRARY ${LIBDIR}/zlib/lib/libz_st.lib)
180 set(ZLIB_DIR ${LIBDIR}/zlib)
181
182 windows_find_package(zlib) # we want to find before finding things that depend on it like png
183 windows_find_package(png)
184
185 if(NOT PNG_FOUND)
186         warn_hardcoded_paths(libpng)
187         set(PNG_PNG_INCLUDE_DIR ${LIBDIR}/png/include)
188         set(PNG_LIBRARIES ${LIBDIR}/png/lib/libpng.lib)
189         set(PNG "${LIBDIR}/png")
190         set(PNG_INCLUDE_DIRS "${PNG}/include")
191         set(PNG_LIBPATH ${PNG}/lib) # not cmake defined
192 endif()
193
194 set(JPEG_NAMES ${JPEG_NAMES} libjpeg)
195 windows_find_package(jpeg REQUIRED)
196 if(NOT JPEG_FOUND)
197         warn_hardcoded_paths(jpeg)
198         set(JPEG_INCLUDE_DIR ${LIBDIR}/jpeg/include)
199         set(JPEG_LIBRARIES ${LIBDIR}/jpeg/lib/libjpeg.lib)
200 endif()
201
202 set(PTHREADS_INCLUDE_DIRS ${LIBDIR}/pthreads/include)
203 set(PTHREADS_LIBRARIES ${LIBDIR}/pthreads/lib/pthreadVC2.lib)
204
205 set(FREETYPE ${LIBDIR}/freetype)
206 set(FREETYPE_INCLUDE_DIRS
207         ${LIBDIR}/freetype/include
208         ${LIBDIR}/freetype/include/freetype2
209 )
210 set(FREETYPE_LIBRARY ${LIBDIR}/freetype/lib/freetype2ST.lib)
211 windows_find_package(freetype REQUIRED)
212
213 if(WITH_FFTW3)
214         set(FFTW3 ${LIBDIR}/fftw3)
215         set(FFTW3_LIBRARIES ${FFTW3}/lib/libfftw.lib)
216         set(FFTW3_INCLUDE_DIRS ${FFTW3}/include)
217         set(FFTW3_LIBPATH ${FFTW3}/lib)
218 endif()
219
220 if(WITH_OPENCOLLADA)
221         set(OPENCOLLADA ${LIBDIR}/opencollada)
222
223         set(OPENCOLLADA_INCLUDE_DIRS
224                 ${OPENCOLLADA}/include/opencollada/COLLADAStreamWriter
225                 ${OPENCOLLADA}/include/opencollada/COLLADABaseUtils
226                 ${OPENCOLLADA}/include/opencollada/COLLADAFramework
227                 ${OPENCOLLADA}/include/opencollada/COLLADASaxFrameworkLoader
228                 ${OPENCOLLADA}/include/opencollada/GeneratedSaxParser
229         )
230
231         set(OPENCOLLADA_LIBRARIES
232                 ${OPENCOLLADA}/lib/opencollada/OpenCOLLADASaxFrameworkLoader.lib
233                 ${OPENCOLLADA}/lib/opencollada/OpenCOLLADAFramework.lib
234                 ${OPENCOLLADA}/lib/opencollada/OpenCOLLADABaseUtils.lib
235                 ${OPENCOLLADA}/lib/opencollada/OpenCOLLADAStreamWriter.lib
236                 ${OPENCOLLADA}/lib/opencollada/MathMLSolver.lib
237                 ${OPENCOLLADA}/lib/opencollada/GeneratedSaxParser.lib
238                 ${OPENCOLLADA}/lib/opencollada/xml.lib
239                 ${OPENCOLLADA}/lib/opencollada/buffer.lib
240                 ${OPENCOLLADA}/lib/opencollada/ftoa.lib
241         )
242
243         if(NOT WITH_LLVM)
244                 list(APPEND OPENCOLLADA_LIBRARIES ${OPENCOLLADA}/lib/opencollada/UTF.lib)
245         endif()
246
247         set(PCRE_LIBRARIES
248                 ${OPENCOLLADA}/lib/opencollada/pcre.lib
249         )
250 endif()
251
252 if(WITH_CODEC_FFMPEG)
253         set(FFMPEG_INCLUDE_DIRS
254                 ${LIBDIR}/ffmpeg/include
255                 ${LIBDIR}/ffmpeg/include/msvc
256         )
257         windows_find_package(FFMPEG)
258         if(NOT FFMPEG_FOUND)
259                 warn_hardcoded_paths(ffmpeg)
260                 set(FFMPEG_LIBRARY_VERSION 57)
261                 set(FFMPEG_LIBRARY_VERSION_AVU 55)
262                 set(FFMPEG_LIBRARIES
263                         ${LIBDIR}/ffmpeg/lib/avcodec.lib
264                         ${LIBDIR}/ffmpeg/lib/avformat.lib
265                         ${LIBDIR}/ffmpeg/lib/avdevice.lib
266                         ${LIBDIR}/ffmpeg/lib/avutil.lib
267                         ${LIBDIR}/ffmpeg/lib/swscale.lib
268                         )
269         endif()
270 endif()
271
272 if(WITH_IMAGE_OPENEXR)
273         set(OPENEXR_ROOT_DIR ${LIBDIR}/openexr)
274         set(OPENEXR_VERSION "2.1")
275         windows_find_package(OPENEXR REQUIRED)
276         if(NOT OPENEXR_FOUND)
277                 warn_hardcoded_paths(OpenEXR)
278                 set(OPENEXR ${LIBDIR}/openexr)
279                 set(OPENEXR_INCLUDE_DIR ${OPENEXR}/include)
280                 set(OPENEXR_INCLUDE_DIRS ${OPENEXR_INCLUDE_DIR} ${OPENEXR}/include/OpenEXR)
281                 set(OPENEXR_LIBPATH ${OPENEXR}/lib)
282                 set(OPENEXR_LIBRARIES
283                         optimized ${OPENEXR_LIBPATH}/Iex-2_2.lib
284                         optimized ${OPENEXR_LIBPATH}/Half.lib
285                         optimized ${OPENEXR_LIBPATH}/IlmImf-2_2.lib
286                         optimized ${OPENEXR_LIBPATH}/Imath-2_2.lib
287                         optimized ${OPENEXR_LIBPATH}/IlmThread-2_2.lib
288                         debug ${OPENEXR_LIBPATH}/Iex-2_2_d.lib
289                         debug ${OPENEXR_LIBPATH}/Half_d.lib
290                         debug ${OPENEXR_LIBPATH}/IlmImf-2_2_d.lib
291                         debug ${OPENEXR_LIBPATH}/Imath-2_2_d.lib
292                         debug ${OPENEXR_LIBPATH}/IlmThread-2_2_d.lib
293                 )
294         endif()
295 endif()
296
297 if(WITH_IMAGE_TIFF)
298         # Try to find tiff first then complain and set static and maybe wrong paths
299         windows_find_package(TIFF)
300         if(NOT TIFF_FOUND)
301                 warn_hardcoded_paths(libtiff)
302                 set(TIFF_LIBRARY ${LIBDIR}/tiff/lib/libtiff.lib)
303                 set(TIFF_INCLUDE_DIR ${LIBDIR}/tiff/include)
304         endif()
305 endif()
306
307 if(WITH_JACK)
308         set(JACK_INCLUDE_DIRS
309                 ${LIBDIR}/jack/include/jack
310                 ${LIBDIR}/jack/include
311         )
312         set(JACK_LIBRARIES optimized ${LIBDIR}/jack/lib/libjack.lib debug ${LIBDIR}/jack/lib/libjack_d.lib)
313 endif()
314
315 if(WITH_PYTHON)
316         set(PYTHON_VERSION 3.6) # CACHE STRING)
317
318         string(REPLACE "." "" _PYTHON_VERSION_NO_DOTS ${PYTHON_VERSION})
319         # Use shared libs for vc2008 and vc2010 until we actually have vc2010 libs
320         set(PYTHON_LIBRARY ${LIBDIR}/python/lib/python${_PYTHON_VERSION_NO_DOTS}.lib)
321         unset(_PYTHON_VERSION_NO_DOTS)
322
323         # Shared includes for both vc2008 and vc2010
324         set(PYTHON_INCLUDE_DIR ${LIBDIR}/python/include/python${PYTHON_VERSION})
325
326         # uncached vars
327         set(PYTHON_INCLUDE_DIRS "${PYTHON_INCLUDE_DIR}")
328         set(PYTHON_LIBRARIES  "${PYTHON_LIBRARY}")
329 endif()
330
331 if(WITH_BOOST)
332         if(WITH_CYCLES_OSL)
333                 set(boost_extra_libs wave)
334         endif()
335         if(WITH_INTERNATIONAL)
336                 list(APPEND boost_extra_libs locale)
337         endif()
338         if(WITH_OPENVDB)
339                 list(APPEND boost_extra_libs iostreams)
340         endif()
341         set(Boost_USE_STATIC_RUNTIME ON) # prefix lib
342         set(Boost_USE_MULTITHREADED ON) # suffix -mt
343         set(Boost_USE_STATIC_LIBS ON) # suffix -s
344         if(WITH_WINDOWS_FIND_MODULES)
345                 find_package(Boost COMPONENTS date_time filesystem thread regex system ${boost_extra_libs})
346         endif()
347         if(NOT Boost_FOUND)
348                 warn_hardcoded_paths(BOOST)
349                 set(BOOST ${LIBDIR}/boost)
350                 set(BOOST_INCLUDE_DIR ${BOOST}/include)
351                 if(MSVC12)
352                         set(BOOST_LIBPATH ${BOOST}/lib)
353                         set(BOOST_POSTFIX "vc120-mt-s-1_60.lib")
354                         set(BOOST_DEBUG_POSTFIX "vc120-mt-sgd-1_60.lib")
355                 else()
356                         set(BOOST_LIBPATH ${BOOST}/lib)
357                         set(BOOST_POSTFIX "vc140-mt-s-1_60.lib")
358                         set(BOOST_DEBUG_POSTFIX "vc140-mt-sgd-1_60.lib")
359                 endif()
360                 set(BOOST_LIBRARIES
361                         optimized ${BOOST_LIBPATH}/libboost_date_time-${BOOST_POSTFIX}
362                         optimized ${BOOST_LIBPATH}/libboost_filesystem-${BOOST_POSTFIX}
363                         optimized ${BOOST_LIBPATH}/libboost_regex-${BOOST_POSTFIX}
364                         optimized ${BOOST_LIBPATH}/libboost_system-${BOOST_POSTFIX}
365                         optimized ${BOOST_LIBPATH}/libboost_thread-${BOOST_POSTFIX}
366                         optimized ${BOOST_LIBPATH}/libboost_chrono-${BOOST_POSTFIX}
367                         debug ${BOOST_LIBPATH}/libboost_date_time-${BOOST_DEBUG_POSTFIX}
368                         debug ${BOOST_LIBPATH}/libboost_filesystem-${BOOST_DEBUG_POSTFIX}
369                         debug ${BOOST_LIBPATH}/libboost_regex-${BOOST_DEBUG_POSTFIX}
370                         debug ${BOOST_LIBPATH}/libboost_system-${BOOST_DEBUG_POSTFIX}
371                         debug ${BOOST_LIBPATH}/libboost_thread-${BOOST_DEBUG_POSTFIX}
372                         debug ${BOOST_LIBPATH}/libboost_chrono-${BOOST_DEBUG_POSTFIX}
373                 )
374                 if(WITH_CYCLES_OSL)
375                         set(BOOST_LIBRARIES ${BOOST_LIBRARIES}
376                                 optimized ${BOOST_LIBPATH}/libboost_wave-${BOOST_POSTFIX}
377                                 debug ${BOOST_LIBPATH}/libboost_wave-${BOOST_DEBUG_POSTFIX})
378                 endif()
379                 if(WITH_INTERNATIONAL)
380                         set(BOOST_LIBRARIES ${BOOST_LIBRARIES}
381                                 optimized ${BOOST_LIBPATH}/libboost_locale-${BOOST_POSTFIX}
382                                 debug ${BOOST_LIBPATH}/libboost_locale-${BOOST_DEBUG_POSTFIX})
383                 endif()
384         else() # we found boost using find_package
385                 set(BOOST_INCLUDE_DIR ${Boost_INCLUDE_DIRS})
386                 set(BOOST_LIBRARIES ${Boost_LIBRARIES})
387                 set(BOOST_LIBPATH ${Boost_LIBRARY_DIRS})
388         endif()
389         set(BOOST_DEFINITIONS "-DBOOST_ALL_NO_LIB")
390 endif()
391
392 if(WITH_OPENIMAGEIO)
393         windows_find_package(OpenImageIO)
394         set(OPENIMAGEIO ${LIBDIR}/openimageio)
395         set(OPENIMAGEIO_LIBPATH ${OPENIMAGEIO}/lib)
396         set(OPENIMAGEIO_INCLUDE_DIRS ${OPENIMAGEIO}/include)
397         set(OIIO_OPTIMIZED optimized ${OPENIMAGEIO_LIBPATH}/OpenImageIO.lib optimized ${OPENIMAGEIO_LIBPATH}/OpenImageIO_Util.lib)
398         set(OIIO_DEBUG debug ${OPENIMAGEIO_LIBPATH}/OpenImageIO_d.lib debug ${OPENIMAGEIO_LIBPATH}/OpenImageIO_Util_d.lib)
399         set(OPENIMAGEIO_LIBRARIES ${OIIO_OPTIMIZED} ${OIIO_DEBUG})
400         
401         set(OPENIMAGEIO_DEFINITIONS "-DUSE_TBB=0")
402         set(OPENCOLORIO_DEFINITIONS "-DOCIO_STATIC_BUILD")
403         set(OPENIMAGEIO_IDIFF "${OPENIMAGEIO}/bin/idiff.exe")
404         add_definitions(-DOIIO_STATIC_BUILD)
405         add_definitions(-DOIIO_NO_SSE=1)
406 endif()
407
408 if(WITH_LLVM)
409         set(LLVM_ROOT_DIR ${LIBDIR}/llvm CACHE PATH     "Path to the LLVM installation")
410         file(GLOB LLVM_LIBRARY_OPTIMIZED ${LLVM_ROOT_DIR}/lib/*.lib)
411
412         if(EXISTS ${LLVM_ROOT_DIR}/debug/lib)
413                 foreach(LLVM_OPTIMIZED_LIB ${LLVM_LIBRARY_OPTIMIZED})
414                         get_filename_component(LIBNAME ${LLVM_OPTIMIZED_LIB} ABSOLUTE)
415                         list(APPEND LLVM_LIBS optimized ${LIBNAME})
416                 endforeach(LLVM_OPTIMIZED_LIB)
417
418                 file(GLOB LLVM_LIBRARY_DEBUG ${LLVM_ROOT_DIR}/debug/lib/*.lib)
419
420                 foreach(LLVM_DEBUG_LIB ${LLVM_LIBRARY_DEBUG})
421                         get_filename_component(LIBNAME ${LLVM_DEBUG_LIB} ABSOLUTE)
422                         list(APPEND LLVM_LIBS debug ${LIBNAME})
423                 endforeach(LLVM_DEBUG_LIB)
424
425                 set(LLVM_LIBRARY ${LLVM_LIBS})
426         else()
427                 message(WARNING "LLVM debug libs not present on this system. Using release libs for debug builds.")
428                 set(LLVM_LIBRARY ${LLVM_LIBRARY_OPTIMIZED})
429         endif()
430
431 endif()
432
433 if(WITH_OPENCOLORIO)
434         set(OPENCOLORIO ${LIBDIR}/opencolorio)
435         set(OPENCOLORIO_INCLUDE_DIRS ${OPENCOLORIO}/include)
436         set(OPENCOLORIO_LIBPATH ${LIBDIR}/opencolorio/lib)
437         set(OPENCOLORIO_LIBRARIES ${OPENCOLORIO_LIBPATH}/OpenColorIO.lib)
438         set(OPENCOLORIO_DEFINITIONS)
439 endif()
440
441 if(WITH_OPENVDB)
442         set(BLOSC_LIBRARIES optimized ${LIBDIR}/blosc/lib/libblosc.lib debug ${LIBDIR}/blosc/lib/libblosc_d.lib)
443         set(TBB_LIBRARIES optimized ${LIBDIR}/tbb/lib/tbb.lib debug ${LIBDIR}/tbb/lib/tbb_debug.lib)
444         set(TBB_INCLUDE_DIR ${LIBDIR}/tbb/include)
445         set(OPENVDB ${LIBDIR}/openvdb)
446         set(OPENVDB_LIBPATH ${LIBDIR}/openvdb/lib)
447         set(OPENVDB_INCLUDE_DIRS ${OPENVDB}/include ${TBB_INCLUDE_DIR})
448         set(OPENVDB_LIBRARIES optimized ${OPENVDB_LIBPATH}/openvdb.lib debug ${OPENVDB_LIBPATH}/openvdb_d.lib ${TBB_LIBRARIES} ${BLOSC_LIBRARIES})
449         
450 endif()
451
452 if(WITH_ALEMBIC)
453         set(ALEMBIC ${LIBDIR}/alembic)
454         set(ALEMBIC_INCLUDE_DIR ${ALEMBIC}/include)
455         set(ALEMBIC_INCLUDE_DIRS ${ALEMBIC_INCLUDE_DIR})
456         set(ALEMBIC_LIBPATH ${ALEMBIC}/lib)
457         set(ALEMBIC_LIBRARIES optimized ${ALEMBIC}/lib/alembic.lib debug ${ALEMBIC}/lib/alembic_d.lib)
458         set(ALEMBIC_FOUND 1)
459 endif()
460
461 if(WITH_MOD_CLOTH_ELTOPO)
462         set(LAPACK ${LIBDIR}/lapack)
463         # set(LAPACK_INCLUDE_DIR ${LAPACK}/include)
464         set(LAPACK_LIBPATH ${LAPACK}/lib)
465         set(LAPACK_LIBRARIES
466                 ${LIBDIR}/lapack/lib/libf2c.lib
467                 ${LIBDIR}/lapack/lib/clapack_nowrap.lib
468                 ${LIBDIR}/lapack/lib/BLAS_nowrap.lib
469         )
470 endif()
471
472 if(WITH_OPENSUBDIV OR WITH_CYCLES_OPENSUBDIV)
473         set(OPENSUBDIV_INCLUDE_DIR ${LIBDIR}/opensubdiv/include)
474         set(OPENSUBDIV_LIBPATH ${LIBDIR}/opensubdiv/lib)
475         set(OPENSUBDIV_LIBRARIES
476                 optimized ${OPENSUBDIV_LIBPATH}/osdCPU.lib
477                 optimized ${OPENSUBDIV_LIBPATH}/osdGPU.lib
478                 debug ${OPENSUBDIV_LIBPATH}/osdCPU_d.lib
479                 debug ${OPENSUBDIV_LIBPATH}/osdGPU_d.lib
480         )
481         set(OPENSUBDIV_HAS_OPENMP TRUE)
482         set(OPENSUBDIV_HAS_TBB FALSE)
483         set(OPENSUBDIV_HAS_OPENCL TRUE)
484         set(OPENSUBDIV_HAS_CUDA FALSE)
485         set(OPENSUBDIV_HAS_GLSL_TRANSFORM_FEEDBACK TRUE)
486         set(OPENSUBDIV_HAS_GLSL_COMPUTE TRUE)
487         windows_find_package(OpenSubdiv)
488 endif()
489
490 if(WITH_SDL)
491         set(SDL ${LIBDIR}/sdl)
492         set(SDL_INCLUDE_DIR ${SDL}/include)
493         set(SDL_LIBPATH ${SDL}/lib)
494         set(SDL_LIBRARY ${SDL_LIBPATH}/SDL2.lib)
495 endif()
496
497 # Audio IO
498 if(WITH_SYSTEM_AUDASPACE)
499         set(AUDASPACE_INCLUDE_DIRS ${LIBDIR}/audaspace/include/audaspace)
500         set(AUDASPACE_LIBRARIES ${LIBDIR}/audaspace/lib/audaspace.lib)
501         set(AUDASPACE_C_INCLUDE_DIRS ${LIBDIR}/audaspace/include/audaspace)
502         set(AUDASPACE_C_LIBRARIES ${LIBDIR}/audaspace/lib/audaspace-c.lib)
503         set(AUDASPACE_PY_INCLUDE_DIRS ${LIBDIR}/audaspace/include/audaspace)
504         set(AUDASPACE_PY_LIBRARIES ${LIBDIR}/audaspace/lib/audaspace-py.lib)
505 endif()
506
507 # used in many places so include globally, like OpenGL
508 blender_include_dirs_sys("${PTHREADS_INCLUDE_DIRS}")
509
510 #find signtool
511 set(ProgramFilesX86_NAME "ProgramFiles(x86)") #env dislikes the ( )
512 find_program(SIGNTOOL_EXE signtool
513         HINTS
514                 "$ENV{${ProgramFilesX86_NAME}}/Windows Kits/10/bin/x86/"
515                 "$ENV{ProgramFiles}/Windows Kits/10/bin/x86/"
516                 "$ENV{${ProgramFilesX86_NAME}}/Windows Kits/8.1/bin/x86/"
517                 "$ENV{ProgramFiles}/Windows Kits/8.1/bin/x86/"
518                 "$ENV{${ProgramFilesX86_NAME}}/Windows Kits/8.0/bin/x86/"
519                 "$ENV{ProgramFiles}/Windows Kits/8.0/bin/x86/"
520 )
521 set(WINTAB_INC ${LIBDIR}/wintab/include)
522
523 if(WITH_OPENAL)
524         set(OPENAL ${LIBDIR}/openal)
525         set(OPENALDIR ${LIBDIR}/openal)
526         set(OPENAL_INCLUDE_DIR ${OPENAL}/include/AL)
527         set(OPENAL_LIBPATH ${OPENAL}/lib)
528         if(MSVC)
529                 set(OPENAL_LIBRARY ${OPENAL_LIBPATH}/openal32.lib)
530         else()
531                 set(OPENAL_LIBRARY ${OPENAL_LIBPATH}/wrap_oal.lib)
532         endif()
533
534 endif()
535
536 if(WITH_CODEC_SNDFILE)
537         set(LIBSNDFILE ${LIBDIR}/sndfile)
538         set(LIBSNDFILE_INCLUDE_DIRS ${LIBSNDFILE}/include)
539         set(LIBSNDFILE_LIBPATH ${LIBSNDFILE}/lib) # TODO, deprecate
540         set(LIBSNDFILE_LIBRARIES ${LIBSNDFILE_LIBPATH}/libsndfile-1.lib)
541 endif()
542
543 if(WITH_RAYOPTIMIZATION AND SUPPORT_SSE_BUILD)
544         add_definitions(-D__SSE__ -D__MMX__)
545 endif()
546
547 if(WITH_CYCLES_OSL)
548         set(CYCLES_OSL ${LIBDIR}/osl CACHE PATH "Path to OpenShadingLanguage installation")
549
550         find_library(OSL_LIB_EXEC NAMES oslexec PATHS ${CYCLES_OSL}/lib)
551         find_library(OSL_LIB_COMP NAMES oslcomp PATHS ${CYCLES_OSL}/lib)
552         find_library(OSL_LIB_QUERY NAMES oslquery PATHS ${CYCLES_OSL}/lib)
553         find_library(OSL_LIB_EXEC_DEBUG NAMES oslexec_d PATHS ${CYCLES_OSL}/lib)
554         find_library(OSL_LIB_COMP_DEBUG NAMES oslcomp_d PATHS ${CYCLES_OSL}/lib)
555         find_library(OSL_LIB_QUERY_DEBUG NAMES oslquery_d PATHS ${CYCLES_OSL}/lib)
556         list(APPEND OSL_LIBRARIES
557                 optimized ${OSL_LIB_COMP}
558                 optimized ${OSL_LIB_EXEC}
559                 optimized ${OSL_LIB_QUERY}
560                 debug ${OSL_LIB_EXEC_DEBUG}
561                 debug ${OSL_LIB_COMP_DEBUG}
562                 debug ${OSL_LIB_QUERY_DEBUG}
563         )
564         find_path(OSL_INCLUDE_DIR OSL/oslclosure.h PATHS ${CYCLES_OSL}/include)
565         find_program(OSL_COMPILER NAMES oslc PATHS ${CYCLES_OSL}/bin)
566
567         if(OSL_INCLUDE_DIR AND OSL_LIBRARIES AND OSL_COMPILER)
568                 set(OSL_FOUND TRUE)
569         else()
570                 message(STATUS "OSL not found")
571                 set(WITH_CYCLES_OSL OFF)
572         endif()
573 endif()