malat
malat

Reputation: 12490

How do I generate Windows DLL versioning information with CMake?

This is very similar to:

but I thought I might asked again since something may have changed since then.

Using the following CMakeLists.txt file:

I append the following code chunk:

add_library(foo SHARED gdcmVersion.cxx)
set_target_properties(foo PROPERTIES VERSION "1.2.3" SOVERSION "4.5")

I would have assumed this would populate the respective version infos, but it does not on my side:

enter image description here

So my question is: what is actually missing from the above two lines cmake code to get proper version/soversion populated in the details box ?

My setup:

  1. Windows 8.1
  2. Visual Studio 2019 / 16.1.2
  3. CMake 3.14.5

Update: I uploaded a minimal-reproducible-example case here:

Using the same setup here is what I see:

enter image description here

Generated version.rc is:

$ cat version.rc
// version.rc.in
#define VER_FILEVERSION             3,5,49,0
#define VER_FILEVERSION_STR         "3.5.49.0\0"

#define VER_PRODUCTVERSION          3,5,49,0
#define VER_PRODUCTVERSION_STR      "3.5.49\0"
//

Upvotes: 4

Views: 2420

Answers (1)

malat
malat

Reputation: 12490

After multiple trials and errors, I was able to properly get what I wanted:

enter image description here

So it turns out that the important section is:

1 VERSIONINFO
FILEVERSION VER_FILEVERSION
PRODUCTVERSION VER_PRODUCTVERSION
BEGIN
  BLOCK "StringFileInfo"
  BEGIN
    BLOCK "040904E4"
    BEGIN
      VALUE "FileVersion", VER_FILEVERSION_STR
      VALUE "ProductVersion", VER_PRODUCTVERSION_STR
    END
  END
  /* For some reason the ProductVersion would not appear unless I add */
  /* the following section: VarFileInfo */
  BLOCK "VarFileInfo"
  BEGIN
    VALUE "Translation", 0x0409, 1252
  END
END

References:

With inspiration from:

Upvotes: 2

Related Questions