Skip to content
Permalink
Browse files

fix qgsversion.h generation [take II]

  • Loading branch information
jef-n committed Jul 15, 2015
1 parent 04bab85 commit 2e772b2c554c1c07366a1d35983b53274074bb97
Showing with 7 additions and 4 deletions.
  1. +3 −4 CMakeLists.txt
  2. +4 −0 cmake/CopyIfChanged.cmake
@@ -713,18 +713,17 @@ IF (GIT_MARKER)
IF(WIN32)
ADD_CUSTOM_COMMAND(
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/qgsversion.h
COMMAND for /f \"usebackq tokens=1\" %%a in "(`\"${GITCOMMAND}\" log -n1 --oneline`)" do echo \#define QGSVERSION \"%%a\" >${CMAKE_CURRENT_BINARY_DIR}/qgsversion.h
COMMAND for /f \"usebackq tokens=1\" %%a in "(`\"${GITCOMMAND}\" log -n1 --oneline`)" do echo \#define QGSVERSION \"%%a\" >${CMAKE_CURRENT_BINARY_DIR}/qgsversion.h.temp
COMMAND ${CMAKE_COMMAND} -DSRC=${CMAKE_CURRENT_BINARY_DIR}/qgsversion.h.temp -DDST=${CMAKE_CURRENT_BINARY_DIR}/qgsversion.h -P ${CMAKE_SOURCE_DIR}/cmake/CopyIfChanged.cmake
MAIN_DEPENDENCY ${GIT_MARKER}
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
)
ELSE(WIN32)
EXECUTE_PROCESS(COMMAND ${CMAKE_COMMAND} -E touch ${GIT_MARKER})
FILE(WRITE ${CMAKE_CURRENT_BINARY_DIR}/qgsversion.h "")
ADD_CUSTOM_COMMAND(
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/qgsversion.h
COMMAND ${GITCOMMAND} log -n1 --pretty=\#define\\ QGSVERSION\\ \\"%h\\" >${CMAKE_CURRENT_BINARY_DIR}/qgsversion.h.temp
COMMAND ${GITCOMMAND} config remote.$$\(${GITCOMMAND} config branch.$$\(${GITCOMMAND} name-rev --name-only HEAD\).remote\).url | sed -e 's/^/\#define QGS_GIT_REMOTE_URL \"/' -e 's/$$/\"/' >>${CMAKE_CURRENT_BINARY_DIR}/qgsversion.h.temp
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_CURRENT_BINARY_DIR}/qgsversion.h.temp ${CMAKE_CURRENT_BINARY_DIR}/qgsversion.h
COMMAND ${CMAKE_COMMAND} -DSRC=${CMAKE_CURRENT_BINARY_DIR}/qgsversion.h.temp -DDST=${CMAKE_CURRENT_BINARY_DIR}/qgsversion.h -P ${CMAKE_SOURCE_DIR}/cmake/CopyIfChanged.cmake
MAIN_DEPENDENCY ${GIT_MARKER}
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
)
@@ -0,0 +1,4 @@
EXECUTE_PROCESS(COMMAND ${CMAKE_COMMAND} -E compare_files ${SRC} ${DST} RESULT_VARIABLE result)
IF(result)
EXECUTE_PROCESS(COMMAND ${CMAKE_COMMAND} -E copy ${SRC} ${DST})
ENDIF(result)

0 comments on commit 2e772b2

Please sign in to comment.
You can’t perform that action at this time.