Skip to content

Commit

Permalink
Fixed qgssvnversion.h generation on Linux, Cygwin, cmd.exe and hopefu…
Browse files Browse the repository at this point in the history
…lly also on Mac

git-svn-id: http://svn.osgeo.org/qgis/branches/Release-0_8_0@6673 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
homann committed Feb 22, 2007
1 parent 3669b87 commit 54eb1ad
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 12 deletions.
32 changes: 20 additions & 12 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -181,21 +181,29 @@ INCLUDE_DIRECTORIES(${CMAKE_BINARY_DIR})

#############################################################
# create qgssvnversion.h
# see http://public.kitware.com/pipermail/cmake/2006-July/010299.html

IF (WIN32)
SET (SVNVER_H ${CMAKE_BINARY_DIR}/qgssvnversion.h)
IF (NOT EXISTS ${SVNVER_H})
WRITE_FILE(${SVNVER_H} "#define QGSSVNVERSION \"svn_rev_unavailable\"")
ENDIF (NOT EXISTS ${SVNVER_H})
ELSE (WIN32)
# We only do this if we are in a .svn dir

ADD_CUSTOM_TARGET(svnversion ALL
QGSSVNDEF='\#define QGSSVNVERSION \"'`svnversion ${QGIS_SOURCE_DIR}`'\"' &&
if [ \"`grep QGSSVNVERSION qgssvnversion.h 2>/dev/null`\" != \"$$QGSSVNDEF\" ]; then
echo $$QGSSVNDEF > qgssvnversion.h \; fi
WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
FIND_FILE(SVN_MARKER ${CMAKE_SOURCE_DIR}/.svn/entries)

ENDIF (WIN32)
IF (NOT SVN_MARKER)
SET (SVN_MARKER ${CMAKE_SOURCE_DIR}/CMakeLists.txt) # Dummy file
ENDIF (NOT SVN_MARKER)
# Add a custom command to drive the svn script whenever the svn entries
# file changes.
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/svnscript.cmake.in_cmake
${CMAKE_CURRENT_BINARY_DIR}/svnscript.cmake
@ONLY)

ADD_CUSTOM_COMMAND (
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/qgssvnversion.h
DEPENDS ${SVN_MARKER}
COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/svnscript.cmake
)

# Add a custom target to drive the custom command.
ADD_CUSTOM_TARGET(svnversion ALL DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/qgssvnversion.h)

#############################################################
# process subdirs
Expand Down
1 change: 1 addition & 0 deletions qgssvnversion.h.in_cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#define QGSSVNVERSION "@MYVERSION@"
17 changes: 17 additions & 0 deletions svnscript.cmake.in_cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Magnus Homann svn hack
# Required?
SET(CMAKE_BACKWARDS_COMPATIBILITY "2.4")

# See if we have svn installed
FIND_PROGRAM(SVNVERSION svnversion)

# Read the version if installed, else set to "unknown"
IF (SVNVERSION)
EXEC_PROGRAM(${SVNVERSION} ARGS @CMAKE_CURRENT_SOURCE_DIR@ OUTPUT_VARIABLE MYVERSION)
ELSE (SVNVERSION)
SET(MYVERSION unknown)
ENDIF (SVNVERSION)

# Configure the qgssvnversion.h
CONFIGURE_FILE(@CMAKE_CURRENT_SOURCE_DIR@/qgssvnversion.h.in_cmake
@CMAKE_CURRENT_BINARY_DIR@/qgssvnversion.h)

0 comments on commit 54eb1ad

Please sign in to comment.