[Kst] branches/work/kst/portto4/kst/cmake/modules

Peter Kümmel syntheticpp at gmx.net
Wed Jan 12 11:44:29 CET 2011


SVN commit 1213969 by kuemmel:

use svnversion

 M  +17 -3     SubversionGenerator.cmake  


--- branches/work/kst/portto4/kst/cmake/modules/SubversionGenerator.cmake #1213968:1213969
@@ -2,6 +2,17 @@
 find_package(Subversion)
 
 if(SUBVERSION_FOUND)
+	# try with 'svnversion'
+	get_filename_component(svn_dir ${Subversion_SVN_EXECUTABLE} PATH)
+	find_program(svnversion_bin svnversion PATH ${svn_dir})
+	if(svnversion_bin)
+		execute_process(
+			COMMAND ${svnversion_bin} ${source_dir}
+			OUTPUT_VARIABLE _revision
+			ERROR_VARIABLE _error
+			RESULT_VARIABLE _result
+			OUTPUT_STRIP_TRAILING_WHITESPACE)
+	else()
 	# extract revision
 	Subversion_WC_INFO(${source_dir} src)
 	set(_revision "${src_WC_REVISION}")
@@ -10,8 +21,8 @@
 	execute_process(
 		COMMAND ${Subversion_SVN_EXECUTABLE} status ${source_dir}
 		OUTPUT_VARIABLE src_WC_STATUS
-		ERROR_VARIABLE Subversion_src_info_error
-		RESULT_VARIABLE Subversion_src_info_result
+			ERROR_VARIABLE _error
+			RESULT_VARIABLE _result
 		OUTPUT_STRIP_TRAILING_WHITESPACE)
 
 	# problems with multiple lines,
@@ -22,7 +33,7 @@
 	foreach(line ${lines})
 		string(REGEX MATCH "^(.*\n)?M ([^\n]+).*" _found "${line}")
 		if(_found)
-			message(STATUS "Modified file: ${_found}")
+				#message(STATUS "Modified file: ${_found}")
 			set(_modified ${_modified} _found)
 		endif()
 	endforeach()
@@ -30,6 +41,7 @@
 	if(_modified)
 		set(_revision "${_revision}${modified_str}")
 	endif()
+	endif()
 
 	# write a file with the SVN_REVISION define
 	file(WRITE ${header_file}.tmp "#define SVN_REVISION \"${_revision}\"\n")
@@ -37,6 +49,8 @@
 	file(WRITE ${header_file}.tmp "#define SVN_REVISION \"unknown\"\n")
 endif()
 
+message(STATUS "Revision: ${_revision}")
+
 # copy the file to the final header only if 
 # the version changes reduces needless rebuilds
 execute_process(COMMAND ${CMAKE_COMMAND}


More information about the Kst mailing list