[CMake] Obtaining a subversion revision number at build time ?

Josef Karthauser joe.karthauser at geomerics.com
Mon Dec 3 12:21:41 EST 2007


Is there a supported method for getting a subversion revision number at
build time? 

I see that I can do it at build tree generation time by using:

       FIND_PACKAGE(Subversion)
       IF(Subversion_FOUND)
           Subversion_WC_INFO(${CMAKE_HOME_DIRECTORY} Project)
           MESSAGE("Current revision is ${Project_WC_REVISION}")
       ENDIF(Subversion_FOUND)

However if I want to do this in a target it appears that I need to do it
from a foo.cmake file and call that from the target like so:

	ADD_CUSTOM_TARGET(FOO ALL
		COMMAND ${CMAKE_COMMAND} ARGS -P
${PROJECT_SOURCE_DIR}/subversion.cmake
	)

with the file subversion.cmake taking the form:

       FIND_PACKAGE(Subversion)
       IF(Subversion_FOUND)
           Subversion_WC_INFO(${CMAKE_HOME_DIRECTORY} Project)
           MESSAGE("Current revision is ${Project_WC_REVISION}")
       ENDIF(Subversion_FOUND)

as above.

But if I do this I get the error:

       CMake Error: Error in cmake code at
C:/Devel/SVN/trunk/Bin/CMake/share/cmake-2.4/Modules/FindSubversion.cmak
e:57:
       Command MARK_AS_ADVANCED not scriptable

Is this a limitation that I can work around in some fashion?

Thanks,
Joe



More information about the CMake mailing list