How to Generate Windows DLL versioning information with CMake

前端 未结 3 1064
一生所求
一生所求 2020-12-12 17:39

I\'m using CMake to build a shared library, however for the Windows DLL I need the versioning information, like:

  • FileDescription
  • FileVersion
3条回答
  •  天涯浪人
    2020-12-12 18:21

    There is an even easier way than the accepted answer. It does not involve transforming an input resource.rc.in. Simply create a generic version.rc file as described here and then from your CMakeLists.txt do this:

    #CMakeLists.txt
    
    add_definitions(-DVER_COMPANYNAME_STR="MyCompany")
    add_definitions(-DVER_FILEVERSION_STR="1,1,0.0")
    # ...
    # add all the other defines here
    
    set(LIC_TARGET MySharedLib)
    add_library(${LIC_TARGET} SHARED ${SOURCES} version.rc)
    

    This has the added benefit that the defines are accessible from your source code as well, so you have programmatic access to your version.

提交回复
热议问题