331623fa449e5003e5f7209d3e55b47ad6404d61
[platform/upstream/cmake.git] / Modules / InstallRequiredSystemLibraries.cmake
1 # Distributed under the OSI-approved BSD 3-Clause License.  See accompanying
2 # file Copyright.txt or https://cmake.org/licensing for details.
3
4 #[=======================================================================[.rst:
5 InstallRequiredSystemLibraries
6 ------------------------------
7
8 Include this module to search for compiler-provided system runtime
9 libraries and add install rules for them.  Some optional variables
10 may be set prior to including the module to adjust behavior:
11
12 ``CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS``
13   Specify additional runtime libraries that may not be detected.
14   After inclusion any detected libraries will be appended to this.
15
16 ``CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS_SKIP``
17   Set to TRUE to skip calling the :command:`install(PROGRAMS)` command to
18   allow the includer to specify its own install rule, using the value of
19   ``CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS`` to get the list of libraries.
20
21 ``CMAKE_INSTALL_DEBUG_LIBRARIES``
22   Set to TRUE to install the debug runtime libraries when available
23   with MSVC tools.
24
25 ``CMAKE_INSTALL_DEBUG_LIBRARIES_ONLY``
26   Set to TRUE to install only the debug runtime libraries with MSVC
27   tools even if the release runtime libraries are also available.
28
29 ``CMAKE_INSTALL_UCRT_LIBRARIES``
30   .. versionadded:: 3.6
31
32   Set to TRUE to install the Windows Universal CRT libraries for
33   app-local deployment (e.g. to Windows XP).  This is meaningful
34   only with MSVC from Visual Studio 2015 or higher.
35
36   .. versionadded:: 3.9
37     One may set a ``CMAKE_WINDOWS_KITS_10_DIR`` *environment variable*
38     to an absolute path to tell CMake to look for Windows 10 SDKs in
39     a custom location.  The specified directory is expected to contain
40     ``Redist/ucrt/DLLs/*`` directories.
41
42 ``CMAKE_INSTALL_MFC_LIBRARIES``
43   Set to TRUE to install the MSVC MFC runtime libraries.
44
45 ``CMAKE_INSTALL_OPENMP_LIBRARIES``
46   Set to TRUE to install the MSVC OpenMP runtime libraries
47
48 ``CMAKE_INSTALL_SYSTEM_RUNTIME_DESTINATION``
49   Specify the :command:`install(PROGRAMS)` command ``DESTINATION``
50   option.  If not specified, the default is ``bin`` on Windows
51   and ``lib`` elsewhere.
52
53 ``CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS_NO_WARNINGS``
54   Set to TRUE to disable warnings about required library files that
55   do not exist.  (For example, Visual Studio Express editions may
56   not provide the redistributable files.)
57
58 ``CMAKE_INSTALL_SYSTEM_RUNTIME_COMPONENT``
59   .. versionadded:: 3.3
60
61   Specify the :command:`install(PROGRAMS)` command ``COMPONENT``
62   option.  If not specified, no such option will be used.
63
64 .. versionadded:: 3.10
65   Support for installing Intel compiler runtimes.
66 #]=======================================================================]
67
68 cmake_policy(PUSH)
69 cmake_policy(SET CMP0054 NEW) # if() quoted variables not dereferenced
70
71 set(_IRSL_HAVE_Intel FALSE)
72 set(_IRSL_HAVE_MSVC FALSE)
73 foreach(LANG IN ITEMS C CXX Fortran)
74   if("${CMAKE_${LANG}_COMPILER_ID}" MATCHES "Intel")
75     if(NOT _IRSL_HAVE_Intel)
76       get_filename_component(_Intel_basedir "${CMAKE_${LANG}_COMPILER}" PATH)
77       if(CMAKE_SIZEOF_VOID_P EQUAL 8)
78         set(_Intel_archdir intel64)
79       else()
80         set(_Intel_archdir ia32)
81       endif()
82       set(_Intel_compiler_ver ${CMAKE_${LANG}_COMPILER_VERSION})
83       if(WIN32 AND EXISTS "${_Intel_basedir}/../redist/${_Intel_archdir}_win/compiler")
84         get_filename_component(_Intel_redistdir "${_Intel_basedir}/../redist/${_Intel_archdir}_win/compiler" ABSOLUTE)
85       elseif(WIN32)
86         get_filename_component(_Intel_redistdir "${_Intel_basedir}/../../redist/${_Intel_archdir}/compiler" ABSOLUTE)
87       elseif(APPLE)
88         get_filename_component(_Intel_redistdir "${_Intel_basedir}/../../compiler/lib" ABSOLUTE)
89       else()
90         if(EXISTS "${_Intel_basedir}/../lib/${_Intel_archdir}_lin")
91           get_filename_component(_Intel_redistdir "${_Intel_basedir}/../lib/${_Intel_archdir}" ABSOLUTE)
92         else()
93           get_filename_component(_Intel_redistdir "${_Intel_basedir}/../../compiler/lib/${_Intel_archdir}_lin" ABSOLUTE)
94         endif()
95       endif()
96       set(_IRSL_HAVE_Intel TRUE)
97     endif()
98   elseif("${CMAKE_${LANG}_COMPILER_ID}" STREQUAL "MSVC")
99     set(_IRSL_HAVE_MSVC TRUE)
100   endif()
101 endforeach()
102
103 if(MSVC)
104   file(TO_CMAKE_PATH "$ENV{SYSTEMROOT}" SYSTEMROOT)
105
106   if(MSVC_C_ARCHITECTURE_ID)
107     string(TOLOWER "${MSVC_C_ARCHITECTURE_ID}" CMAKE_MSVC_ARCH)
108   elseif(MSVC_CXX_ARCHITECTURE_ID)
109     string(TOLOWER "${MSVC_CXX_ARCHITECTURE_ID}" CMAKE_MSVC_ARCH)
110   else()
111     set(CMAKE_MSVC_ARCH x86)
112   endif()
113   if(CMAKE_MSVC_ARCH STREQUAL "x64")
114     if(MSVC_VERSION LESS 1600)
115       # VS 9 and earlier:
116       set(CMAKE_MSVC_ARCH amd64)
117     endif()
118   endif()
119
120   get_filename_component(devenv_dir "${CMAKE_MAKE_PROGRAM}" PATH)
121   get_filename_component(base_dir "${devenv_dir}/../.." ABSOLUTE)
122
123   if(MSVC_VERSION EQUAL 1300)
124     set(__install__libs
125       "${SYSTEMROOT}/system32/msvcp70.dll"
126       "${SYSTEMROOT}/system32/msvcr70.dll"
127       )
128   endif()
129
130   if(MSVC_VERSION EQUAL 1310)
131     set(__install__libs
132       "${SYSTEMROOT}/system32/msvcp71.dll"
133       "${SYSTEMROOT}/system32/msvcr71.dll"
134       )
135   endif()
136
137   if(MSVC_TOOLSET_VERSION EQUAL 80)
138     # Find the runtime library redistribution directory.
139     get_filename_component(msvc_install_dir
140       "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\8.0;InstallDir]" ABSOLUTE)
141     if(DEFINED MSVC80_REDIST_DIR AND EXISTS "${MSVC80_REDIST_DIR}")
142       set(MSVC_REDIST_DIR "${MSVC80_REDIST_DIR}") # use old cache entry
143     endif()
144     find_path(MSVC_REDIST_DIR NAMES ${CMAKE_MSVC_ARCH}/Microsoft.VC80.CRT/Microsoft.VC80.CRT.manifest
145       PATHS
146         "${msvc_install_dir}/../../VC/redist"
147         "${base_dir}/VC/redist"
148       )
149     mark_as_advanced(MSVC_REDIST_DIR)
150     set(MSVC_CRT_DIR "${MSVC_REDIST_DIR}/${CMAKE_MSVC_ARCH}/Microsoft.VC80.CRT")
151
152     # Install the manifest that allows DLLs to be loaded from the
153     # directory containing the executable.
154     if(NOT CMAKE_INSTALL_DEBUG_LIBRARIES_ONLY)
155       set(__install__libs
156         "${MSVC_CRT_DIR}/Microsoft.VC80.CRT.manifest"
157         "${MSVC_CRT_DIR}/msvcm80.dll"
158         "${MSVC_CRT_DIR}/msvcp80.dll"
159         "${MSVC_CRT_DIR}/msvcr80.dll"
160         )
161     else()
162       set(__install__libs)
163     endif()
164
165     if(CMAKE_INSTALL_DEBUG_LIBRARIES)
166       set(MSVC_CRT_DIR
167         "${MSVC_REDIST_DIR}/Debug_NonRedist/${CMAKE_MSVC_ARCH}/Microsoft.VC80.DebugCRT")
168       set(__install__libs ${__install__libs}
169         "${MSVC_CRT_DIR}/Microsoft.VC80.DebugCRT.manifest"
170         "${MSVC_CRT_DIR}/msvcm80d.dll"
171         "${MSVC_CRT_DIR}/msvcp80d.dll"
172         "${MSVC_CRT_DIR}/msvcr80d.dll"
173         )
174     endif()
175   endif()
176
177   if(MSVC_TOOLSET_VERSION EQUAL 90)
178     # Find the runtime library redistribution directory.
179     get_filename_component(msvc_install_dir
180       "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\9.0;InstallDir]" ABSOLUTE)
181     get_filename_component(msvc_express_install_dir
182       "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VCExpress\\9.0;InstallDir]" ABSOLUTE)
183     if(DEFINED MSVC90_REDIST_DIR AND EXISTS "${MSVC90_REDIST_DIR}")
184       set(MSVC_REDIST_DIR "${MSVC90_REDIST_DIR}") # use old cache entry
185     endif()
186     find_path(MSVC_REDIST_DIR NAMES ${CMAKE_MSVC_ARCH}/Microsoft.VC90.CRT/Microsoft.VC90.CRT.manifest
187       PATHS
188         "${msvc_install_dir}/../../VC/redist"
189         "${msvc_express_install_dir}/../../VC/redist"
190         "${base_dir}/VC/redist"
191       )
192     mark_as_advanced(MSVC_REDIST_DIR)
193     set(MSVC_CRT_DIR "${MSVC_REDIST_DIR}/${CMAKE_MSVC_ARCH}/Microsoft.VC90.CRT")
194
195     # Install the manifest that allows DLLs to be loaded from the
196     # directory containing the executable.
197     if(NOT CMAKE_INSTALL_DEBUG_LIBRARIES_ONLY)
198       set(__install__libs
199         "${MSVC_CRT_DIR}/Microsoft.VC90.CRT.manifest"
200         "${MSVC_CRT_DIR}/msvcm90.dll"
201         "${MSVC_CRT_DIR}/msvcp90.dll"
202         "${MSVC_CRT_DIR}/msvcr90.dll"
203         )
204     else()
205       set(__install__libs)
206     endif()
207
208     if(CMAKE_INSTALL_DEBUG_LIBRARIES)
209       set(MSVC_CRT_DIR
210         "${MSVC_REDIST_DIR}/Debug_NonRedist/${CMAKE_MSVC_ARCH}/Microsoft.VC90.DebugCRT")
211       set(__install__libs ${__install__libs}
212         "${MSVC_CRT_DIR}/Microsoft.VC90.DebugCRT.manifest"
213         "${MSVC_CRT_DIR}/msvcm90d.dll"
214         "${MSVC_CRT_DIR}/msvcp90d.dll"
215         "${MSVC_CRT_DIR}/msvcr90d.dll"
216         )
217     endif()
218   endif()
219
220   set(MSVC_REDIST_NAME "")
221   set(_MSVC_DLL_VERSION "")
222   set(_MSVC_IDE_VERSION "")
223   if(MSVC_VERSION GREATER_EQUAL 2000)
224     message(WARNING "MSVC ${MSVC_VERSION} not yet supported.")
225   elseif(MSVC_TOOLSET_VERSION GREATER_EQUAL 144)
226     message(WARNING "MSVC toolset v${MSVC_TOOLSET_VERSION} not yet supported.")
227   elseif(MSVC_TOOLSET_VERSION EQUAL 143)
228     set(MSVC_REDIST_NAME VC142)
229     set(_MSVC_DLL_VERSION 140)
230     set(_MSVC_IDE_VERSION 17)
231   elseif(MSVC_TOOLSET_VERSION EQUAL 142)
232     set(MSVC_REDIST_NAME VC142)
233     set(_MSVC_DLL_VERSION 140)
234     set(_MSVC_IDE_VERSION 16)
235     if(MSVC_VERSION EQUAL 1920)
236       # VS2019 named this differently prior to update 1.
237       set(MSVC_REDIST_NAME VC141)
238     endif()
239   elseif(MSVC_TOOLSET_VERSION EQUAL 141)
240     set(MSVC_REDIST_NAME VC141)
241     set(_MSVC_DLL_VERSION 140)
242     set(_MSVC_IDE_VERSION 15)
243     if(MSVC_VERSION EQUAL 1910)
244       # VS2017 named this differently prior to update 3.
245       set(MSVC_REDIST_NAME VC150)
246     endif()
247   elseif(MSVC_TOOLSET_VERSION)
248     set(MSVC_REDIST_NAME VC${MSVC_TOOLSET_VERSION})
249     math(EXPR _MSVC_DLL_VERSION "${MSVC_TOOLSET_VERSION} / 10 * 10")
250     math(EXPR _MSVC_IDE_VERSION "${MSVC_TOOLSET_VERSION} / 10")
251   endif()
252
253   set(_MSVCRT_DLL_VERSION "")
254   set(_MSVCRT_IDE_VERSION "")
255   if(_MSVC_IDE_VERSION GREATER_EQUAL 10)
256     set(_MSVCRT_DLL_VERSION "${_MSVC_DLL_VERSION}")
257     set(_MSVCRT_IDE_VERSION "${_MSVC_IDE_VERSION}")
258   endif()
259
260   if(_MSVCRT_DLL_VERSION)
261     set(v "${_MSVCRT_DLL_VERSION}")
262     set(vs "${_MSVCRT_IDE_VERSION}")
263
264     # Find the runtime library redistribution directory.
265     if(vs VERSION_LESS 15 AND DEFINED MSVC${vs}_REDIST_DIR AND EXISTS "${MSVC${vs}_REDIST_DIR}")
266       set(MSVC_REDIST_DIR "${MSVC${vs}_REDIST_DIR}") # use old cache entry
267     endif()
268     if(NOT vs VERSION_LESS 15)
269       set(_vs_redist_paths "")
270       # The toolset and its redistributables may come with any VS version 15 or newer.
271       set(_MSVC_IDE_VERSIONS 17 16 15)
272       foreach(_vs_ver ${_MSVC_IDE_VERSIONS})
273         set(_vs_glob_redist_paths "")
274         cmake_host_system_information(RESULT _vs_dir QUERY VS_${_vs_ver}_DIR) # undocumented query
275         if(IS_DIRECTORY "${_vs_dir}")
276           file(GLOB _vs_glob_redist_paths "${_vs_dir}/VC/Redist/MSVC/*")
277           list(REVERSE _vs_glob_redist_paths)
278           list(APPEND _vs_redist_paths ${_vs_glob_redist_paths})
279         endif()
280         unset(_vs_glob_redist_paths)
281       endforeach()
282       unset(_MSVC_IDE_VERSIONS)
283       unset(_vs_dir)
284     else()
285       get_filename_component(_vs_dir
286         "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\${vs}.0;InstallDir]" ABSOLUTE)
287       set(programfilesx86 "ProgramFiles(x86)")
288       set(_vs_redist_paths
289         "${_vs_dir}/../../VC/redist"
290         "${base_dir}/VC/redist"
291         "$ENV{ProgramFiles}/Microsoft Visual Studio ${vs}.0/VC/redist"
292         "$ENV{${programfilesx86}}/Microsoft Visual Studio ${vs}.0/VC/redist"
293         )
294       unset(_vs_dir)
295       unset(programfilesx86)
296     endif()
297     find_path(MSVC_REDIST_DIR NAMES ${CMAKE_MSVC_ARCH}/Microsoft.${MSVC_REDIST_NAME}.CRT PATHS ${_vs_redist_paths})
298     unset(_vs_redist_paths)
299     mark_as_advanced(MSVC_REDIST_DIR)
300     set(MSVC_CRT_DIR "${MSVC_REDIST_DIR}/${CMAKE_MSVC_ARCH}/Microsoft.${MSVC_REDIST_NAME}.CRT")
301
302     if(NOT CMAKE_INSTALL_DEBUG_LIBRARIES_ONLY)
303       set(__install__libs
304         "${MSVC_CRT_DIR}/msvcp${v}.dll"
305         )
306       if(NOT vs VERSION_LESS 14)
307         foreach(crt
308             "${MSVC_CRT_DIR}/msvcp${v}_1.dll"
309             "${MSVC_CRT_DIR}/msvcp${v}_2.dll"
310             "${MSVC_CRT_DIR}/msvcp${v}_atomic_wait.dll"
311             "${MSVC_CRT_DIR}/msvcp${v}_codecvt_ids.dll"
312             "${MSVC_CRT_DIR}/vcruntime${v}_1.dll"
313             )
314           if(EXISTS "${crt}")
315             list(APPEND __install__libs "${crt}")
316           endif()
317         endforeach()
318         list(APPEND __install__libs
319             "${MSVC_CRT_DIR}/vcruntime${v}.dll"
320             "${MSVC_CRT_DIR}/concrt${v}.dll"
321             )
322       else()
323         list(APPEND __install__libs "${MSVC_CRT_DIR}/msvcr${v}.dll")
324       endif()
325     else()
326       set(__install__libs)
327     endif()
328
329     if(CMAKE_INSTALL_DEBUG_LIBRARIES)
330       set(MSVC_CRT_DIR
331         "${MSVC_REDIST_DIR}/Debug_NonRedist/${CMAKE_MSVC_ARCH}/Microsoft.${MSVC_REDIST_NAME}.DebugCRT")
332       set(__install__libs ${__install__libs}
333         "${MSVC_CRT_DIR}/msvcp${v}d.dll"
334         )
335       if(NOT vs VERSION_LESS 14)
336         foreach(crt
337             "${MSVC_CRT_DIR}/msvcp${v}_1d.dll"
338             "${MSVC_CRT_DIR}/msvcp${v}_2d.dll"
339             "${MSVC_CRT_DIR}/msvcp${v}d_atomic_wait.dll"
340             "${MSVC_CRT_DIR}/msvcp${v}d_codecvt_ids.dll"
341             "${MSVC_CRT_DIR}/vcruntime${v}_1d.dll"
342             )
343           if(EXISTS "${crt}")
344             list(APPEND __install__libs "${crt}")
345           endif()
346         endforeach()
347         list(APPEND __install__libs
348             "${MSVC_CRT_DIR}/vcruntime${v}d.dll"
349             "${MSVC_CRT_DIR}/concrt${v}d.dll"
350             )
351       else()
352         list(APPEND __install__libs "${MSVC_CRT_DIR}/msvcr${v}d.dll")
353       endif()
354     endif()
355
356     if(CMAKE_INSTALL_UCRT_LIBRARIES AND NOT vs VERSION_LESS 14)
357       # Find the Windows Kits directory.
358       get_filename_component(windows_kits_dir
359         "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows Kits\\Installed Roots;KitsRoot10]" ABSOLUTE)
360       set(programfilesx86 "ProgramFiles(x86)")
361       if(";${CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION};$ENV{UCRTVersion};$ENV{WindowsSDKVersion};" MATCHES [=[;(10\.[0-9.]+)[;\]]=])
362         set(__ucrt_version "${CMAKE_MATCH_1}/")
363       else()
364         set(__ucrt_version "")
365       endif()
366       find_path(WINDOWS_KITS_DIR
367         NAMES
368           Redist/${__ucrt_version}ucrt/DLLs/${CMAKE_MSVC_ARCH}/ucrtbase.dll
369           Redist/ucrt/DLLs/${CMAKE_MSVC_ARCH}/ucrtbase.dll
370         PATHS
371         $ENV{CMAKE_WINDOWS_KITS_10_DIR}
372         "${windows_kits_dir}"
373         "$ENV{ProgramFiles}/Windows Kits/10"
374         "$ENV{${programfilesx86}}/Windows Kits/10"
375         )
376       mark_as_advanced(WINDOWS_KITS_DIR)
377
378       # Glob the list of UCRT DLLs.
379       if(NOT CMAKE_INSTALL_DEBUG_LIBRARIES_ONLY)
380         if(EXISTS "${WINDOWS_KITS_DIR}/Redist/${__ucrt_version}ucrt/DLLs/${CMAKE_MSVC_ARCH}/ucrtbase.dll")
381           file(GLOB __ucrt_dlls "${WINDOWS_KITS_DIR}/Redist/${__ucrt_version}ucrt/DLLs/${CMAKE_MSVC_ARCH}/*.dll")
382         else()
383           file(GLOB __ucrt_dlls "${WINDOWS_KITS_DIR}/Redist/ucrt/DLLs/${CMAKE_MSVC_ARCH}/*.dll")
384         endif()
385         list(APPEND __install__libs ${__ucrt_dlls})
386       endif()
387       if(CMAKE_INSTALL_DEBUG_LIBRARIES)
388         if(EXISTS "${WINDOWS_KITS_DIR}/bin/${__ucrt_version}${CMAKE_MSVC_ARCH}/ucrt/ucrtbased.dll")
389           file(GLOB __ucrt_dlls "${WINDOWS_KITS_DIR}/bin/${__ucrt_version}${CMAKE_MSVC_ARCH}/ucrt/*.dll")
390         else()
391           file(GLOB __ucrt_dlls "${WINDOWS_KITS_DIR}/bin/${CMAKE_MSVC_ARCH}/ucrt/*.dll")
392         endif()
393         list(APPEND __install__libs ${__ucrt_dlls})
394       endif()
395     endif()
396   endif()
397
398   if(CMAKE_INSTALL_MFC_LIBRARIES)
399     if(MSVC_VERSION EQUAL 1300)
400       set(__install__libs ${__install__libs}
401         "${SYSTEMROOT}/system32/mfc70.dll"
402         )
403     endif()
404
405     if(MSVC_VERSION EQUAL 1310)
406       set(__install__libs ${__install__libs}
407         "${SYSTEMROOT}/system32/mfc71.dll"
408         )
409     endif()
410
411     if(MSVC_VERSION EQUAL 1400)
412       if(CMAKE_INSTALL_DEBUG_LIBRARIES)
413         set(MSVC_MFC_DIR
414           "${MSVC_REDIST_DIR}/Debug_NonRedist/${CMAKE_MSVC_ARCH}/Microsoft.VC80.DebugMFC")
415         set(__install__libs ${__install__libs}
416           "${MSVC_MFC_DIR}/Microsoft.VC80.DebugMFC.manifest"
417           "${MSVC_MFC_DIR}/mfc80d.dll"
418           "${MSVC_MFC_DIR}/mfc80ud.dll"
419           "${MSVC_MFC_DIR}/mfcm80d.dll"
420           "${MSVC_MFC_DIR}/mfcm80ud.dll"
421           )
422       endif()
423
424       set(MSVC_MFC_DIR "${MSVC_REDIST_DIR}/${CMAKE_MSVC_ARCH}/Microsoft.VC80.MFC")
425       # Install the manifest that allows DLLs to be loaded from the
426       # directory containing the executable.
427       if(NOT CMAKE_INSTALL_DEBUG_LIBRARIES_ONLY)
428         set(__install__libs ${__install__libs}
429           "${MSVC_MFC_DIR}/Microsoft.VC80.MFC.manifest"
430           "${MSVC_MFC_DIR}/mfc80.dll"
431           "${MSVC_MFC_DIR}/mfc80u.dll"
432           "${MSVC_MFC_DIR}/mfcm80.dll"
433           "${MSVC_MFC_DIR}/mfcm80u.dll"
434           )
435       endif()
436
437       # include the language dll's for vs8 as well as the actual dll's
438       set(MSVC_MFCLOC_DIR "${MSVC_REDIST_DIR}/${CMAKE_MSVC_ARCH}/Microsoft.VC80.MFCLOC")
439       # Install the manifest that allows DLLs to be loaded from the
440       # directory containing the executable.
441       set(__install__libs ${__install__libs}
442         "${MSVC_MFCLOC_DIR}/Microsoft.VC80.MFCLOC.manifest"
443         "${MSVC_MFCLOC_DIR}/mfc80chs.dll"
444         "${MSVC_MFCLOC_DIR}/mfc80cht.dll"
445         "${MSVC_MFCLOC_DIR}/mfc80enu.dll"
446         "${MSVC_MFCLOC_DIR}/mfc80esp.dll"
447         "${MSVC_MFCLOC_DIR}/mfc80deu.dll"
448         "${MSVC_MFCLOC_DIR}/mfc80fra.dll"
449         "${MSVC_MFCLOC_DIR}/mfc80ita.dll"
450         "${MSVC_MFCLOC_DIR}/mfc80jpn.dll"
451         "${MSVC_MFCLOC_DIR}/mfc80kor.dll"
452         )
453     endif()
454
455     if(MSVC_VERSION EQUAL 1500)
456       if(CMAKE_INSTALL_DEBUG_LIBRARIES)
457         set(MSVC_MFC_DIR
458           "${MSVC_REDIST_DIR}/Debug_NonRedist/${CMAKE_MSVC_ARCH}/Microsoft.VC90.DebugMFC")
459         set(__install__libs ${__install__libs}
460           "${MSVC_MFC_DIR}/Microsoft.VC90.DebugMFC.manifest"
461           "${MSVC_MFC_DIR}/mfc90d.dll"
462           "${MSVC_MFC_DIR}/mfc90ud.dll"
463           "${MSVC_MFC_DIR}/mfcm90d.dll"
464           "${MSVC_MFC_DIR}/mfcm90ud.dll"
465           )
466       endif()
467
468       set(MSVC_MFC_DIR "${MSVC_REDIST_DIR}/${CMAKE_MSVC_ARCH}/Microsoft.VC90.MFC")
469       # Install the manifest that allows DLLs to be loaded from the
470       # directory containing the executable.
471       if(NOT CMAKE_INSTALL_DEBUG_LIBRARIES_ONLY)
472         set(__install__libs ${__install__libs}
473           "${MSVC_MFC_DIR}/Microsoft.VC90.MFC.manifest"
474           "${MSVC_MFC_DIR}/mfc90.dll"
475           "${MSVC_MFC_DIR}/mfc90u.dll"
476           "${MSVC_MFC_DIR}/mfcm90.dll"
477           "${MSVC_MFC_DIR}/mfcm90u.dll"
478           )
479       endif()
480
481       # include the language dll's for vs9 as well as the actual dll's
482       set(MSVC_MFCLOC_DIR "${MSVC_REDIST_DIR}/${CMAKE_MSVC_ARCH}/Microsoft.VC90.MFCLOC")
483       # Install the manifest that allows DLLs to be loaded from the
484       # directory containing the executable.
485       set(__install__libs ${__install__libs}
486         "${MSVC_MFCLOC_DIR}/Microsoft.VC90.MFCLOC.manifest"
487         "${MSVC_MFCLOC_DIR}/mfc90chs.dll"
488         "${MSVC_MFCLOC_DIR}/mfc90cht.dll"
489         "${MSVC_MFCLOC_DIR}/mfc90enu.dll"
490         "${MSVC_MFCLOC_DIR}/mfc90esp.dll"
491         "${MSVC_MFCLOC_DIR}/mfc90deu.dll"
492         "${MSVC_MFCLOC_DIR}/mfc90fra.dll"
493         "${MSVC_MFCLOC_DIR}/mfc90ita.dll"
494         "${MSVC_MFCLOC_DIR}/mfc90jpn.dll"
495         "${MSVC_MFCLOC_DIR}/mfc90kor.dll"
496         )
497     endif()
498
499     set(_MFC_DLL_VERSION "")
500     set(_MFC_IDE_VERSION "")
501     if(_MSVC_IDE_VERSION GREATER_EQUAL 10)
502       set(_MFC_DLL_VERSION ${_MSVC_DLL_VERSION})
503       set(_MFC_IDE_VERSION ${_MSVC_IDE_VERSION})
504     endif()
505
506     if(_MFC_DLL_VERSION)
507       set(v "${_MFC_DLL_VERSION}")
508       set(vs "${_MFC_IDE_VERSION}")
509
510       # Starting with VS 15 the MFC DLLs may be in a different directory.
511       if (NOT vs VERSION_LESS 15)
512         file(GLOB _MSVC_REDIST_DIRS "${MSVC_REDIST_DIR}/../*")
513         find_path(MSVC_REDIST_MFC_DIR NAMES ${CMAKE_MSVC_ARCH}/Microsoft.${MSVC_REDIST_NAME}.MFC
514           PATHS ${_MSVC_REDIST_DIRS} NO_DEFAULT_PATH)
515         mark_as_advanced(MSVC_REDIST_MFC_DIR)
516         unset(_MSVC_REDIST_DIRS)
517       else()
518         set(MSVC_REDIST_MFC_DIR "${MSVC_REDIST_DIR}")
519       endif()
520
521       # Multi-Byte Character Set versions of MFC are available as optional
522       # addon since Visual Studio 12.  So for version 12 or higher, check
523       # whether they are available and exclude them if they are not.
524
525       if(CMAKE_INSTALL_DEBUG_LIBRARIES)
526         set(MSVC_MFC_DIR
527           "${MSVC_REDIST_MFC_DIR}/Debug_NonRedist/${CMAKE_MSVC_ARCH}/Microsoft.${MSVC_REDIST_NAME}.DebugMFC")
528         set(__install__libs ${__install__libs}
529           "${MSVC_MFC_DIR}/mfc${v}ud.dll"
530           "${MSVC_MFC_DIR}/mfcm${v}ud.dll"
531           )
532         if("${v}" LESS 12 OR EXISTS "${MSVC_MFC_DIR}/mfc${v}d.dll")
533           set(__install__libs ${__install__libs}
534             "${MSVC_MFC_DIR}/mfc${v}d.dll"
535           )
536         endif()
537         if("${v}" LESS 12 OR EXISTS "${MSVC_MFC_DIR}/mfcm${v}d.dll")
538           set(__install__libs ${__install__libs}
539             "${MSVC_MFC_DIR}/mfcm${v}d.dll"
540           )
541         endif()
542       endif()
543
544       set(MSVC_MFC_DIR "${MSVC_REDIST_MFC_DIR}/${CMAKE_MSVC_ARCH}/Microsoft.${MSVC_REDIST_NAME}.MFC")
545       if(NOT CMAKE_INSTALL_DEBUG_LIBRARIES_ONLY)
546         set(__install__libs ${__install__libs}
547           "${MSVC_MFC_DIR}/mfc${v}u.dll"
548           "${MSVC_MFC_DIR}/mfcm${v}u.dll"
549           )
550         if("${v}" LESS 12 OR EXISTS "${MSVC_MFC_DIR}/mfc${v}.dll")
551           set(__install__libs ${__install__libs}
552             "${MSVC_MFC_DIR}/mfc${v}.dll"
553           )
554         endif()
555         if("${v}" LESS 12 OR EXISTS "${MSVC_MFC_DIR}/mfcm${v}.dll")
556           set(__install__libs ${__install__libs}
557             "${MSVC_MFC_DIR}/mfcm${v}.dll"
558           )
559         endif()
560       endif()
561
562       # include the language dll's as well as the actual dll's
563       set(MSVC_MFCLOC_DIR "${MSVC_REDIST_MFC_DIR}/${CMAKE_MSVC_ARCH}/Microsoft.${MSVC_REDIST_NAME}.MFCLOC")
564       set(__install__libs ${__install__libs}
565         "${MSVC_MFCLOC_DIR}/mfc${v}chs.dll"
566         "${MSVC_MFCLOC_DIR}/mfc${v}cht.dll"
567         "${MSVC_MFCLOC_DIR}/mfc${v}deu.dll"
568         "${MSVC_MFCLOC_DIR}/mfc${v}enu.dll"
569         "${MSVC_MFCLOC_DIR}/mfc${v}esn.dll"
570         "${MSVC_MFCLOC_DIR}/mfc${v}fra.dll"
571         "${MSVC_MFCLOC_DIR}/mfc${v}ita.dll"
572         "${MSVC_MFCLOC_DIR}/mfc${v}jpn.dll"
573         "${MSVC_MFCLOC_DIR}/mfc${v}kor.dll"
574         "${MSVC_MFCLOC_DIR}/mfc${v}rus.dll"
575         )
576     endif()
577   endif()
578
579   # MSVC 8 was the first version with OpenMP
580   # Furthermore, there is no debug version of this
581   if(CMAKE_INSTALL_OPENMP_LIBRARIES AND _IRSL_HAVE_MSVC)
582     set(_MSOMP_DLL_VERSION ${_MSVC_DLL_VERSION})
583     set(_MSOMP_IDE_VERSION ${_MSVC_IDE_VERSION})
584
585     if(_MSOMP_DLL_VERSION)
586       set(v "${_MSOMP_DLL_VERSION}")
587       set(vs "${_MSOMP_IDE_VERSION}")
588       set(MSVC_OPENMP_DIR "${MSVC_REDIST_DIR}/${CMAKE_MSVC_ARCH}/Microsoft.${MSVC_REDIST_NAME}.OPENMP")
589
590       if(NOT CMAKE_INSTALL_DEBUG_LIBRARIES_ONLY)
591         set(__install__libs ${__install__libs}
592           "${MSVC_OPENMP_DIR}/vcomp${v}.dll")
593       endif()
594     endif()
595   endif()
596
597   foreach(lib
598       ${__install__libs}
599       )
600     if(EXISTS ${lib})
601       set(CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS
602         ${CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS} ${lib})
603     else()
604       if(NOT CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS_NO_WARNINGS)
605         message(WARNING "system runtime library file does not exist: '${lib}'")
606         # This warning indicates an incomplete Visual Studio installation
607         # or a bug somewhere above here in this file.
608         # If you would like to avoid this warning, fix the real problem, or
609         # set CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS_NO_WARNINGS before including
610         # this file.
611       endif()
612     endif()
613   endforeach()
614 endif()
615
616 if(_IRSL_HAVE_Intel)
617   unset(__install_libs)
618   if(CMAKE_INSTALL_OPENMP_LIBRARIES)
619     if(WIN32)
620       list(APPEND __install_libs "${_Intel_redistdir}/libiomp5md.dll" "${_Intel_redistdir}/libiompstubs5md.dll")
621     elseif(APPLE)
622       list(APPEND __install_libs "${_Intel_redistdir}/libiomp5.dylib" "${_Intel_redistdir}/libiompstubs5.dylib")
623     else()
624       list(APPEND __install_libs "${_Intel_redistdir}/libiomp5.so" "${_Intel_redistdir}/libiompstubs5.so")
625       if(_Intel_compiler_ver VERSION_LESS 17)
626         list(APPEND __install_libs "${_Intel_redistdir}/libomp_db.so")
627       endif()
628       if(_Intel_compiler_ver VERSION_LESS 13)
629         list(APPEND __install_libs "${_Intel_redistdir}/libiompprof5.so")
630       endif()
631     endif()
632   endif()
633   if(WIN32)
634     set(__install_dirs "${_Intel_redistdir}/1033")
635     if(EXISTS "${_Intel_redistdir}/1041")
636       list(APPEND __install_dirs "${_Intel_redistdir}/1041")
637     endif()
638     if(_Intel_compiler_ver VERSION_LESS 18)
639       list(APPEND __install_dirs "${_Intel_redistdir}/irml" "${_Intel_redistdir}/irml_c")
640     endif()
641     foreach(__Intel_lib IN ITEMS cilkrts20.dll libchkp.dll libioffload_host.dll libirngmd.dll
642       libmmd.dll libmmdd.dll libmpx.dll liboffload.dll svml_dispmd.dll)
643
644       list(APPEND __install_libs "${_Intel_redistdir}/${__Intel_lib}")
645     endforeach()
646     if(CMAKE_C_COMPILER_ID MATCHES Intel OR CMAKE_CXX_COMPILER_ID MATCHES Intel)
647       list(APPEND __install_libs "${_Intel_redistdir}/libgfxoffload.dll")
648     endif()
649     if(CMAKE_Fortran_COMPILER_ID MATCHES Intel)
650       foreach(__Intel_lib IN ITEMS ifdlg100.dll libicaf.dll libifcoremd.dll libifcoremdd.dll libifcorert.dll libifcorertd.dll libifportmd.dll)
651
652         list(APPEND __install_libs "${_Intel_redistdir}/${__Intel_lib}")
653       endforeach()
654     endif()
655   elseif(APPLE)
656     foreach(__Intel_lib IN ITEMS libchkp.dylib libcilkrts.5.dylib libcilkrts.dylib libimf.dylib libintlc.dylib libirc.dylib libirng.dylib libsvml.dylib)
657       list(APPEND __install_libs "${_Intel_redistdir}/${__Intel_lib}")
658     endforeach()
659     if(CMAKE_C_COMPILER_ID MATCHES Intel OR CMAKE_CXX_COMPILER_ID MATCHES Intel)
660       if(_Intel_compiler_ver VERSION_LESS 17)
661         list(APPEND __install_libs "${_Intel_redistdir}/libistrconv.dylib")
662       endif()
663     endif()
664     if(CMAKE_Fortran_COMPILER_ID MATCHES Intel)
665       foreach(__Intel_lib IN ITEMS libifcore.dylib libifcoremt.dylib libifport.dylib libifportmt.dylib)
666
667         list(APPEND __install_libs "${_Intel_redistdir}/${__Intel_lib}")
668       endforeach()
669     endif()
670   else()
671     foreach(__Intel_lib IN ITEMS libchkp.so libcilkrts.so libcilkrts.so.5 libimf.so libintlc.so libintlc.so.5 libirc.so libpdbx.so libpdbx.so.5 libsvml.so)
672
673       list(APPEND __install_libs "${_Intel_redistdir}/${__Intel_lib}")
674     endforeach()
675     if(_Intel_compiler_ver VERSION_GREATER_EQUAL 13)
676       foreach(__Intel_lib IN ITEMS libirng.so liboffload.so liboffload.so.5)
677
678         list(APPEND __install_libs "${_Intel_redistdir}/${__Intel_lib}")
679       endforeach()
680     endif()
681     if(CMAKE_C_COMPILER_ID MATCHES Intel OR CMAKE_CXX_COMPILER_ID MATCHES Intel)
682       set(__install_dirs "${_Intel_redistdir}/irml")
683       list(APPEND __install_libs "${_Intel_redistdir}/cilk_db.so")
684       if(_Intel_compiler_ver VERSION_GREATER_EQUAL 15)
685         list(APPEND __install_libs "${_Intel_redistdir}/libistrconv.so" "${_Intel_redistdir}/libgfxoffload.so")
686       endif()
687     endif()
688     if(_Intel_compiler_ver VERSION_GREATER_EQUAL 16)
689       foreach(__Intel_lib IN ITEMS libioffload_host.so libioffload_host.so.5 libioffload_target.so libioffload_target.so.5 libmpx.so offload_main)
690
691         list(APPEND __install_libs "${_Intel_redistdir}/${__Intel_lib}")
692       endforeach()
693     endif()
694     if(_Intel_compiler_ver VERSION_LESS 15)
695       foreach(__Intel_lib IN ITEMS libcxaguard.so libcxaguard.so.5)
696
697         list(APPEND __install_libs "${_Intel_redistdir}/${__Intel_lib}")
698       endforeach()
699     endif()
700     if(CMAKE_Fortran_COMPILER_ID MATCHES Intel)
701       foreach(__Intel_lib IN ITEMS libicaf.so libifcore.so libifcore.so.5 libifcoremt.so libifcoremt.so.5 libifport.so libifport.so.5)
702
703         list(APPEND __install_libs "${_Intel_redistdir}/${__Intel_lib}")
704       endforeach()
705     endif()
706   endif()
707
708   foreach(lib IN LISTS __install_libs)
709     if(EXISTS ${lib})
710       list(APPEND CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS ${lib})
711     else()
712       if(NOT CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS_NO_WARNINGS)
713         message(WARNING "system runtime library file does not exist: '${lib}'")
714       endif()
715     endif()
716   endforeach()
717
718   foreach(dir IN LISTS __install_dirs)
719     if(EXISTS ${dir})
720       list(APPEND CMAKE_INSTALL_SYSTEM_RUNTIME_DIRECTORIES ${dir})
721     else()
722       if(NOT CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS_NO_WARNINGS)
723         message(WARNING "system runtime library file does not exist: '${dir}'")
724       endif()
725     endif()
726   endforeach()
727 endif()
728
729 if(WATCOM)
730   get_filename_component( CompilerPath ${CMAKE_C_COMPILER} PATH )
731   if(CMAKE_C_COMPILER_VERSION)
732     set(_compiler_version ${CMAKE_C_COMPILER_VERSION})
733   else()
734     set(_compiler_version ${CMAKE_CXX_COMPILER_VERSION})
735   endif()
736   string(REGEX MATCHALL "[0-9]+" _watcom_version_list "${_compiler_version}")
737   list(GET _watcom_version_list 0 _watcom_major)
738   list(GET _watcom_version_list 1 _watcom_minor)
739   set( __install__libs
740     ${CompilerPath}/clbr${_watcom_major}${_watcom_minor}.dll
741     ${CompilerPath}/mt7r${_watcom_major}${_watcom_minor}.dll
742     ${CompilerPath}/plbr${_watcom_major}${_watcom_minor}.dll )
743   foreach(lib
744       ${__install__libs}
745       )
746     if(EXISTS ${lib})
747       set(CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS
748         ${CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS} ${lib})
749     else()
750       if(NOT CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS_NO_WARNINGS)
751         message(WARNING "system runtime library file does not exist: '${lib}'")
752         # This warning indicates an incomplete Watcom installation
753         # or a bug somewhere above here in this file.
754         # If you would like to avoid this warning, fix the real problem, or
755         # set CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS_NO_WARNINGS before including
756         # this file.
757       endif()
758     endif()
759   endforeach()
760 endif()
761
762
763 # Include system runtime libraries in the installation if any are
764 # specified by CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS.
765 if(CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS)
766   if(NOT CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS_SKIP)
767     if(NOT CMAKE_INSTALL_SYSTEM_RUNTIME_DESTINATION)
768       if(WIN32)
769         set(CMAKE_INSTALL_SYSTEM_RUNTIME_DESTINATION bin)
770       else()
771         set(CMAKE_INSTALL_SYSTEM_RUNTIME_DESTINATION lib)
772       endif()
773     endif()
774     if(CMAKE_INSTALL_SYSTEM_RUNTIME_COMPONENT)
775       set(_CMAKE_INSTALL_SYSTEM_RUNTIME_COMPONENT
776         COMPONENT ${CMAKE_INSTALL_SYSTEM_RUNTIME_COMPONENT})
777     endif()
778     install(PROGRAMS ${CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS}
779       DESTINATION ${CMAKE_INSTALL_SYSTEM_RUNTIME_DESTINATION}
780       ${_CMAKE_INSTALL_SYSTEM_RUNTIME_COMPONENT}
781       )
782
783     install(DIRECTORY ${CMAKE_INSTALL_SYSTEM_RUNTIME_DIRECTORIES}
784       DESTINATION ${CMAKE_INSTALL_SYSTEM_RUNTIME_DESTINATION}
785       ${_CMAKE_INSTALL_SYSTEM_RUNTIME_COMPONENT}
786       )
787   endif()
788 endif()
789
790 cmake_policy(POP)