deps-windows.cmake 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299
  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://boostorg.jfrog.io/artifactory/main/release/1.75.0/source/boost_1_75_0.tar.gz"
  54. URL_HASH SHA256=aeb26f80e80945e82ee93e5939baebdca47b9dee80a07d3144be1e1a6a66dd6a
  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. --with-date_time
  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. --disable-icu
  75. "${DEP_BOOST_DEBUG}" release install
  76. INSTALL_COMMAND "" # b2 does that already
  77. )
  78. ExternalProject_Add(dep_tbb
  79. EXCLUDE_FROM_ALL 1
  80. URL "https://github.com/wjakob/tbb/archive/a0dc9bf76d0120f917b641ed095360448cabc85b.tar.gz"
  81. URL_HASH SHA256=0545cb6033bd1873fcae3ea304def720a380a88292726943ae3b9b207f322efe
  82. CMAKE_GENERATOR "${DEP_MSVC_GEN}"
  83. CMAKE_GENERATOR_PLATFORM "${DEP_PLATFORM}"
  84. CMAKE_ARGS
  85. -DCMAKE_DEBUG_POSTFIX=_debug
  86. -DTBB_BUILD_SHARED=OFF
  87. -DTBB_BUILD_TESTS=OFF
  88. "-DCMAKE_INSTALL_PREFIX:PATH=${DESTDIR}\\usr\\local"
  89. BUILD_COMMAND msbuild /m /P:Configuration=Release INSTALL.vcxproj
  90. INSTALL_COMMAND ""
  91. )
  92. add_debug_dep(dep_tbb)
  93. # ExternalProject_Add(dep_gtest
  94. # EXCLUDE_FROM_ALL 1
  95. # URL "https://github.com/google/googletest/archive/release-1.8.1.tar.gz"
  96. # URL_HASH SHA256=9bf1fe5182a604b4135edc1a425ae356c9ad15e9b23f9f12a02e80184c3a249c
  97. # CMAKE_GENERATOR "${DEP_MSVC_GEN}"
  98. # CMAKE_GENERATOR_PLATFORM "${DEP_PLATFORM}"
  99. # CMAKE_ARGS
  100. # -DBUILD_GMOCK=OFF
  101. # -Dgtest_force_shared_crt=ON
  102. # -DCMAKE_POSITION_INDEPENDENT_CODE=ON
  103. # "-DCMAKE_INSTALL_PREFIX:PATH=${DESTDIR}\\usr\\local"
  104. # BUILD_COMMAND msbuild /m /P:Configuration=Release INSTALL.vcxproj
  105. # INSTALL_COMMAND ""
  106. # )
  107. # add_debug_dep(dep_gtest)
  108. ExternalProject_Add(dep_cereal
  109. EXCLUDE_FROM_ALL 1
  110. URL "https://github.com/USCiLab/cereal/archive/v1.2.2.tar.gz"
  111. # URL_HASH SHA256=c6dd7a5701fff8ad5ebb45a3dc8e757e61d52658de3918e38bab233e7fd3b4ae
  112. CMAKE_GENERATOR "${DEP_MSVC_GEN}"
  113. CMAKE_GENERATOR_PLATFORM "${DEP_PLATFORM}"
  114. CMAKE_ARGS
  115. -DJUST_INSTALL_CEREAL=on
  116. "-DCMAKE_INSTALL_PREFIX:PATH=${DESTDIR}\\usr\\local"
  117. BUILD_COMMAND msbuild /m /P:Configuration=Release INSTALL.vcxproj
  118. INSTALL_COMMAND ""
  119. )
  120. ExternalProject_Add(dep_nlopt
  121. EXCLUDE_FROM_ALL 1
  122. URL "https://github.com/stevengj/nlopt/archive/v2.5.0.tar.gz"
  123. URL_HASH SHA256=c6dd7a5701fff8ad5ebb45a3dc8e757e61d52658de3918e38bab233e7fd3b4ae
  124. CMAKE_GENERATOR "${DEP_MSVC_GEN}"
  125. CMAKE_GENERATOR_PLATFORM "${DEP_PLATFORM}"
  126. CMAKE_ARGS
  127. -DBUILD_SHARED_LIBS=OFF
  128. -DNLOPT_PYTHON=OFF
  129. -DNLOPT_OCTAVE=OFF
  130. -DNLOPT_MATLAB=OFF
  131. -DNLOPT_GUILE=OFF
  132. -DCMAKE_POSITION_INDEPENDENT_CODE=ON
  133. -DCMAKE_DEBUG_POSTFIX=d
  134. "-DCMAKE_INSTALL_PREFIX:PATH=${DESTDIR}\\usr\\local"
  135. BUILD_COMMAND msbuild /m /P:Configuration=Release INSTALL.vcxproj
  136. INSTALL_COMMAND ""
  137. )
  138. add_debug_dep(dep_nlopt)
  139. if (${DEPS_BITS} EQUAL 32)
  140. set(DEP_LIBCURL_TARGET "x86")
  141. else ()
  142. set(DEP_LIBCURL_TARGET "x64")
  143. endif ()
  144. ExternalProject_Add(dep_libcurl
  145. EXCLUDE_FROM_ALL 1
  146. URL "https://curl.haxx.se/download/curl-7.58.0.tar.gz"
  147. URL_HASH SHA256=cc245bf9a1a42a45df491501d97d5593392a03f7b4f07b952793518d97666115
  148. BUILD_IN_SOURCE 1
  149. CONFIGURE_COMMAND ""
  150. BUILD_COMMAND cd winbuild && nmake /f Makefile.vc mode=static "VC=${DEP_VS_VER}" GEN_PDB=yes DEBUG=no "MACHINE=${DEP_LIBCURL_TARGET}"
  151. INSTALL_COMMAND cd builds\\libcurl-*-release-*-winssl
  152. && "${CMAKE_COMMAND}" -E copy_directory include "${DESTDIR}\\usr\\local\\include"
  153. && "${CMAKE_COMMAND}" -E copy_directory lib "${DESTDIR}\\usr\\local\\lib"
  154. )
  155. if (${DEP_DEBUG})
  156. ExternalProject_Get_Property(dep_libcurl SOURCE_DIR)
  157. ExternalProject_Add_Step(dep_libcurl build_debug
  158. DEPENDEES build
  159. DEPENDERS install
  160. COMMAND cd winbuild && nmake /f Makefile.vc mode=static "VC=${DEP_VS_VER}" GEN_PDB=yes DEBUG=yes "MACHINE=${DEP_LIBCURL_TARGET}"
  161. WORKING_DIRECTORY "${SOURCE_DIR}"
  162. )
  163. ExternalProject_Add_Step(dep_libcurl install_debug
  164. DEPENDEES install
  165. COMMAND cd builds\\libcurl-*-debug-*-winssl
  166. && "${CMAKE_COMMAND}" -E copy_directory include "${DESTDIR}\\usr\\local\\include"
  167. && "${CMAKE_COMMAND}" -E copy_directory lib "${DESTDIR}\\usr\\local\\lib"
  168. WORKING_DIRECTORY "${SOURCE_DIR}"
  169. )
  170. endif ()
  171. ExternalProject_Add(dep_qhull
  172. EXCLUDE_FROM_ALL 1
  173. #URL "https://github.com/qhull/qhull/archive/v7.3.2.tar.gz"
  174. #URL_HASH SHA256=619c8a954880d545194bc03359404ef36a1abd2dde03678089459757fd790cb0
  175. GIT_REPOSITORY https://github.com/qhull/qhull.git
  176. GIT_TAG 7afedcc73666e46a9f1d74632412ebecf53b1b30 # v7.3.2 plus the mac build patch
  177. CMAKE_GENERATOR "${DEP_MSVC_GEN}"
  178. CMAKE_ARGS
  179. -DCMAKE_INSTALL_PREFIX=${DESTDIR}/usr/local
  180. -DBUILD_SHARED_LIBS=OFF
  181. -DCMAKE_POSITION_INDEPENDENT_CODE=ON
  182. -DCMAKE_DEBUG_POSTFIX=d
  183. BUILD_COMMAND msbuild /m /P:Configuration=Release INSTALL.vcxproj
  184. INSTALL_COMMAND ""
  185. )
  186. add_debug_dep(dep_qhull)
  187. if (${DEPS_BITS} EQUAL 32)
  188. set(DEP_WXWIDGETS_TARGET "")
  189. set(DEP_WXWIDGETS_LIBDIR "vc_lib")
  190. else ()
  191. set(DEP_WXWIDGETS_TARGET "TARGET_CPU=X64")
  192. set(DEP_WXWIDGETS_LIBDIR "vc_x64_lib")
  193. endif ()
  194. find_package(Git REQUIRED)
  195. ExternalProject_Add(dep_blosc
  196. EXCLUDE_FROM_ALL 1
  197. #URL https://github.com/Blosc/c-blosc/archive/v1.17.0.zip
  198. #URL_HASH SHA256=7463a1df566704f212263312717ab2c36b45d45cba6cd0dccebf91b2cc4b4da9
  199. GIT_REPOSITORY https://github.com/Blosc/c-blosc.git
  200. GIT_TAG e63775855294b50820ef44d1b157f4de1cc38d3e #v1.17.0
  201. CMAKE_GENERATOR "${DEP_MSVC_GEN}"
  202. CMAKE_GENERATOR_PLATFORM "${DEP_PLATFORM}"
  203. CMAKE_ARGS
  204. -DCMAKE_INSTALL_PREFIX=${DESTDIR}/usr/local
  205. -DBUILD_SHARED_LIBS=OFF
  206. -DCMAKE_POSITION_INDEPENDENT_CODE=ON
  207. -DCMAKE_DEBUG_POSTFIX=d
  208. -DBUILD_SHARED=OFF
  209. -DBUILD_STATIC=ON
  210. -DBUILD_TESTS=OFF
  211. -DBUILD_BENCHMARKS=OFF
  212. -DPREFER_EXTERNAL_ZLIB=ON
  213. -DBLOSC_IS_SUBPROJECT:BOOL=ON
  214. -DBLOSC_INSTALL:BOOL=ON
  215. PATCH_COMMAND ${GIT_EXECUTABLE} checkout -f -- . && git clean -df &&
  216. ${GIT_EXECUTABLE} apply --whitespace=fix ${CMAKE_CURRENT_SOURCE_DIR}/blosc-mods.patch
  217. BUILD_COMMAND msbuild /m /P:Configuration=Release INSTALL.vcxproj
  218. INSTALL_COMMAND ""
  219. )
  220. add_debug_dep(dep_blosc)
  221. ExternalProject_Add(dep_openexr
  222. EXCLUDE_FROM_ALL 1
  223. GIT_REPOSITORY https://github.com/openexr/openexr.git
  224. GIT_TAG eae0e337c9f5117e78114fd05f7a415819df413a #v2.4.0
  225. CMAKE_GENERATOR "${DEP_MSVC_GEN}"
  226. CMAKE_GENERATOR_PLATFORM "${DEP_PLATFORM}"
  227. CMAKE_ARGS
  228. -DCMAKE_INSTALL_PREFIX=${DESTDIR}/usr/local
  229. -DBUILD_SHARED_LIBS=OFF
  230. -DCMAKE_POSITION_INDEPENDENT_CODE=ON
  231. -DBUILD_TESTING=OFF
  232. -DPYILMBASE_ENABLE:BOOL=OFF
  233. -DOPENEXR_VIEWERS_ENABLE:BOOL=OFF
  234. -DOPENEXR_BUILD_UTILS:BOOL=OFF
  235. BUILD_COMMAND msbuild /m /P:Configuration=Release INSTALL.vcxproj
  236. INSTALL_COMMAND ""
  237. )
  238. add_debug_dep(dep_openexr)
  239. ExternalProject_Add(dep_openvdb
  240. EXCLUDE_FROM_ALL 1
  241. #URL https://github.com/AcademySoftwareFoundation/openvdb/archive/v6.2.1.zip
  242. #URL_HASH SHA256=dc337399dce8e1c9f21f20e97b1ce7e4933cb0a63bb3b8b734d8fcc464aa0c48
  243. GIT_REPOSITORY https://github.com/AcademySoftwareFoundation/openvdb.git
  244. GIT_TAG aebaf8d95be5e57fd33949281ec357db4a576c2e #v6.2.1
  245. DEPENDS dep_blosc dep_openexr dep_tbb dep_boost
  246. CMAKE_GENERATOR "${DEP_MSVC_GEN}"
  247. CMAKE_GENERATOR_PLATFORM "${DEP_PLATFORM}"
  248. CMAKE_ARGS
  249. -DCMAKE_INSTALL_PREFIX=${DESTDIR}/usr/local
  250. -DCMAKE_DEBUG_POSTFIX=d
  251. -DCMAKE_PREFIX_PATH=${DESTDIR}/usr/local
  252. -DBUILD_SHARED_LIBS=OFF
  253. -DCMAKE_POSITION_INDEPENDENT_CODE=ON
  254. -DOPENVDB_BUILD_PYTHON_MODULE=OFF
  255. -DUSE_BLOSC=ON
  256. -DOPENVDB_CORE_SHARED=OFF
  257. -DOPENVDB_CORE_STATIC=ON
  258. -DTBB_STATIC=ON
  259. -DOPENVDB_BUILD_VDB_PRINT=ON
  260. BUILD_COMMAND msbuild /m /P:Configuration=Release INSTALL.vcxproj
  261. PATCH_COMMAND ${GIT_EXECUTABLE} checkout -f -- . && git clean -df &&
  262. ${GIT_EXECUTABLE} apply --whitespace=fix ${CMAKE_CURRENT_SOURCE_DIR}/openvdb-mods.patch
  263. INSTALL_COMMAND ""
  264. )
  265. if (${DEP_DEBUG})
  266. ExternalProject_Get_Property(dep_openvdb BINARY_DIR)
  267. ExternalProject_Add_Step(dep_openvdb build_debug
  268. DEPENDEES build
  269. DEPENDERS install
  270. COMMAND ${CMAKE_COMMAND} ../dep_openvdb -DOPENVDB_BUILD_VDB_PRINT=OFF
  271. COMMAND msbuild /m /P:Configuration=Debug INSTALL.vcxproj
  272. WORKING_DIRECTORY "${BINARY_DIR}"
  273. )
  274. endif ()