[CMake] Dealing with down servers when using FindSubversion.cmake

John Drescher drescherjm at gmail.com
Mon Jun 13 13:02:34 EDT 2011


I use code like the following to append a version to my applications
based on the current svn rev.

FIND_PACKAGE(Subversion)
IF(Subversion_FOUND)
	Subversion_WC_INFO(${PROJECT_SOURCE_DIR} Project)
	MESSAGE("Current revision is ${Project_WC_REVISION}")
	Subversion_WC_LOG(${PROJECT_SOURCE_DIR} Project)
	MESSAGE("Last changed log is ${Project_LAST_CHANGED_LOG}")
	set (${PROJECT_NAME}_VERSION_PATCH
${${PROJECT_NAME}_VERSION_PATCH}.${Project_WC_REVISION})
ENDIF(Subversion_FOUND)


The problem is if the server is down it prevented me from working
since the failure to get a version ends up blocking the generate so I
added an option to disable the appending if I disable the option:

FIND_PACKAGE(Subversion)
IF(Subversion_FOUND)
	OPTION(APPEND_SVN_REV "Append subversion rev to application version" ON)
	
	IF(APPEND_SVN_REV)
		Subversion_WC_INFO(${PROJECT_SOURCE_DIR} Project)
		MESSAGE("Current revision is ${Project_WC_REVISION}")
		Subversion_WC_LOG(${PROJECT_SOURCE_DIR} Project)
		MESSAGE("Last changed log is ${Project_LAST_CHANGED_LOG}")
	
		set (${PROJECT_NAME}_VERSION_PATCH
${${PROJECT_NAME}_VERSION_PATCH}.${Project_WC_REVISION})
	ENDIF(APPEND_SVN_REV)
	
ENDIF(Subversion_FOUND)


Is there an easy way it can just cache result of these checks and if
the server is down just use the cache instead of being fatal so I do
not have to use the switch to turn off this when the server is down?

-- 
John M. Drescher


More information about the CMake mailing list