Skip to content

Commit 1b0a49a

Browse files
authored
CDRIVER-3091 add VERSIONINFO to dlls (#1451)
1 parent 99ba0b4 commit 1b0a49a

File tree

4 files changed

+86
-2
lines changed

4 files changed

+86
-2
lines changed

src/libbson/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ if(ENABLE_STATIC)
228228
endif()
229229

230230
if(ENABLE_SHARED)
231-
add_library(bson_shared SHARED)
231+
add_library(bson_shared SHARED $<$<PLATFORM_ID:Windows>:libbson.rc>)
232232
target_link_libraries(bson_shared PRIVATE $<BUILD_INTERFACE:bson_obj_pic>)
233233
list(APPEND bson_libs bson_shared)
234234
endif()

src/libbson/libbson.rc

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
// Defines Version Information to include in DLL on Windows.
2+
// Refer: https://learn.microsoft.com/en-us/windows/win32/menurc/versioninfo-resource
3+
#include <winver.h> // Defines VS_VERSION_INFO
4+
#define BSON_COMPILATION // Tell bson-version.h it is part of compilation.
5+
#include <bson/bson-version.h> // Defines BSON_MAJOR_VERSION and other version macros.
6+
#undef BSON_COMPILATION
7+
8+
VS_VERSION_INFO VERSIONINFO
9+
FILEVERSION BSON_MAJOR_VERSION,BSON_MINOR_VERSION,BSON_MICRO_VERSION,0
10+
PRODUCTVERSION BSON_MAJOR_VERSION,BSON_MINOR_VERSION,BSON_MICRO_VERSION,0
11+
FILEFLAGSMASK VS_FFI_FILEFLAGSMASK
12+
#ifdef _DEBUG
13+
FILEFLAGS VS_FF_DEBUG
14+
#else
15+
FILEFLAGS 0L
16+
#endif
17+
// Set FILEOS to VOS_UNKNOWN. There is no documented value for 64-bit builds.
18+
FILEOS VOS_UNKNOWN
19+
FILETYPE VFT_DLL
20+
// Set FILESUBTYPE to VFT2_UNKNOWN. There is no applicable value.
21+
FILESUBTYPE VFT2_UNKNOWN
22+
BEGIN
23+
BLOCK "StringFileInfo"
24+
BEGIN
25+
// Use langID `0409` for "US English". Use charsetID `04b0` for "Unicode"
26+
BLOCK "040904b0"
27+
BEGIN
28+
VALUE "CompanyName", "MongoDB, Inc"
29+
VALUE "FileDescription", "A BSON Library for C"
30+
VALUE "FileVersion", BSON_VERSION_S
31+
VALUE "InternalName", "bson-1.0"
32+
VALUE "OriginalFilename", "bson-1.0.dll"
33+
VALUE "ProductName", "MongoDB C Driver"
34+
VALUE "ProductVersion", BSON_VERSION_S
35+
VALUE "LegalCopyright", "Copyright (C) 2023-present MongoDB, Inc."
36+
END
37+
END
38+
BLOCK "VarFileInfo"
39+
BEGIN
40+
// Use langID `0x0409` for "U.S. English". Use charsetID `1200` for "Unicode".
41+
VALUE "Translation", 0x409, 1200
42+
END
43+
END

src/libmongoc/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -812,7 +812,7 @@ if (MONGOC_ENABLE_STATIC_BUILD)
812812
set_target_properties (mcd_rpc PROPERTIES OUTPUT_NAME "mcd-rpc")
813813
endif ()
814814

815-
add_library (mongoc_shared SHARED ${SOURCES} ${HEADERS} ${HEADERS_FORWARDING})
815+
add_library (mongoc_shared SHARED ${SOURCES} ${HEADERS} ${HEADERS_FORWARDING} $<$<PLATFORM_ID:Windows>:libmongoc.rc>)
816816
set_target_properties (mongoc_shared PROPERTIES CMAKE_CXX_VISIBILITY_PRESET hidden)
817817
target_link_libraries (mongoc_shared PRIVATE ${LIBRARIES} PUBLIC ${BSON_LIBRARIES} mongo::detail::c_dependencies)
818818
target_include_directories (mongoc_shared PRIVATE ${ZLIB_INCLUDE_DIRS})

src/libmongoc/libmongoc.rc

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
// Defines Version Information to include in DLL on Windows.
2+
// Refer: https://learn.microsoft.com/en-us/windows/win32/menurc/versioninfo-resource
3+
#include <winver.h> // Defines VS_VERSION_INFO
4+
#include <mongoc/mongoc-version.h> // Defines MONGOC_MAJOR_VERSION and other version macros.
5+
6+
VS_VERSION_INFO VERSIONINFO
7+
FILEVERSION MONGOC_MAJOR_VERSION,MONGOC_MINOR_VERSION,MONGOC_MICRO_VERSION,0
8+
PRODUCTVERSION MONGOC_MAJOR_VERSION,MONGOC_MINOR_VERSION,MONGOC_MICRO_VERSION,0
9+
FILEFLAGSMASK VS_FFI_FILEFLAGSMASK
10+
#ifdef _DEBUG
11+
FILEFLAGS VS_FF_DEBUG
12+
#else
13+
FILEFLAGS 0L
14+
#endif
15+
// Set FILEOS to VOS_UNKNOWN. There is no documented value for 64-bit builds.
16+
FILEOS VOS_UNKNOWN
17+
FILETYPE VFT_DLL
18+
// Set FILESUBTYPE to VFT2_UNKNOWN. There is no applicable value.
19+
FILESUBTYPE VFT2_UNKNOWN
20+
BEGIN
21+
BLOCK "StringFileInfo"
22+
BEGIN
23+
// Use langID `0409` for "US English". Use charsetID `04b0` for "Unicode"
24+
BLOCK "040904b0"
25+
BEGIN
26+
VALUE "CompanyName", "MongoDB, Inc"
27+
VALUE "FileDescription", "MongoDB Client Library for C"
28+
VALUE "FileVersion", MONGOC_VERSION_S
29+
VALUE "InternalName", "mongoc-1.0"
30+
VALUE "OriginalFilename", "mongoc-1.0.dll"
31+
VALUE "ProductName", "MongoDB C Driver"
32+
VALUE "ProductVersion", MONGOC_VERSION_S
33+
VALUE "LegalCopyright", "Copyright (C) 2023-present MongoDB, Inc."
34+
END
35+
END
36+
BLOCK "VarFileInfo"
37+
BEGIN
38+
// Use langID `0x0409` for "U.S. English". Use charsetID `1200` for "Unicode".
39+
VALUE "Translation", 0x409, 1200
40+
END
41+
END

0 commit comments

Comments
 (0)