InstallRequiredSystemLibraries.cmake 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419
  1. #.rst:
  2. # InstallRequiredSystemLibraries
  3. # ------------------------------
  4. #
  5. #
  6. #
  7. # By including this file, all library files listed in the variable
  8. # CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS will be installed with
  9. # install(PROGRAMS ...) into bin for WIN32 and lib for non-WIN32. If
  10. # CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS_SKIP is set to TRUE before including
  11. # this file, then the INSTALL command is not called. The user can use
  12. # the variable CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS to use a custom install
  13. # command and install them however they want. If it is the MSVC
  14. # compiler, then the microsoft run time libraries will be found and
  15. # automatically added to the CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS, and
  16. # installed. If CMAKE_INSTALL_DEBUG_LIBRARIES is set and it is the MSVC
  17. # compiler, then the debug libraries are installed when available. If
  18. # CMAKE_INSTALL_DEBUG_LIBRARIES_ONLY is set then only the debug
  19. # libraries are installed when both debug and release are available. If
  20. # CMAKE_INSTALL_MFC_LIBRARIES is set then the MFC run time libraries are
  21. # installed as well as the CRT run time libraries. If
  22. # CMAKE_INSTALL_SYSTEM_RUNTIME_DESTINATION is set then the libraries are
  23. # installed to that directory rather than the default. If
  24. # CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS_NO_WARNINGS is NOT set, then this
  25. # file warns about required files that do not exist. You can set this
  26. # variable to ON before including this file to avoid the warning. For
  27. # example, the Visual Studio Express editions do not include the
  28. # redistributable files, so if you include this file on a machine with
  29. # only VS Express installed, you'll get the warning.
  30. #=============================================================================
  31. # Copyright 2006-2009 Kitware, Inc.
  32. #
  33. # Distributed under the OSI-approved BSD License (the "License");
  34. # see accompanying file Copyright.txt for details.
  35. #
  36. # This software is distributed WITHOUT ANY WARRANTY; without even the
  37. # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  38. # See the License for more information.
  39. #=============================================================================
  40. # (To distribute this file outside of CMake, substitute the full
  41. # License text for the above reference.)
  42. if(MSVC)
  43. file(TO_CMAKE_PATH "$ENV{SYSTEMROOT}" SYSTEMROOT)
  44. if(CMAKE_CL_64)
  45. if(MSVC_VERSION GREATER 1599)
  46. # VS 10 and later:
  47. set(CMAKE_MSVC_ARCH x64)
  48. else()
  49. # VS 9 and earlier:
  50. set(CMAKE_MSVC_ARCH amd64)
  51. endif()
  52. else()
  53. set(CMAKE_MSVC_ARCH x86)
  54. endif()
  55. get_filename_component(devenv_dir "${CMAKE_MAKE_PROGRAM}" PATH)
  56. get_filename_component(base_dir "${devenv_dir}/../.." ABSOLUTE)
  57. if(MSVC70)
  58. set(__install__libs
  59. "${SYSTEMROOT}/system32/msvcp70.dll"
  60. "${SYSTEMROOT}/system32/msvcr70.dll"
  61. )
  62. endif()
  63. if(MSVC71)
  64. set(__install__libs
  65. "${SYSTEMROOT}/system32/msvcp71.dll"
  66. "${SYSTEMROOT}/system32/msvcr71.dll"
  67. )
  68. endif()
  69. if(MSVC80)
  70. # Find the runtime library redistribution directory.
  71. get_filename_component(msvc_install_dir
  72. "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\8.0;InstallDir]" ABSOLUTE)
  73. find_path(MSVC80_REDIST_DIR NAMES ${CMAKE_MSVC_ARCH}/Microsoft.VC80.CRT/Microsoft.VC80.CRT.manifest
  74. PATHS
  75. "${msvc_install_dir}/../../VC/redist"
  76. "${base_dir}/VC/redist"
  77. )
  78. mark_as_advanced(MSVC80_REDIST_DIR)
  79. set(MSVC80_CRT_DIR "${MSVC80_REDIST_DIR}/${CMAKE_MSVC_ARCH}/Microsoft.VC80.CRT")
  80. # Install the manifest that allows DLLs to be loaded from the
  81. # directory containing the executable.
  82. if(NOT CMAKE_INSTALL_DEBUG_LIBRARIES_ONLY)
  83. set(__install__libs
  84. "${MSVC80_CRT_DIR}/Microsoft.VC80.CRT.manifest"
  85. "${MSVC80_CRT_DIR}/msvcm80.dll"
  86. "${MSVC80_CRT_DIR}/msvcp80.dll"
  87. "${MSVC80_CRT_DIR}/msvcr80.dll"
  88. )
  89. endif()
  90. if(CMAKE_INSTALL_DEBUG_LIBRARIES)
  91. set(MSVC80_CRT_DIR
  92. "${MSVC80_REDIST_DIR}/Debug_NonRedist/${CMAKE_MSVC_ARCH}/Microsoft.VC80.DebugCRT")
  93. set(__install__libs ${__install__libs}
  94. "${MSVC80_CRT_DIR}/Microsoft.VC80.DebugCRT.manifest"
  95. "${MSVC80_CRT_DIR}/msvcm80d.dll"
  96. "${MSVC80_CRT_DIR}/msvcp80d.dll"
  97. "${MSVC80_CRT_DIR}/msvcr80d.dll"
  98. )
  99. endif()
  100. endif()
  101. if(MSVC90)
  102. # Find the runtime library redistribution directory.
  103. get_filename_component(msvc_install_dir
  104. "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\9.0;InstallDir]" ABSOLUTE)
  105. get_filename_component(msvc_express_install_dir
  106. "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VCExpress\\9.0;InstallDir]" ABSOLUTE)
  107. find_path(MSVC90_REDIST_DIR NAMES ${CMAKE_MSVC_ARCH}/Microsoft.VC90.CRT/Microsoft.VC90.CRT.manifest
  108. PATHS
  109. "${msvc_install_dir}/../../VC/redist"
  110. "${msvc_express_install_dir}/../../VC/redist"
  111. "${base_dir}/VC/redist"
  112. )
  113. mark_as_advanced(MSVC90_REDIST_DIR)
  114. set(MSVC90_CRT_DIR "${MSVC90_REDIST_DIR}/${CMAKE_MSVC_ARCH}/Microsoft.VC90.CRT")
  115. # Install the manifest that allows DLLs to be loaded from the
  116. # directory containing the executable.
  117. if(NOT CMAKE_INSTALL_DEBUG_LIBRARIES_ONLY)
  118. set(__install__libs
  119. "${MSVC90_CRT_DIR}/Microsoft.VC90.CRT.manifest"
  120. "${MSVC90_CRT_DIR}/msvcm90.dll"
  121. "${MSVC90_CRT_DIR}/msvcp90.dll"
  122. "${MSVC90_CRT_DIR}/msvcr90.dll"
  123. )
  124. endif()
  125. if(CMAKE_INSTALL_DEBUG_LIBRARIES)
  126. set(MSVC90_CRT_DIR
  127. "${MSVC90_REDIST_DIR}/Debug_NonRedist/${CMAKE_MSVC_ARCH}/Microsoft.VC90.DebugCRT")
  128. set(__install__libs ${__install__libs}
  129. "${MSVC90_CRT_DIR}/Microsoft.VC90.DebugCRT.manifest"
  130. "${MSVC90_CRT_DIR}/msvcm90d.dll"
  131. "${MSVC90_CRT_DIR}/msvcp90d.dll"
  132. "${MSVC90_CRT_DIR}/msvcr90d.dll"
  133. )
  134. endif()
  135. endif()
  136. macro(MSVCRT_FILES_FOR_VERSION version)
  137. set(v "${version}")
  138. # Find the runtime library redistribution directory.
  139. get_filename_component(msvc_install_dir
  140. "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\${v}.0;InstallDir]" ABSOLUTE)
  141. find_path(MSVC${v}_REDIST_DIR NAMES ${CMAKE_MSVC_ARCH}/Microsoft.VC${v}0.CRT
  142. PATHS
  143. "${msvc_install_dir}/../../VC/redist"
  144. "${base_dir}/VC/redist"
  145. "$ENV{ProgramFiles}/Microsoft Visual Studio ${v}.0/VC/redist"
  146. "$ENV{ProgramFiles(x86)}/Microsoft Visual Studio ${v}.0/VC/redist"
  147. )
  148. mark_as_advanced(MSVC${v}_REDIST_DIR)
  149. set(MSVC${v}_CRT_DIR "${MSVC${v}_REDIST_DIR}/${CMAKE_MSVC_ARCH}/Microsoft.VC${v}0.CRT")
  150. if(NOT CMAKE_INSTALL_DEBUG_LIBRARIES_ONLY)
  151. set(__install__libs
  152. "${MSVC${v}_CRT_DIR}/msvcp${v}0.dll"
  153. "${MSVC${v}_CRT_DIR}/msvcr${v}0.dll"
  154. )
  155. endif()
  156. if(CMAKE_INSTALL_DEBUG_LIBRARIES)
  157. set(MSVC${v}_CRT_DIR
  158. "${MSVC${v}_REDIST_DIR}/Debug_NonRedist/${CMAKE_MSVC_ARCH}/Microsoft.VC${v}0.DebugCRT")
  159. set(__install__libs ${__install__libs}
  160. "${MSVC${v}_CRT_DIR}/msvcp${v}0d.dll"
  161. "${MSVC${v}_CRT_DIR}/msvcr${v}0d.dll"
  162. )
  163. endif()
  164. endmacro()
  165. if(MSVC10)
  166. MSVCRT_FILES_FOR_VERSION(10)
  167. endif()
  168. if(MSVC11)
  169. MSVCRT_FILES_FOR_VERSION(11)
  170. endif()
  171. if(MSVC12)
  172. MSVCRT_FILES_FOR_VERSION(12)
  173. endif()
  174. if(CMAKE_INSTALL_MFC_LIBRARIES)
  175. if(MSVC70)
  176. set(__install__libs ${__install__libs}
  177. "${SYSTEMROOT}/system32/mfc70.dll"
  178. )
  179. endif()
  180. if(MSVC71)
  181. set(__install__libs ${__install__libs}
  182. "${SYSTEMROOT}/system32/mfc71.dll"
  183. )
  184. endif()
  185. if(MSVC80)
  186. if(CMAKE_INSTALL_DEBUG_LIBRARIES)
  187. set(MSVC80_MFC_DIR
  188. "${MSVC80_REDIST_DIR}/Debug_NonRedist/${CMAKE_MSVC_ARCH}/Microsoft.VC80.DebugMFC")
  189. set(__install__libs ${__install__libs}
  190. "${MSVC80_MFC_DIR}/Microsoft.VC80.DebugMFC.manifest"
  191. "${MSVC80_MFC_DIR}/mfc80d.dll"
  192. "${MSVC80_MFC_DIR}/mfc80ud.dll"
  193. "${MSVC80_MFC_DIR}/mfcm80d.dll"
  194. "${MSVC80_MFC_DIR}/mfcm80ud.dll"
  195. )
  196. endif()
  197. set(MSVC80_MFC_DIR "${MSVC80_REDIST_DIR}/${CMAKE_MSVC_ARCH}/Microsoft.VC80.MFC")
  198. # Install the manifest that allows DLLs to be loaded from the
  199. # directory containing the executable.
  200. if(NOT CMAKE_INSTALL_DEBUG_LIBRARIES_ONLY)
  201. set(__install__libs ${__install__libs}
  202. "${MSVC80_MFC_DIR}/Microsoft.VC80.MFC.manifest"
  203. "${MSVC80_MFC_DIR}/mfc80.dll"
  204. "${MSVC80_MFC_DIR}/mfc80u.dll"
  205. "${MSVC80_MFC_DIR}/mfcm80.dll"
  206. "${MSVC80_MFC_DIR}/mfcm80u.dll"
  207. )
  208. endif()
  209. # include the language dll's for vs8 as well as the actuall dll's
  210. set(MSVC80_MFCLOC_DIR "${MSVC80_REDIST_DIR}/${CMAKE_MSVC_ARCH}/Microsoft.VC80.MFCLOC")
  211. # Install the manifest that allows DLLs to be loaded from the
  212. # directory containing the executable.
  213. set(__install__libs ${__install__libs}
  214. "${MSVC80_MFCLOC_DIR}/Microsoft.VC80.MFCLOC.manifest"
  215. "${MSVC80_MFCLOC_DIR}/mfc80chs.dll"
  216. "${MSVC80_MFCLOC_DIR}/mfc80cht.dll"
  217. "${MSVC80_MFCLOC_DIR}/mfc80enu.dll"
  218. "${MSVC80_MFCLOC_DIR}/mfc80esp.dll"
  219. "${MSVC80_MFCLOC_DIR}/mfc80deu.dll"
  220. "${MSVC80_MFCLOC_DIR}/mfc80fra.dll"
  221. "${MSVC80_MFCLOC_DIR}/mfc80ita.dll"
  222. "${MSVC80_MFCLOC_DIR}/mfc80jpn.dll"
  223. "${MSVC80_MFCLOC_DIR}/mfc80kor.dll"
  224. )
  225. endif()
  226. if(MSVC90)
  227. if(CMAKE_INSTALL_DEBUG_LIBRARIES)
  228. set(MSVC90_MFC_DIR
  229. "${MSVC90_REDIST_DIR}/Debug_NonRedist/${CMAKE_MSVC_ARCH}/Microsoft.VC90.DebugMFC")
  230. set(__install__libs ${__install__libs}
  231. "${MSVC90_MFC_DIR}/Microsoft.VC90.DebugMFC.manifest"
  232. "${MSVC90_MFC_DIR}/mfc90d.dll"
  233. "${MSVC90_MFC_DIR}/mfc90ud.dll"
  234. "${MSVC90_MFC_DIR}/mfcm90d.dll"
  235. "${MSVC90_MFC_DIR}/mfcm90ud.dll"
  236. )
  237. endif()
  238. set(MSVC90_MFC_DIR "${MSVC90_REDIST_DIR}/${CMAKE_MSVC_ARCH}/Microsoft.VC90.MFC")
  239. # Install the manifest that allows DLLs to be loaded from the
  240. # directory containing the executable.
  241. if(NOT CMAKE_INSTALL_DEBUG_LIBRARIES_ONLY)
  242. set(__install__libs ${__install__libs}
  243. "${MSVC90_MFC_DIR}/Microsoft.VC90.MFC.manifest"
  244. "${MSVC90_MFC_DIR}/mfc90.dll"
  245. "${MSVC90_MFC_DIR}/mfc90u.dll"
  246. "${MSVC90_MFC_DIR}/mfcm90.dll"
  247. "${MSVC90_MFC_DIR}/mfcm90u.dll"
  248. )
  249. endif()
  250. # include the language dll's for vs9 as well as the actuall dll's
  251. set(MSVC90_MFCLOC_DIR "${MSVC90_REDIST_DIR}/${CMAKE_MSVC_ARCH}/Microsoft.VC90.MFCLOC")
  252. # Install the manifest that allows DLLs to be loaded from the
  253. # directory containing the executable.
  254. set(__install__libs ${__install__libs}
  255. "${MSVC90_MFCLOC_DIR}/Microsoft.VC90.MFCLOC.manifest"
  256. "${MSVC90_MFCLOC_DIR}/mfc90chs.dll"
  257. "${MSVC90_MFCLOC_DIR}/mfc90cht.dll"
  258. "${MSVC90_MFCLOC_DIR}/mfc90enu.dll"
  259. "${MSVC90_MFCLOC_DIR}/mfc90esp.dll"
  260. "${MSVC90_MFCLOC_DIR}/mfc90deu.dll"
  261. "${MSVC90_MFCLOC_DIR}/mfc90fra.dll"
  262. "${MSVC90_MFCLOC_DIR}/mfc90ita.dll"
  263. "${MSVC90_MFCLOC_DIR}/mfc90jpn.dll"
  264. "${MSVC90_MFCLOC_DIR}/mfc90kor.dll"
  265. )
  266. endif()
  267. macro(MFC_FILES_FOR_VERSION version)
  268. set(v "${version}")
  269. if(CMAKE_INSTALL_DEBUG_LIBRARIES)
  270. set(MSVC${v}_MFC_DIR
  271. "${MSVC${v}_REDIST_DIR}/Debug_NonRedist/${CMAKE_MSVC_ARCH}/Microsoft.VC${v}0.DebugMFC")
  272. set(__install__libs ${__install__libs}
  273. "${MSVC${v}_MFC_DIR}/mfc${v}0d.dll"
  274. "${MSVC${v}_MFC_DIR}/mfc${v}0ud.dll"
  275. "${MSVC${v}_MFC_DIR}/mfcm${v}0d.dll"
  276. "${MSVC${v}_MFC_DIR}/mfcm${v}0ud.dll"
  277. )
  278. endif()
  279. set(MSVC${v}_MFC_DIR "${MSVC${v}_REDIST_DIR}/${CMAKE_MSVC_ARCH}/Microsoft.VC${v}0.MFC")
  280. if(NOT CMAKE_INSTALL_DEBUG_LIBRARIES_ONLY)
  281. set(__install__libs ${__install__libs}
  282. "${MSVC${v}_MFC_DIR}/mfc${v}0.dll"
  283. "${MSVC${v}_MFC_DIR}/mfc${v}0u.dll"
  284. "${MSVC${v}_MFC_DIR}/mfcm${v}0.dll"
  285. "${MSVC${v}_MFC_DIR}/mfcm${v}0u.dll"
  286. )
  287. endif()
  288. # include the language dll's as well as the actuall dll's
  289. set(MSVC${v}_MFCLOC_DIR "${MSVC${v}_REDIST_DIR}/${CMAKE_MSVC_ARCH}/Microsoft.VC${v}0.MFCLOC")
  290. set(__install__libs ${__install__libs}
  291. "${MSVC${v}_MFCLOC_DIR}/mfc${v}0chs.dll"
  292. "${MSVC${v}_MFCLOC_DIR}/mfc${v}0cht.dll"
  293. "${MSVC${v}_MFCLOC_DIR}/mfc${v}0deu.dll"
  294. "${MSVC${v}_MFCLOC_DIR}/mfc${v}0enu.dll"
  295. "${MSVC${v}_MFCLOC_DIR}/mfc${v}0esn.dll"
  296. "${MSVC${v}_MFCLOC_DIR}/mfc${v}0fra.dll"
  297. "${MSVC${v}_MFCLOC_DIR}/mfc${v}0ita.dll"
  298. "${MSVC${v}_MFCLOC_DIR}/mfc${v}0jpn.dll"
  299. "${MSVC${v}_MFCLOC_DIR}/mfc${v}0kor.dll"
  300. "${MSVC${v}_MFCLOC_DIR}/mfc${v}0rus.dll"
  301. )
  302. endmacro()
  303. if(MSVC10)
  304. MFC_FILES_FOR_VERSION(10)
  305. endif()
  306. if(MSVC11)
  307. MFC_FILES_FOR_VERSION(11)
  308. endif()
  309. if(MSVC12)
  310. MFC_FILES_FOR_VERSION(12)
  311. endif()
  312. endif()
  313. foreach(lib
  314. ${__install__libs}
  315. )
  316. if(EXISTS ${lib})
  317. set(CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS
  318. ${CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS} ${lib})
  319. else()
  320. if(NOT CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS_NO_WARNINGS)
  321. message(WARNING "system runtime library file does not exist: '${lib}'")
  322. # This warning indicates an incomplete Visual Studio installation
  323. # or a bug somewhere above here in this file.
  324. # If you would like to avoid this warning, fix the real problem, or
  325. # set CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS_NO_WARNINGS before including
  326. # this file.
  327. endif()
  328. endif()
  329. endforeach()
  330. endif()
  331. if(WATCOM)
  332. get_filename_component( CompilerPath ${CMAKE_C_COMPILER} PATH )
  333. if(CMAKE_C_COMPILER_VERSION)
  334. set(_compiler_version ${CMAKE_C_COMPILER_VERSION})
  335. else()
  336. set(_compiler_version ${CMAKE_CXX_COMPILER_VERSION})
  337. endif()
  338. string(REGEX MATCHALL "[0-9]+" _watcom_version_list "${_compiler_version}")
  339. list(GET _watcom_version_list 0 _watcom_major)
  340. list(GET _watcom_version_list 1 _watcom_minor)
  341. if(${_watcom_major} GREATER 11)
  342. math(EXPR _watcom_major "${_watcom_major} - 11")
  343. endif()
  344. math(EXPR _watcom_minor "${_watcom_minor} / 10")
  345. set( __install__libs
  346. ${CompilerPath}/clbr${_watcom_major}${_watcom_minor}.dll
  347. ${CompilerPath}/mt7r${_watcom_major}${_watcom_minor}.dll
  348. ${CompilerPath}/plbr${_watcom_major}${_watcom_minor}.dll )
  349. foreach(lib
  350. ${__install__libs}
  351. )
  352. if(EXISTS ${lib})
  353. set(CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS
  354. ${CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS} ${lib})
  355. else()
  356. if(NOT CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS_NO_WARNINGS)
  357. message(WARNING "system runtime library file does not exist: '${lib}'")
  358. # This warning indicates an incomplete Watcom installation
  359. # or a bug somewhere above here in this file.
  360. # If you would like to avoid this warning, fix the real problem, or
  361. # set CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS_NO_WARNINGS before including
  362. # this file.
  363. endif()
  364. endif()
  365. endforeach()
  366. endif()
  367. # Include system runtime libraries in the installation if any are
  368. # specified by CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS.
  369. if(CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS)
  370. if(NOT CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS_SKIP)
  371. if(NOT CMAKE_INSTALL_SYSTEM_RUNTIME_DESTINATION)
  372. if(WIN32)
  373. set(CMAKE_INSTALL_SYSTEM_RUNTIME_DESTINATION bin)
  374. else()
  375. set(CMAKE_INSTALL_SYSTEM_RUNTIME_DESTINATION lib)
  376. endif()
  377. endif()
  378. install(PROGRAMS ${CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS}
  379. DESTINATION ${CMAKE_INSTALL_SYSTEM_RUNTIME_DESTINATION})
  380. endif()
  381. endif()