deps-windows.cmake 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270
  1. if (MSVC_VERSION EQUAL 1800)
  2. set(DEP_VS_VER "12")
  3. set(DEP_BOOST_TOOLSET "msvc-12.0")
  4. elseif (MSVC_VERSION EQUAL 1900)
  5. set(DEP_VS_VER "14")
  6. set(DEP_BOOST_TOOLSET "msvc-14.0")
  7. elseif (MSVC_VERSION GREATER 1900)
  8. set(DEP_VS_VER "15")
  9. set(DEP_BOOST_TOOLSET "msvc-14.1")
  10. else ()
  11. message(FATAL_ERROR "Unsupported MSVC version")
  12. endif ()
  13. if (${DEPS_BITS} EQUAL 32)
  14. set(DEP_MSVC_GEN "Visual Studio ${DEP_VS_VER}")
  15. else ()
  16. set(DEP_MSVC_GEN "Visual Studio ${DEP_VS_VER} Win64")
  17. endif ()
  18. if (${DEP_DEBUG})
  19. set(DEP_BOOST_DEBUG "debug")
  20. else ()
  21. set(DEP_BOOST_DEBUG "")
  22. endif ()
  23. ExternalProject_Add(dep_boost
  24. EXCLUDE_FROM_ALL 1
  25. URL "https://dl.bintray.com/boostorg/release/1.66.0/source/boost_1_66_0.tar.gz"
  26. URL_HASH SHA256=bd0df411efd9a585e5a2212275f8762079fed8842264954675a4fddc46cfcf60
  27. BUILD_IN_SOURCE 1
  28. CONFIGURE_COMMAND bootstrap.bat
  29. BUILD_COMMAND b2.exe
  30. -j "${NPROC}"
  31. --with-system
  32. --with-filesystem
  33. --with-thread
  34. --with-log
  35. --with-locale
  36. --with-regex
  37. "--prefix=${DESTDIR}/usr/local"
  38. "address-model=${DEPS_BITS}"
  39. "toolset=${DEP_BOOST_TOOLSET}"
  40. link=static
  41. variant=release
  42. threading=multi
  43. boost.locale.icu=off
  44. "${DEP_BOOST_DEBUG}" release install
  45. INSTALL_COMMAND "" # b2 does that already
  46. )
  47. ExternalProject_Add(dep_tbb
  48. EXCLUDE_FROM_ALL 1
  49. URL "https://github.com/wjakob/tbb/archive/a0dc9bf76d0120f917b641ed095360448cabc85b.tar.gz"
  50. URL_HASH SHA256=0545cb6033bd1873fcae3ea304def720a380a88292726943ae3b9b207f322efe
  51. CMAKE_GENERATOR "${DEP_MSVC_GEN}"
  52. CMAKE_ARGS
  53. -DCMAKE_DEBUG_POSTFIX=_debug
  54. -DTBB_BUILD_SHARED=OFF
  55. -DTBB_BUILD_TESTS=OFF
  56. "-DCMAKE_INSTALL_PREFIX:PATH=${DESTDIR}\\usr\\local"
  57. BUILD_COMMAND msbuild /P:Configuration=Release INSTALL.vcxproj
  58. INSTALL_COMMAND ""
  59. )
  60. if (${DEP_DEBUG})
  61. ExternalProject_Get_Property(dep_tbb BINARY_DIR)
  62. ExternalProject_Add_Step(dep_tbb build_debug
  63. DEPENDEES build
  64. DEPENDERS install
  65. COMMAND msbuild /P:Configuration=Debug INSTALL.vcxproj
  66. WORKING_DIRECTORY "${BINARY_DIR}"
  67. )
  68. endif ()
  69. ExternalProject_Add(dep_gtest
  70. EXCLUDE_FROM_ALL 1
  71. URL "https://github.com/google/googletest/archive/release-1.8.1.tar.gz"
  72. URL_HASH SHA256=9bf1fe5182a604b4135edc1a425ae356c9ad15e9b23f9f12a02e80184c3a249c
  73. CMAKE_GENERATOR "${DEP_MSVC_GEN}"
  74. CMAKE_ARGS
  75. -DBUILD_GMOCK=OFF
  76. -Dgtest_force_shared_crt=ON
  77. -DCMAKE_POSITION_INDEPENDENT_CODE=ON
  78. "-DCMAKE_INSTALL_PREFIX:PATH=${DESTDIR}\\usr\\local"
  79. BUILD_COMMAND msbuild /P:Configuration=Release INSTALL.vcxproj
  80. INSTALL_COMMAND ""
  81. )
  82. if (${DEP_DEBUG})
  83. ExternalProject_Get_Property(dep_gtest BINARY_DIR)
  84. ExternalProject_Add_Step(dep_gtest build_debug
  85. DEPENDEES build
  86. DEPENDERS install
  87. COMMAND msbuild /P:Configuration=Debug INSTALL.vcxproj
  88. WORKING_DIRECTORY "${BINARY_DIR}"
  89. )
  90. endif ()
  91. ExternalProject_Add(dep_nlopt
  92. EXCLUDE_FROM_ALL 1
  93. URL "https://github.com/stevengj/nlopt/archive/v2.5.0.tar.gz"
  94. URL_HASH SHA256=c6dd7a5701fff8ad5ebb45a3dc8e757e61d52658de3918e38bab233e7fd3b4ae
  95. CMAKE_GENERATOR "${DEP_MSVC_GEN}"
  96. CMAKE_ARGS
  97. -DBUILD_SHARED_LIBS=OFF
  98. -DNLOPT_PYTHON=OFF
  99. -DNLOPT_OCTAVE=OFF
  100. -DNLOPT_MATLAB=OFF
  101. -DNLOPT_GUILE=OFF
  102. -DCMAKE_POSITION_INDEPENDENT_CODE=ON
  103. -DCMAKE_DEBUG_POSTFIX=d
  104. "-DCMAKE_INSTALL_PREFIX:PATH=${DESTDIR}\\usr\\local"
  105. BUILD_COMMAND msbuild /P:Configuration=Release INSTALL.vcxproj
  106. INSTALL_COMMAND ""
  107. )
  108. if (${DEP_DEBUG})
  109. ExternalProject_Get_Property(dep_nlopt BINARY_DIR)
  110. ExternalProject_Add_Step(dep_nlopt build_debug
  111. DEPENDEES build
  112. DEPENDERS install
  113. COMMAND msbuild /P:Configuration=Debug INSTALL.vcxproj
  114. WORKING_DIRECTORY "${BINARY_DIR}"
  115. )
  116. endif ()
  117. ExternalProject_Add(dep_zlib
  118. EXCLUDE_FROM_ALL 1
  119. URL "https://zlib.net/zlib-1.2.11.tar.xz"
  120. URL_HASH SHA256=4ff941449631ace0d4d203e3483be9dbc9da454084111f97ea0a2114e19bf066
  121. CMAKE_GENERATOR "${DEP_MSVC_GEN}"
  122. CMAKE_ARGS
  123. -DSKIP_INSTALL_FILES=ON # Prevent installation of man pages et al.
  124. "-DINSTALL_BIN_DIR=${CMAKE_CURRENT_BINARY_DIR}\\fallout" # I found no better way of preventing zlib from creating & installing DLLs :-/
  125. -DCMAKE_POSITION_INDEPENDENT_CODE=ON
  126. "-DCMAKE_INSTALL_PREFIX:PATH=${DESTDIR}\\usr\\local"
  127. BUILD_COMMAND msbuild /P:Configuration=Release INSTALL.vcxproj
  128. INSTALL_COMMAND ""
  129. )
  130. if (${DEP_DEBUG})
  131. ExternalProject_Get_Property(dep_zlib BINARY_DIR)
  132. ExternalProject_Add_Step(dep_zlib build_debug
  133. DEPENDEES build
  134. DEPENDERS install
  135. COMMAND msbuild /P:Configuration=Debug INSTALL.vcxproj
  136. WORKING_DIRECTORY "${BINARY_DIR}"
  137. )
  138. endif ()
  139. # The following steps are unfortunately needed to remove the _static suffix on libraries
  140. ExternalProject_Add_Step(dep_zlib fix_static
  141. DEPENDEES install
  142. COMMAND "${CMAKE_COMMAND}" -E rename zlibstatic.lib zlib.lib
  143. WORKING_DIRECTORY "${DESTDIR}\\usr\\local\\lib\\"
  144. )
  145. if (${DEP_DEBUG})
  146. ExternalProject_Add_Step(dep_zlib fix_static_debug
  147. DEPENDEES install
  148. COMMAND "${CMAKE_COMMAND}" -E rename zlibstaticd.lib zlibd.lib
  149. WORKING_DIRECTORY "${DESTDIR}\\usr\\local\\lib\\"
  150. )
  151. endif ()
  152. ExternalProject_Add(dep_libpng
  153. DEPENDS dep_zlib
  154. EXCLUDE_FROM_ALL 1
  155. URL "https://github.com/glennrp/libpng/archive/v1.6.36.tar.gz"
  156. URL_HASH SHA256=5bef5a850a9255365a2dc344671b7e9ef810de491bd479c2506ac3c337e2d84f
  157. CMAKE_GENERATOR "${DEP_MSVC_GEN}"
  158. CMAKE_ARGS
  159. -DPNG_SHARED=OFF
  160. -DPNG_TESTS=OFF
  161. -DSKIP_INSTALL_FILES=ON # Prevent installation of man pages et al.
  162. -DCMAKE_POSITION_INDEPENDENT_CODE=ON
  163. "-DCMAKE_INSTALL_PREFIX:PATH=${DESTDIR}\\usr\\local"
  164. BUILD_COMMAND msbuild /P:Configuration=Release INSTALL.vcxproj
  165. INSTALL_COMMAND ""
  166. )
  167. if (${DEP_DEBUG})
  168. ExternalProject_Get_Property(dep_libpng BINARY_DIR)
  169. ExternalProject_Add_Step(dep_libpng build_debug
  170. DEPENDEES build
  171. DEPENDERS install
  172. COMMAND msbuild /P:Configuration=Debug INSTALL.vcxproj
  173. WORKING_DIRECTORY "${BINARY_DIR}"
  174. )
  175. endif ()
  176. # The following steps are unfortunately needed to remove the _static suffix on libraries
  177. # (And also overwrite the dynamic .lib)
  178. ExternalProject_Add_Step(dep_libpng fix_static
  179. DEPENDEES install
  180. COMMAND "${CMAKE_COMMAND}" -E rename libpng16_static.lib libpng16.lib
  181. WORKING_DIRECTORY "${DESTDIR}\\usr\\local\\lib\\"
  182. )
  183. if (${DEP_DEBUG})
  184. ExternalProject_Add_Step(dep_libpng fix_static_debug
  185. DEPENDEES install
  186. COMMAND "${CMAKE_COMMAND}" -E rename libpng16_staticd.lib libpng16d.lib
  187. WORKING_DIRECTORY "${DESTDIR}\\usr\\local\\lib\\"
  188. )
  189. endif ()
  190. if (${DEPS_BITS} EQUAL 32)
  191. set(DEP_LIBCURL_TARGET "x86")
  192. else ()
  193. set(DEP_LIBCURL_TARGET "x64")
  194. endif ()
  195. ExternalProject_Add(dep_libcurl
  196. EXCLUDE_FROM_ALL 1
  197. URL "https://curl.haxx.se/download/curl-7.58.0.tar.gz"
  198. URL_HASH SHA256=cc245bf9a1a42a45df491501d97d5593392a03f7b4f07b952793518d97666115
  199. BUILD_IN_SOURCE 1
  200. CONFIGURE_COMMAND ""
  201. BUILD_COMMAND cd winbuild && nmake /f Makefile.vc mode=static "VC=${DEP_VS_VER}" GEN_PDB=yes DEBUG=no "MACHINE=${DEP_LIBCURL_TARGET}"
  202. INSTALL_COMMAND cd builds\\libcurl-*-release-*-winssl
  203. && "${CMAKE_COMMAND}" -E copy_directory include "${DESTDIR}\\usr\\local\\include"
  204. && "${CMAKE_COMMAND}" -E copy_directory lib "${DESTDIR}\\usr\\local\\lib"
  205. )
  206. if (${DEP_DEBUG})
  207. ExternalProject_Get_Property(dep_libcurl SOURCE_DIR)
  208. ExternalProject_Add_Step(dep_libcurl build_debug
  209. DEPENDEES build
  210. DEPENDERS install
  211. COMMAND cd winbuild && nmake /f Makefile.vc mode=static "VC=${DEP_VS_VER}" GEN_PDB=yes DEBUG=yes "MACHINE=${DEP_LIBCURL_TARGET}"
  212. WORKING_DIRECTORY "${SOURCE_DIR}"
  213. )
  214. ExternalProject_Add_Step(dep_libcurl install_debug
  215. DEPENDEES install
  216. COMMAND cd builds\\libcurl-*-debug-*-winssl
  217. && "${CMAKE_COMMAND}" -E copy_directory include "${DESTDIR}\\usr\\local\\include"
  218. && "${CMAKE_COMMAND}" -E copy_directory lib "${DESTDIR}\\usr\\local\\lib"
  219. WORKING_DIRECTORY "${SOURCE_DIR}"
  220. )
  221. endif ()
  222. if (${DEPS_BITS} EQUAL 32)
  223. set(DEP_WXWIDGETS_TARGET "")
  224. set(DEP_WXWIDGETS_LIBDIR "vc_lib")
  225. else ()
  226. set(DEP_WXWIDGETS_TARGET "TARGET_CPU=X64")
  227. set(DEP_WXWIDGETS_LIBDIR "vc_x64_lib")
  228. endif ()
  229. ExternalProject_Add(dep_wxwidgets
  230. EXCLUDE_FROM_ALL 1
  231. URL "https://github.com/wxWidgets/wxWidgets/releases/download/v3.1.1/wxWidgets-3.1.1.tar.bz2"
  232. URL_HASH SHA256=c925dfe17e8f8b09eb7ea9bfdcfcc13696a3e14e92750effd839f5e10726159e
  233. BUILD_IN_SOURCE 1
  234. PATCH_COMMAND "${CMAKE_COMMAND}" -E copy "${CMAKE_CURRENT_SOURCE_DIR}\\wxwidgets-pngprefix.h" src\\png\\pngprefix.h
  235. CONFIGURE_COMMAND ""
  236. BUILD_COMMAND cd build\\msw && nmake /f makefile.vc BUILD=release SHARED=0 UNICODE=1 USE_GUI=1 "${DEP_WXWIDGETS_TARGET}"
  237. INSTALL_COMMAND "${CMAKE_COMMAND}" -E copy_directory include "${DESTDIR}\\usr\\local\\include"
  238. && "${CMAKE_COMMAND}" -E copy_directory "lib\\${DEP_WXWIDGETS_LIBDIR}" "${DESTDIR}\\usr\\local\\lib\\${DEP_WXWIDGETS_LIBDIR}"
  239. )
  240. if (${DEP_DEBUG})
  241. ExternalProject_Get_Property(dep_wxwidgets SOURCE_DIR)
  242. ExternalProject_Add_Step(dep_wxwidgets build_debug
  243. DEPENDEES build
  244. DEPENDERS install
  245. COMMAND cd build\\msw && nmake /f makefile.vc BUILD=debug SHARED=0 UNICODE=1 USE_GUI=1 "${DEP_WXWIDGETS_TARGET}"
  246. WORKING_DIRECTORY "${SOURCE_DIR}"
  247. )
  248. endif ()