如何使用CMake生成Windows

如何使用CMake生成Windows

本文介绍了如何使用CMake生成Windows DLL版本信息?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这非常类似于:






  • 所以我的问题是:以上两行cmake代码实际上缺少什么,以便在详细信息框中填充正确的版本/转换?



    我的设置:


    1. Windows 8.1

    2. Visual Studio 2019 / 16.1.2

    3. CMake 3.14.5






    更新:我在此处上传了



    生成的 version.rc 是:

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

    #定义VER_PRODUCTVERSION 3,5,49,0
    #定义VER_PRODUCTVERSION_STR 3.5.49\0
    //


    解决方案

    经过多次试验和错误,我能够正确地获得所需的内容:





    因此,重要的部分是:

      1 VERSIONINFO 
    文件版本VER_FILEVERSION
    产品版本VER_PRODUCTVERSION
    开始
    块 StringFileInfo
    开始
    块 040904E4
    开始
    VALUE FileVersion,VER_FILEVERSION_STR
    VALUE ProductVersion,VER_PRODUCTVERSION_STR
    END
    END
    / *由于某些原因,除非我添加* /
    / *以下部分:VarFileInfo * /
    块 VarFileInfo
    BEGIN
    值 Translation,0x0409、1252
    END
    END

    参考文献:







    灵感来自:






    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:

    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:

    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"
    //
    
    解决方案

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

    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:

    这篇关于如何使用CMake生成Windows DLL版本信息?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-03 04:15