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