caca6977baa0e3645ff797ff4c2579b45118b7f3
[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}_codecvt_ids.dll"
295             "${MSVC_CRT_DIR}/vcruntime${v}_1.dll"
296             )
297           if(EXISTS "${crt}")
298             list(APPEND __install__libs "${crt}")
299           endif()
300         endforeach()
301         list(APPEND __install__libs
302             "${MSVC_CRT_DIR}/vcruntime${v}.dll"
303             "${MSVC_CRT_DIR}/concrt${v}.dll"
304             )
305       else()
306         list(APPEND __install__libs "${MSVC_CRT_DIR}/msvcr${v}.dll")
307       endif()
308     else()
309       set(__install__libs)
310     endif()
311
312     if(CMAKE_INSTALL_DEBUG_LIBRARIES)
313       set(MSVC_CRT_DIR
314         "${MSVC_REDIST_DIR}/Debug_NonRedist/${CMAKE_MSVC_ARCH}/Microsoft.${MSVC_REDIST_NAME}.DebugCRT")
315       set(__install__libs ${__install__libs}
316         "${MSVC_CRT_DIR}/msvcp${v}d.dll"
317         )
318       if(NOT vs VERSION_LESS 14)
319         foreach(crt
320             "${MSVC_CRT_DIR}/msvcp${v}_1d.dll"
321             "${MSVC_CRT_DIR}/msvcp${v}_2d.dll"
322             "${MSVC_CRT_DIR}/msvcp${v}d_codecvt_ids.dll"
323             "${MSVC_CRT_DIR}/vcruntime${v}_1d.dll"
324             )
325           if(EXISTS "${crt}")
326             list(APPEND __install__libs "${crt}")
327           endif()
328         endforeach()
329         list(APPEND __install__libs
330             "${MSVC_CRT_DIR}/vcruntime${v}d.dll"
331             "${MSVC_CRT_DIR}/concrt${v}d.dll"
332             )
333       else()
334         list(APPEND __install__libs "${MSVC_CRT_DIR}/msvcr${v}d.dll")
335       endif()
336     endif()
337
338     if(CMAKE_INSTALL_UCRT_LIBRARIES AND NOT vs VERSION_LESS 14)
339       # Find the Windows Kits directory.
340       get_filename_component(windows_kits_dir
341         "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows Kits\\Installed Roots;KitsRoot10]" ABSOLUTE)
342       set(programfilesx86 "ProgramFiles(x86)")
343       if(";${CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION};$ENV{UCRTVersion};$ENV{WindowsSDKVersion};" MATCHES [=[;(10\.[0-9.]+)[;\]]=])
344         set(__ucrt_version "${CMAKE_MATCH_1}/")
345       else()
346         set(__ucrt_version "")
347       endif()
348       find_path(WINDOWS_KITS_DIR
349         NAMES
350           Redist/${__ucrt_version}ucrt/DLLs/${CMAKE_MSVC_ARCH}/ucrtbase.dll
351           Redist/ucrt/DLLs/${CMAKE_MSVC_ARCH}/ucrtbase.dll
352         PATHS
353         $ENV{CMAKE_WINDOWS_KITS_10_DIR}
354         "${windows_kits_dir}"
355         "$ENV{ProgramFiles}/Windows Kits/10"
356         "$ENV{${programfilesx86}}/Windows Kits/10"
357         )
358       mark_as_advanced(WINDOWS_KITS_DIR)
359
360       # Glob the list of UCRT DLLs.
361       if(NOT CMAKE_INSTALL_DEBUG_LIBRARIES_ONLY)
362         if(EXISTS "${WINDOWS_KITS_DIR}/Redist/${__ucrt_version}ucrt/DLLs/${CMAKE_MSVC_ARCH}/ucrtbase.dll")
363           file(GLOB __ucrt_dlls "${WINDOWS_KITS_DIR}/Redist/${__ucrt_version}ucrt/DLLs/${CMAKE_MSVC_ARCH}/*.dll")
364         else()
365           file(GLOB __ucrt_dlls "${WINDOWS_KITS_DIR}/Redist/ucrt/DLLs/${CMAKE_MSVC_ARCH}/*.dll")
366         endif()
367         list(APPEND __install__libs ${__ucrt_dlls})
368       endif()
369       if(CMAKE_INSTALL_DEBUG_LIBRARIES)
370         if(EXISTS "${WINDOWS_KITS_DIR}/bin/${__ucrt_version}${CMAKE_MSVC_ARCH}/ucrt/ucrtbased.dll")
371           file(GLOB __ucrt_dlls "${WINDOWS_KITS_DIR}/bin/${__ucrt_version}${CMAKE_MSVC_ARCH}/ucrt/*.dll")
372         else()
373           file(GLOB __ucrt_dlls "${WINDOWS_KITS_DIR}/bin/${CMAKE_MSVC_ARCH}/ucrt/*.dll")
374         endif()
375         list(APPEND __install__libs ${__ucrt_dlls})
376       endif()
377     endif()
378   endif()
379
380   if(CMAKE_INSTALL_MFC_LIBRARIES)
381     if(MSVC_VERSION EQUAL 1300)
382       set(__install__libs ${__install__libs}
383         "${SYSTEMROOT}/system32/mfc70.dll"
384         )
385     endif()
386
387     if(MSVC_VERSION EQUAL 1310)
388       set(__install__libs ${__install__libs}
389         "${SYSTEMROOT}/system32/mfc71.dll"
390         )
391     endif()
392
393     if(MSVC_VERSION EQUAL 1400)
394       if(CMAKE_INSTALL_DEBUG_LIBRARIES)
395         set(MSVC_MFC_DIR
396           "${MSVC_REDIST_DIR}/Debug_NonRedist/${CMAKE_MSVC_ARCH}/Microsoft.VC80.DebugMFC")
397         set(__install__libs ${__install__libs}
398           "${MSVC_MFC_DIR}/Microsoft.VC80.DebugMFC.manifest"
399           "${MSVC_MFC_DIR}/mfc80d.dll"
400           "${MSVC_MFC_DIR}/mfc80ud.dll"
401           "${MSVC_MFC_DIR}/mfcm80d.dll"
402           "${MSVC_MFC_DIR}/mfcm80ud.dll"
403           )
404       endif()
405
406       set(MSVC_MFC_DIR "${MSVC_REDIST_DIR}/${CMAKE_MSVC_ARCH}/Microsoft.VC80.MFC")
407       # Install the manifest that allows DLLs to be loaded from the
408       # directory containing the executable.
409       if(NOT CMAKE_INSTALL_DEBUG_LIBRARIES_ONLY)
410         set(__install__libs ${__install__libs}
411           "${MSVC_MFC_DIR}/Microsoft.VC80.MFC.manifest"
412           "${MSVC_MFC_DIR}/mfc80.dll"
413           "${MSVC_MFC_DIR}/mfc80u.dll"
414           "${MSVC_MFC_DIR}/mfcm80.dll"
415           "${MSVC_MFC_DIR}/mfcm80u.dll"
416           )
417       endif()
418
419       # include the language dll's for vs8 as well as the actual dll's
420       set(MSVC_MFCLOC_DIR "${MSVC_REDIST_DIR}/${CMAKE_MSVC_ARCH}/Microsoft.VC80.MFCLOC")
421       # Install the manifest that allows DLLs to be loaded from the
422       # directory containing the executable.
423       set(__install__libs ${__install__libs}
424         "${MSVC_MFCLOC_DIR}/Microsoft.VC80.MFCLOC.manifest"
425         "${MSVC_MFCLOC_DIR}/mfc80chs.dll"
426         "${MSVC_MFCLOC_DIR}/mfc80cht.dll"
427         "${MSVC_MFCLOC_DIR}/mfc80enu.dll"
428         "${MSVC_MFCLOC_DIR}/mfc80esp.dll"
429         "${MSVC_MFCLOC_DIR}/mfc80deu.dll"
430         "${MSVC_MFCLOC_DIR}/mfc80fra.dll"
431         "${MSVC_MFCLOC_DIR}/mfc80ita.dll"
432         "${MSVC_MFCLOC_DIR}/mfc80jpn.dll"
433         "${MSVC_MFCLOC_DIR}/mfc80kor.dll"
434         )
435     endif()
436
437     if(MSVC_VERSION EQUAL 1500)
438       if(CMAKE_INSTALL_DEBUG_LIBRARIES)
439         set(MSVC_MFC_DIR
440           "${MSVC_REDIST_DIR}/Debug_NonRedist/${CMAKE_MSVC_ARCH}/Microsoft.VC90.DebugMFC")
441         set(__install__libs ${__install__libs}
442           "${MSVC_MFC_DIR}/Microsoft.VC90.DebugMFC.manifest"
443           "${MSVC_MFC_DIR}/mfc90d.dll"
444           "${MSVC_MFC_DIR}/mfc90ud.dll"
445           "${MSVC_MFC_DIR}/mfcm90d.dll"
446           "${MSVC_MFC_DIR}/mfcm90ud.dll"
447           )
448       endif()
449
450       set(MSVC_MFC_DIR "${MSVC_REDIST_DIR}/${CMAKE_MSVC_ARCH}/Microsoft.VC90.MFC")
451       # Install the manifest that allows DLLs to be loaded from the
452       # directory containing the executable.
453       if(NOT CMAKE_INSTALL_DEBUG_LIBRARIES_ONLY)
454         set(__install__libs ${__install__libs}
455           "${MSVC_MFC_DIR}/Microsoft.VC90.MFC.manifest"
456           "${MSVC_MFC_DIR}/mfc90.dll"
457           "${MSVC_MFC_DIR}/mfc90u.dll"
458           "${MSVC_MFC_DIR}/mfcm90.dll"
459           "${MSVC_MFC_DIR}/mfcm90u.dll"
460           )
461       endif()
462
463       # include the language dll's for vs9 as well as the actual dll's
464       set(MSVC_MFCLOC_DIR "${MSVC_REDIST_DIR}/${CMAKE_MSVC_ARCH}/Microsoft.VC90.MFCLOC")
465       # Install the manifest that allows DLLs to be loaded from the
466       # directory containing the executable.
467       set(__install__libs ${__install__libs}
468         "${MSVC_MFCLOC_DIR}/Microsoft.VC90.MFCLOC.manifest"
469         "${MSVC_MFCLOC_DIR}/mfc90chs.dll"
470         "${MSVC_MFCLOC_DIR}/mfc90cht.dll"
471         "${MSVC_MFCLOC_DIR}/mfc90enu.dll"
472         "${MSVC_MFCLOC_DIR}/mfc90esp.dll"
473         "${MSVC_MFCLOC_DIR}/mfc90deu.dll"
474         "${MSVC_MFCLOC_DIR}/mfc90fra.dll"
475         "${MSVC_MFCLOC_DIR}/mfc90ita.dll"
476         "${MSVC_MFCLOC_DIR}/mfc90jpn.dll"
477         "${MSVC_MFCLOC_DIR}/mfc90kor.dll"
478         )
479     endif()
480
481     set(_MFC_DLL_VERSION "")
482     set(_MFC_IDE_VERSION "")
483     if(_MSVC_IDE_VERSION GREATER_EQUAL 10)
484       set(_MFC_DLL_VERSION ${_MSVC_DLL_VERSION})
485       set(_MFC_IDE_VERSION ${_MSVC_IDE_VERSION})
486     endif()
487
488     if(_MFC_DLL_VERSION)
489       set(v "${_MFC_DLL_VERSION}")
490       set(vs "${_MFC_IDE_VERSION}")
491
492       # Starting with VS 15 the MFC DLLs may be in a different directory.
493       if (NOT vs VERSION_LESS 15)
494         file(GLOB _MSVC_REDIST_DIRS "${MSVC_REDIST_DIR}/../*")
495         find_path(MSVC_REDIST_MFC_DIR NAMES ${CMAKE_MSVC_ARCH}/Microsoft.${MSVC_REDIST_NAME}.MFC
496           PATHS ${_MSVC_REDIST_DIRS} NO_DEFAULT_PATH)
497         mark_as_advanced(MSVC_REDIST_MFC_DIR)
498         unset(_MSVC_REDIST_DIRS)
499       else()
500         set(MSVC_REDIST_MFC_DIR "${MSVC_REDIST_DIR}")
501       endif()
502
503       # Multi-Byte Character Set versions of MFC are available as optional
504       # addon since Visual Studio 12.  So for version 12 or higher, check
505       # whether they are available and exclude them if they are not.
506
507       if(CMAKE_INSTALL_DEBUG_LIBRARIES)
508         set(MSVC_MFC_DIR
509           "${MSVC_REDIST_MFC_DIR}/Debug_NonRedist/${CMAKE_MSVC_ARCH}/Microsoft.${MSVC_REDIST_NAME}.DebugMFC")
510         set(__install__libs ${__install__libs}
511           "${MSVC_MFC_DIR}/mfc${v}ud.dll"
512           "${MSVC_MFC_DIR}/mfcm${v}ud.dll"
513           )
514         if("${v}" LESS 12 OR EXISTS "${MSVC_MFC_DIR}/mfc${v}d.dll")
515           set(__install__libs ${__install__libs}
516             "${MSVC_MFC_DIR}/mfc${v}d.dll"
517           )
518         endif()
519         if("${v}" LESS 12 OR EXISTS "${MSVC_MFC_DIR}/mfcm${v}d.dll")
520           set(__install__libs ${__install__libs}
521             "${MSVC_MFC_DIR}/mfcm${v}d.dll"
522           )
523         endif()
524       endif()
525
526       set(MSVC_MFC_DIR "${MSVC_REDIST_MFC_DIR}/${CMAKE_MSVC_ARCH}/Microsoft.${MSVC_REDIST_NAME}.MFC")
527       if(NOT CMAKE_INSTALL_DEBUG_LIBRARIES_ONLY)
528         set(__install__libs ${__install__libs}
529           "${MSVC_MFC_DIR}/mfc${v}u.dll"
530           "${MSVC_MFC_DIR}/mfcm${v}u.dll"
531           )
532         if("${v}" LESS 12 OR EXISTS "${MSVC_MFC_DIR}/mfc${v}.dll")
533           set(__install__libs ${__install__libs}
534             "${MSVC_MFC_DIR}/mfc${v}.dll"
535           )
536         endif()
537         if("${v}" LESS 12 OR EXISTS "${MSVC_MFC_DIR}/mfcm${v}.dll")
538           set(__install__libs ${__install__libs}
539             "${MSVC_MFC_DIR}/mfcm${v}.dll"
540           )
541         endif()
542       endif()
543
544       # include the language dll's as well as the actual dll's
545       set(MSVC_MFCLOC_DIR "${MSVC_REDIST_MFC_DIR}/${CMAKE_MSVC_ARCH}/Microsoft.${MSVC_REDIST_NAME}.MFCLOC")
546       set(__install__libs ${__install__libs}
547         "${MSVC_MFCLOC_DIR}/mfc${v}chs.dll"
548         "${MSVC_MFCLOC_DIR}/mfc${v}cht.dll"
549         "${MSVC_MFCLOC_DIR}/mfc${v}deu.dll"
550         "${MSVC_MFCLOC_DIR}/mfc${v}enu.dll"
551         "${MSVC_MFCLOC_DIR}/mfc${v}esn.dll"
552         "${MSVC_MFCLOC_DIR}/mfc${v}fra.dll"
553         "${MSVC_MFCLOC_DIR}/mfc${v}ita.dll"
554         "${MSVC_MFCLOC_DIR}/mfc${v}jpn.dll"
555         "${MSVC_MFCLOC_DIR}/mfc${v}kor.dll"
556         "${MSVC_MFCLOC_DIR}/mfc${v}rus.dll"
557         )
558     endif()
559   endif()
560
561   # MSVC 8 was the first version with OpenMP
562   # Furthermore, there is no debug version of this
563   if(CMAKE_INSTALL_OPENMP_LIBRARIES AND _IRSL_HAVE_MSVC)
564     set(_MSOMP_DLL_VERSION ${_MSVC_DLL_VERSION})
565     set(_MSOMP_IDE_VERSION ${_MSVC_IDE_VERSION})
566
567     if(_MSOMP_DLL_VERSION)
568       set(v "${_MSOMP_DLL_VERSION}")
569       set(vs "${_MSOMP_IDE_VERSION}")
570       set(MSVC_OPENMP_DIR "${MSVC_REDIST_DIR}/${CMAKE_MSVC_ARCH}/Microsoft.${MSVC_REDIST_NAME}.OPENMP")
571
572       if(NOT CMAKE_INSTALL_DEBUG_LIBRARIES_ONLY)
573         set(__install__libs ${__install__libs}
574           "${MSVC_OPENMP_DIR}/vcomp${v}.dll")
575       endif()
576     endif()
577   endif()
578
579   foreach(lib
580       ${__install__libs}
581       )
582     if(EXISTS ${lib})
583       set(CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS
584         ${CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS} ${lib})
585     else()
586       if(NOT CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS_NO_WARNINGS)
587         message(WARNING "system runtime library file does not exist: '${lib}'")
588         # This warning indicates an incomplete Visual Studio installation
589         # or a bug somewhere above here in this file.
590         # If you would like to avoid this warning, fix the real problem, or
591         # set CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS_NO_WARNINGS before including
592         # this file.
593       endif()
594     endif()
595   endforeach()
596 endif()
597
598 if(_IRSL_HAVE_Intel)
599   unset(__install_libs)
600   if(CMAKE_INSTALL_OPENMP_LIBRARIES)
601     if(WIN32)
602       list(APPEND __install_libs "${_Intel_redistdir}/libiomp5md.dll" "${_Intel_redistdir}/libiompstubs5md.dll")
603     elseif(APPLE)
604       list(APPEND __install_libs "${_Intel_redistdir}/libiomp5.dylib" "${_Intel_redistdir}/libiompstubs5.dylib")
605     else()
606       list(APPEND __install_libs "${_Intel_redistdir}/libiomp5.so" "${_Intel_redistdir}/libiompstubs5.so")
607       if(_Intel_compiler_ver VERSION_LESS 17)
608         list(APPEND __install_libs "${_Intel_redistdir}/libomp_db.so")
609       endif()
610       if(_Intel_compiler_ver VERSION_LESS 13)
611         list(APPEND __install_libs "${_Intel_redistdir}/libiompprof5.so")
612       endif()
613     endif()
614   endif()
615   if(WIN32)
616     set(__install_dirs "${_Intel_redistdir}/1033")
617     if(EXISTS "${_Intel_redistdir}/1041")
618       list(APPEND __install_dirs "${_Intel_redistdir}/1041")
619     endif()
620     if(_Intel_compiler_ver VERSION_LESS 18)
621       list(APPEND __install_dirs "${_Intel_redistdir}/irml" "${_Intel_redistdir}/irml_c")
622     endif()
623     foreach(__Intel_lib IN ITEMS cilkrts20.dll libchkp.dll libioffload_host.dll libirngmd.dll
624       libmmd.dll libmmdd.dll libmpx.dll liboffload.dll svml_dispmd.dll)
625
626       list(APPEND __install_libs "${_Intel_redistdir}/${__Intel_lib}")
627     endforeach()
628     if(CMAKE_C_COMPILER_ID STREQUAL Intel OR CMAKE_CXX_COMPILER_ID STREQUAL Intel)
629       list(APPEND __install_libs "${_Intel_redistdir}/libgfxoffload.dll")
630     endif()
631     if(CMAKE_Fortran_COMPILER_ID STREQUAL Intel)
632       foreach(__Intel_lib IN ITEMS ifdlg100.dll libicaf.dll libifcoremd.dll libifcoremdd.dll libifcorert.dll libifcorertd.dll libifportmd.dll)
633
634         list(APPEND __install_libs "${_Intel_redistdir}/${__Intel_lib}")
635       endforeach()
636     endif()
637   elseif(APPLE)
638     foreach(__Intel_lib IN ITEMS libchkp.dylib libcilkrts.5.dylib libcilkrts.dylib libimf.dylib libintlc.dylib libirc.dylib libirng.dylib libsvml.dylib)
639       list(APPEND __install_libs "${_Intel_redistdir}/${__Intel_lib}")
640     endforeach()
641     if(CMAKE_C_COMPILER_ID STREQUAL Intel OR CMAKE_CXX_COMPILER_ID STREQUAL Intel)
642       if(_Intel_compiler_ver VERSION_LESS 17)
643         list(APPEND __install_libs "${_Intel_redistdir}/libistrconv.dylib")
644       endif()
645     endif()
646     if(CMAKE_Fortran_COMPILER_ID STREQUAL Intel)
647       foreach(__Intel_lib IN ITEMS libifcore.dylib libifcoremt.dylib libifport.dylib libifportmt.dylib)
648
649         list(APPEND __install_libs "${_Intel_redistdir}/${__Intel_lib}")
650       endforeach()
651     endif()
652   else()
653     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)
654
655       list(APPEND __install_libs "${_Intel_redistdir}/${__Intel_lib}")
656     endforeach()
657     if(_Intel_compiler_ver VERSION_GREATER_EQUAL 13)
658       foreach(__Intel_lib IN ITEMS libirng.so liboffload.so liboffload.so.5)
659
660         list(APPEND __install_libs "${_Intel_redistdir}/${__Intel_lib}")
661       endforeach()
662     endif()
663     if(CMAKE_C_COMPILER_ID STREQUAL Intel OR CMAKE_CXX_COMPILER_ID STREQUAL Intel)
664       set(__install_dirs "${_Intel_redistdir}/irml")
665       list(APPEND __install_libs "${_Intel_redistdir}/cilk_db.so")
666       if(_Intel_compiler_ver VERSION_GREATER_EQUAL 15)
667         list(APPEND __install_libs "${_Intel_redistdir}/libistrconv.so" "${_Intel_redistdir}/libgfxoffload.so")
668       endif()
669     endif()
670     if(_Intel_compiler_ver VERSION_GREATER_EQUAL 16)
671       foreach(__Intel_lib IN ITEMS libioffload_host.so libioffload_host.so.5 libioffload_target.so libioffload_target.so.5 libmpx.so offload_main)
672
673         list(APPEND __install_libs "${_Intel_redistdir}/${__Intel_lib}")
674       endforeach()
675     endif()
676     if(_Intel_compiler_ver VERSION_LESS 15)
677       foreach(__Intel_lib IN ITEMS libcxaguard.so libcxaguard.so.5)
678
679         list(APPEND __install_libs "${_Intel_redistdir}/${__Intel_lib}")
680       endforeach()
681     endif()
682     if(CMAKE_Fortran_COMPILER_ID STREQUAL Intel)
683       foreach(__Intel_lib IN ITEMS libicaf.so libifcore.so libifcore.so.5 libifcoremt.so libifcoremt.so.5 libifport.so libifport.so.5)
684
685         list(APPEND __install_libs "${_Intel_redistdir}/${__Intel_lib}")
686       endforeach()
687     endif()
688   endif()
689
690   foreach(lib IN LISTS __install_libs)
691     if(EXISTS ${lib})
692       list(APPEND CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS ${lib})
693     else()
694       if(NOT CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS_NO_WARNINGS)
695         message(WARNING "system runtime library file does not exist: '${lib}'")
696       endif()
697     endif()
698   endforeach()
699
700   foreach(dir IN LISTS __install_dirs)
701     if(EXISTS ${dir})
702       list(APPEND CMAKE_INSTALL_SYSTEM_RUNTIME_DIRECTORIES ${dir})
703     else()
704       if(NOT CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS_NO_WARNINGS)
705         message(WARNING "system runtime library file does not exist: '${dir}'")
706       endif()
707     endif()
708   endforeach()
709 endif()
710
711 if(WATCOM)
712   get_filename_component( CompilerPath ${CMAKE_C_COMPILER} PATH )
713   if(CMAKE_C_COMPILER_VERSION)
714     set(_compiler_version ${CMAKE_C_COMPILER_VERSION})
715   else()
716     set(_compiler_version ${CMAKE_CXX_COMPILER_VERSION})
717   endif()
718   string(REGEX MATCHALL "[0-9]+" _watcom_version_list "${_compiler_version}")
719   list(GET _watcom_version_list 0 _watcom_major)
720   list(GET _watcom_version_list 1 _watcom_minor)
721   set( __install__libs
722     ${CompilerPath}/clbr${_watcom_major}${_watcom_minor}.dll
723     ${CompilerPath}/mt7r${_watcom_major}${_watcom_minor}.dll
724     ${CompilerPath}/plbr${_watcom_major}${_watcom_minor}.dll )
725   foreach(lib
726       ${__install__libs}
727       )
728     if(EXISTS ${lib})
729       set(CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS
730         ${CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS} ${lib})
731     else()
732       if(NOT CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS_NO_WARNINGS)
733         message(WARNING "system runtime library file does not exist: '${lib}'")
734         # This warning indicates an incomplete Watcom installation
735         # or a bug somewhere above here in this file.
736         # If you would like to avoid this warning, fix the real problem, or
737         # set CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS_NO_WARNINGS before including
738         # this file.
739       endif()
740     endif()
741   endforeach()
742 endif()
743
744
745 # Include system runtime libraries in the installation if any are
746 # specified by CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS.
747 if(CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS)
748   if(NOT CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS_SKIP)
749     if(NOT CMAKE_INSTALL_SYSTEM_RUNTIME_DESTINATION)
750       if(WIN32)
751         set(CMAKE_INSTALL_SYSTEM_RUNTIME_DESTINATION bin)
752       else()
753         set(CMAKE_INSTALL_SYSTEM_RUNTIME_DESTINATION lib)
754       endif()
755     endif()
756     if(CMAKE_INSTALL_SYSTEM_RUNTIME_COMPONENT)
757       set(_CMAKE_INSTALL_SYSTEM_RUNTIME_COMPONENT
758         COMPONENT ${CMAKE_INSTALL_SYSTEM_RUNTIME_COMPONENT})
759     endif()
760     install(PROGRAMS ${CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS}
761       DESTINATION ${CMAKE_INSTALL_SYSTEM_RUNTIME_DESTINATION}
762       ${_CMAKE_INSTALL_SYSTEM_RUNTIME_COMPONENT}
763       )
764
765     install(DIRECTORY ${CMAKE_INSTALL_SYSTEM_RUNTIME_DIRECTORIES}
766       DESTINATION ${CMAKE_INSTALL_SYSTEM_RUNTIME_DESTINATION}
767       ${_CMAKE_INSTALL_SYSTEM_RUNTIME_COMPONENT}
768       )
769   endif()
770 endif()
771
772 cmake_policy(POP)