I am using VS2019. I one solution I have few c++ projects sharing a common static library. For managing version info I use Version resource. The only modification on executables I do perform is changing the library's code. So I would like for the exec's version to be determined by the version of my lib.
I was thinking about whether it is possible to dynamically change the version of my executables based on a version of lib, er external resource. For example as a precompile event?
I want to controll only FILEVERSION property.
One solution would be to factor out the library's version into one of its headers, and include that.
include/MyLib/Version.rh
:
#pragma once
#define MYLIB_VERSION_STR() "1.0.0"
#define MYLIB_VERSION_COMMA() 1, 0, 0, 0
Then you can #include
it into the library's RC file, as well as your project's, and use it within the VERSION
resource:
#include <MyLib/Version.rh>
VS_VERSION_INFO VERSIONINFO
FILEVERSION MYLIB_VERSION_COMMA()
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "040904B0"
BEGIN
VALUE "FileVersion", MYLIB_VERSION_STR()
END
END
END