[CMake] How to add version number to dlls ?

Dekeyser, Kris Kris.Dekeyser at lms.be
Mon Oct 4 03:58:50 EDT 2004


Personally, I use the freeware tool StampVer
(http://www.elphin.com/products/stampver.html) to achieve this. I have
integrated this as a post-build command in CMake. Here's my code:

  IF(WIN32)
    IF(EXISTS "${CMAKE_SOURCE_DIR}/adm/StampVersion.txt")
      ADD_CUSTOM_COMMAND(TARGET ${ProjectName} POST_BUILD COMMAND
"${StampVersionExe}" ARGS -k -v"${CMAKE_SOURCE_DIR}/adm/StampVersion.txt"
"$(OutDir)\\${ProjectName}.dll" COMMENT "Stamp the DLL version")
    ENDIF(EXISTS "${CMAKE_SOURCE_DIR}/adm/StampVersion.txt")
  ENDIF(WIN32)

Read StampVer's readme file carefully.

--- StampVersion.txt ---
;StampVer information file
FileVersion=1.0.0.0
ProductVersion=1.0.0.0
FileFormat=%a.%b.%c Build %ty%tj
ProductFormat=Release %a.%b Service level %c

I also create the resource files on the fly, using CONFIGURE_FILE with some
predefined templates. Just create a version resource manually in VS and
replace the text with @VAR@ entries. You can put some interesting things in
your version info this way: PROJECT_NAME, CMAKE_BUILD_TYPE, BUILD_HOST, ...

Best regards, Kris

> -----Original Message-----
> From: Brad King [mailto:brad.king at kitware.com]
> Sent: Thursday, September 30, 2004 13:19
> To: Pavani, Sri Kaushik
> Cc: cmake at www.cmake.org
> Subject: Re: [CMake] How to add version number to dlls ?
> 
> 
> Pavani, Sri Kaushik wrote:
> > I am using CMake to create a dll. Is there a way to add a version 
> > resource type to the dll so that it would show up when I check the 
> > properties of the dll? I searched for a suitable command, 
> but could'nt 
> > find one.
> 
> CMake does support version numbers for shared libraries on some 
> platforms, but currently windows DLL versioning is not included.  You 
> can try using
> 
> SET_TARGET_PROPERTIES(mydll PROPERTIES LINK_FLAGS "/versionflags")
> 
> where "/versionflags" are the proper flags to tell MSVC to 
> put a version 
> number in the DLL.  I do not know if this will work and have 
> not tried it.
> 
> Please also add a feature request for this to the bug tracker:
> 
> http://www.cmake.org/Bug
> 
> and you will be notified automatically when the feature is 
> implemented.
> 
> -Brad
> _______________________________________________
> CMake mailing list
> CMake at www.cmake.org
> http://www.cmake.org/mailman/listinfo/cmake
> 
+-+-+- Email Confidentiality Footer +-+-+- 
Privileged/Confidential Information may be contained in this message. If you
are not the addressee indicated in this message (or responsible for delivery
of the message to such person), you may not print, retain, copy nor
disseminate this message or any part of it to anyone and you should notify
the sender by reply email and destroy this message. Neglecting this clause
could be a breach of confidence. Please advise immediately if you or your
employer does not consent to Internet email for messages of this kind.
Opinions, conclusions and other information in this message that are not
related to the official business of my firm shall be understood as neither
given nor endorsed by it.



More information about the CMake mailing list