Skip to content

Commit

Permalink
Buildsystem/Genrev: Fixed revision generator not reading existing cma…
Browse files Browse the repository at this point in the history
…ke cache variables
  • Loading branch information
Shauren authored and click committed Feb 24, 2015
1 parent 2502c38 commit 869bc4e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 11 deletions.
16 changes: 7 additions & 9 deletions cmake/genrev.cmake
Expand Up @@ -12,21 +12,19 @@
# This is done EACH compile so they can be alerted about the consequences.

if(NOT BUILDDIR)
# Workaround for funny MSVC behaviour - this segment only run during compile
set(NO_GIT ${WITHOUT_GIT})
set(GIT_EXEC ${GIT_EXECUTABLE})
# Workaround for funny MSVC behaviour - this segment is only used when using cmake gui
set(BUILDDIR ${CMAKE_BINARY_DIR})
endif()

if(NO_GIT)
if(WITHOUT_GIT)
set(rev_date "1970-01-01 00:00:00 +0000")
set(rev_hash "unknown")
set(rev_branch "Archived")
else()
if(GIT_EXEC)
if(GIT_EXECUTABLE)
# Create a revision-string that we can use
execute_process(
COMMAND "${GIT_EXEC}" describe --match init --dirty=+ --abbrev=12
COMMAND "${GIT_EXECUTABLE}" describe --match init --dirty=+ --abbrev=12
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
OUTPUT_VARIABLE rev_info
OUTPUT_STRIP_TRAILING_WHITESPACE
Expand All @@ -35,7 +33,7 @@ else()

# And grab the commits timestamp
execute_process(
COMMAND "${GIT_EXEC}" show -s --format=%ci
COMMAND "${GIT_EXECUTABLE}" show -s --format=%ci
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
OUTPUT_VARIABLE rev_date
OUTPUT_STRIP_TRAILING_WHITESPACE
Expand All @@ -44,7 +42,7 @@ else()

# Also retrieve branch name
execute_process(
COMMAND "${GIT_EXEC}" rev-parse --abbrev-ref HEAD
COMMAND "${GIT_EXECUTABLE}" rev-parse --abbrev-ref HEAD
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
OUTPUT_VARIABLE rev_branch
OUTPUT_STRIP_TRAILING_WHITESPACE
Expand All @@ -69,7 +67,7 @@ else()
endif()

# Create the actual revision.h file from the above params
if(NOT "${rev_hash_cached}" MATCHES "${rev_hash}" OR NOT "${rev_branch_cached}" MATCHES "${rev_branch}")
if(NOT "${rev_hash_cached}" MATCHES "${rev_hash}" OR NOT "${rev_branch_cached}" MATCHES "${rev_branch}" OR NOT EXISTS "${BUILDDIR}/revision.h")
configure_file(
"${CMAKE_SOURCE_DIR}/revision.h.in.cmake"
"${BUILDDIR}/revision.h"
Expand Down
4 changes: 2 additions & 2 deletions src/genrev/CMakeLists.txt
Expand Up @@ -10,6 +10,6 @@

# Need to pass old ${CMAKE_BINARY_DIR} as param because its different at build stage
add_custom_target(revision.h ALL
COMMAND ${CMAKE_COMMAND} -DNO_GIT=${WITHOUT_GIT} -DGIT_EXEC=${GIT_EXECUTABLE} -DBUILDDIR=${CMAKE_BINARY_DIR} -P ${CMAKE_SOURCE_DIR}/cmake/genrev.cmake
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
COMMAND "${CMAKE_COMMAND}" -DBUILDDIR="${CMAKE_BINARY_DIR}" -P "${CMAKE_SOURCE_DIR}/cmake/genrev.cmake" "${CMAKE_BINARY_DIR}"
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
)

1 comment on commit 869bc4e

@DDuarte
Copy link
Contributor

Choose a reason for hiding this comment

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

This commit came from the 6.x (4669f94)

perhaps @click can use git cherry-pick -x next time to have the original commit in the commit message

Please sign in to comment.