[CMake] CMake generated build number?

Blezek, Daniel J. Blezek.Daniel at mayo.edu
Wed Nov 5 11:22:16 EST 2008


  This is great and it works.  I have several sub-projects in our main
source code, but I can't seem to share the ADD_CUSTOM_COMMAND amongst
them.  Is there some way to do this once for all projects?


-----Original Message-----
From: Bill Hoffman [mailto:bill.hoffman at kitware.com] 
Sent: Wednesday, November 05, 2008 9:37 AM
To: Blezek, Daniel J.
Cc: Mike Arthur; cmake at cmake.org
Subject: Re: [CMake] CMake generated build number?

Blezek, Daniel J. wrote:
> Hi Mike,
>   This only works during the CMake configure process, not during the 
> build.  So it's possible for this information to be out of date.  I 
> think I'll have to make a bogus target to grab the info from 
> Subversion, which is not what I had wanted to do.

You should just use a cmake -P script to create a header file or .cxx
file that has the information you want in it.

You would use a custom command to drive this.

You should be able to follow this FAQ entry:


So, something like this:

    OUTPUT myVersion.cxx
    DEPENDS generate ${CMAKE_CURRENT_SOURCE_DIR}/version.cmake
  ADD_EXECUTABLE(product product.c myVersion.cxx)

execute_process(svn ....)
configure_file(myVersion.cxx.in myVersion.cxx)


More information about the CMake mailing list