deps-windows.cmake 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304
  1. # https://cmake.org/cmake/help/latest/variable/MSVC_VERSION.html
  2. if (MSVC_VERSION EQUAL 1800)
  3. # 1800 = VS 12.0 (v120 toolset)
  4. set(DEP_VS_VER "12")
  5. set(DEP_BOOST_TOOLSET "msvc-12.0")
  6. elseif (MSVC_VERSION EQUAL 1900)
  7. # 1900 = VS 14.0 (v140 toolset)
  8. set(DEP_VS_VER "14")
  9. set(DEP_BOOST_TOOLSET "msvc-14.0")
  10. elseif (MSVC_VERSION LESS 1920)
  11. # 1910-1919 = VS 15.0 (v141 toolset)
  12. set(DEP_VS_VER "15")
  13. set(DEP_BOOST_TOOLSET "msvc-14.1")
  14. elseif (MSVC_VERSION LESS 1930)
  15. # 1920-1929 = VS 16.0 (v142 toolset)
  16. set(DEP_VS_VER "16")
  17. set(DEP_BOOST_TOOLSET "msvc-14.2")
  18. else ()
  19. message(FATAL_ERROR "Unsupported MSVC version")
  20. endif ()
  21. if (CMAKE_CXX_COMPILER_ID STREQUAL Clang)
  22. set(DEP_BOOST_TOOLSET "clang-win")
  23. endif ()
  24. if (${DEPS_BITS} EQUAL 32)
  25. set(DEP_MSVC_GEN "Visual Studio ${DEP_VS_VER}")
  26. # set(DEP_PLATFORM "Win32")
  27. else ()
  28. if (DEP_VS_VER LESS 16)
  29. set(DEP_MSVC_GEN "Visual Studio ${DEP_VS_VER} Win64")
  30. else ()
  31. set(DEP_MSVC_GEN "Visual Studio ${DEP_VS_VER}")
  32. set(DEP_PLATFORM "x64")
  33. endif ()
  34. # set(DEP_PLATFORM "x64")
  35. endif ()
  36. if (${DEP_DEBUG})
  37. set(DEP_BOOST_DEBUG "debug")
  38. else ()
  39. set(DEP_BOOST_DEBUG "")
  40. endif ()
  41. macro(add_debug_dep _dep)
  42. if (${DEP_DEBUG})
  43. ExternalProject_Get_Property(${_dep} BINARY_DIR)
  44. ExternalProject_Add_Step(${_dep} build_debug
  45. DEPENDEES build
  46. DEPENDERS install
  47. COMMAND msbuild /m /P:Configuration=Debug INSTALL.vcxproj
  48. WORKING_DIRECTORY "${BINARY_DIR}"
  49. )
  50. endif ()
  51. endmacro()
  52. ExternalProject_Add(dep_boost
  53. EXCLUDE_FROM_ALL 1
  54. URL "https://github.com/supermerill/SuperSlicer_deps/releases/download/0.4/boost_1_70_0.tar.gz"
  55. URL_HASH SHA256=882b48708d211a5f48e60b0124cf5863c1534cd544ecd0664bb534a4b5d506e9
  56. BUILD_IN_SOURCE 1
  57. CONFIGURE_COMMAND bootstrap.bat
  58. BUILD_COMMAND b2.exe
  59. -j "${NPROC}"
  60. --with-system
  61. --with-iostreams
  62. --with-filesystem
  63. --with-thread
  64. --with-log
  65. --with-locale
  66. --with-regex
  67. "--prefix=${DESTDIR}/usr/local"
  68. "address-model=${DEPS_BITS}"
  69. "toolset=${DEP_BOOST_TOOLSET}"
  70. link=static
  71. variant=release
  72. threading=multi
  73. boost.locale.icu=off
  74. "${DEP_BOOST_DEBUG}" release install
  75. INSTALL_COMMAND "" # b2 does that already
  76. )
  77. ExternalProject_Add(dep_tbb
  78. EXCLUDE_FROM_ALL 1
  79. URL "https://github.com/wjakob/tbb/archive/a0dc9bf76d0120f917b641ed095360448cabc85b.tar.gz"
  80. URL_HASH SHA256=0545cb6033bd1873fcae3ea304def720a380a88292726943ae3b9b207f322efe
  81. CMAKE_GENERATOR "${DEP_MSVC_GEN}"
  82. if (DEP_VS_VER MORE 15)
  83. CMAKE_GENERATOR_PLATFORM "${DEP_PLATFORM}"
  84. endif()
  85. CMAKE_ARGS
  86. -DCMAKE_DEBUG_POSTFIX=_debug
  87. -DTBB_BUILD_SHARED=OFF
  88. -DTBB_BUILD_TESTS=OFF
  89. "-DCMAKE_INSTALL_PREFIX:PATH=${DESTDIR}\\usr\\local"
  90. BUILD_COMMAND msbuild /m /P:Configuration=Release INSTALL.vcxproj
  91. INSTALL_COMMAND ""
  92. )
  93. add_debug_dep(dep_tbb)
  94. # ExternalProject_Add(dep_gtest
  95. # EXCLUDE_FROM_ALL 1
  96. # URL "https://github.com/google/googletest/archive/release-1.8.1.tar.gz"
  97. # URL_HASH SHA256=9bf1fe5182a604b4135edc1a425ae356c9ad15e9b23f9f12a02e80184c3a249c
  98. # CMAKE_GENERATOR "${DEP_MSVC_GEN}"
  99. # CMAKE_GENERATOR_PLATFORM "${DEP_PLATFORM}"
  100. # CMAKE_ARGS
  101. # -DBUILD_GMOCK=OFF
  102. # -Dgtest_force_shared_crt=ON
  103. # -DCMAKE_POSITION_INDEPENDENT_CODE=ON
  104. # "-DCMAKE_INSTALL_PREFIX:PATH=${DESTDIR}\\usr\\local"
  105. # BUILD_COMMAND msbuild /m /P:Configuration=Release INSTALL.vcxproj
  106. # INSTALL_COMMAND ""
  107. # )
  108. # add_debug_dep(dep_gtest)
  109. ExternalProject_Add(dep_cereal
  110. EXCLUDE_FROM_ALL 1
  111. URL "https://github.com/USCiLab/cereal/archive/v1.2.2.tar.gz"
  112. # URL_HASH SHA256=c6dd7a5701fff8ad5ebb45a3dc8e757e61d52658de3918e38bab233e7fd3b4ae
  113. CMAKE_GENERATOR "${DEP_MSVC_GEN}"
  114. if (DEP_VS_VER MORE 15)
  115. CMAKE_GENERATOR_PLATFORM "${DEP_PLATFORM}"
  116. endif()
  117. CMAKE_ARGS
  118. -DJUST_INSTALL_CEREAL=on
  119. "-DCMAKE_INSTALL_PREFIX:PATH=${DESTDIR}\\usr\\local"
  120. BUILD_COMMAND msbuild /m /P:Configuration=Release INSTALL.vcxproj
  121. INSTALL_COMMAND ""
  122. )
  123. ExternalProject_Add(dep_nlopt
  124. EXCLUDE_FROM_ALL 1
  125. URL "https://github.com/stevengj/nlopt/archive/v2.5.0.tar.gz"
  126. # URL_HASH SHA256=c81bf6d981c328f3e634709dc84746e32ff5cfb715f698ead2de4d57e30a0e70
  127. URL_HASH SHA256=c6dd7a5701fff8ad5ebb45a3dc8e757e61d52658de3918e38bab233e7fd3b4ae
  128. CMAKE_GENERATOR "${DEP_MSVC_GEN}"
  129. if (DEP_VS_VER MORE 15)
  130. CMAKE_GENERATOR_PLATFORM "${DEP_PLATFORM}"
  131. endif()
  132. CMAKE_ARGS
  133. -DBUILD_SHARED_LIBS=OFF
  134. -DNLOPT_PYTHON=OFF
  135. -DNLOPT_OCTAVE=OFF
  136. -DNLOPT_MATLAB=OFF
  137. -DNLOPT_GUILE=OFF
  138. -DCMAKE_POSITION_INDEPENDENT_CODE=ON
  139. -DCMAKE_DEBUG_POSTFIX=d
  140. "-DCMAKE_INSTALL_PREFIX:PATH=${DESTDIR}\\usr\\local"
  141. BUILD_COMMAND msbuild /m /P:Configuration=Release INSTALL.vcxproj
  142. INSTALL_COMMAND ""
  143. )
  144. add_debug_dep(dep_nlopt)
  145. if (${DEPS_BITS} EQUAL 32)
  146. set(DEP_LIBCURL_TARGET "x86")
  147. else ()
  148. set(DEP_LIBCURL_TARGET "x64")
  149. endif ()
  150. ExternalProject_Add(dep_libcurl
  151. EXCLUDE_FROM_ALL 1
  152. URL "https://curl.haxx.se/download/curl-7.58.0.tar.gz"
  153. URL_HASH SHA256=cc245bf9a1a42a45df491501d97d5593392a03f7b4f07b952793518d97666115
  154. BUILD_IN_SOURCE 1
  155. CONFIGURE_COMMAND ""
  156. BUILD_COMMAND cd winbuild && nmake /f Makefile.vc mode=static "VC=${DEP_VS_VER}" GEN_PDB=yes DEBUG=no "MACHINE=${DEP_LIBCURL_TARGET}"
  157. INSTALL_COMMAND cd builds\\libcurl-*-release-*-winssl
  158. && "${CMAKE_COMMAND}" -E copy_directory include "${DESTDIR}\\usr\\local\\include"
  159. && "${CMAKE_COMMAND}" -E copy_directory lib "${DESTDIR}\\usr\\local\\lib"
  160. )
  161. if (${DEP_DEBUG})
  162. ExternalProject_Get_Property(dep_libcurl SOURCE_DIR)
  163. ExternalProject_Add_Step(dep_libcurl build_debug
  164. DEPENDEES build
  165. DEPENDERS install
  166. COMMAND cd winbuild && nmake /f Makefile.vc mode=static "VC=${DEP_VS_VER}" GEN_PDB=yes DEBUG=yes "MACHINE=${DEP_LIBCURL_TARGET}"
  167. WORKING_DIRECTORY "${SOURCE_DIR}"
  168. )
  169. ExternalProject_Add_Step(dep_libcurl install_debug
  170. DEPENDEES install
  171. COMMAND cd builds\\libcurl-*-debug-*-winssl
  172. && "${CMAKE_COMMAND}" -E copy_directory include "${DESTDIR}\\usr\\local\\include"
  173. && "${CMAKE_COMMAND}" -E copy_directory lib "${DESTDIR}\\usr\\local\\lib"
  174. WORKING_DIRECTORY "${SOURCE_DIR}"
  175. )
  176. endif ()
  177. ExternalProject_Add(dep_qhull
  178. EXCLUDE_FROM_ALL 1
  179. #URL "https://github.com/qhull/qhull/archive/v7.3.2.tar.gz"
  180. #URL_HASH SHA256=619c8a954880d545194bc03359404ef36a1abd2dde03678089459757fd790cb0
  181. GIT_REPOSITORY https://github.com/qhull/qhull.git
  182. GIT_TAG 7afedcc73666e46a9f1d74632412ebecf53b1b30 # v7.3.2 plus the mac build patch
  183. CMAKE_GENERATOR "${DEP_MSVC_GEN}"
  184. CMAKE_ARGS
  185. -DCMAKE_INSTALL_PREFIX=${DESTDIR}/usr/local
  186. -DBUILD_SHARED_LIBS=OFF
  187. -DCMAKE_POSITION_INDEPENDENT_CODE=ON
  188. -DCMAKE_DEBUG_POSTFIX=d
  189. BUILD_COMMAND msbuild /m /P:Configuration=Release INSTALL.vcxproj
  190. INSTALL_COMMAND ""
  191. )
  192. add_debug_dep(dep_qhull)
  193. if (${DEPS_BITS} EQUAL 32)
  194. set(DEP_WXWIDGETS_TARGET "")
  195. set(DEP_WXWIDGETS_LIBDIR "vc_lib")
  196. else ()
  197. set(DEP_WXWIDGETS_TARGET "TARGET_CPU=X64")
  198. set(DEP_WXWIDGETS_LIBDIR "vc_x64_lib")
  199. endif ()
  200. find_package(Git REQUIRED)
  201. ExternalProject_Add(dep_blosc
  202. EXCLUDE_FROM_ALL 1
  203. #URL https://github.com/Blosc/c-blosc/archive/v1.17.0.zip
  204. #URL_HASH SHA256=7463a1df566704f212263312717ab2c36b45d45cba6cd0dccebf91b2cc4b4da9
  205. GIT_REPOSITORY https://github.com/Blosc/c-blosc.git
  206. GIT_TAG e63775855294b50820ef44d1b157f4de1cc38d3e #v1.17.0
  207. CMAKE_GENERATOR "${DEP_MSVC_GEN}"
  208. CMAKE_GENERATOR_PLATFORM "${DEP_PLATFORM}"
  209. CMAKE_ARGS
  210. -DCMAKE_INSTALL_PREFIX=${DESTDIR}/usr/local
  211. -DBUILD_SHARED_LIBS=OFF
  212. -DCMAKE_POSITION_INDEPENDENT_CODE=ON
  213. -DCMAKE_DEBUG_POSTFIX=d
  214. -DBUILD_SHARED=OFF
  215. -DBUILD_STATIC=ON
  216. -DBUILD_TESTS=OFF
  217. -DBUILD_BENCHMARKS=OFF
  218. -DPREFER_EXTERNAL_ZLIB=ON
  219. -DBLOSC_IS_SUBPROJECT:BOOL=ON
  220. -DBLOSC_INSTALL:BOOL=ON
  221. PATCH_COMMAND ${GIT_EXECUTABLE} checkout -f -- . && git clean -df &&
  222. ${GIT_EXECUTABLE} apply --whitespace=fix ${CMAKE_CURRENT_SOURCE_DIR}/blosc-mods.patch
  223. BUILD_COMMAND msbuild /m /P:Configuration=Release INSTALL.vcxproj
  224. INSTALL_COMMAND ""
  225. )
  226. add_debug_dep(dep_blosc)
  227. ExternalProject_Add(dep_openexr
  228. EXCLUDE_FROM_ALL 1
  229. GIT_REPOSITORY https://github.com/openexr/openexr.git
  230. GIT_TAG eae0e337c9f5117e78114fd05f7a415819df413a #v2.4.0
  231. CMAKE_GENERATOR "${DEP_MSVC_GEN}"
  232. CMAKE_GENERATOR_PLATFORM "${DEP_PLATFORM}"
  233. CMAKE_ARGS
  234. -DCMAKE_INSTALL_PREFIX=${DESTDIR}/usr/local
  235. -DBUILD_SHARED_LIBS=OFF
  236. -DCMAKE_POSITION_INDEPENDENT_CODE=ON
  237. -DBUILD_TESTING=OFF
  238. -DPYILMBASE_ENABLE:BOOL=OFF
  239. -DOPENEXR_VIEWERS_ENABLE:BOOL=OFF
  240. -DOPENEXR_BUILD_UTILS:BOOL=OFF
  241. BUILD_COMMAND msbuild /m /P:Configuration=Release INSTALL.vcxproj
  242. INSTALL_COMMAND ""
  243. )
  244. add_debug_dep(dep_openexr)
  245. ExternalProject_Add(dep_openvdb
  246. EXCLUDE_FROM_ALL 1
  247. #URL https://github.com/AcademySoftwareFoundation/openvdb/archive/v6.2.1.zip
  248. #URL_HASH SHA256=dc337399dce8e1c9f21f20e97b1ce7e4933cb0a63bb3b8b734d8fcc464aa0c48
  249. GIT_REPOSITORY https://github.com/AcademySoftwareFoundation/openvdb.git
  250. GIT_TAG aebaf8d95be5e57fd33949281ec357db4a576c2e #v6.2.1
  251. DEPENDS dep_blosc dep_openexr dep_tbb dep_boost
  252. CMAKE_GENERATOR "${DEP_MSVC_GEN}"
  253. CMAKE_GENERATOR_PLATFORM "${DEP_PLATFORM}"
  254. CMAKE_ARGS
  255. -DCMAKE_INSTALL_PREFIX=${DESTDIR}/usr/local
  256. -DCMAKE_DEBUG_POSTFIX=d
  257. -DCMAKE_PREFIX_PATH=${DESTDIR}/usr/local
  258. -DBUILD_SHARED_LIBS=OFF
  259. -DCMAKE_POSITION_INDEPENDENT_CODE=ON
  260. -DOPENVDB_BUILD_PYTHON_MODULE=OFF
  261. -DUSE_BLOSC=ON
  262. -DOPENVDB_CORE_SHARED=OFF
  263. -DOPENVDB_CORE_STATIC=ON
  264. -DTBB_STATIC=ON
  265. -DOPENVDB_BUILD_VDB_PRINT=ON
  266. BUILD_COMMAND msbuild /m /P:Configuration=Release INSTALL.vcxproj
  267. PATCH_COMMAND ${GIT_EXECUTABLE} checkout -f -- . && git clean -df &&
  268. ${GIT_EXECUTABLE} apply --whitespace=fix ${CMAKE_CURRENT_SOURCE_DIR}/openvdb-mods.patch
  269. INSTALL_COMMAND ""
  270. )
  271. if (${DEP_DEBUG})
  272. ExternalProject_Get_Property(dep_openvdb BINARY_DIR)
  273. ExternalProject_Add_Step(dep_openvdb build_debug
  274. DEPENDEES build
  275. DEPENDERS install
  276. COMMAND ${CMAKE_COMMAND} ../dep_openvdb -DOPENVDB_BUILD_VDB_PRINT=OFF
  277. COMMAND msbuild /m /P:Configuration=Debug INSTALL.vcxproj
  278. WORKING_DIRECTORY "${BINARY_DIR}"
  279. )
  280. endif ()