Skip to content

Commit

Permalink
Fix qgsversion.h creation
Browse files Browse the repository at this point in the history
  • Loading branch information
jef-n committed Jul 17, 2017
1 parent 06cb634 commit bcc8e90
Showing 1 changed file with 16 additions and 16 deletions.
32 changes: 16 additions & 16 deletions cmake/CreateQgsVersion.cmake
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
MACRO(CREATE_QGSVERSION)
IF (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/../.git/index)
IF (EXISTS ${CMAKE_SOURCE_DIR}/.git/index)
FIND_PROGRAM(GITCOMMAND git PATHS c:/cygwin/bin)
IF(GITCOMMAND)
IF(WIN32)
Expand All @@ -9,20 +9,20 @@ MACRO(CREATE_QGSVERSION)
SET(ARG %%a)
ENDIF(USING_NINJA)
ADD_CUSTOM_COMMAND(
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/qgsversion.h ${CMAKE_CURRENT_BINARY_DIR}/qgsversion.inc
COMMAND for /f \"usebackq tokens=1\" ${ARG} in "(`\"${GITCOMMAND}\" log -n1 --oneline`)" do echo \#define QGSVERSION \"${ARG}\" >${CMAKE_CURRENT_BINARY_DIR}/qgsversion.h.temp
COMMAND for /f \"usebackq tokens=1\" ${ARG} in "(`\"${GITCOMMAND}\" log -n1 --oneline`)" do echo PROJECT_NUMBER = \"${COMPLETE_VERSION}-${RELEASE_NAME} \(${ARG}\)\" >${CMAKE_CURRENT_BINARY_DIR}/qgsversion.inc
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
OUTPUT ${CMAKE_BINARY_DIR}/qgsversion.h ${CMAKE_BINARY_DIR}/qgsversion.inc
COMMAND for /f \"usebackq tokens=1\" ${ARG} in "(`\"${GITCOMMAND}\" log -n1 --oneline`)" do echo \#define QGSVERSION \"${ARG}\" >${CMAKE_BINARY_DIR}/qgsversion.h.temp
COMMAND for /f \"usebackq tokens=1\" ${ARG} in "(`\"${GITCOMMAND}\" log -n1 --oneline`)" do echo PROJECT_NUMBER = \"${COMPLETE_VERSION}-${RELEASE_NAME} \(${ARG}\)\" >${CMAKE_BINARY_DIR}/qgsversion.inc
COMMAND ${CMAKE_COMMAND} -DSRC=${CMAKE_BINARY_DIR}/qgsversion.h.temp -DDST=${CMAKE_BINARY_DIR}/qgsversion.h -P ${CMAKE_SOURCE_DIR}/cmake/CopyIfChanged.cmake
MAIN_DEPENDENCY ${CMAKE_SOURCE_DIR}/.git/index
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
)
ELSE(WIN32)
ADD_CUSTOM_COMMAND(
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/qgsversion.h ${CMAKE_CURRENT_BINARY_DIR}/qgsversion.inc
COMMAND ${GITCOMMAND} log -n1 --pretty=\#define\\ QGSVERSION\\ \\"%h\\" >${CMAKE_CURRENT_BINARY_DIR}/qgsversion.h.temp
COMMAND ${GITCOMMAND} log -n1 --pretty='PROJECT_NUMBER = \"${COMPLETE_VERSION}-${RELEASE_NAME} \(%h\)\"' >${CMAKE_CURRENT_BINARY_DIR}/qgsversion.inc
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} -DSRC=${CMAKE_CURRENT_BINARY_DIR}/qgsversion.h.temp -DDST=${CMAKE_CURRENT_BINARY_DIR}/qgsversion.h -P ${CMAKE_SOURCE_DIR}/cmake/CopyIfChanged.cmake
OUTPUT ${CMAKE_BINARY_DIR}/qgsversion.h ${CMAKE_BINARY_DIR}/qgsversion.inc
COMMAND ${GITCOMMAND} log -n1 --pretty=\#define\\ QGSVERSION\\ \\"%h\\" >${CMAKE_BINARY_DIR}/qgsversion.h.temp
COMMAND ${GITCOMMAND} log -n1 --pretty='PROJECT_NUMBER = \"${COMPLETE_VERSION}-${RELEASE_NAME} \(%h\)\"' >${CMAKE_BINARY_DIR}/qgsversion.inc
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_BINARY_DIR}/qgsversion.h.temp
COMMAND ${CMAKE_COMMAND} -DSRC=${CMAKE_BINARY_DIR}/qgsversion.h.temp -DDST=${CMAKE_BINARY_DIR}/qgsversion.h -P ${CMAKE_SOURCE_DIR}/cmake/CopyIfChanged.cmake
MAIN_DEPENDENCY ${CMAKE_SOURCE_DIR}/.git/index
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
)
Expand All @@ -32,16 +32,16 @@ MACRO(CREATE_QGSVERSION)
IF(NOT SHA)
SET(SHA "unknown")
ENDIF(NOT SHA)
FILE(WRITE ${CMAKE_CURRENT_BINARY_DIR}/qgsversion.h "#define QGSVERSION \"${SHA}\"\n")
FILE(WRITE ${CMAKE_CURRENT_BINARY_DIR}/qgsversion.inc "PROJECT_NUMBER = \"${COMPLETE_VERSION}-${RELEASE_NAME} (${SHA})\"\n")
FILE(WRITE ${CMAKE_BINARY_DIR}/qgsversion.h "#define QGSVERSION \"${SHA}\"\n")
FILE(WRITE ${CMAKE_BINARY_DIR}/qgsversion.inc "PROJECT_NUMBER = \"${COMPLETE_VERSION}-${RELEASE_NAME} (${SHA})\"\n")
ENDIF(GITCOMMAND)
ELSE (EXISTS ${CMAKE_SOURCE_DIR}/.git/index)
IF(NOT SHA)
SET(SHA "exported")
ENDIF(NOT SHA)
FILE(WRITE ${CMAKE_CURRENT_BINARY_DIR}/qgsversion.h "#define QGSVERSION \"${SHA}\"\n")
FILE(WRITE ${CMAKE_CURRENT_BINARY_DIR}/qgsversion.inc "PROJECT_NUMBER = \"${COMPLETE_VERSION}-${RELEASE_NAME} (${SHA})\"\n")
ENDIF (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/../.git/index)
FILE(WRITE ${CMAKE_BINARY_DIR}/qgsversion.h "#define QGSVERSION \"${SHA}\"\n")
FILE(WRITE ${CMAKE_BINARY_DIR}/qgsversion.inc "PROJECT_NUMBER = \"${COMPLETE_VERSION}-${RELEASE_NAME} (${SHA})\"\n")
ENDIF (EXISTS ${CMAKE_SOURCE_DIR}/.git/index)

ADD_CUSTOM_TARGET(version ALL DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/qgsversion.h)
ADD_CUSTOM_TARGET(version ALL DEPENDS ${CMAKE_BINARY_DIR}/qgsversion.h)
ENDMACRO(CREATE_QGSVERSION)

1 comment on commit bcc8e90

@3nids
Copy link
Member

@3nids 3nids commented on bcc8e90 Jul 17, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

my fault, sorry!
thanks @jef-n for the quick fix.

Please sign in to comment.