CMake: prevent unnecessary rebuilds due to version.h

Ninja (but not Unix Makefiles or others) require an explicit BYPRODUCTS
command to ensure that the target is executed before evaluating others.

Change-Id: Iccbeb2516f7bf22ffdb444f3261ca58d22897891
Reviewed-on: https://code.wireshark.org/review/23342
Petri-Dish: Peter Wu <peter@lekensteyn.nl>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Peter Wu <peter@lekensteyn.nl>
This commit is contained in:
Peter Wu 2017-09-01 00:22:26 +01:00
parent e1a591fc74
commit 1ef3866719
1 changed files with 8 additions and 0 deletions

View File

@ -1462,7 +1462,15 @@ if (${GIT_EXECUTABLE})
set(GIT_BIN_PARAM "--git-bin ${GIT_EXECUTABLE}")
endif()
set( VERSION ${PROJECT_VERSION} )
if(NOT CMAKE_VERSION VERSION_LESS "3.2.1")
# Prevents unnecessary rebuilds by ensuring that dependents are not
# built before make-version.pl finishes (which may touch version.h).
set(version_byproducts BYPRODUCTS version.h)
else()
set(version_byproducts "")
endif()
add_custom_target(version
${version_byproducts}
COMMAND ${PERL_EXECUTABLE}
${CMAKE_SOURCE_DIR}/make-version.pl
--set-vcs ${GIT_BIN_PARAM}