Project

General

Profile

Patch #993 ยป cmake-svn.patch

Daniel Kaneider, 21 Sep 2014 11:14

View differences:

CMakeLists.txt (working copy)
154 154
    ADD_DEFINITIONS( -DEXV_HAVE_STDINT_H )
155 155
ENDIF( ${EXV_HAVE_STDINT_H} )
156 156

  
157
FIND_PACKAGE(Subversion QUIET)
158
SET(SVN_REVISION "0")
159
IF(SUBVERSION_FOUND)
160
    IF(EXISTS "${CMAKE_SOURCE_DIR}/.svn")
161
        Subversion_WC_INFO(${PROJECT_SOURCE_DIR} svnExiv2)
162
        SET(SVN_REVISION "${svnExiv2_WC_REVISION}")
163
    ENDIF()
164
ENDIF()
165
MESSAGE(STATUS  "SVN version:  ${SVN_REVISION}")
166

  
167

  
157 168
ADD_SUBDIRECTORY( xmpsdk )
158 169
ADD_SUBDIRECTORY( src )
159 170

  
......
165 176
    ADD_SUBDIRECTORY( po )
166 177
ENDIF( EXIV2_ENABLE_BUILD_PO )
167 178

  
168
IF( NOT MSVC )
169
  # Issue #722: out of source builds compiled against standard include files such as /usr/local/lib/include/exiv2
170
  # do not use CREATE_SYMLINK or CMAKE_CAN_SYMLINK as they don't work on CYGWIN
171
  EXECUTE_PROCESS( WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}           COMMAND ln -sf ${CMAKE_CURRENT_SOURCE_DIR}/src exiv2)
172
  
173
  IF( EXIV2_ENABLE_BUILD_SAMPLES )
174
    EXECUTE_PROCESS( WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/samples COMMAND ln -sf ${CMAKE_CURRENT_SOURCE_DIR}/src exiv2)
175
  ENDIF( EXIV2_ENABLE_BUILD_SAMPLES )
176

  
177
  IF( EXIV2_ENABLE_BUILD_PO )
178
    EXECUTE_PROCESS( WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/po      COMMAND ln -sf ${CMAKE_CURRENT_SOURCE_DIR}/src exiv2)
179
  ENDIF( EXIV2_ENABLE_BUILD_PO )
180
  
181
  MESSAGE(STATUS         "generating ${CMAKE_CURRENT_SOURCE_DIR}/src/svn_version.h")
182
  EXECUTE_PROCESS( WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/src       COMMAND ./svn_version.sh)
183
ENDIF()
184

  
185 179
##
186 180
# tests
187 181
ADD_CUSTOM_TARGET(tests COMMAND make test  "EXIV2_BINDIR=${CMAKE_BINARY_DIR}/bin"  WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}/test/" )
src/CMakeLists.txt (working copy)
148 148
    ENDIF( ZLIB_FOUND )
149 149
ENDIF( EXIV2_ENABLE_PNG )
150 150

  
151
IF( NOT MSVC )
152
    SET( LIBEXIV2_HDR     ${LIBEXIV2_HDR}
153
                          svn_version.h
154
    )
151
CONFIGURE_FILE( ${CMAKE_CURRENT_SOURCE_DIR}/svn_version.h.in
152
                ${CMAKE_CURRENT_BINARY_DIR}/svn_version.h @ONLY)
153

  
154
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR})
155

  
156
IF( MSVC ) # to support the old VS solution builds
157
    ADD_DEFINITIONS("-DCMAKE_BUILD_SVN")
155 158
ENDIF()
156 159

  
160
SET( LIBEXIV2_HDR     ${LIBEXIV2_HDR}
161
                      svn_version.h
162
)
163

  
157 164
##
158 165
# add xmp source if xmp is requested and xmp library not built
159 166
IF( EXIV2_ENABLE_XMP )
src/svn_version.h.in (revision 0)
1
#define SVN_VERSION @SVN_REVISION@
src/svn_version.sh (working copy)
1
#!/bin/bash
2

  
3
## 
4
# update svn_version.h when the revision has changed
5
svn_version=$(svn info .. 2>/dev/null | grep ^Revision | cut -f 2 -d' ')
6
if [ -z "$svn_version" ]; then svn_version=0 ; fi
7
if [ -e svn_version.h ]; then
8
	old=$(cut -f 3 -d' ' svn_version.h)
9
	if [ "$old" != "$svn_version" ]; then
10
		rm -rf svn_version.h
11
	fi
12
fi
13
if [ ! -e svn_version.h ]; then
14
	echo "#define SVN_VERSION $svn_version" > svn_version.h
15
fi
16

  
17
# That's all Folks!
18
##
src/version.hpp (working copy)
38 38
#include <string>
39 39

  
40 40
// svn version has not been implemented yet for DevStudio
41
#if     defined(_MSC_VER)
41
#if     defined(_MSC_VER) && !defined(CMAKE_BUILD_SVN)
42 42
#define SVN_VERSION 0
43 43
#else
44 44
#include "svn_version.h"
    (1-1/1)