llvm.org GIT mirror llvm / c2165f1
In MSVC builds embed a VERSIONINFO resource in our exe and DLL files. This embeds Windows version information into our executables and DLLs. The most visible place to view this data is in the details tab of the file properties window in Windows explorer. Differential Revision: http://reviews.llvm.org/D7828 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@238740 91177308-0d34-0410-b5e6-96231b3b80d8 Greg Bedwell 4 years ago
2 changed file(s) with 175 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
226226 set_target_properties(${target} PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${moddir})
227227 endif()
228228 endfunction()
229
230 # If on Windows and building with MSVC, add the resource script containing the
231 # VERSIONINFO data to the project. This embeds version resource information
232 # into the output .exe or .dll.
233 # TODO: Enable for MinGW Windows builds too.
234 #
235 function(add_windows_version_resource_file OUT_VAR)
236 set(sources ${ARGN})
237 if (MSVC)
238 set(resource_file ${LLVM_SOURCE_DIR}/resources/windows_version_resource.rc)
239 set(sources ${sources} ${resource_file})
240 source_group("Resource Files" ${resource_file})
241 set(windows_resource_file ${resource_file} PARENT_SCOPE)
242 endif(MSVC)
243
244 set(${OUT_VAR} ${sources} PARENT_SCOPE)
245 endfunction(add_windows_version_resource_file)
246
247 # set_windows_version_resource_properties(name resource_file...
248 # VERSION_MAJOR int
249 # Optional major version number (defaults to LLVM_VERSION_MAJOR)
250 # VERSION_MINOR int
251 # Optional minor version number (defaults to LLVM_VERSION_MINOR)
252 # VERSION_PATCHLEVEL int
253 # Optional patchlevel version number (defaults to LLVM_VERSION_PATCH)
254 # VERSION_STRING
255 # Optional version string (defaults to PACKAGE_VERSION)
256 # PRODUCT_NAME
257 # Optional product name string (defaults to "LLVM")
258 # )
259 function(set_windows_version_resource_properties name resource_file)
260 cmake_parse_arguments(ARG
261 ""
262 "VERSION_MAJOR;VERSION_MINOR;VERSION_PATCHLEVEL;VERSION_STRING;PRODUCT_NAME"
263 ""
264 ${ARGN})
265
266 if (NOT DEFINED ARG_VERSION_MAJOR)
267 set(ARG_VERSION_MAJOR ${LLVM_VERSION_MAJOR})
268 endif()
269
270 if (NOT DEFINED ARG_VERSION_MINOR)
271 set(ARG_VERSION_MINOR ${LLVM_VERSION_MINOR})
272 endif()
273
274 if (NOT DEFINED ARG_VERSION_PATCHLEVEL)
275 set(ARG_VERSION_PATCHLEVEL ${LLVM_VERSION_PATCH})
276 endif()
277
278 if (NOT DEFINED ARG_VERSION_STRING)
279 set(ARG_VERSION_STRING ${PACKAGE_VERSION})
280 endif()
281
282 if (NOT DEFINED ARG_PRODUCT_NAME)
283 set(ARG_PRODUCT_NAME "LLVM")
284 endif()
285
286 get_target_property(target_location ${name} LOCATION)
287 get_filename_component(target_filename ${target_location} NAME)
288
289 set_property(SOURCE ${resource_file}
290 PROPERTY COMPILE_DEFINITIONS
291 "RC_VERSION_FIELD_1=${ARG_VERSION_MAJOR}"
292 "RC_VERSION_FIELD_2=${ARG_VERSION_MINOR}"
293 "RC_VERSION_FIELD_3=${ARG_VERSION_PATCHLEVEL}"
294 "RC_VERSION_FIELD_4=0"
295 "RC_FILE_VERSION=\"${ARG_VERSION_STRING}\""
296 "RC_INTERNAL_NAME=\"${name}\""
297 "RC_ORIGINAL_FILENAME=\"${target_filename}\""
298 "RC_PRODUCT_NAME=\"${ARG_PRODUCT_NAME}\""
299 "RC_PRODUCT_VERSION=\"${ARG_VERSION_STRING}\"")
300 endfunction(set_windows_version_resource_properties)
229301
230302 # llvm_add_library(name sources...
231303 # SHARED;STATIC
315387 if(ARG_MODULE)
316388 add_library(${name} MODULE ${ALL_FILES})
317389 elseif(ARG_SHARED)
390 add_windows_version_resource_file(ALL_FILES ${ALL_FILES})
318391 add_library(${name} SHARED ${ALL_FILES})
319392 else()
320393 add_library(${name} STATIC ${ALL_FILES})
321394 endif()
395
396 if(DEFINED windows_resource_file)
397 set_windows_version_resource_properties(${name} ${windows_resource_file})
398 set(windows_resource_file ${windows_resource_file} PARENT_SCOPE)
399 endif()
400
322401 set_output_directory(${name} ${LLVM_RUNTIME_OUTPUT_INTDIR} ${LLVM_LIBRARY_OUTPUT_INTDIR})
323402 llvm_update_compile_flags(${name})
324403 add_link_opts( ${name} )
481560
482561 macro(add_llvm_executable name)
483562 llvm_process_sources( ALL_FILES ${ARGN} )
563 add_windows_version_resource_file(ALL_FILES ${ALL_FILES})
564
484565 if( EXCLUDE_FROM_ALL )
485566 add_executable(${name} EXCLUDE_FROM_ALL ${ALL_FILES})
486567 else()
487568 add_executable(${name} ${ALL_FILES})
488569 endif()
570
571 if(DEFINED windows_resource_file)
572 set_windows_version_resource_properties(${name} ${windows_resource_file})
573 endif()
574
489575 llvm_update_compile_flags(${name})
490576 add_link_opts( ${name} )
491577
0 // Microsoft Visual C++ resource script for embedding version information.
1 // The format is described at:
2 // http://msdn.microsoft.com/en-gb/library/windows/desktop/aa380599(v=vs.85).aspx
3 // The VERSIONINFO resource is described at:
4 // https://msdn.microsoft.com/en-gb/library/windows/desktop/aa381058(v=vs.85).aspx
5
6
7 // Default values for required fields.
8
9 #ifndef RC_VERSION_FIELD_1
10 #define RC_VERSION_FIELD_1 0
11 #endif
12
13 #ifndef RC_VERSION_FIELD_2
14 #define RC_VERSION_FIELD_2 0
15 #endif
16
17 #ifndef RC_VERSION_FIELD_3
18 #define RC_VERSION_FIELD_3 0
19 #endif
20
21 #ifndef RC_VERSION_FIELD_4
22 #define RC_VERSION_FIELD_4 0
23 #endif
24
25 #ifndef RC_COMPANY_NAME
26 #define RC_COMPANY_NAME ""
27 #endif
28
29 #ifndef RC_FILE_DESCRIPTION
30 #define RC_FILE_DESCRIPTION ""
31 #endif
32
33 #ifndef RC_FILE_VERSION
34 #define RC_FILE_VERSION ""
35 #endif
36
37 #ifndef RC_INTERNAL_NAME
38 #define RC_INTERNAL_NAME ""
39 #endif
40
41 #ifndef RC_ORIGINAL_FILENAME
42 #define RC_ORIGINAL_FILENAME ""
43 #endif
44
45 #ifndef RC_PRODUCT_NAME
46 #define RC_PRODUCT_NAME ""
47 #endif
48
49 #ifndef RC_PRODUCT_VERSION
50 #define RC_PRODUCT_VERSION ""
51 #endif
52
53
54 1 VERSIONINFO
55 FILEVERSION RC_VERSION_FIELD_1,RC_VERSION_FIELD_2,RC_VERSION_FIELD_3,RC_VERSION_FIELD_4
56 BEGIN
57 BLOCK "StringFileInfo"
58 BEGIN
59 BLOCK "040904B0"
60 BEGIN
61 // Required strings
62 VALUE "CompanyName", RC_COMPANY_NAME
63 VALUE "FileDescription", RC_FILE_DESCRIPTION
64 VALUE "FileVersion", RC_FILE_VERSION
65 VALUE "InternalName", RC_INTERNAL_NAME
66 VALUE "OriginalFilename", RC_ORIGINAL_FILENAME
67 VALUE "ProductName", RC_PRODUCT_NAME
68 VALUE "ProductVersion", RC_PRODUCT_VERSION
69
70 // Optional strings
71 #ifdef RC_COMMENTS
72 VALUE "Comments", RC_COMMENTS
73 #endif
74
75 #ifdef RC_COPYRIGHT
76 VALUE "LegalCopyright", RC_COPYRIGHT
77 #endif
78 END
79 END
80
81 BLOCK "VarFileInfo"
82 BEGIN
83 // The translation must correspond to the above BLOCK inside StringFileInfo
84 // langID 0x0409 U.S. English
85 // charsetID 0x04B0 Unicode
86 VALUE "Translation", 0x0409, 0x04B0
87 END
88 END