Imported Upstream version 2.8.10.2
[platform/upstream/cmake.git] / Modules / InstallRequiredSystemLibraries.cmake
1 # By including this file, all library files listed in the variable
2 # CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS will be installed with
3 # install(PROGRAMS ...) into bin for WIN32 and lib
4 # for non-WIN32. If CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS_SKIP is set to TRUE
5 # before including this file, then the INSTALL command is not called.
6 # The user can use the variable CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS to use a
7 # custom install command and install them however they want.
8 # If it is the MSVC compiler, then the microsoft run
9 # time libraries will be found and automatically added to the
10 # CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS, and installed.
11 # If CMAKE_INSTALL_DEBUG_LIBRARIES is set and it is the MSVC
12 # compiler, then the debug libraries are installed when available.
13 # If CMAKE_INSTALL_DEBUG_LIBRARIES_ONLY is set then only the debug
14 # libraries are installed when both debug and release are available.
15 # If CMAKE_INSTALL_MFC_LIBRARIES is set then the MFC run time
16 # libraries are installed as well as the CRT run time libraries.
17 # If CMAKE_INSTALL_SYSTEM_RUNTIME_DESTINATION is set then the libraries are
18 # installed to that directory rather than the default.
19 # If CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS_NO_WARNINGS is NOT set, then this file
20 # warns about required files that do not exist. You can set this variable to
21 # ON before including this file to avoid the warning. For example, the Visual
22 # Studio Express editions do not include the redistributable files, so if you
23 # include this file on a machine with only VS Express installed, you'll get
24 # the warning.
25
26 #=============================================================================
27 # Copyright 2006-2009 Kitware, Inc.
28 #
29 # Distributed under the OSI-approved BSD License (the "License");
30 # see accompanying file Copyright.txt for details.
31 #
32 # This software is distributed WITHOUT ANY WARRANTY; without even the
33 # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
34 # See the License for more information.
35 #=============================================================================
36 # (To distribute this file outside of CMake, substitute the full
37 #  License text for the above reference.)
38
39 if(MSVC)
40   file(TO_CMAKE_PATH "$ENV{SYSTEMROOT}" SYSTEMROOT)
41
42   if(CMAKE_CL_64)
43     if(MSVC_VERSION GREATER 1599)
44       # VS 10 and later:
45       set(CMAKE_MSVC_ARCH x64)
46     else()
47       # VS 9 and earlier:
48       set(CMAKE_MSVC_ARCH amd64)
49     endif()
50   else()
51     set(CMAKE_MSVC_ARCH x86)
52   endif()
53
54   get_filename_component(devenv_dir "${CMAKE_MAKE_PROGRAM}" PATH)
55   get_filename_component(base_dir "${devenv_dir}/../.." ABSOLUTE)
56
57   if(MSVC70)
58     set(__install__libs
59       "${SYSTEMROOT}/system32/msvcp70.dll"
60       "${SYSTEMROOT}/system32/msvcr70.dll"
61       )
62   endif()
63
64   if(MSVC71)
65     set(__install__libs
66       "${SYSTEMROOT}/system32/msvcp71.dll"
67       "${SYSTEMROOT}/system32/msvcr71.dll"
68       )
69   endif()
70
71   if(MSVC80)
72     # Find the runtime library redistribution directory.
73     get_filename_component(msvc_install_dir
74       "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\8.0;InstallDir]" ABSOLUTE)
75     find_path(MSVC80_REDIST_DIR NAMES ${CMAKE_MSVC_ARCH}/Microsoft.VC80.CRT/Microsoft.VC80.CRT.manifest
76       PATHS
77         "${msvc_install_dir}/../../VC/redist"
78         "${base_dir}/VC/redist"
79       )
80     mark_as_advanced(MSVC80_REDIST_DIR)
81     set(MSVC80_CRT_DIR "${MSVC80_REDIST_DIR}/${CMAKE_MSVC_ARCH}/Microsoft.VC80.CRT")
82
83     # Install the manifest that allows DLLs to be loaded from the
84     # directory containing the executable.
85     if(NOT CMAKE_INSTALL_DEBUG_LIBRARIES_ONLY)
86       set(__install__libs
87         "${MSVC80_CRT_DIR}/Microsoft.VC80.CRT.manifest"
88         "${MSVC80_CRT_DIR}/msvcm80.dll"
89         "${MSVC80_CRT_DIR}/msvcp80.dll"
90         "${MSVC80_CRT_DIR}/msvcr80.dll"
91         )
92     endif()
93
94     if(CMAKE_INSTALL_DEBUG_LIBRARIES)
95       set(MSVC80_CRT_DIR
96         "${MSVC80_REDIST_DIR}/Debug_NonRedist/${CMAKE_MSVC_ARCH}/Microsoft.VC80.DebugCRT")
97       set(__install__libs ${__install__libs}
98         "${MSVC80_CRT_DIR}/Microsoft.VC80.DebugCRT.manifest"
99         "${MSVC80_CRT_DIR}/msvcm80d.dll"
100         "${MSVC80_CRT_DIR}/msvcp80d.dll"
101         "${MSVC80_CRT_DIR}/msvcr80d.dll"
102         )
103     endif()
104   endif()
105
106   if(MSVC90)
107     # Find the runtime library redistribution directory.
108     get_filename_component(msvc_install_dir
109       "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\9.0;InstallDir]" ABSOLUTE)
110     get_filename_component(msvc_express_install_dir
111       "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VCExpress\\9.0;InstallDir]" ABSOLUTE)
112     find_path(MSVC90_REDIST_DIR NAMES ${CMAKE_MSVC_ARCH}/Microsoft.VC90.CRT/Microsoft.VC90.CRT.manifest
113       PATHS
114         "${msvc_install_dir}/../../VC/redist"
115         "${msvc_express_install_dir}/../../VC/redist"
116         "${base_dir}/VC/redist"
117       )
118     mark_as_advanced(MSVC90_REDIST_DIR)
119     set(MSVC90_CRT_DIR "${MSVC90_REDIST_DIR}/${CMAKE_MSVC_ARCH}/Microsoft.VC90.CRT")
120
121     # Install the manifest that allows DLLs to be loaded from the
122     # directory containing the executable.
123     if(NOT CMAKE_INSTALL_DEBUG_LIBRARIES_ONLY)
124       set(__install__libs
125         "${MSVC90_CRT_DIR}/Microsoft.VC90.CRT.manifest"
126         "${MSVC90_CRT_DIR}/msvcm90.dll"
127         "${MSVC90_CRT_DIR}/msvcp90.dll"
128         "${MSVC90_CRT_DIR}/msvcr90.dll"
129         )
130     endif()
131
132     if(CMAKE_INSTALL_DEBUG_LIBRARIES)
133       set(MSVC90_CRT_DIR
134         "${MSVC90_REDIST_DIR}/Debug_NonRedist/${CMAKE_MSVC_ARCH}/Microsoft.VC90.DebugCRT")
135       set(__install__libs ${__install__libs}
136         "${MSVC90_CRT_DIR}/Microsoft.VC90.DebugCRT.manifest"
137         "${MSVC90_CRT_DIR}/msvcm90d.dll"
138         "${MSVC90_CRT_DIR}/msvcp90d.dll"
139         "${MSVC90_CRT_DIR}/msvcr90d.dll"
140         )
141     endif()
142   endif()
143
144   macro(MSVCRT_FILES_FOR_VERSION version)
145     set(v "${version}")
146
147     # Find the runtime library redistribution directory.
148     get_filename_component(msvc_install_dir
149       "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\${v}.0;InstallDir]" ABSOLUTE)
150     find_path(MSVC${v}_REDIST_DIR NAMES ${CMAKE_MSVC_ARCH}/Microsoft.VC${v}0.CRT
151       PATHS
152         "${msvc_install_dir}/../../VC/redist"
153         "${base_dir}/VC/redist"
154         "$ENV{ProgramFiles}/Microsoft Visual Studio ${v}.0/VC/redist"
155         "$ENV{ProgramFiles(x86)}/Microsoft Visual Studio ${v}.0/VC/redist"
156       )
157     mark_as_advanced(MSVC${v}_REDIST_DIR)
158     set(MSVC${v}_CRT_DIR "${MSVC${v}_REDIST_DIR}/${CMAKE_MSVC_ARCH}/Microsoft.VC${v}0.CRT")
159
160     if(NOT CMAKE_INSTALL_DEBUG_LIBRARIES_ONLY)
161       set(__install__libs
162         "${MSVC${v}_CRT_DIR}/msvcp${v}0.dll"
163         "${MSVC${v}_CRT_DIR}/msvcr${v}0.dll"
164         )
165     endif()
166
167     if(CMAKE_INSTALL_DEBUG_LIBRARIES)
168       set(MSVC${v}_CRT_DIR
169         "${MSVC${v}_REDIST_DIR}/Debug_NonRedist/${CMAKE_MSVC_ARCH}/Microsoft.VC${v}0.DebugCRT")
170       set(__install__libs ${__install__libs}
171         "${MSVC${v}_CRT_DIR}/msvcp${v}0d.dll"
172         "${MSVC${v}_CRT_DIR}/msvcr${v}0d.dll"
173         )
174     endif()
175   endmacro()
176
177   if(MSVC10)
178     MSVCRT_FILES_FOR_VERSION(10)
179   endif()
180
181   if(MSVC11)
182     MSVCRT_FILES_FOR_VERSION(11)
183   endif()
184
185   if(CMAKE_INSTALL_MFC_LIBRARIES)
186     if(MSVC70)
187       set(__install__libs ${__install__libs}
188         "${SYSTEMROOT}/system32/mfc70.dll"
189         )
190     endif()
191
192     if(MSVC71)
193       set(__install__libs ${__install__libs}
194         "${SYSTEMROOT}/system32/mfc71.dll"
195         )
196     endif()
197
198     if(MSVC80)
199       if(CMAKE_INSTALL_DEBUG_LIBRARIES)
200         set(MSVC80_MFC_DIR
201           "${MSVC80_REDIST_DIR}/Debug_NonRedist/${CMAKE_MSVC_ARCH}/Microsoft.VC80.DebugMFC")
202         set(__install__libs ${__install__libs}
203           "${MSVC80_MFC_DIR}/Microsoft.VC80.DebugMFC.manifest"
204           "${MSVC80_MFC_DIR}/mfc80d.dll"
205           "${MSVC80_MFC_DIR}/mfc80ud.dll"
206           "${MSVC80_MFC_DIR}/mfcm80d.dll"
207           "${MSVC80_MFC_DIR}/mfcm80ud.dll"
208           )
209       endif()
210
211       set(MSVC80_MFC_DIR "${MSVC80_REDIST_DIR}/${CMAKE_MSVC_ARCH}/Microsoft.VC80.MFC")
212       # Install the manifest that allows DLLs to be loaded from the
213       # directory containing the executable.
214       if(NOT CMAKE_INSTALL_DEBUG_LIBRARIES_ONLY)
215         set(__install__libs ${__install__libs}
216           "${MSVC80_MFC_DIR}/Microsoft.VC80.MFC.manifest"
217           "${MSVC80_MFC_DIR}/mfc80.dll"
218           "${MSVC80_MFC_DIR}/mfc80u.dll"
219           "${MSVC80_MFC_DIR}/mfcm80.dll"
220           "${MSVC80_MFC_DIR}/mfcm80u.dll"
221           )
222       endif()
223
224       # include the language dll's for vs8 as well as the actuall dll's
225       set(MSVC80_MFCLOC_DIR "${MSVC80_REDIST_DIR}/${CMAKE_MSVC_ARCH}/Microsoft.VC80.MFCLOC")
226       # Install the manifest that allows DLLs to be loaded from the
227       # directory containing the executable.
228       set(__install__libs ${__install__libs}
229         "${MSVC80_MFCLOC_DIR}/Microsoft.VC80.MFCLOC.manifest"
230         "${MSVC80_MFCLOC_DIR}/mfc80chs.dll"
231         "${MSVC80_MFCLOC_DIR}/mfc80cht.dll"
232         "${MSVC80_MFCLOC_DIR}/mfc80enu.dll"
233         "${MSVC80_MFCLOC_DIR}/mfc80esp.dll"
234         "${MSVC80_MFCLOC_DIR}/mfc80deu.dll"
235         "${MSVC80_MFCLOC_DIR}/mfc80fra.dll"
236         "${MSVC80_MFCLOC_DIR}/mfc80ita.dll"
237         "${MSVC80_MFCLOC_DIR}/mfc80jpn.dll"
238         "${MSVC80_MFCLOC_DIR}/mfc80kor.dll"
239         )
240     endif()
241
242     if(MSVC90)
243       if(CMAKE_INSTALL_DEBUG_LIBRARIES)
244         set(MSVC90_MFC_DIR
245           "${MSVC90_REDIST_DIR}/Debug_NonRedist/${CMAKE_MSVC_ARCH}/Microsoft.VC90.DebugMFC")
246         set(__install__libs ${__install__libs}
247           "${MSVC90_MFC_DIR}/Microsoft.VC90.DebugMFC.manifest"
248           "${MSVC90_MFC_DIR}/mfc90d.dll"
249           "${MSVC90_MFC_DIR}/mfc90ud.dll"
250           "${MSVC90_MFC_DIR}/mfcm90d.dll"
251           "${MSVC90_MFC_DIR}/mfcm90ud.dll"
252           )
253       endif()
254
255       set(MSVC90_MFC_DIR "${MSVC90_REDIST_DIR}/${CMAKE_MSVC_ARCH}/Microsoft.VC90.MFC")
256       # Install the manifest that allows DLLs to be loaded from the
257       # directory containing the executable.
258       if(NOT CMAKE_INSTALL_DEBUG_LIBRARIES_ONLY)
259         set(__install__libs ${__install__libs}
260           "${MSVC90_MFC_DIR}/Microsoft.VC90.MFC.manifest"
261           "${MSVC90_MFC_DIR}/mfc90.dll"
262           "${MSVC90_MFC_DIR}/mfc90u.dll"
263           "${MSVC90_MFC_DIR}/mfcm90.dll"
264           "${MSVC90_MFC_DIR}/mfcm90u.dll"
265           )
266       endif()
267
268       # include the language dll's for vs9 as well as the actuall dll's
269       set(MSVC90_MFCLOC_DIR "${MSVC90_REDIST_DIR}/${CMAKE_MSVC_ARCH}/Microsoft.VC90.MFCLOC")
270       # Install the manifest that allows DLLs to be loaded from the
271       # directory containing the executable.
272       set(__install__libs ${__install__libs}
273         "${MSVC90_MFCLOC_DIR}/Microsoft.VC90.MFCLOC.manifest"
274         "${MSVC90_MFCLOC_DIR}/mfc90chs.dll"
275         "${MSVC90_MFCLOC_DIR}/mfc90cht.dll"
276         "${MSVC90_MFCLOC_DIR}/mfc90enu.dll"
277         "${MSVC90_MFCLOC_DIR}/mfc90esp.dll"
278         "${MSVC90_MFCLOC_DIR}/mfc90deu.dll"
279         "${MSVC90_MFCLOC_DIR}/mfc90fra.dll"
280         "${MSVC90_MFCLOC_DIR}/mfc90ita.dll"
281         "${MSVC90_MFCLOC_DIR}/mfc90jpn.dll"
282         "${MSVC90_MFCLOC_DIR}/mfc90kor.dll"
283         )
284     endif()
285
286     macro(MFC_FILES_FOR_VERSION version)
287       set(v "${version}")
288
289       if(CMAKE_INSTALL_DEBUG_LIBRARIES)
290         set(MSVC${v}_MFC_DIR
291           "${MSVC${v}_REDIST_DIR}/Debug_NonRedist/${CMAKE_MSVC_ARCH}/Microsoft.VC${v}0.DebugMFC")
292         set(__install__libs ${__install__libs}
293           "${MSVC${v}_MFC_DIR}/mfc${v}0d.dll"
294           "${MSVC${v}_MFC_DIR}/mfc${v}0ud.dll"
295           "${MSVC${v}_MFC_DIR}/mfcm${v}0d.dll"
296           "${MSVC${v}_MFC_DIR}/mfcm${v}0ud.dll"
297           )
298       endif()
299
300       set(MSVC${v}_MFC_DIR "${MSVC${v}_REDIST_DIR}/${CMAKE_MSVC_ARCH}/Microsoft.VC${v}0.MFC")
301       if(NOT CMAKE_INSTALL_DEBUG_LIBRARIES_ONLY)
302         set(__install__libs ${__install__libs}
303           "${MSVC${v}_MFC_DIR}/mfc${v}0.dll"
304           "${MSVC${v}_MFC_DIR}/mfc${v}0u.dll"
305           "${MSVC${v}_MFC_DIR}/mfcm${v}0.dll"
306           "${MSVC${v}_MFC_DIR}/mfcm${v}0u.dll"
307           )
308       endif()
309
310       # include the language dll's as well as the actuall dll's
311       set(MSVC${v}_MFCLOC_DIR "${MSVC${v}_REDIST_DIR}/${CMAKE_MSVC_ARCH}/Microsoft.VC${v}0.MFCLOC")
312       set(__install__libs ${__install__libs}
313         "${MSVC${v}_MFCLOC_DIR}/mfc${v}0chs.dll"
314         "${MSVC${v}_MFCLOC_DIR}/mfc${v}0cht.dll"
315         "${MSVC${v}_MFCLOC_DIR}/mfc${v}0deu.dll"
316         "${MSVC${v}_MFCLOC_DIR}/mfc${v}0enu.dll"
317         "${MSVC${v}_MFCLOC_DIR}/mfc${v}0esn.dll"
318         "${MSVC${v}_MFCLOC_DIR}/mfc${v}0fra.dll"
319         "${MSVC${v}_MFCLOC_DIR}/mfc${v}0ita.dll"
320         "${MSVC${v}_MFCLOC_DIR}/mfc${v}0jpn.dll"
321         "${MSVC${v}_MFCLOC_DIR}/mfc${v}0kor.dll"
322         "${MSVC${v}_MFCLOC_DIR}/mfc${v}0rus.dll"
323         )
324     endmacro()
325
326     if(MSVC10)
327       MFC_FILES_FOR_VERSION(10)
328     endif()
329
330     if(MSVC11)
331       MFC_FILES_FOR_VERSION(11)
332     endif()
333   endif()
334
335   foreach(lib
336       ${__install__libs}
337       )
338     if(EXISTS ${lib})
339       set(CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS
340         ${CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS} ${lib})
341     else()
342       if(NOT CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS_NO_WARNINGS)
343         message(WARNING "system runtime library file does not exist: '${lib}'")
344         # This warning indicates an incomplete Visual Studio installation
345         # or a bug somewhere above here in this file.
346         # If you would like to avoid this warning, fix the real problem, or
347         # set CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS_NO_WARNINGS before including
348         # this file.
349       endif()
350     endif()
351   endforeach()
352 endif()
353
354 if(WATCOM)
355   get_filename_component( CompilerPath ${CMAKE_C_COMPILER} PATH )
356   if(WATCOM17)
357      set( __install__libs ${CompilerPath}/clbr17.dll
358        ${CompilerPath}/mt7r17.dll ${CompilerPath}/plbr17.dll )
359   endif()
360   if(WATCOM18)
361      set( __install__libs ${CompilerPath}/clbr18.dll
362        ${CompilerPath}/mt7r18.dll ${CompilerPath}/plbr18.dll )
363   endif()
364   if(WATCOM19)
365      set( __install__libs ${CompilerPath}/clbr19.dll
366        ${CompilerPath}/mt7r19.dll ${CompilerPath}/plbr19.dll )
367   endif()
368   foreach(lib
369       ${__install__libs}
370       )
371     if(EXISTS ${lib})
372       set(CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS
373         ${CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS} ${lib})
374     else()
375       if(NOT CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS_NO_WARNINGS)
376         message(WARNING "system runtime library file does not exist: '${lib}'")
377         # This warning indicates an incomplete Watcom installation
378         # or a bug somewhere above here in this file.
379         # If you would like to avoid this warning, fix the real problem, or
380         # set CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS_NO_WARNINGS before including
381         # this file.
382       endif()
383     endif()
384   endforeach()
385 endif()
386
387
388 # Include system runtime libraries in the installation if any are
389 # specified by CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS.
390 if(CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS)
391   if(NOT CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS_SKIP)
392     if(NOT CMAKE_INSTALL_SYSTEM_RUNTIME_DESTINATION)
393       if(WIN32)
394         set(CMAKE_INSTALL_SYSTEM_RUNTIME_DESTINATION bin)
395       else()
396         set(CMAKE_INSTALL_SYSTEM_RUNTIME_DESTINATION lib)
397       endif()
398     endif()
399     install(PROGRAMS ${CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS}
400       DESTINATION ${CMAKE_INSTALL_SYSTEM_RUNTIME_DESTINATION})
401   endif()
402 endif()