deps-windows.cmake 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296
  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. if (${DEPS_BITS} EQUAL 32)
  138. set(DEP_LIBCURL_TARGET "x86")
  139. else ()
  140. set(DEP_LIBCURL_TARGET "x64")
  141. endif ()
  142. ExternalProject_Add(dep_libcurl
  143. EXCLUDE_FROM_ALL 1
  144. URL "https://curl.haxx.se/download/curl-7.58.0.tar.gz"
  145. URL_HASH SHA256=cc245bf9a1a42a45df491501d97d5593392a03f7b4f07b952793518d97666115
  146. BUILD_IN_SOURCE 1
  147. CONFIGURE_COMMAND ""
  148. BUILD_COMMAND cd winbuild && nmake /f Makefile.vc mode=static "VC=${DEP_VS_VER}" GEN_PDB=yes DEBUG=no "MACHINE=${DEP_LIBCURL_TARGET}"
  149. INSTALL_COMMAND cd builds\\libcurl-*-release-*-winssl
  150. && "${CMAKE_COMMAND}" -E copy_directory include "${DESTDIR}\\usr\\local\\include"
  151. && "${CMAKE_COMMAND}" -E copy_directory lib "${DESTDIR}\\usr\\local\\lib"
  152. )
  153. if (${DEP_DEBUG})
  154. ExternalProject_Get_Property(dep_libcurl SOURCE_DIR)
  155. ExternalProject_Add_Step(dep_libcurl build_debug
  156. DEPENDEES build
  157. DEPENDERS install
  158. COMMAND cd winbuild && nmake /f Makefile.vc mode=static "VC=${DEP_VS_VER}" GEN_PDB=yes DEBUG=yes "MACHINE=${DEP_LIBCURL_TARGET}"
  159. WORKING_DIRECTORY "${SOURCE_DIR}"
  160. )
  161. ExternalProject_Add_Step(dep_libcurl install_debug
  162. DEPENDEES install
  163. COMMAND cd builds\\libcurl-*-debug-*-winssl
  164. && "${CMAKE_COMMAND}" -E copy_directory include "${DESTDIR}\\usr\\local\\include"
  165. && "${CMAKE_COMMAND}" -E copy_directory lib "${DESTDIR}\\usr\\local\\lib"
  166. WORKING_DIRECTORY "${SOURCE_DIR}"
  167. )
  168. endif ()
  169. ExternalProject_Add(dep_qhull
  170. EXCLUDE_FROM_ALL 1
  171. #URL "https://github.com/qhull/qhull/archive/v7.3.2.tar.gz"
  172. #URL_HASH SHA256=619c8a954880d545194bc03359404ef36a1abd2dde03678089459757fd790cb0
  173. GIT_REPOSITORY https://github.com/qhull/qhull.git
  174. GIT_TAG 7afedcc73666e46a9f1d74632412ebecf53b1b30 # v7.3.2 plus the mac build patch
  175. CMAKE_GENERATOR "${DEP_MSVC_GEN}"
  176. CMAKE_ARGS
  177. -DCMAKE_INSTALL_PREFIX=${DESTDIR}/usr/local
  178. -DBUILD_SHARED_LIBS=OFF
  179. -DCMAKE_POSITION_INDEPENDENT_CODE=ON
  180. -DCMAKE_DEBUG_POSTFIX=d
  181. BUILD_COMMAND msbuild /m /P:Configuration=Release INSTALL.vcxproj
  182. INSTALL_COMMAND ""
  183. )
  184. add_debug_dep(dep_qhull)
  185. if (${DEPS_BITS} EQUAL 32)
  186. set(DEP_WXWIDGETS_TARGET "")
  187. set(DEP_WXWIDGETS_LIBDIR "vc_lib")
  188. else ()
  189. set(DEP_WXWIDGETS_TARGET "TARGET_CPU=X64")
  190. set(DEP_WXWIDGETS_LIBDIR "vc_x64_lib")
  191. endif ()
  192. find_package(Git REQUIRED)
  193. ExternalProject_Add(dep_blosc
  194. EXCLUDE_FROM_ALL 1
  195. #URL https://github.com/Blosc/c-blosc/archive/v1.17.0.zip
  196. #URL_HASH SHA256=7463a1df566704f212263312717ab2c36b45d45cba6cd0dccebf91b2cc4b4da9
  197. GIT_REPOSITORY https://github.com/Blosc/c-blosc.git
  198. GIT_TAG e63775855294b50820ef44d1b157f4de1cc38d3e #v1.17.0
  199. CMAKE_GENERATOR "${DEP_MSVC_GEN}"
  200. CMAKE_GENERATOR_PLATFORM "${DEP_PLATFORM}"
  201. CMAKE_ARGS
  202. -DCMAKE_INSTALL_PREFIX=${DESTDIR}/usr/local
  203. -DBUILD_SHARED_LIBS=OFF
  204. -DCMAKE_POSITION_INDEPENDENT_CODE=ON
  205. -DCMAKE_DEBUG_POSTFIX=d
  206. -DBUILD_SHARED=OFF
  207. -DBUILD_STATIC=ON
  208. -DBUILD_TESTS=OFF
  209. -DBUILD_BENCHMARKS=OFF
  210. -DPREFER_EXTERNAL_ZLIB=ON
  211. -DBLOSC_IS_SUBPROJECT:BOOL=ON
  212. -DBLOSC_INSTALL:BOOL=ON
  213. PATCH_COMMAND ${GIT_EXECUTABLE} checkout -f -- . && git clean -df &&
  214. ${GIT_EXECUTABLE} apply --whitespace=fix ${CMAKE_CURRENT_SOURCE_DIR}/blosc-mods.patch
  215. BUILD_COMMAND msbuild /m /P:Configuration=Release INSTALL.vcxproj
  216. INSTALL_COMMAND ""
  217. )
  218. add_debug_dep(dep_blosc)
  219. ExternalProject_Add(dep_openexr
  220. EXCLUDE_FROM_ALL 1
  221. GIT_REPOSITORY https://github.com/openexr/openexr.git
  222. GIT_TAG eae0e337c9f5117e78114fd05f7a415819df413a #v2.4.0
  223. CMAKE_GENERATOR "${DEP_MSVC_GEN}"
  224. CMAKE_GENERATOR_PLATFORM "${DEP_PLATFORM}"
  225. CMAKE_ARGS
  226. -DCMAKE_INSTALL_PREFIX=${DESTDIR}/usr/local
  227. -DBUILD_SHARED_LIBS=OFF
  228. -DCMAKE_POSITION_INDEPENDENT_CODE=ON
  229. -DBUILD_TESTING=OFF
  230. -DPYILMBASE_ENABLE:BOOL=OFF
  231. -DOPENEXR_VIEWERS_ENABLE:BOOL=OFF
  232. -DOPENEXR_BUILD_UTILS:BOOL=OFF
  233. BUILD_COMMAND msbuild /m /P:Configuration=Release INSTALL.vcxproj
  234. INSTALL_COMMAND ""
  235. )
  236. add_debug_dep(dep_openexr)
  237. ExternalProject_Add(dep_openvdb
  238. EXCLUDE_FROM_ALL 1
  239. #URL https://github.com/AcademySoftwareFoundation/openvdb/archive/v6.2.1.zip
  240. #URL_HASH SHA256=dc337399dce8e1c9f21f20e97b1ce7e4933cb0a63bb3b8b734d8fcc464aa0c48
  241. GIT_REPOSITORY https://github.com/AcademySoftwareFoundation/openvdb.git
  242. GIT_TAG aebaf8d95be5e57fd33949281ec357db4a576c2e #v6.2.1
  243. DEPENDS dep_blosc dep_openexr dep_tbb dep_boost
  244. CMAKE_GENERATOR "${DEP_MSVC_GEN}"
  245. CMAKE_GENERATOR_PLATFORM "${DEP_PLATFORM}"
  246. CMAKE_ARGS
  247. -DCMAKE_INSTALL_PREFIX=${DESTDIR}/usr/local
  248. -DCMAKE_DEBUG_POSTFIX=d
  249. -DCMAKE_PREFIX_PATH=${DESTDIR}/usr/local
  250. -DBUILD_SHARED_LIBS=OFF
  251. -DCMAKE_POSITION_INDEPENDENT_CODE=ON
  252. -DOPENVDB_BUILD_PYTHON_MODULE=OFF
  253. -DUSE_BLOSC=ON
  254. -DOPENVDB_CORE_SHARED=OFF
  255. -DOPENVDB_CORE_STATIC=ON
  256. -DTBB_STATIC=ON
  257. -DOPENVDB_BUILD_VDB_PRINT=ON
  258. BUILD_COMMAND msbuild /m /P:Configuration=Release INSTALL.vcxproj
  259. PATCH_COMMAND ${GIT_EXECUTABLE} checkout -f -- . && git clean -df &&
  260. ${GIT_EXECUTABLE} apply --whitespace=fix ${CMAKE_CURRENT_SOURCE_DIR}/openvdb-mods.patch
  261. INSTALL_COMMAND ""
  262. )
  263. if (${DEP_DEBUG})
  264. ExternalProject_Get_Property(dep_openvdb BINARY_DIR)
  265. ExternalProject_Add_Step(dep_openvdb build_debug
  266. DEPENDEES build
  267. DEPENDERS install
  268. COMMAND ${CMAKE_COMMAND} ../dep_openvdb -DOPENVDB_BUILD_VDB_PRINT=OFF
  269. COMMAND msbuild /m /P:Configuration=Debug INSTALL.vcxproj
  270. WORKING_DIRECTORY "${BINARY_DIR}"
  271. )
  272. endif ()