platform_win32.cmake 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682
  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. # ***** END GPL LICENSE BLOCK *****
  20. # Libraries configuration for Windows.
  21. add_definitions(-DWIN32)
  22. if(NOT MSVC)
  23. message(FATAL_ERROR "Compiler is unsupported")
  24. endif()
  25. if(CMAKE_C_COMPILER_ID MATCHES "Clang")
  26. set(MSVC_CLANG On)
  27. set(VC_TOOLS_DIR $ENV{VCToolsRedistDir} CACHE STRING "Location of the msvc redistributables")
  28. set(MSVC_REDIST_DIR ${VC_TOOLS_DIR})
  29. if(DEFINED MSVC_REDIST_DIR)
  30. file(TO_CMAKE_PATH ${MSVC_REDIST_DIR} MSVC_REDIST_DIR)
  31. else()
  32. message("Unable to detect the Visual Studio redist directory, copying of the runtime dlls will not work, try running from the visual studio developer prompt.")
  33. endif()
  34. endif()
  35. set_property(GLOBAL PROPERTY USE_FOLDERS ${WINDOWS_USE_VISUAL_STUDIO_PROJECT_FOLDERS})
  36. if(NOT WITH_PYTHON_MODULE)
  37. set_property(DIRECTORY PROPERTY VS_STARTUP_PROJECT blender)
  38. endif()
  39. macro(warn_hardcoded_paths package_name
  40. )
  41. if(WITH_WINDOWS_FIND_MODULES)
  42. message(WARNING "Using HARDCODED ${package_name} locations")
  43. endif()
  44. endmacro()
  45. macro(windows_find_package package_name
  46. )
  47. if(WITH_WINDOWS_FIND_MODULES)
  48. find_package(${package_name})
  49. endif()
  50. endmacro()
  51. macro(find_package_wrapper)
  52. if(WITH_WINDOWS_FIND_MODULES)
  53. find_package(${ARGV})
  54. endif()
  55. endmacro()
  56. add_definitions(-DWIN32)
  57. # Needed, otherwise system encoding causes utf-8 encoding to fail in some cases (C4819)
  58. add_compile_options("$<$<C_COMPILER_ID:MSVC>:/utf-8>")
  59. add_compile_options("$<$<CXX_COMPILER_ID:MSVC>:/utf-8>")
  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. # needed for some MSVC installations
  81. set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /SAFESEH:NO")
  82. set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /SAFESEH:NO")
  83. set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} /SAFESEH:NO")
  84. list(APPEND PLATFORM_LINKLIBS
  85. ws2_32 vfw32 winmm kernel32 user32 gdi32 comdlg32
  86. advapi32 shfolder shell32 ole32 oleaut32 uuid psapi Dbghelp
  87. )
  88. if(WITH_INPUT_IME)
  89. list(APPEND PLATFORM_LINKLIBS imm32)
  90. endif()
  91. add_definitions(
  92. -D_CRT_NONSTDC_NO_DEPRECATE
  93. -D_CRT_SECURE_NO_DEPRECATE
  94. -D_SCL_SECURE_NO_DEPRECATE
  95. -D_CONSOLE
  96. -D_LIB
  97. )
  98. # MSVC11 needs _ALLOW_KEYWORD_MACROS to build
  99. add_definitions(-D_ALLOW_KEYWORD_MACROS)
  100. # We want to support Vista level ABI
  101. add_definitions(-D_WIN32_WINNT=0x600)
  102. # Make cmake find the msvc redistributables
  103. set(CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS_SKIP FALSE)
  104. set(CMAKE_INSTALL_UCRT_LIBRARIES TRUE)
  105. set(CMAKE_INSTALL_OPENMP_LIBRARIES ${WITH_OPENMP})
  106. set(CMAKE_INSTALL_SYSTEM_RUNTIME_DESTINATION .)
  107. include(InstallRequiredSystemLibraries)
  108. remove_cc_flag("/MDd" "/MD")
  109. if(MSVC_CLANG) # Clangs version of cl doesn't support all flags
  110. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CXX_WARN_FLAGS} /nologo /J /Gd /EHsc -Wno-unused-command-line-argument -Wno-microsoft-enum-forward-reference ")
  111. set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /nologo /J /Gd -Wno-unused-command-line-argument -Wno-microsoft-enum-forward-reference")
  112. else()
  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. endif()
  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. set(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} /SUBSYSTEM:CONSOLE /STACK:2097152 /INCREMENTAL:NO ")
  125. set(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} /NODEFAULTLIB:msvcrt.lib /NODEFAULTLIB:msvcmrt.lib /NODEFAULTLIB:msvcurt.lib /NODEFAULTLIB:msvcrtd.lib ")
  126. # Ignore meaningless for us linker warnings.
  127. set(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} /ignore:4049 /ignore:4217 /ignore:4221")
  128. set(CMAKE_STATIC_LINKER_FLAGS "${CMAKE_STATIC_LINKER_FLAGS} /ignore:4221")
  129. if(CMAKE_CL_64)
  130. set(PLATFORM_LINKFLAGS "/MACHINE:X64 ${PLATFORM_LINKFLAGS}")
  131. else()
  132. set(PLATFORM_LINKFLAGS "/MACHINE:IX86 /LARGEADDRESSAWARE ${PLATFORM_LINKFLAGS}")
  133. endif()
  134. set(PLATFORM_LINKFLAGS_DEBUG "${PLATFORM_LINKFLAGS_DEBUG} /IGNORE:4099 /NODEFAULTLIB:libcmt.lib /NODEFAULTLIB:libc.lib")
  135. if(NOT DEFINED LIBDIR)
  136. # Setup 64bit and 64bit windows systems
  137. if(CMAKE_CL_64)
  138. message(STATUS "64 bit compiler detected.")
  139. set(LIBDIR_BASE "win64")
  140. else()
  141. message(STATUS "32 bit compiler detected.")
  142. set(LIBDIR_BASE "windows")
  143. endif()
  144. # Can be 1910..1912
  145. if(MSVC_VERSION GREATER 1919)
  146. message(STATUS "Visual Studio 2019 detected.")
  147. set(LIBDIR ${CMAKE_SOURCE_DIR}/../lib/${LIBDIR_BASE}_vc14)
  148. elseif(MSVC_VERSION GREATER 1909)
  149. message(STATUS "Visual Studio 2017 detected.")
  150. set(LIBDIR ${CMAKE_SOURCE_DIR}/../lib/${LIBDIR_BASE}_vc14)
  151. elseif(MSVC_VERSION EQUAL 1900)
  152. message(STATUS "Visual Studio 2015 detected.")
  153. set(LIBDIR ${CMAKE_SOURCE_DIR}/../lib/${LIBDIR_BASE}_vc14)
  154. else()
  155. message(STATUS "Visual Studio 2013 detected.")
  156. set(LIBDIR ${CMAKE_SOURCE_DIR}/../lib/${LIBDIR_BASE}_vc12)
  157. endif()
  158. else()
  159. message(STATUS "Using pre-compiled LIBDIR: ${LIBDIR}")
  160. endif()
  161. if(NOT EXISTS "${LIBDIR}/")
  162. message(FATAL_ERROR "Windows requires pre-compiled libs at: '${LIBDIR}'")
  163. endif()
  164. # Mark libdir as system headers with a lower warn level, to resolve some warnings
  165. # that we have very little control over
  166. if(MSVC_VERSION GREATER_EQUAL 1914 AND NOT MSVC_CLANG)
  167. add_compile_options(/experimental:external /external:templates- /external:I "${LIBDIR}" /external:W0)
  168. endif()
  169. # Add each of our libraries to our cmake_prefix_path so find_package() could work
  170. file(GLOB children RELATIVE ${LIBDIR} ${LIBDIR}/*)
  171. foreach(child ${children})
  172. if(IS_DIRECTORY ${LIBDIR}/${child})
  173. list(APPEND CMAKE_PREFIX_PATH ${LIBDIR}/${child})
  174. endif()
  175. endforeach()
  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. windows_find_package(zlib) # we want to find before finding things that depend on it like png
  182. windows_find_package(png)
  183. if(NOT PNG_FOUND)
  184. warn_hardcoded_paths(libpng)
  185. set(PNG_PNG_INCLUDE_DIR ${LIBDIR}/png/include)
  186. set(PNG_LIBRARIES ${LIBDIR}/png/lib/libpng.lib)
  187. set(PNG "${LIBDIR}/png")
  188. set(PNG_INCLUDE_DIRS "${PNG}/include")
  189. set(PNG_LIBPATH ${PNG}/lib) # not cmake defined
  190. endif()
  191. set(JPEG_NAMES ${JPEG_NAMES} libjpeg)
  192. windows_find_package(jpeg REQUIRED)
  193. if(NOT JPEG_FOUND)
  194. warn_hardcoded_paths(jpeg)
  195. set(JPEG_INCLUDE_DIR ${LIBDIR}/jpeg/include)
  196. set(JPEG_LIBRARIES ${LIBDIR}/jpeg/lib/libjpeg.lib)
  197. endif()
  198. set(PTHREADS_INCLUDE_DIRS ${LIBDIR}/pthreads/include)
  199. set(PTHREADS_LIBRARIES ${LIBDIR}/pthreads/lib/pthreadVC3.lib)
  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. if(WITH_FFTW3)
  208. set(FFTW3 ${LIBDIR}/fftw3)
  209. set(FFTW3_LIBRARIES ${FFTW3}/lib/libfftw.lib)
  210. set(FFTW3_INCLUDE_DIRS ${FFTW3}/include)
  211. set(FFTW3_LIBPATH ${FFTW3}/lib)
  212. endif()
  213. if(WITH_OPENCOLLADA)
  214. set(OPENCOLLADA ${LIBDIR}/opencollada)
  215. set(OPENCOLLADA_INCLUDE_DIRS
  216. ${OPENCOLLADA}/include/opencollada/COLLADAStreamWriter
  217. ${OPENCOLLADA}/include/opencollada/COLLADABaseUtils
  218. ${OPENCOLLADA}/include/opencollada/COLLADAFramework
  219. ${OPENCOLLADA}/include/opencollada/COLLADASaxFrameworkLoader
  220. ${OPENCOLLADA}/include/opencollada/GeneratedSaxParser
  221. )
  222. set(OPENCOLLADA_LIBRARIES
  223. ${OPENCOLLADA}/lib/opencollada/OpenCOLLADASaxFrameworkLoader.lib
  224. ${OPENCOLLADA}/lib/opencollada/OpenCOLLADAFramework.lib
  225. ${OPENCOLLADA}/lib/opencollada/OpenCOLLADABaseUtils.lib
  226. ${OPENCOLLADA}/lib/opencollada/OpenCOLLADAStreamWriter.lib
  227. ${OPENCOLLADA}/lib/opencollada/MathMLSolver.lib
  228. ${OPENCOLLADA}/lib/opencollada/GeneratedSaxParser.lib
  229. ${OPENCOLLADA}/lib/opencollada/xml.lib
  230. ${OPENCOLLADA}/lib/opencollada/buffer.lib
  231. ${OPENCOLLADA}/lib/opencollada/ftoa.lib
  232. )
  233. list(APPEND OPENCOLLADA_LIBRARIES ${OPENCOLLADA}/lib/opencollada/UTF.lib)
  234. set(PCRE_LIBRARIES
  235. ${OPENCOLLADA}/lib/opencollada/pcre.lib
  236. )
  237. endif()
  238. if(WITH_CODEC_FFMPEG)
  239. set(FFMPEG_INCLUDE_DIRS
  240. ${LIBDIR}/ffmpeg/include
  241. ${LIBDIR}/ffmpeg/include/msvc
  242. )
  243. windows_find_package(FFMPEG)
  244. if(NOT FFMPEG_FOUND)
  245. warn_hardcoded_paths(ffmpeg)
  246. set(FFMPEG_LIBRARIES
  247. ${LIBDIR}/ffmpeg/lib/avcodec.lib
  248. ${LIBDIR}/ffmpeg/lib/avformat.lib
  249. ${LIBDIR}/ffmpeg/lib/avdevice.lib
  250. ${LIBDIR}/ffmpeg/lib/avutil.lib
  251. ${LIBDIR}/ffmpeg/lib/swscale.lib
  252. )
  253. endif()
  254. endif()
  255. if(WITH_IMAGE_OPENEXR)
  256. set(OPENEXR_ROOT_DIR ${LIBDIR}/openexr)
  257. set(OPENEXR_VERSION "2.1")
  258. windows_find_package(OPENEXR REQUIRED)
  259. if(NOT OPENEXR_FOUND)
  260. warn_hardcoded_paths(OpenEXR)
  261. set(OPENEXR ${LIBDIR}/openexr)
  262. set(OPENEXR_INCLUDE_DIR ${OPENEXR}/include)
  263. set(OPENEXR_INCLUDE_DIRS ${OPENEXR_INCLUDE_DIR} ${OPENEXR}/include/OpenEXR)
  264. set(OPENEXR_LIBPATH ${OPENEXR}/lib)
  265. set(OPENEXR_LIBRARIES
  266. optimized ${OPENEXR_LIBPATH}/Iex_s.lib
  267. optimized ${OPENEXR_LIBPATH}/Half_s.lib
  268. optimized ${OPENEXR_LIBPATH}/IlmImf_s.lib
  269. optimized ${OPENEXR_LIBPATH}/Imath_s.lib
  270. optimized ${OPENEXR_LIBPATH}/IlmThread_s.lib
  271. debug ${OPENEXR_LIBPATH}/Iex_s_d.lib
  272. debug ${OPENEXR_LIBPATH}/Half_s_d.lib
  273. debug ${OPENEXR_LIBPATH}/IlmImf_s_d.lib
  274. debug ${OPENEXR_LIBPATH}/Imath_s_d.lib
  275. debug ${OPENEXR_LIBPATH}/IlmThread_s_d.lib
  276. )
  277. endif()
  278. endif()
  279. if(WITH_IMAGE_TIFF)
  280. # Try to find tiff first then complain and set static and maybe wrong paths
  281. windows_find_package(TIFF)
  282. if(NOT TIFF_FOUND)
  283. warn_hardcoded_paths(libtiff)
  284. set(TIFF_LIBRARY ${LIBDIR}/tiff/lib/libtiff.lib)
  285. set(TIFF_INCLUDE_DIR ${LIBDIR}/tiff/include)
  286. endif()
  287. endif()
  288. if(WITH_JACK)
  289. set(JACK_INCLUDE_DIRS
  290. ${LIBDIR}/jack/include/jack
  291. ${LIBDIR}/jack/include
  292. )
  293. set(JACK_LIBRARIES optimized ${LIBDIR}/jack/lib/libjack.lib debug ${LIBDIR}/jack/lib/libjack_d.lib)
  294. endif()
  295. if(WITH_PYTHON)
  296. set(PYTHON_VERSION 3.7) # CACHE STRING)
  297. string(REPLACE "." "" _PYTHON_VERSION_NO_DOTS ${PYTHON_VERSION})
  298. # Use shared libs for vc2008 and vc2010 until we actually have vc2010 libs
  299. set(PYTHON_LIBRARY ${LIBDIR}/python/lib/python${_PYTHON_VERSION_NO_DOTS}.lib)
  300. set(PYTHON_LIBRARY_DEBUG ${LIBDIR}/python/lib/python${_PYTHON_VERSION_NO_DOTS}_d.lib)
  301. unset(_PYTHON_VERSION_NO_DOTS)
  302. # Shared includes for both vc2008 and vc2010
  303. set(PYTHON_INCLUDE_DIR ${LIBDIR}/python/include/python${PYTHON_VERSION})
  304. # uncached vars
  305. set(PYTHON_INCLUDE_DIRS "${PYTHON_INCLUDE_DIR}")
  306. set(PYTHON_LIBRARIES debug "${PYTHON_LIBRARY_DEBUG}" optimized "${PYTHON_LIBRARY}" )
  307. endif()
  308. if(WITH_BOOST)
  309. if(WITH_CYCLES_OSL)
  310. set(boost_extra_libs wave)
  311. endif()
  312. if(WITH_INTERNATIONAL)
  313. list(APPEND boost_extra_libs locale)
  314. endif()
  315. if(WITH_OPENVDB)
  316. list(APPEND boost_extra_libs iostreams)
  317. endif()
  318. set(Boost_USE_STATIC_RUNTIME ON) # prefix lib
  319. set(Boost_USE_MULTITHREADED ON) # suffix -mt
  320. set(Boost_USE_STATIC_LIBS ON) # suffix -s
  321. if(WITH_WINDOWS_FIND_MODULES)
  322. find_package(Boost COMPONENTS date_time filesystem thread regex system ${boost_extra_libs})
  323. endif()
  324. if(NOT Boost_FOUND)
  325. warn_hardcoded_paths(BOOST)
  326. set(BOOST ${LIBDIR}/boost)
  327. set(BOOST_INCLUDE_DIR ${BOOST}/include)
  328. set(BOOST_LIBPATH ${BOOST}/lib)
  329. if(CMAKE_CL_64)
  330. set(BOOST_POSTFIX "vc140-mt-s-x64-1_68.lib")
  331. set(BOOST_DEBUG_POSTFIX "vc140-mt-sgd-x64-1_68.lib")
  332. else()
  333. set(BOOST_POSTFIX "vc140-mt-s-x32-1_68.lib")
  334. set(BOOST_DEBUG_POSTFIX "vc140-mt-sgd-x32-1_68.lib")
  335. endif()
  336. set(BOOST_LIBRARIES
  337. optimized ${BOOST_LIBPATH}/libboost_date_time-${BOOST_POSTFIX}
  338. optimized ${BOOST_LIBPATH}/libboost_filesystem-${BOOST_POSTFIX}
  339. optimized ${BOOST_LIBPATH}/libboost_regex-${BOOST_POSTFIX}
  340. optimized ${BOOST_LIBPATH}/libboost_system-${BOOST_POSTFIX}
  341. optimized ${BOOST_LIBPATH}/libboost_thread-${BOOST_POSTFIX}
  342. optimized ${BOOST_LIBPATH}/libboost_chrono-${BOOST_POSTFIX}
  343. debug ${BOOST_LIBPATH}/libboost_date_time-${BOOST_DEBUG_POSTFIX}
  344. debug ${BOOST_LIBPATH}/libboost_filesystem-${BOOST_DEBUG_POSTFIX}
  345. debug ${BOOST_LIBPATH}/libboost_regex-${BOOST_DEBUG_POSTFIX}
  346. debug ${BOOST_LIBPATH}/libboost_system-${BOOST_DEBUG_POSTFIX}
  347. debug ${BOOST_LIBPATH}/libboost_thread-${BOOST_DEBUG_POSTFIX}
  348. debug ${BOOST_LIBPATH}/libboost_chrono-${BOOST_DEBUG_POSTFIX}
  349. )
  350. if(WITH_CYCLES_OSL)
  351. set(BOOST_LIBRARIES ${BOOST_LIBRARIES}
  352. optimized ${BOOST_LIBPATH}/libboost_wave-${BOOST_POSTFIX}
  353. debug ${BOOST_LIBPATH}/libboost_wave-${BOOST_DEBUG_POSTFIX})
  354. endif()
  355. if(WITH_INTERNATIONAL)
  356. set(BOOST_LIBRARIES ${BOOST_LIBRARIES}
  357. optimized ${BOOST_LIBPATH}/libboost_locale-${BOOST_POSTFIX}
  358. debug ${BOOST_LIBPATH}/libboost_locale-${BOOST_DEBUG_POSTFIX})
  359. endif()
  360. else() # we found boost using find_package
  361. set(BOOST_INCLUDE_DIR ${Boost_INCLUDE_DIRS})
  362. set(BOOST_LIBRARIES ${Boost_LIBRARIES})
  363. set(BOOST_LIBPATH ${Boost_LIBRARY_DIRS})
  364. endif()
  365. set(BOOST_DEFINITIONS "-DBOOST_ALL_NO_LIB")
  366. endif()
  367. if(WITH_OPENIMAGEIO)
  368. windows_find_package(OpenImageIO)
  369. set(OPENIMAGEIO ${LIBDIR}/openimageio)
  370. set(OPENIMAGEIO_LIBPATH ${OPENIMAGEIO}/lib)
  371. set(OPENIMAGEIO_INCLUDE_DIRS ${OPENIMAGEIO}/include)
  372. set(OIIO_OPTIMIZED optimized ${OPENIMAGEIO_LIBPATH}/OpenImageIO.lib optimized ${OPENIMAGEIO_LIBPATH}/OpenImageIO_Util.lib)
  373. set(OIIO_DEBUG debug ${OPENIMAGEIO_LIBPATH}/OpenImageIO_d.lib debug ${OPENIMAGEIO_LIBPATH}/OpenImageIO_Util_d.lib)
  374. set(OPENIMAGEIO_LIBRARIES ${OIIO_OPTIMIZED} ${OIIO_DEBUG})
  375. set(OPENIMAGEIO_DEFINITIONS "-DUSE_TBB=0")
  376. set(OPENCOLORIO_DEFINITIONS "-DOCIO_STATIC_BUILD")
  377. set(OPENIMAGEIO_IDIFF "${OPENIMAGEIO}/bin/idiff.exe")
  378. add_definitions(-DOIIO_STATIC_BUILD)
  379. add_definitions(-DOIIO_NO_SSE=1)
  380. endif()
  381. if(WITH_LLVM)
  382. set(LLVM_ROOT_DIR ${LIBDIR}/llvm CACHE PATH "Path to the LLVM installation")
  383. set(LLVM_INCLUDE_DIRS ${LLVM_ROOT_DIR}/$<$<CONFIG:Debug>:Debug>/include CACHE PATH "Path to the LLVM include directory")
  384. file(GLOB LLVM_LIBRARY_OPTIMIZED ${LLVM_ROOT_DIR}/lib/*.lib)
  385. if(EXISTS ${LLVM_ROOT_DIR}/debug/lib)
  386. foreach(LLVM_OPTIMIZED_LIB ${LLVM_LIBRARY_OPTIMIZED})
  387. get_filename_component(LIBNAME ${LLVM_OPTIMIZED_LIB} ABSOLUTE)
  388. list(APPEND LLVM_LIBS optimized ${LIBNAME})
  389. endforeach(LLVM_OPTIMIZED_LIB)
  390. file(GLOB LLVM_LIBRARY_DEBUG ${LLVM_ROOT_DIR}/debug/lib/*.lib)
  391. foreach(LLVM_DEBUG_LIB ${LLVM_LIBRARY_DEBUG})
  392. get_filename_component(LIBNAME ${LLVM_DEBUG_LIB} ABSOLUTE)
  393. list(APPEND LLVM_LIBS debug ${LIBNAME})
  394. endforeach(LLVM_DEBUG_LIB)
  395. set(LLVM_LIBRARY ${LLVM_LIBS})
  396. else()
  397. message(WARNING "LLVM debug libs not present on this system. Using release libs for debug builds.")
  398. set(LLVM_LIBRARY ${LLVM_LIBRARY_OPTIMIZED})
  399. endif()
  400. endif()
  401. if(WITH_OPENCOLORIO)
  402. set(OPENCOLORIO ${LIBDIR}/opencolorio)
  403. set(OPENCOLORIO_INCLUDE_DIRS ${OPENCOLORIO}/include)
  404. set(OPENCOLORIO_LIBPATH ${LIBDIR}/opencolorio/lib)
  405. set(OPENCOLORIO_LIBRARIES
  406. optimized ${OPENCOLORIO_LIBPATH}/OpenColorIO.lib
  407. optimized ${OPENCOLORIO_LIBPATH}/tinyxml.lib
  408. optimized ${OPENCOLORIO_LIBPATH}/libyaml-cpp.lib
  409. debug ${OPENCOLORIO_LIBPATH}/OpenColorIO_d.lib
  410. debug ${OPENCOLORIO_LIBPATH}/tinyxml_d.lib
  411. debug ${OPENCOLORIO_LIBPATH}/libyaml-cpp_d.lib
  412. )
  413. set(OPENCOLORIO_DEFINITIONS)
  414. endif()
  415. if(WITH_OPENVDB)
  416. set(BLOSC_LIBRARIES optimized ${LIBDIR}/blosc/lib/libblosc.lib debug ${LIBDIR}/blosc/lib/libblosc_d.lib)
  417. set(TBB_LIBRARIES optimized ${LIBDIR}/tbb/lib/tbb.lib debug ${LIBDIR}/tbb/lib/tbb_debug.lib)
  418. set(TBB_INCLUDE_DIR ${LIBDIR}/tbb/include)
  419. set(OPENVDB ${LIBDIR}/openvdb)
  420. set(OPENVDB_LIBPATH ${LIBDIR}/openvdb/lib)
  421. set(OPENVDB_INCLUDE_DIRS ${OPENVDB}/include ${TBB_INCLUDE_DIR})
  422. set(OPENVDB_LIBRARIES optimized ${OPENVDB_LIBPATH}/openvdb.lib debug ${OPENVDB_LIBPATH}/openvdb_d.lib ${TBB_LIBRARIES} ${BLOSC_LIBRARIES})
  423. set(OPENVDB_DEFINITIONS -DNOMINMAX)
  424. endif()
  425. if(WITH_ALEMBIC)
  426. set(ALEMBIC ${LIBDIR}/alembic)
  427. set(ALEMBIC_INCLUDE_DIR ${ALEMBIC}/include)
  428. set(ALEMBIC_INCLUDE_DIRS ${ALEMBIC_INCLUDE_DIR})
  429. set(ALEMBIC_LIBPATH ${ALEMBIC}/lib)
  430. set(ALEMBIC_LIBRARIES optimized ${ALEMBIC}/lib/alembic.lib debug ${ALEMBIC}/lib/alembic_d.lib)
  431. set(ALEMBIC_FOUND 1)
  432. endif()
  433. if(WITH_MOD_CLOTH_ELTOPO)
  434. set(LAPACK ${LIBDIR}/lapack)
  435. # set(LAPACK_INCLUDE_DIR ${LAPACK}/include)
  436. set(LAPACK_LIBPATH ${LAPACK}/lib)
  437. set(LAPACK_LIBRARIES
  438. ${LIBDIR}/lapack/lib/libf2c.lib
  439. ${LIBDIR}/lapack/lib/clapack_nowrap.lib
  440. ${LIBDIR}/lapack/lib/BLAS_nowrap.lib
  441. )
  442. endif()
  443. if(WITH_IMAGE_OPENJPEG)
  444. set(OPENJPEG ${LIBDIR}/openjpeg)
  445. set(OPENJPEG_INCLUDE_DIRS ${OPENJPEG}/include/openjpeg-2.3)
  446. set(OPENJPEG_LIBRARIES ${OPENJPEG}/lib/openjp2.lib)
  447. endif()
  448. if(WITH_OPENSUBDIV)
  449. set(OPENSUBDIV_INCLUDE_DIR ${LIBDIR}/opensubdiv/include)
  450. set(OPENSUBDIV_LIBPATH ${LIBDIR}/opensubdiv/lib)
  451. set(OPENSUBDIV_LIBRARIES
  452. optimized ${OPENSUBDIV_LIBPATH}/osdCPU.lib
  453. optimized ${OPENSUBDIV_LIBPATH}/osdGPU.lib
  454. debug ${OPENSUBDIV_LIBPATH}/osdCPU_d.lib
  455. debug ${OPENSUBDIV_LIBPATH}/osdGPU_d.lib
  456. )
  457. set(OPENSUBDIV_HAS_OPENMP TRUE)
  458. set(OPENSUBDIV_HAS_TBB FALSE)
  459. set(OPENSUBDIV_HAS_OPENCL TRUE)
  460. set(OPENSUBDIV_HAS_CUDA FALSE)
  461. set(OPENSUBDIV_HAS_GLSL_TRANSFORM_FEEDBACK TRUE)
  462. set(OPENSUBDIV_HAS_GLSL_COMPUTE TRUE)
  463. windows_find_package(OpenSubdiv)
  464. endif()
  465. if(WITH_SDL)
  466. set(SDL ${LIBDIR}/sdl)
  467. set(SDL_INCLUDE_DIR ${SDL}/include)
  468. set(SDL_LIBPATH ${SDL}/lib)
  469. set(SDL_LIBRARY ${SDL_LIBPATH}/SDL2.lib)
  470. endif()
  471. # Audio IO
  472. if(WITH_SYSTEM_AUDASPACE)
  473. set(AUDASPACE_INCLUDE_DIRS ${LIBDIR}/audaspace/include/audaspace)
  474. set(AUDASPACE_LIBRARIES ${LIBDIR}/audaspace/lib/audaspace.lib)
  475. set(AUDASPACE_C_INCLUDE_DIRS ${LIBDIR}/audaspace/include/audaspace)
  476. set(AUDASPACE_C_LIBRARIES ${LIBDIR}/audaspace/lib/audaspace-c.lib)
  477. set(AUDASPACE_PY_INCLUDE_DIRS ${LIBDIR}/audaspace/include/audaspace)
  478. set(AUDASPACE_PY_LIBRARIES ${LIBDIR}/audaspace/lib/audaspace-py.lib)
  479. endif()
  480. # used in many places so include globally, like OpenGL
  481. blender_include_dirs_sys("${PTHREADS_INCLUDE_DIRS}")
  482. #find signtool
  483. set(ProgramFilesX86_NAME "ProgramFiles(x86)") #env dislikes the ( )
  484. find_program(SIGNTOOL_EXE signtool
  485. HINTS
  486. "$ENV{${ProgramFilesX86_NAME}}/Windows Kits/10/bin/x86/"
  487. "$ENV{ProgramFiles}/Windows Kits/10/bin/x86/"
  488. "$ENV{${ProgramFilesX86_NAME}}/Windows Kits/8.1/bin/x86/"
  489. "$ENV{ProgramFiles}/Windows Kits/8.1/bin/x86/"
  490. "$ENV{${ProgramFilesX86_NAME}}/Windows Kits/8.0/bin/x86/"
  491. "$ENV{ProgramFiles}/Windows Kits/8.0/bin/x86/"
  492. )
  493. set(WINTAB_INC ${LIBDIR}/wintab/include)
  494. if(WITH_OPENAL)
  495. set(OPENAL ${LIBDIR}/openal)
  496. set(OPENALDIR ${LIBDIR}/openal)
  497. set(OPENAL_INCLUDE_DIR ${OPENAL}/include/AL)
  498. set(OPENAL_LIBPATH ${OPENAL}/lib)
  499. if(MSVC)
  500. set(OPENAL_LIBRARY ${OPENAL_LIBPATH}/openal32.lib)
  501. else()
  502. set(OPENAL_LIBRARY ${OPENAL_LIBPATH}/wrap_oal.lib)
  503. endif()
  504. endif()
  505. if(WITH_CODEC_SNDFILE)
  506. set(LIBSNDFILE ${LIBDIR}/sndfile)
  507. set(LIBSNDFILE_INCLUDE_DIRS ${LIBSNDFILE}/include)
  508. set(LIBSNDFILE_LIBPATH ${LIBSNDFILE}/lib) # TODO, deprecate
  509. set(LIBSNDFILE_LIBRARIES ${LIBSNDFILE_LIBPATH}/libsndfile-1.lib)
  510. endif()
  511. if(WITH_RAYOPTIMIZATION AND SUPPORT_SSE_BUILD)
  512. add_definitions(-D__SSE__ -D__MMX__)
  513. endif()
  514. if(WITH_CYCLES_OSL)
  515. set(CYCLES_OSL ${LIBDIR}/osl CACHE PATH "Path to OpenShadingLanguage installation")
  516. find_library(OSL_LIB_EXEC NAMES oslexec PATHS ${CYCLES_OSL}/lib)
  517. find_library(OSL_LIB_COMP NAMES oslcomp PATHS ${CYCLES_OSL}/lib)
  518. find_library(OSL_LIB_QUERY NAMES oslquery PATHS ${CYCLES_OSL}/lib)
  519. find_library(OSL_LIB_EXEC_DEBUG NAMES oslexec_d PATHS ${CYCLES_OSL}/lib)
  520. find_library(OSL_LIB_COMP_DEBUG NAMES oslcomp_d PATHS ${CYCLES_OSL}/lib)
  521. find_library(OSL_LIB_QUERY_DEBUG NAMES oslquery_d PATHS ${CYCLES_OSL}/lib)
  522. list(APPEND OSL_LIBRARIES
  523. optimized ${OSL_LIB_COMP}
  524. optimized ${OSL_LIB_EXEC}
  525. optimized ${OSL_LIB_QUERY}
  526. optimized ${CYCLES_OSL}/lib/pugixml.lib
  527. debug ${OSL_LIB_EXEC_DEBUG}
  528. debug ${OSL_LIB_COMP_DEBUG}
  529. debug ${OSL_LIB_QUERY_DEBUG}
  530. debug ${CYCLES_OSL}/lib/pugixml_d.lib
  531. )
  532. find_path(OSL_INCLUDE_DIR OSL/oslclosure.h PATHS ${CYCLES_OSL}/include)
  533. find_program(OSL_COMPILER NAMES oslc PATHS ${CYCLES_OSL}/bin)
  534. if(OSL_INCLUDE_DIR AND OSL_LIBRARIES AND OSL_COMPILER)
  535. set(OSL_FOUND TRUE)
  536. else()
  537. message(STATUS "OSL not found")
  538. set(WITH_CYCLES_OSL OFF)
  539. endif()
  540. endif()
  541. if(WITH_CYCLES_EMBREE)
  542. windows_find_package(Embree)
  543. if(NOT EMBREE_FOUND)
  544. set(EMBREE_INCLUDE_DIRS ${LIBDIR}/embree/include)
  545. set(EMBREE_LIBRARIES
  546. optimized ${LIBDIR}/embree/lib/embree3.lib
  547. optimized ${LIBDIR}/embree/lib/embree_avx2.lib
  548. optimized ${LIBDIR}/embree/lib/embree_avx.lib
  549. optimized ${LIBDIR}/embree/lib/embree_sse42.lib
  550. optimized ${LIBDIR}/embree/lib/lexers.lib
  551. optimized ${LIBDIR}/embree/lib/math.lib
  552. optimized ${LIBDIR}/embree/lib/simd.lib
  553. optimized ${LIBDIR}/embree/lib/sys.lib
  554. optimized ${LIBDIR}/embree/lib/tasking.lib
  555. debug ${LIBDIR}/embree/lib/embree3_d.lib
  556. debug ${LIBDIR}/embree/lib/embree_avx2_d.lib
  557. debug ${LIBDIR}/embree/lib/embree_avx_d.lib
  558. debug ${LIBDIR}/embree/lib/embree_sse42_d.lib
  559. debug ${LIBDIR}/embree/lib/lexers_d.lib
  560. debug ${LIBDIR}/embree/lib/math_d.lib
  561. debug ${LIBDIR}/embree/lib/simd_d.lib
  562. debug ${LIBDIR}/embree/lib/sys_d.lib
  563. debug ${LIBDIR}/embree/lib/tasking_d.lib)
  564. endif()
  565. endif()
  566. if(WINDOWS_PYTHON_DEBUG)
  567. # Include the system scripts in the blender_python_system_scripts project.
  568. FILE(GLOB_RECURSE inFiles "${CMAKE_SOURCE_DIR}/release/scripts/*.*" )
  569. ADD_CUSTOM_TARGET(blender_python_system_scripts SOURCES ${inFiles})
  570. foreach(_source IN ITEMS ${inFiles})
  571. get_filename_component(_source_path "${_source}" PATH)
  572. string(REPLACE "${CMAKE_SOURCE_DIR}/release/scripts/" "" _source_path "${_source_path}")
  573. string(REPLACE "/" "\\" _group_path "${_source_path}")
  574. source_group("${_group_path}" FILES "${_source}")
  575. endforeach()
  576. # Include the user scripts from the profile folder in the blender_python_user_scripts project.
  577. set(USER_SCRIPTS_ROOT "$ENV{appdata}/blender foundation/blender/${BLENDER_VERSION}")
  578. file(TO_CMAKE_PATH ${USER_SCRIPTS_ROOT} USER_SCRIPTS_ROOT)
  579. FILE(GLOB_RECURSE inFiles "${USER_SCRIPTS_ROOT}/scripts/*.*" )
  580. ADD_CUSTOM_TARGET(blender_python_user_scripts SOURCES ${inFiles})
  581. foreach(_source IN ITEMS ${inFiles})
  582. get_filename_component(_source_path "${_source}" PATH)
  583. string(REPLACE "${USER_SCRIPTS_ROOT}/scripts" "" _source_path "${_source_path}")
  584. string(REPLACE "/" "\\" _group_path "${_source_path}")
  585. source_group("${_group_path}" FILES "${_source}")
  586. endforeach()
  587. set_target_properties(blender_python_system_scripts PROPERTIES FOLDER "scripts")
  588. set_target_properties(blender_python_user_scripts PROPERTIES FOLDER "scripts")
  589. # Set the default debugging options for the project, only write this file once so the user
  590. # is free to override them at their own perril.
  591. set(USER_PROPS_FILE "${CMAKE_CURRENT_BINARY_DIR}/source/creator/blender.Cpp.user.props")
  592. if(NOT EXISTS ${USER_PROPS_FILE})
  593. # Layout below is messy, because otherwise the generated file will look messy.
  594. file(WRITE ${USER_PROPS_FILE} "<?xml version=\"1.0\" encoding=\"utf-8\"?>
  595. <Project DefaultTargets=\"Build\" xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">
  596. <PropertyGroup>
  597. <LocalDebuggerCommandArguments>-con --env-system-scripts \"${CMAKE_SOURCE_DIR}/release/scripts\" </LocalDebuggerCommandArguments>
  598. </PropertyGroup>
  599. </Project>")
  600. endif()
  601. endif()