[CMake] How to set Windows DLL version information

Hendrik Sattler post at hendrik-sattler.de
Thu Jan 29 04:09:34 EST 2009


Anders Backman schrieb:
> so set_target_properties(target PROPERTIES VERSION 1.1 SOVERSION 1.1)
> 
> doesnt work under windows then?

No. A RC file is not created automatically. A bit complicated as other
information is included in that file, too. However, you can use
configure_file to automatically fill in the information. An example from
openobex:
---------------------------------------------------
#include <winresrc.h>

VS_VERSION_INFO VERSIONINFO
  FILEVERSION
@openobex_VERSION_MAJOR@, at openobex_VERSION_MINOR@, at openobex_VERSION_PATCH@,0
  PRODUCTVERSION @VERSION_MAJOR@, at VERSION_MINOR@, at VERSION_PATCH@,0
  FILEFLAGSMASK VS_FFI_FILEFLAGSMASK
#ifndef NDEBUG
  FILEFLAGS 0
#else
  FILEFLAGS VER_DEBUG
#endif
  FILEOS VOS_NT_WINDOWS32
#ifdef OPENOBEX_EXPORTS
  FILETYPE VFT_DLL
#else
  FILETYPE VFT_STATIC_LIB
#endif
  FILESUBTYPE VFT2_UNKNOWN
  BEGIN
    BLOCK "StringFileInfo"
    BEGIN
      BLOCK "04090000"
      BEGIN
        VALUE "FileDescription", "Object Exchange Protocol Implementation"
        VALUE "FileVersion", "@openobex_VERSION@"
        VALUE "InternalName", "openobex"
        VALUE "LegalCopyright", "Licensed under GPLv2 or any later version"
        VALUE "OriginalFilename", "openobex.dll"
        VALUE "ProductName", "OpenObex"
        VALUE "ProductVersion", "@VERSION@"
      END
    END
    BLOCK "VarFileInfo"
    BEGIN
      VALUE "Translation", 0x409, 1200
    END
  END
---------------------------------------------------

Basicly, that defines FileVersion and ProductVersion (which are often
equal). It works with the MS rc compiler (rc.exe), not tested with
windres.exe.
Additionally, you can have a third version information in the VERSION
flag in a .def file or as compiler argument on the command line. The
dependency checker tool can show you all three of those version
information.

CMake could not create this file as e.g. a cmake project() call has no
version information (why not? it could be the ProductVersion above).

HS


More information about the CMake mailing list