Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I generate Windows DLL versioning information with CMake?

Tags:

windows

dll

cmake

This is very similar to:

  • How to Generate Windows DLL versioning information with CMake

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

Using the following CMakeLists.txt file:

  • https://github.com/malaterre/GDCM/blob/master/Source/Common/CMakeLists.txt

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:

  • https://github.com/malaterre/PublicRep/tree/master/CMake/test3

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"
//
like image 768
malat Avatar asked Sep 02 '25 09:09

malat


1 Answers

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:

  • https://learn.microsoft.com/fr-fr/windows/win32/menurc/versioninfo-resource

With inspiration from:

  • https://github.com/Kitware/CMake/blob/master/Source/CMakeVersion.rc.in
like image 135
malat Avatar answered Sep 04 '25 05:09

malat