I'm using CMake to build a shared library, however for the Windows DLL I need the versioning information, like:
- FileDescription
- FileVersion
- InternalName
- LegalCopyright
- OriginalFilename
- ProductName
- ProductVersion
So far, all I have are the VERSION and SOVERSION properties, but these don't seem to correlate to the FileVersion information I was expecting.
set(LIC_TARGET MySharedLib)
add_library(${LIC_TARGET} SHARED ${SOURCES} )
SET_TARGET_PROPERTIES(${LIC_TARGET}
PROPERTIES
VERSION ${MY_PRODUCT_NUMBER}.${MY_PRODUCT_VERSION}.${MY_BUILD_NUMBER}
SOVERSION ${MY_PRODUCT_NUMBER})
I've found manual methods (see example at the bottom) but would prefer to contain this within CMake.
Help?
You could use your CMake variable values in conjunction with a version.rc.in file and the configure_file command.
And then, in your CMakeLists.txt file:
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:
This has the added benefit that the defines are accessible from your source code as well, so you have programmatic access to your version.
I'm had same problem and have automated version generation for my projects. You need three files from github:
Put it in cmake subdirectory of your project and make sure to include it to CMAKE_MODULE_PATH like:
Then before add_executable() or add_library(SHARED) your target, use:
Full list of supported resource strings see in generate_product_version.cmake.
VersionInfo.h and VersionResource.rc will be generated to cmake binaries folder. Variable VersionFilesOutputVariable will hold paths to these files. Just add this list to your target:
UPDATE: Corrected generate_product_version script parameters from VERSION_PATH to VERSION_PATCH.