797f9e4b7fbd3b539b962be0418ce4451af208ed
[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             "${MSVC_MFC_DIR}/mfcm${v}d.dll"
485           )
486         endif()
487       endif()
488
489       set(MSVC_MFC_DIR "${MSVC_REDIST_MFC_DIR}/${CMAKE_MSVC_ARCH}/Microsoft.${MSVC_REDIST_NAME}.MFC")
490       if(NOT CMAKE_INSTALL_DEBUG_LIBRARIES_ONLY)
491         set(__install__libs ${__install__libs}
492           "${MSVC_MFC_DIR}/mfc${v}u.dll"
493           "${MSVC_MFC_DIR}/mfcm${v}u.dll"
494           )
495         if("${v}" LESS 12 OR EXISTS "${MSVC_MFC_DIR}/mfc${v}.dll")
496           set(__install__libs ${__install__libs}
497             "${MSVC_MFC_DIR}/mfc${v}.dll"
498             "${MSVC_MFC_DIR}/mfcm${v}.dll"
499           )
500         endif()
501       endif()
502
503       # include the language dll's as well as the actuall dll's
504       set(MSVC_MFCLOC_DIR "${MSVC_REDIST_MFC_DIR}/${CMAKE_MSVC_ARCH}/Microsoft.${MSVC_REDIST_NAME}.MFCLOC")
505       set(__install__libs ${__install__libs}
506         "${MSVC_MFCLOC_DIR}/mfc${v}chs.dll"
507         "${MSVC_MFCLOC_DIR}/mfc${v}cht.dll"
508         "${MSVC_MFCLOC_DIR}/mfc${v}deu.dll"
509         "${MSVC_MFCLOC_DIR}/mfc${v}enu.dll"
510         "${MSVC_MFCLOC_DIR}/mfc${v}esn.dll"
511         "${MSVC_MFCLOC_DIR}/mfc${v}fra.dll"
512         "${MSVC_MFCLOC_DIR}/mfc${v}ita.dll"
513         "${MSVC_MFCLOC_DIR}/mfc${v}jpn.dll"
514         "${MSVC_MFCLOC_DIR}/mfc${v}kor.dll"
515         "${MSVC_MFCLOC_DIR}/mfc${v}rus.dll"
516         )
517     endif()
518   endif()
519
520   # MSVC 8 was the first version with OpenMP
521   # Furthermore, there is no debug version of this
522   if(CMAKE_INSTALL_OPENMP_LIBRARIES AND _IRSL_HAVE_MSVC)
523     set(_MSOMP_DLL_VERSION "")
524     set(_MSOMP_IDE_VERSION "")
525     if(MSVC_VERSION GREATER_EQUAL 2000)
526       # Version not yet supported.
527     elseif(MSVC_VERSION GREATER_EQUAL 1910)
528       set(_MSOMP_DLL_VERSION 140)
529       set(_MSOMP_IDE_VERSION 15)
530     elseif(MSVC_VERSION EQUAL 1900)
531       set(_MSOMP_DLL_VERSION 140)
532       set(_MSOMP_IDE_VERSION 14)
533     elseif(MSVC_VERSION EQUAL 1800)
534       set(_MSOMP_DLL_VERSION 120)
535       set(_MSOMP_IDE_VERSION 12)
536     elseif(MSVC_VERSION EQUAL 1700)
537       set(_MSOMP_DLL_VERSION 110)
538       set(_MSOMP_IDE_VERSION 11)
539     elseif(MSVC_VERSION EQUAL 1600)
540       set(_MSOMP_DLL_VERSION 100)
541       set(_MSOMP_IDE_VERSION 10)
542     elseif(MSVC_VERSION EQUAL 1500)
543       set(_MSOMP_DLL_VERSION 90)
544       set(_MSOMP_IDE_VERSION 9)
545     elseif(MSVC_VERSION EQUAL 1400)
546       set(_MSOMP_DLL_VERSION 80)
547       set(_MSOMP_IDE_VERSION 8)
548     endif()
549
550     if(_MSOMP_DLL_VERSION)
551       set(v "${_MSOMP_DLL_VERSION}")
552       set(vs "${_MSOMP_IDE_VERSION}")
553       set(MSVC_OPENMP_DIR "${MSVC_REDIST_DIR}/${CMAKE_MSVC_ARCH}/Microsoft.${MSVC_REDIST_NAME}.OPENMP")
554
555       if(NOT CMAKE_INSTALL_DEBUG_LIBRARIES_ONLY)
556         set(__install__libs ${__install__libs}
557           "${MSVC_OPENMP_DIR}/vcomp${v}.dll")
558       endif()
559     endif()
560   endif()
561
562   foreach(lib
563       ${__install__libs}
564       )
565     if(EXISTS ${lib})
566       set(CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS
567         ${CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS} ${lib})
568     else()
569       if(NOT CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS_NO_WARNINGS)
570         message(WARNING "system runtime library file does not exist: '${lib}'")
571         # This warning indicates an incomplete Visual Studio installation
572         # or a bug somewhere above here in this file.
573         # If you would like to avoid this warning, fix the real problem, or
574         # set CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS_NO_WARNINGS before including
575         # this file.
576       endif()
577     endif()
578   endforeach()
579 endif()
580
581 if(_IRSL_HAVE_Intel)
582   unset(__install_libs)
583   if(CMAKE_INSTALL_OPENMP_LIBRARIES)
584     if(WIN32)
585       list(APPEND __install_libs "${_Intel_redistdir}/libiomp5md.dll" "${_Intel_redistdir}/libiompstubs5md.dll")
586     elseif(APPLE)
587       list(APPEND __install_libs "${_Intel_redistdir}/libiomp5.dylib" "${_Intel_redistdir}/libiompstubs5.dylib")
588     else()
589       list(APPEND __install_libs "${_Intel_redistdir}/libiomp5.so" "${_Intel_redistdir}/libiompstubs5.so")
590       if(_Intel_compiler_ver VERSION_LESS 17)
591         list(APPEND __install_libs "${_Intel_redistdir}/libomp_db.so")
592       endif()
593       if(_Intel_compiler_ver VERSION_LESS 13)
594         list(APPEND __install_libs "${_Intel_redistdir}/libiompprof5.so")
595       endif()
596     endif()
597   endif()
598   if(WIN32)
599     set(__install_dirs "${_Intel_redistdir}/1033")
600     if(EXISTS "${_Intel_redistdir}/1041")
601       list(APPEND __install_dirs "${_Intel_redistdir}/1041")
602     endif()
603     if(_Intel_compiler_ver VERSION_LESS 18)
604       list(APPEND __install_dirs "${_Intel_redistdir}/irml" "${_Intel_redistdir}/irml_c")
605     endif()
606     foreach(__Intel_lib IN ITEMS cilkrts20.dll libchkp.dll libioffload_host.dll libirngmd.dll
607       libmmd.dll libmmdd.dll libmpx.dll liboffload.dll svml_dispmd.dll)
608
609       list(APPEND __install_libs "${_Intel_redistdir}/${__Intel_lib}")
610     endforeach()
611     if(CMAKE_C_COMPILER_ID STREQUAL Intel OR CMAKE_CXX_COMPILER_ID STREQUAL Intel)
612       list(APPEND __install_libs "${_Intel_redistdir}/libgfxoffload.dll")
613     endif()
614     if(CMAKE_Fortran_COMPILER_ID STREQUAL Intel)
615       foreach(__Intel_lib IN ITEMS ifdlg100.dll libicaf.dll libifcoremd.dll libifcoremdd.dll libifcorert.dll libifcorertd.dll libifportmd.dll)
616
617         list(APPEND __install_libs "${_Intel_redistdir}/${__Intel_lib}")
618       endforeach()
619     endif()
620   elseif(APPLE)
621     foreach(__Intel_lib IN ITEMS libchkp.dylib libcilkrts.5.dylib libcilkrts.dylib libimf.dylib libintlc.dylib libirc.dylib libirng.dylib libsvml.dylib)
622       list(APPEND __install_libs "${_Intel_redistdir}/${__Intel_lib}")
623     endforeach()
624     if(_Intel_compiler_ver VERSION_LESS 17)
625       list(APPEND __install_libs "${_Intel_redistdir}/libistrconv.dylib")
626     endif()
627     if(CMAKE_Fortran_COMPILER_ID STREQUAL Intel)
628       foreach(__Intel_lib IN ITEMS libifcore.dylib libifcoremt.dylib libifport.dylib libifportmt.dylib)
629
630         list(APPEND __install_libs "${_Intel_redistdir}/${__Intel_lib}")
631       endforeach()
632     endif()
633   else()
634     set(__install_dirs "${_Intel_redistdir}/irml")
635     foreach(__Intel_lib IN ITEMS cilk_db.so libchkp.so libcilkrts.so libcilkrts.so.5 libimf.so libintlc.so libintlc.so.5 libirc.so libpdbx.so libpdbx.so.5 libsvml.so)
636
637       list(APPEND __install_libs "${_Intel_redistdir}/${__Intel_lib}")
638     endforeach()
639     if(_Intel_compiler_ver VERSION_GREATER_EQUAL 13)
640       foreach(__Intel_lib IN ITEMS libirng.so liboffload.so liboffload.so.5)
641
642         list(APPEND __install_libs "${_Intel_redistdir}/${__Intel_lib}")
643       endforeach()
644     endif()
645     if(_Intel_compiler_ver VERSION_GREATER_EQUAL 15)
646       list(APPEND __install_libs "${_Intel_redistdir}/libistrconv.so")
647       if(CMAKE_C_COMPILER_ID STREQUAL Intel OR CMAKE_CXX_COMPILER_ID STREQUAL Intel)
648         list(APPEND __install_libs "${_Intel_redistdir}/libgfxoffload.so")
649       endif()
650     endif()
651     if(_Intel_compiler_ver VERSION_GREATER_EQUAL 16)
652       foreach(__Intel_lib IN ITEMS libioffload_host.so libioffload_host.so.5 libioffload_target.so libioffload_target.so.5 libmpx.so offload_main)
653
654         list(APPEND __install_libs "${_Intel_redistdir}/${__Intel_lib}")
655       endforeach()
656     endif()
657     if(_Intel_compiler_ver VERSION_LESS 15)
658       foreach(__Intel_lib IN ITEMS libcxaguard.so libcxaguard.so.5)
659
660         list(APPEND __install_libs "${_Intel_redistdir}/${__Intel_lib}")
661       endforeach()
662     endif()
663     if(CMAKE_Fortran_COMPILER_ID STREQUAL Intel)
664       foreach(__Intel_lib IN ITEMS libicaf.so libifcore.so libifcore.so.5 libifcoremt.so libifcoremt.so.5 libifport.so libifport.so.5)
665
666         list(APPEND __install_libs "${_Intel_redistdir}/${__Intel_lib}")
667       endforeach()
668     endif()
669   endif()
670
671   foreach(lib IN LISTS __install_libs)
672     if(EXISTS ${lib})
673       list(APPEND CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS ${lib})
674     else()
675       if(NOT CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS_NO_WARNINGS)
676         message(WARNING "system runtime library file does not exist: '${lib}'")
677       endif()
678     endif()
679   endforeach()
680
681   foreach(dir IN LISTS __install_dirs)
682     if(EXISTS ${dir})
683       list(APPEND CMAKE_INSTALL_SYSTEM_RUNTIME_DIRECTORIES ${dir})
684     else()
685       if(NOT CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS_NO_WARNINGS)
686         message(WARNING "system runtime library file does not exist: '${dir}'")
687       endif()
688     endif()
689   endforeach()
690 endif()
691
692 if(WATCOM)
693   get_filename_component( CompilerPath ${CMAKE_C_COMPILER} PATH )
694   if(CMAKE_C_COMPILER_VERSION)
695     set(_compiler_version ${CMAKE_C_COMPILER_VERSION})
696   else()
697     set(_compiler_version ${CMAKE_CXX_COMPILER_VERSION})
698   endif()
699   string(REGEX MATCHALL "[0-9]+" _watcom_version_list "${_compiler_version}")
700   list(GET _watcom_version_list 0 _watcom_major)
701   list(GET _watcom_version_list 1 _watcom_minor)
702   set( __install__libs
703     ${CompilerPath}/clbr${_watcom_major}${_watcom_minor}.dll
704     ${CompilerPath}/mt7r${_watcom_major}${_watcom_minor}.dll
705     ${CompilerPath}/plbr${_watcom_major}${_watcom_minor}.dll )
706   foreach(lib
707       ${__install__libs}
708       )
709     if(EXISTS ${lib})
710       set(CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS
711         ${CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS} ${lib})
712     else()
713       if(NOT CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS_NO_WARNINGS)
714         message(WARNING "system runtime library file does not exist: '${lib}'")
715         # This warning indicates an incomplete Watcom installation
716         # or a bug somewhere above here in this file.
717         # If you would like to avoid this warning, fix the real problem, or
718         # set CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS_NO_WARNINGS before including
719         # this file.
720       endif()
721     endif()
722   endforeach()
723 endif()
724
725
726 # Include system runtime libraries in the installation if any are
727 # specified by CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS.
728 if(CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS)
729   if(NOT CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS_SKIP)
730     if(NOT CMAKE_INSTALL_SYSTEM_RUNTIME_DESTINATION)
731       if(WIN32)
732         set(CMAKE_INSTALL_SYSTEM_RUNTIME_DESTINATION bin)
733       else()
734         set(CMAKE_INSTALL_SYSTEM_RUNTIME_DESTINATION lib)
735       endif()
736     endif()
737     if(CMAKE_INSTALL_SYSTEM_RUNTIME_COMPONENT)
738       set(_CMAKE_INSTALL_SYSTEM_RUNTIME_COMPONENT
739         COMPONENT ${CMAKE_INSTALL_SYSTEM_RUNTIME_COMPONENT})
740     endif()
741     install(PROGRAMS ${CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS}
742       DESTINATION ${CMAKE_INSTALL_SYSTEM_RUNTIME_DESTINATION}
743       ${_CMAKE_INSTALL_SYSTEM_RUNTIME_COMPONENT}
744       )
745
746     install(DIRECTORY ${CMAKE_INSTALL_SYSTEM_RUNTIME_DIRECTORIES}
747       DESTINATION ${CMAKE_INSTALL_SYSTEM_RUNTIME_DESTINATION}
748       ${_CMAKE_INSTALL_SYSTEM_RUNTIME_COMPONENT}
749       )
750   endif()
751 endif()
752
753 cmake_policy(POP)