deps-windows.cmake 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355
  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. endif ()
  33. set(DEP_PLATFORM "x64")
  34. endif ()
  35. if (${DEP_DEBUG})
  36. set(DEP_BOOST_DEBUG "debug")
  37. else ()
  38. set(DEP_BOOST_DEBUG "")
  39. endif ()
  40. macro(add_debug_dep _dep)
  41. if (${DEP_DEBUG})
  42. ExternalProject_Get_Property(${_dep} BINARY_DIR)
  43. ExternalProject_Add_Step(${_dep} build_debug
  44. DEPENDEES build
  45. DEPENDERS install
  46. COMMAND msbuild /m /P:Configuration=Debug INSTALL.vcxproj
  47. WORKING_DIRECTORY "${BINARY_DIR}"
  48. )
  49. endif ()
  50. endmacro()
  51. ExternalProject_Add(dep_boost
  52. EXCLUDE_FROM_ALL 1
  53. URL "https://dl.bintray.com/boostorg/release/1.70.0/source/boost_1_70_0.tar.gz"
  54. URL_HASH SHA256=882b48708d211a5f48e60b0124cf5863c1534cd544ecd0664bb534a4b5d506e9
  55. BUILD_IN_SOURCE 1
  56. CONFIGURE_COMMAND bootstrap.bat
  57. BUILD_COMMAND b2.exe
  58. -j "${NPROC}"
  59. --with-system
  60. --with-iostreams
  61. --with-filesystem
  62. --with-thread
  63. --with-log
  64. --with-locale
  65. --with-regex
  66. "--prefix=${DESTDIR}/usr/local"
  67. "address-model=${DEPS_BITS}"
  68. "toolset=${DEP_BOOST_TOOLSET}"
  69. link=static
  70. variant=release
  71. threading=multi
  72. boost.locale.icu=off
  73. "${DEP_BOOST_DEBUG}" release install
  74. INSTALL_COMMAND "" # b2 does that already
  75. )
  76. ExternalProject_Add(dep_tbb
  77. EXCLUDE_FROM_ALL 1
  78. URL "https://github.com/wjakob/tbb/archive/a0dc9bf76d0120f917b641ed095360448cabc85b.tar.gz"
  79. URL_HASH SHA256=0545cb6033bd1873fcae3ea304def720a380a88292726943ae3b9b207f322efe
  80. CMAKE_GENERATOR "${DEP_MSVC_GEN}"
  81. CMAKE_GENERATOR_PLATFORM "${DEP_PLATFORM}"
  82. CMAKE_ARGS
  83. -DCMAKE_DEBUG_POSTFIX=_debug
  84. -DTBB_BUILD_SHARED=OFF
  85. -DTBB_BUILD_TESTS=OFF
  86. "-DCMAKE_INSTALL_PREFIX:PATH=${DESTDIR}\\usr\\local"
  87. BUILD_COMMAND msbuild /m /P:Configuration=Release INSTALL.vcxproj
  88. INSTALL_COMMAND ""
  89. )
  90. add_debug_dep(dep_tbb)
  91. # ExternalProject_Add(dep_gtest
  92. # EXCLUDE_FROM_ALL 1
  93. # URL "https://github.com/google/googletest/archive/release-1.8.1.tar.gz"
  94. # URL_HASH SHA256=9bf1fe5182a604b4135edc1a425ae356c9ad15e9b23f9f12a02e80184c3a249c
  95. # CMAKE_GENERATOR "${DEP_MSVC_GEN}"
  96. # CMAKE_GENERATOR_PLATFORM "${DEP_PLATFORM}"
  97. # CMAKE_ARGS
  98. # -DBUILD_GMOCK=OFF
  99. # -Dgtest_force_shared_crt=ON
  100. # -DCMAKE_POSITION_INDEPENDENT_CODE=ON
  101. # "-DCMAKE_INSTALL_PREFIX:PATH=${DESTDIR}\\usr\\local"
  102. # BUILD_COMMAND msbuild /m /P:Configuration=Release INSTALL.vcxproj
  103. # INSTALL_COMMAND ""
  104. # )
  105. # add_debug_dep(dep_gtest)
  106. ExternalProject_Add(dep_cereal
  107. EXCLUDE_FROM_ALL 1
  108. URL "https://github.com/USCiLab/cereal/archive/v1.2.2.tar.gz"
  109. # URL_HASH SHA256=c6dd7a5701fff8ad5ebb45a3dc8e757e61d52658de3918e38bab233e7fd3b4ae
  110. CMAKE_GENERATOR "${DEP_MSVC_GEN}"
  111. CMAKE_GENERATOR_PLATFORM "${DEP_PLATFORM}"
  112. CMAKE_ARGS
  113. -DJUST_INSTALL_CEREAL=on
  114. "-DCMAKE_INSTALL_PREFIX:PATH=${DESTDIR}\\usr\\local"
  115. BUILD_COMMAND msbuild /m /P:Configuration=Release INSTALL.vcxproj
  116. INSTALL_COMMAND ""
  117. )
  118. ExternalProject_Add(dep_nlopt
  119. EXCLUDE_FROM_ALL 1
  120. URL "https://github.com/stevengj/nlopt/archive/v2.5.0.tar.gz"
  121. URL_HASH SHA256=c6dd7a5701fff8ad5ebb45a3dc8e757e61d52658de3918e38bab233e7fd3b4ae
  122. CMAKE_GENERATOR "${DEP_MSVC_GEN}"
  123. CMAKE_GENERATOR_PLATFORM "${DEP_PLATFORM}"
  124. CMAKE_ARGS
  125. -DBUILD_SHARED_LIBS=OFF
  126. -DNLOPT_PYTHON=OFF
  127. -DNLOPT_OCTAVE=OFF
  128. -DNLOPT_MATLAB=OFF
  129. -DNLOPT_GUILE=OFF
  130. -DCMAKE_POSITION_INDEPENDENT_CODE=ON
  131. -DCMAKE_DEBUG_POSTFIX=d
  132. "-DCMAKE_INSTALL_PREFIX:PATH=${DESTDIR}\\usr\\local"
  133. BUILD_COMMAND msbuild /m /P:Configuration=Release INSTALL.vcxproj
  134. INSTALL_COMMAND ""
  135. )
  136. add_debug_dep(dep_nlopt)
  137. include(ZLIB/ZLIB.cmake)
  138. # ExternalProject_Add(dep_zlib
  139. # EXCLUDE_FROM_ALL 1
  140. # URL "https://zlib.net/zlib-1.2.11.tar.xz"
  141. # URL_HASH SHA256=4ff941449631ace0d4d203e3483be9dbc9da454084111f97ea0a2114e19bf066
  142. # CMAKE_GENERATOR "${DEP_MSVC_GEN}"
  143. # CMAKE_GENERATOR_PLATFORM "${DEP_PLATFORM}"
  144. # CMAKE_ARGS
  145. # -DSKIP_INSTALL_FILES=ON # Prevent installation of man pages et al.
  146. # "-DINSTALL_BIN_DIR=${CMAKE_CURRENT_BINARY_DIR}\\fallout" # I found no better way of preventing zlib from creating & installing DLLs :-/
  147. # -DCMAKE_POSITION_INDEPENDENT_CODE=ON
  148. # "-DCMAKE_INSTALL_PREFIX:PATH=${DESTDIR}\\usr\\local"
  149. # BUILD_COMMAND msbuild /m /P:Configuration=Release INSTALL.vcxproj
  150. # INSTALL_COMMAND ""
  151. # )
  152. add_debug_dep(dep_ZLIB)
  153. # The following steps are unfortunately needed to remove the _static suffix on libraries
  154. # ExternalProject_Add_Step(dep_zlib fix_static
  155. # DEPENDEES install
  156. # COMMAND "${CMAKE_COMMAND}" -E rename zlibstatic.lib zlib.lib
  157. # WORKING_DIRECTORY "${DESTDIR}\\usr\\local\\lib\\"
  158. # )
  159. # if (${DEP_DEBUG})
  160. # ExternalProject_Add_Step(dep_zlib fix_static_debug
  161. # DEPENDEES install
  162. # COMMAND "${CMAKE_COMMAND}" -E rename zlibstaticd.lib zlibd.lib
  163. # WORKING_DIRECTORY "${DESTDIR}\\usr\\local\\lib\\"
  164. # )
  165. # endif ()
  166. if (${DEPS_BITS} EQUAL 32)
  167. set(DEP_LIBCURL_TARGET "x86")
  168. else ()
  169. set(DEP_LIBCURL_TARGET "x64")
  170. endif ()
  171. ExternalProject_Add(dep_libcurl
  172. EXCLUDE_FROM_ALL 1
  173. URL "https://curl.haxx.se/download/curl-7.58.0.tar.gz"
  174. URL_HASH SHA256=cc245bf9a1a42a45df491501d97d5593392a03f7b4f07b952793518d97666115
  175. BUILD_IN_SOURCE 1
  176. CONFIGURE_COMMAND ""
  177. BUILD_COMMAND cd winbuild && nmake /f Makefile.vc mode=static "VC=${DEP_VS_VER}" GEN_PDB=yes DEBUG=no "MACHINE=${DEP_LIBCURL_TARGET}"
  178. INSTALL_COMMAND cd builds\\libcurl-*-release-*-winssl
  179. && "${CMAKE_COMMAND}" -E copy_directory include "${DESTDIR}\\usr\\local\\include"
  180. && "${CMAKE_COMMAND}" -E copy_directory lib "${DESTDIR}\\usr\\local\\lib"
  181. )
  182. if (${DEP_DEBUG})
  183. ExternalProject_Get_Property(dep_libcurl SOURCE_DIR)
  184. ExternalProject_Add_Step(dep_libcurl build_debug
  185. DEPENDEES build
  186. DEPENDERS install
  187. COMMAND cd winbuild && nmake /f Makefile.vc mode=static "VC=${DEP_VS_VER}" GEN_PDB=yes DEBUG=yes "MACHINE=${DEP_LIBCURL_TARGET}"
  188. WORKING_DIRECTORY "${SOURCE_DIR}"
  189. )
  190. ExternalProject_Add_Step(dep_libcurl install_debug
  191. DEPENDEES install
  192. COMMAND cd builds\\libcurl-*-debug-*-winssl
  193. && "${CMAKE_COMMAND}" -E copy_directory include "${DESTDIR}\\usr\\local\\include"
  194. && "${CMAKE_COMMAND}" -E copy_directory lib "${DESTDIR}\\usr\\local\\lib"
  195. WORKING_DIRECTORY "${SOURCE_DIR}"
  196. )
  197. endif ()
  198. ExternalProject_Add(dep_qhull
  199. EXCLUDE_FROM_ALL 1
  200. #URL "https://github.com/qhull/qhull/archive/v7.3.2.tar.gz"
  201. #URL_HASH SHA256=619c8a954880d545194bc03359404ef36a1abd2dde03678089459757fd790cb0
  202. GIT_REPOSITORY https://github.com/qhull/qhull.git
  203. GIT_TAG 7afedcc73666e46a9f1d74632412ebecf53b1b30 # v7.3.2 plus the mac build patch
  204. CMAKE_GENERATOR "${DEP_MSVC_GEN}"
  205. CMAKE_ARGS
  206. -DCMAKE_INSTALL_PREFIX=${DESTDIR}/usr/local
  207. -DBUILD_SHARED_LIBS=OFF
  208. -DCMAKE_POSITION_INDEPENDENT_CODE=ON
  209. -DCMAKE_DEBUG_POSTFIX=d
  210. BUILD_COMMAND msbuild /m /P:Configuration=Release INSTALL.vcxproj
  211. INSTALL_COMMAND ""
  212. )
  213. add_debug_dep(dep_qhull)
  214. if (${DEPS_BITS} EQUAL 32)
  215. set(DEP_WXWIDGETS_TARGET "")
  216. set(DEP_WXWIDGETS_LIBDIR "vc_lib")
  217. else ()
  218. set(DEP_WXWIDGETS_TARGET "TARGET_CPU=X64")
  219. set(DEP_WXWIDGETS_LIBDIR "vc_x64_lib")
  220. endif ()
  221. find_package(Git REQUIRED)
  222. ExternalProject_Add(dep_wxwidgets
  223. EXCLUDE_FROM_ALL 1
  224. GIT_REPOSITORY "https://github.com/prusa3d/wxWidgets"
  225. GIT_TAG v3.1.1-patched
  226. # URL "https://github.com/wxWidgets/wxWidgets/releases/download/v3.1.1/wxWidgets-3.1.1.tar.bz2"
  227. # URL_HASH SHA256=c925dfe17e8f8b09eb7ea9bfdcfcc13696a3e14e92750effd839f5e10726159e
  228. BUILD_IN_SOURCE 1
  229. # PATCH_COMMAND "${CMAKE_COMMAND}" -E copy "${CMAKE_CURRENT_SOURCE_DIR}\\wxwidgets-pngprefix.h" src\\png\\pngprefix.h
  230. CONFIGURE_COMMAND ""
  231. BUILD_COMMAND cd build\\msw && nmake /f makefile.vc BUILD=release SHARED=0 UNICODE=1 USE_GUI=1 "${DEP_WXWIDGETS_TARGET}"
  232. INSTALL_COMMAND "${CMAKE_COMMAND}" -E copy_directory include "${DESTDIR}\\usr\\local\\include"
  233. && "${CMAKE_COMMAND}" -E copy_directory "lib\\${DEP_WXWIDGETS_LIBDIR}" "${DESTDIR}\\usr\\local\\lib\\${DEP_WXWIDGETS_LIBDIR}"
  234. )
  235. if (${DEP_DEBUG})
  236. ExternalProject_Get_Property(dep_wxwidgets SOURCE_DIR)
  237. ExternalProject_Add_Step(dep_wxwidgets build_debug
  238. DEPENDEES build
  239. DEPENDERS install
  240. COMMAND cd build\\msw && nmake /f makefile.vc BUILD=debug SHARED=0 UNICODE=1 USE_GUI=1 "${DEP_WXWIDGETS_TARGET}"
  241. WORKING_DIRECTORY "${SOURCE_DIR}"
  242. )
  243. endif ()
  244. ExternalProject_Add(dep_blosc
  245. EXCLUDE_FROM_ALL 1
  246. #URL https://github.com/Blosc/c-blosc/archive/v1.17.0.zip
  247. #URL_HASH SHA256=7463a1df566704f212263312717ab2c36b45d45cba6cd0dccebf91b2cc4b4da9
  248. GIT_REPOSITORY https://github.com/Blosc/c-blosc.git
  249. GIT_TAG e63775855294b50820ef44d1b157f4de1cc38d3e #v1.17.0
  250. DEPENDS dep_ZLIB
  251. CMAKE_GENERATOR "${DEP_MSVC_GEN}"
  252. CMAKE_GENERATOR_PLATFORM "${DEP_PLATFORM}"
  253. CMAKE_ARGS
  254. -DCMAKE_INSTALL_PREFIX=${DESTDIR}/usr/local
  255. -DBUILD_SHARED_LIBS=OFF
  256. -DCMAKE_POSITION_INDEPENDENT_CODE=ON
  257. -DCMAKE_DEBUG_POSTFIX=d
  258. -DBUILD_SHARED=OFF
  259. -DBUILD_STATIC=ON
  260. -DBUILD_TESTS=OFF
  261. -DBUILD_BENCHMARKS=OFF
  262. -DPREFER_EXTERNAL_ZLIB=ON
  263. -DBLOSC_IS_SUBPROJECT:BOOL=ON
  264. -DBLOSC_INSTALL:BOOL=ON
  265. PATCH_COMMAND ${GIT_EXECUTABLE} checkout -f -- . && git clean -df &&
  266. ${GIT_EXECUTABLE} apply --whitespace=fix ${CMAKE_CURRENT_SOURCE_DIR}/blosc-mods.patch
  267. BUILD_COMMAND msbuild /m /P:Configuration=Release INSTALL.vcxproj
  268. INSTALL_COMMAND ""
  269. )
  270. add_debug_dep(dep_blosc)
  271. ExternalProject_Add(dep_openexr
  272. EXCLUDE_FROM_ALL 1
  273. GIT_REPOSITORY https://github.com/openexr/openexr.git
  274. GIT_TAG eae0e337c9f5117e78114fd05f7a415819df413a #v2.4.0
  275. DEPENDS dep_ZLIB
  276. CMAKE_GENERATOR "${DEP_MSVC_GEN}"
  277. CMAKE_GENERATOR_PLATFORM "${DEP_PLATFORM}"
  278. CMAKE_ARGS
  279. -DCMAKE_INSTALL_PREFIX=${DESTDIR}/usr/local
  280. -DBUILD_SHARED_LIBS=OFF
  281. -DCMAKE_POSITION_INDEPENDENT_CODE=ON
  282. -DBUILD_TESTING=OFF
  283. -DPYILMBASE_ENABLE:BOOL=OFF
  284. -DOPENEXR_VIEWERS_ENABLE:BOOL=OFF
  285. -DOPENEXR_BUILD_UTILS:BOOL=OFF
  286. BUILD_COMMAND msbuild /m /P:Configuration=Release INSTALL.vcxproj
  287. INSTALL_COMMAND ""
  288. )
  289. add_debug_dep(dep_openexr)
  290. ExternalProject_Add(dep_openvdb
  291. EXCLUDE_FROM_ALL 1
  292. #URL https://github.com/AcademySoftwareFoundation/openvdb/archive/v6.2.1.zip
  293. #URL_HASH SHA256=dc337399dce8e1c9f21f20e97b1ce7e4933cb0a63bb3b8b734d8fcc464aa0c48
  294. GIT_REPOSITORY https://github.com/AcademySoftwareFoundation/openvdb.git
  295. GIT_TAG aebaf8d95be5e57fd33949281ec357db4a576c2e #v6.2.1
  296. DEPENDS dep_blosc dep_openexr dep_tbb dep_boost
  297. CMAKE_GENERATOR "${DEP_MSVC_GEN}"
  298. CMAKE_GENERATOR_PLATFORM "${DEP_PLATFORM}"
  299. CMAKE_ARGS
  300. -DCMAKE_INSTALL_PREFIX=${DESTDIR}/usr/local
  301. -DCMAKE_DEBUG_POSTFIX=d
  302. -DCMAKE_PREFIX_PATH=${DESTDIR}/usr/local
  303. -DBUILD_SHARED_LIBS=OFF
  304. -DCMAKE_POSITION_INDEPENDENT_CODE=ON
  305. -DOPENVDB_BUILD_PYTHON_MODULE=OFF
  306. -DUSE_BLOSC=ON
  307. -DOPENVDB_CORE_SHARED=OFF
  308. -DOPENVDB_CORE_STATIC=ON
  309. -DTBB_STATIC=ON
  310. -DOPENVDB_BUILD_VDB_PRINT=ON
  311. BUILD_COMMAND msbuild /m /P:Configuration=Release INSTALL.vcxproj
  312. PATCH_COMMAND ${GIT_EXECUTABLE} checkout -f -- . && git clean -df &&
  313. ${GIT_EXECUTABLE} apply --whitespace=fix ${CMAKE_CURRENT_SOURCE_DIR}/openvdb-mods.patch
  314. INSTALL_COMMAND ""
  315. )
  316. if (${DEP_DEBUG})
  317. ExternalProject_Get_Property(dep_openvdb BINARY_DIR)
  318. ExternalProject_Add_Step(dep_openvdb build_debug
  319. DEPENDEES build
  320. DEPENDERS install
  321. COMMAND ${CMAKE_COMMAND} ../dep_openvdb -DOPENVDB_BUILD_VDB_PRINT=OFF
  322. COMMAND msbuild /m /P:Configuration=Debug INSTALL.vcxproj
  323. WORKING_DIRECTORY "${BINARY_DIR}"
  324. )
  325. endif ()