build: inform the build of what generates version.h
Without this, Ninja requires a two-step process because it doesn't know what generates version.h it sees from its depfile support and when it changes in one run, it has already pruned the dependent nodes from its internal graph and requires a second run to catch it.
This commit is contained in:
parent
eba180a1c7
commit
9ed415ad43
@ -11,12 +11,22 @@ if ("$Format:$" STREQUAL "")
|
|||||||
write_static_version_header("release")
|
write_static_version_header("release")
|
||||||
elseif (GIT_FOUND OR Git_FOUND)
|
elseif (GIT_FOUND OR Git_FOUND)
|
||||||
message(STATUS "Found Git: ${GIT_EXECUTABLE}")
|
message(STATUS "Found Git: ${GIT_EXECUTABLE}")
|
||||||
add_custom_target(version ALL
|
set(extra_output)
|
||||||
|
if (CMAKE_GENERATOR MATCHES "Ninja")
|
||||||
|
# Ninja will not rerun the command every time if the file doesn't change,
|
||||||
|
# so inject this bogus output so that it always runs.
|
||||||
|
set(extra_output "${CMAKE_SOURCE_DIR}/.force-git-version-check")
|
||||||
|
endif ()
|
||||||
|
add_custom_command(
|
||||||
|
OUTPUT "${CMAKE_BINARY_DIR}/version/version.h"
|
||||||
|
${extra_output}
|
||||||
COMMAND "${CMAKE_COMMAND}"
|
COMMAND "${CMAKE_COMMAND}"
|
||||||
"-D" "GIT=${GIT_EXECUTABLE}"
|
"-D" "GIT=${GIT_EXECUTABLE}"
|
||||||
"-D" "TO=${CMAKE_BINARY_DIR}/version/version.h"
|
"-D" "TO=${CMAKE_BINARY_DIR}/version/version.h"
|
||||||
"-P" "src/version.cmake"
|
"-P" "src/version.cmake"
|
||||||
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}")
|
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}")
|
||||||
|
add_custom_target(version ALL
|
||||||
|
DEPENDS "${CMAKE_BINARY_DIR}/version/version.h")
|
||||||
else()
|
else()
|
||||||
message(STATUS "WARNING: Git was not found!")
|
message(STATUS "WARNING: Git was not found!")
|
||||||
write_static_version_header("unknown")
|
write_static_version_header("unknown")
|
||||||
|
Loading…
Reference in New Issue
Block a user