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