On 02/02/2011 01:44 PM, Ilja Golshtein wrote:
> Hello!
> 
> I am trying to generate version.h in my project as described 
> http://addisu.taddese.com/blog/inserting-svn-revision-number-in-your-cc-code/
> 
> I think the most natural place to do it is my project root CMakeLists.txt. 
> The problem is it does not contain any target - just setting some variables 
> and add_subdirectory(src)
> 
> The question is what is the best way to perform an action make-time 
> unconditionally.

You might use a custom target to trigger a CMake script which invokes
EXECUTE_PROCESS() to query Subversion for the current revision number
and CONFIGURE_FILE() to transform a version.h.in template into the
desired version.h header. Finally, use ADD_DEPENDENCIES() to establish
a dependency of your targets on the custom target. See [1] for a quite
similar example.

Regards,

Michael

[1] http://www.mail-archive.com/[email protected]/msg29944.html
_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake

Reply via email to