llvm.org GIT mirror llvm / cb2dfa6
In MSVC builds embed a VERSIONINFO resource in our exe and DLL files. This reinstates my commits r238740/r238741 which I reverted due to a failure in the clang-cl selfhost tests on Windows. I've now fixed the issue in clang-cl that caused the failure so hopefully all should be well now. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@239612 91177308-0d34-0410-b5e6-96231b3b80d8 Greg Bedwell 4 years ago
2 changed file(s) with 171 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 set_property(SOURCE ${resource_file}
287 PROPERTY COMPILE_DEFINITIONS
288 "RC_VERSION_FIELD_1=${ARG_VERSION_MAJOR}"
289 "RC_VERSION_FIELD_2=${ARG_VERSION_MINOR}"
290 "RC_VERSION_FIELD_3=${ARG_VERSION_PATCHLEVEL}"
291 "RC_VERSION_FIELD_4=0"
292 "RC_FILE_VERSION=\"${ARG_VERSION_STRING}\""
293 "RC_INTERNAL_NAME=\"${name}\""
294 "RC_PRODUCT_NAME=\"${ARG_PRODUCT_NAME}\""
295 "RC_PRODUCT_VERSION=\"${ARG_VERSION_STRING}\"")
296 endfunction(set_windows_version_resource_properties)
229297
230298 # llvm_add_library(name sources...
231299 # SHARED;STATIC
315383 if(ARG_MODULE)
316384 add_library(${name} MODULE ${ALL_FILES})
317385 elseif(ARG_SHARED)
386 add_windows_version_resource_file(ALL_FILES ${ALL_FILES})
318387 add_library(${name} SHARED ${ALL_FILES})
319388 else()
320389 add_library(${name} STATIC ${ALL_FILES})
321390 endif()
391
392 if(DEFINED windows_resource_file)
393 set_windows_version_resource_properties(${name} ${windows_resource_file})
394 set(windows_resource_file ${windows_resource_file} PARENT_SCOPE)
395 endif()
396
322397 set_output_directory(${name} ${LLVM_RUNTIME_OUTPUT_INTDIR} ${LLVM_LIBRARY_OUTPUT_INTDIR})
323398 llvm_update_compile_flags(${name})
324399 add_link_opts( ${name} )
481556
482557 macro(add_llvm_executable name)
483558 llvm_process_sources( ALL_FILES ${ARGN} )
559 add_windows_version_resource_file(ALL_FILES ${ALL_FILES})
560
484561 if( EXCLUDE_FROM_ALL )
485562 add_executable(${name} EXCLUDE_FROM_ALL ${ALL_FILES})
486563 else()
487564 add_executable(${name} ${ALL_FILES})
488565 endif()
566
567 if(DEFINED windows_resource_file)
568 set_windows_version_resource_properties(${name} ${windows_resource_file})
569 endif()
570
489571 llvm_update_compile_flags(${name})
490572 add_link_opts( ${name} )
491573
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