deps-windows.cmake 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361
  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://dl.bintray.com/boostorg/release/1.70.0/source/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. CMAKE_GENERATOR_PLATFORM "${DEP_PLATFORM}"
  115. CMAKE_ARGS
  116. -DJUST_INSTALL_CEREAL=on
  117. "-DCMAKE_INSTALL_PREFIX:PATH=${DESTDIR}\\usr\\local"
  118. BUILD_COMMAND msbuild /m /P:Configuration=Release INSTALL.vcxproj
  119. INSTALL_COMMAND ""
  120. )
  121. ExternalProject_Add(dep_nlopt
  122. EXCLUDE_FROM_ALL 1
  123. URL "https://github.com/stevengj/nlopt/archive/v2.5.0.tar.gz"
  124. # URL_HASH SHA256=c81bf6d981c328f3e634709dc84746e32ff5cfb715f698ead2de4d57e30a0e70
  125. URL_HASH SHA256=c6dd7a5701fff8ad5ebb45a3dc8e757e61d52658de3918e38bab233e7fd3b4ae
  126. CMAKE_GENERATOR "${DEP_MSVC_GEN}"
  127. # if (DEP_VS_VER MORE 15)
  128. # CMAKE_GENERATOR_PLATFORM "${DEP_PLATFORM}"
  129. # endif()
  130. CMAKE_ARGS
  131. -DBUILD_SHARED_LIBS=OFF
  132. -DNLOPT_PYTHON=OFF
  133. -DNLOPT_OCTAVE=OFF
  134. -DNLOPT_MATLAB=OFF
  135. -DNLOPT_GUILE=OFF
  136. -DCMAKE_POSITION_INDEPENDENT_CODE=ON
  137. -DCMAKE_DEBUG_POSTFIX=d
  138. "-DCMAKE_INSTALL_PREFIX:PATH=${DESTDIR}\\usr\\local"
  139. BUILD_COMMAND msbuild /m /P:Configuration=Release INSTALL.vcxproj
  140. INSTALL_COMMAND ""
  141. )
  142. add_debug_dep(dep_nlopt)
  143. include(ZLIB/ZLIB.cmake)
  144. # ExternalProject_Add(dep_zlib
  145. # EXCLUDE_FROM_ALL 1
  146. # URL "https://zlib.net/zlib-1.2.11.tar.xz"
  147. # URL_HASH SHA256=4ff941449631ace0d4d203e3483be9dbc9da454084111f97ea0a2114e19bf066
  148. # CMAKE_GENERATOR "${DEP_MSVC_GEN}"
  149. # CMAKE_GENERATOR_PLATFORM "${DEP_PLATFORM}"
  150. # CMAKE_ARGS
  151. # -DSKIP_INSTALL_FILES=ON # Prevent installation of man pages et al.
  152. # "-DINSTALL_BIN_DIR=${CMAKE_CURRENT_BINARY_DIR}\\fallout" # I found no better way of preventing zlib from creating & installing DLLs :-/
  153. # -DCMAKE_POSITION_INDEPENDENT_CODE=ON
  154. # "-DCMAKE_INSTALL_PREFIX:PATH=${DESTDIR}\\usr\\local"
  155. # BUILD_COMMAND msbuild /m /P:Configuration=Release INSTALL.vcxproj
  156. # INSTALL_COMMAND ""
  157. # )
  158. add_debug_dep(dep_ZLIB)
  159. # The following steps are unfortunately needed to remove the _static suffix on libraries
  160. # ExternalProject_Add_Step(dep_zlib fix_static
  161. # DEPENDEES install
  162. # COMMAND "${CMAKE_COMMAND}" -E rename zlibstatic.lib zlib.lib
  163. # WORKING_DIRECTORY "${DESTDIR}\\usr\\local\\lib\\"
  164. # )
  165. # if (${DEP_DEBUG})
  166. # ExternalProject_Add_Step(dep_zlib fix_static_debug
  167. # DEPENDEES install
  168. # COMMAND "${CMAKE_COMMAND}" -E rename zlibstaticd.lib zlibd.lib
  169. # WORKING_DIRECTORY "${DESTDIR}\\usr\\local\\lib\\"
  170. # )
  171. # endif ()
  172. if (${DEPS_BITS} EQUAL 32)
  173. set(DEP_LIBCURL_TARGET "x86")
  174. else ()
  175. set(DEP_LIBCURL_TARGET "x64")
  176. endif ()
  177. ExternalProject_Add(dep_libcurl
  178. EXCLUDE_FROM_ALL 1
  179. URL "https://curl.haxx.se/download/curl-7.58.0.tar.gz"
  180. URL_HASH SHA256=cc245bf9a1a42a45df491501d97d5593392a03f7b4f07b952793518d97666115
  181. BUILD_IN_SOURCE 1
  182. CONFIGURE_COMMAND ""
  183. BUILD_COMMAND cd winbuild && nmake /f Makefile.vc mode=static "VC=${DEP_VS_VER}" GEN_PDB=yes DEBUG=no "MACHINE=${DEP_LIBCURL_TARGET}"
  184. INSTALL_COMMAND cd builds\\libcurl-*-release-*-winssl
  185. && "${CMAKE_COMMAND}" -E copy_directory include "${DESTDIR}\\usr\\local\\include"
  186. && "${CMAKE_COMMAND}" -E copy_directory lib "${DESTDIR}\\usr\\local\\lib"
  187. )
  188. if (${DEP_DEBUG})
  189. ExternalProject_Get_Property(dep_libcurl SOURCE_DIR)
  190. ExternalProject_Add_Step(dep_libcurl build_debug
  191. DEPENDEES build
  192. DEPENDERS install
  193. COMMAND cd winbuild && nmake /f Makefile.vc mode=static "VC=${DEP_VS_VER}" GEN_PDB=yes DEBUG=yes "MACHINE=${DEP_LIBCURL_TARGET}"
  194. WORKING_DIRECTORY "${SOURCE_DIR}"
  195. )
  196. ExternalProject_Add_Step(dep_libcurl install_debug
  197. DEPENDEES install
  198. COMMAND cd builds\\libcurl-*-debug-*-winssl
  199. && "${CMAKE_COMMAND}" -E copy_directory include "${DESTDIR}\\usr\\local\\include"
  200. && "${CMAKE_COMMAND}" -E copy_directory lib "${DESTDIR}\\usr\\local\\lib"
  201. WORKING_DIRECTORY "${SOURCE_DIR}"
  202. )
  203. endif ()
  204. ExternalProject_Add(dep_qhull
  205. EXCLUDE_FROM_ALL 1
  206. #URL "https://github.com/qhull/qhull/archive/v7.3.2.tar.gz"
  207. #URL_HASH SHA256=619c8a954880d545194bc03359404ef36a1abd2dde03678089459757fd790cb0
  208. GIT_REPOSITORY https://github.com/qhull/qhull.git
  209. GIT_TAG 7afedcc73666e46a9f1d74632412ebecf53b1b30 # v7.3.2 plus the mac build patch
  210. CMAKE_GENERATOR "${DEP_MSVC_GEN}"
  211. CMAKE_ARGS
  212. -DCMAKE_INSTALL_PREFIX=${DESTDIR}/usr/local
  213. -DBUILD_SHARED_LIBS=OFF
  214. -DCMAKE_POSITION_INDEPENDENT_CODE=ON
  215. -DCMAKE_DEBUG_POSTFIX=d
  216. BUILD_COMMAND msbuild /m /P:Configuration=Release INSTALL.vcxproj
  217. INSTALL_COMMAND ""
  218. )
  219. add_debug_dep(dep_qhull)
  220. if (${DEPS_BITS} EQUAL 32)
  221. set(DEP_WXWIDGETS_TARGET "")
  222. set(DEP_WXWIDGETS_LIBDIR "vc_lib")
  223. else ()
  224. set(DEP_WXWIDGETS_TARGET "TARGET_CPU=X64")
  225. set(DEP_WXWIDGETS_LIBDIR "vc_x64_lib")
  226. endif ()
  227. find_package(Git REQUIRED)
  228. ExternalProject_Add(dep_wxwidgets
  229. EXCLUDE_FROM_ALL 1
  230. GIT_REPOSITORY "https://github.com/prusa3d/wxWidgets"
  231. GIT_TAG v3.1.1-patched
  232. # URL "https://github.com/wxWidgets/wxWidgets/releases/download/v3.1.1/wxWidgets-3.1.1.tar.bz2"
  233. # URL_HASH SHA256=c925dfe17e8f8b09eb7ea9bfdcfcc13696a3e14e92750effd839f5e10726159e
  234. BUILD_IN_SOURCE 1
  235. # PATCH_COMMAND "${CMAKE_COMMAND}" -E copy "${CMAKE_CURRENT_SOURCE_DIR}\\wxwidgets-pngprefix.h" src\\png\\pngprefix.h
  236. CONFIGURE_COMMAND ""
  237. BUILD_COMMAND cd build\\msw && nmake /f makefile.vc BUILD=release SHARED=0 UNICODE=1 USE_GUI=1 "${DEP_WXWIDGETS_TARGET}"
  238. INSTALL_COMMAND "${CMAKE_COMMAND}" -E copy_directory include "${DESTDIR}\\usr\\local\\include"
  239. && "${CMAKE_COMMAND}" -E copy_directory "lib\\${DEP_WXWIDGETS_LIBDIR}" "${DESTDIR}\\usr\\local\\lib\\${DEP_WXWIDGETS_LIBDIR}"
  240. )
  241. if (${DEP_DEBUG})
  242. ExternalProject_Get_Property(dep_wxwidgets SOURCE_DIR)
  243. ExternalProject_Add_Step(dep_wxwidgets build_debug
  244. DEPENDEES build
  245. DEPENDERS install
  246. COMMAND cd build\\msw && nmake /f makefile.vc BUILD=debug SHARED=0 UNICODE=1 USE_GUI=1 "${DEP_WXWIDGETS_TARGET}"
  247. WORKING_DIRECTORY "${SOURCE_DIR}"
  248. )
  249. endif ()
  250. ExternalProject_Add(dep_blosc
  251. EXCLUDE_FROM_ALL 1
  252. #URL https://github.com/Blosc/c-blosc/archive/v1.17.0.zip
  253. #URL_HASH SHA256=7463a1df566704f212263312717ab2c36b45d45cba6cd0dccebf91b2cc4b4da9
  254. GIT_REPOSITORY https://github.com/Blosc/c-blosc.git
  255. GIT_TAG e63775855294b50820ef44d1b157f4de1cc38d3e #v1.17.0
  256. DEPENDS dep_ZLIB
  257. CMAKE_GENERATOR "${DEP_MSVC_GEN}"
  258. CMAKE_GENERATOR_PLATFORM "${DEP_PLATFORM}"
  259. CMAKE_ARGS
  260. -DCMAKE_INSTALL_PREFIX=${DESTDIR}/usr/local
  261. -DBUILD_SHARED_LIBS=OFF
  262. -DCMAKE_POSITION_INDEPENDENT_CODE=ON
  263. -DCMAKE_DEBUG_POSTFIX=d
  264. -DBUILD_SHARED=OFF
  265. -DBUILD_STATIC=ON
  266. -DBUILD_TESTS=OFF
  267. -DBUILD_BENCHMARKS=OFF
  268. -DPREFER_EXTERNAL_ZLIB=ON
  269. -DBLOSC_IS_SUBPROJECT:BOOL=ON
  270. -DBLOSC_INSTALL:BOOL=ON
  271. PATCH_COMMAND ${GIT_EXECUTABLE} checkout -f -- . && git clean -df &&
  272. ${GIT_EXECUTABLE} apply --whitespace=fix ${CMAKE_CURRENT_SOURCE_DIR}/blosc-mods.patch
  273. BUILD_COMMAND msbuild /m /P:Configuration=Release INSTALL.vcxproj
  274. INSTALL_COMMAND ""
  275. )
  276. add_debug_dep(dep_blosc)
  277. ExternalProject_Add(dep_openexr
  278. EXCLUDE_FROM_ALL 1
  279. GIT_REPOSITORY https://github.com/openexr/openexr.git
  280. GIT_TAG eae0e337c9f5117e78114fd05f7a415819df413a #v2.4.0
  281. DEPENDS dep_ZLIB
  282. CMAKE_GENERATOR "${DEP_MSVC_GEN}"
  283. CMAKE_GENERATOR_PLATFORM "${DEP_PLATFORM}"
  284. CMAKE_ARGS
  285. -DCMAKE_INSTALL_PREFIX=${DESTDIR}/usr/local
  286. -DBUILD_SHARED_LIBS=OFF
  287. -DCMAKE_POSITION_INDEPENDENT_CODE=ON
  288. -DBUILD_TESTING=OFF
  289. -DPYILMBASE_ENABLE:BOOL=OFF
  290. -DOPENEXR_VIEWERS_ENABLE:BOOL=OFF
  291. -DOPENEXR_BUILD_UTILS:BOOL=OFF
  292. BUILD_COMMAND msbuild /m /P:Configuration=Release INSTALL.vcxproj
  293. INSTALL_COMMAND ""
  294. )
  295. add_debug_dep(dep_openexr)
  296. ExternalProject_Add(dep_openvdb
  297. EXCLUDE_FROM_ALL 1
  298. #URL https://github.com/AcademySoftwareFoundation/openvdb/archive/v6.2.1.zip
  299. #URL_HASH SHA256=dc337399dce8e1c9f21f20e97b1ce7e4933cb0a63bb3b8b734d8fcc464aa0c48
  300. GIT_REPOSITORY https://github.com/AcademySoftwareFoundation/openvdb.git
  301. GIT_TAG aebaf8d95be5e57fd33949281ec357db4a576c2e #v6.2.1
  302. DEPENDS dep_blosc dep_openexr dep_tbb dep_boost
  303. CMAKE_GENERATOR "${DEP_MSVC_GEN}"
  304. CMAKE_GENERATOR_PLATFORM "${DEP_PLATFORM}"
  305. CMAKE_ARGS
  306. -DCMAKE_INSTALL_PREFIX=${DESTDIR}/usr/local
  307. -DCMAKE_DEBUG_POSTFIX=d
  308. -DCMAKE_PREFIX_PATH=${DESTDIR}/usr/local
  309. -DBUILD_SHARED_LIBS=OFF
  310. -DCMAKE_POSITION_INDEPENDENT_CODE=ON
  311. -DOPENVDB_BUILD_PYTHON_MODULE=OFF
  312. -DUSE_BLOSC=ON
  313. -DOPENVDB_CORE_SHARED=OFF
  314. -DOPENVDB_CORE_STATIC=ON
  315. -DTBB_STATIC=ON
  316. -DOPENVDB_BUILD_VDB_PRINT=ON
  317. BUILD_COMMAND msbuild /m /P:Configuration=Release INSTALL.vcxproj
  318. PATCH_COMMAND ${GIT_EXECUTABLE} checkout -f -- . && git clean -df &&
  319. ${GIT_EXECUTABLE} apply --whitespace=fix ${CMAKE_CURRENT_SOURCE_DIR}/openvdb-mods.patch
  320. INSTALL_COMMAND ""
  321. )
  322. if (${DEP_DEBUG})
  323. ExternalProject_Get_Property(dep_openvdb BINARY_DIR)
  324. ExternalProject_Add_Step(dep_openvdb build_debug
  325. DEPENDEES build
  326. DEPENDERS install
  327. COMMAND ${CMAKE_COMMAND} ../dep_openvdb -DOPENVDB_BUILD_VDB_PRINT=OFF
  328. COMMAND msbuild /m /P:Configuration=Debug INSTALL.vcxproj
  329. WORKING_DIRECTORY "${BINARY_DIR}"
  330. )
  331. endif ()