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