From 1ef38667197289f585c7315beacb87179c21b1b6 Mon Sep 17 00:00:00 2001 From: Peter Wu Date: Fri, 1 Sep 2017 00:22:26 +0100 Subject: 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 Tested-by: Petri Dish Buildbot Reviewed-by: Peter Wu --- CMakeLists.txt | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'CMakeLists.txt') diff --git a/CMakeLists.txt b/CMakeLists.txt index 5c0fb227b4..cfd4df9457 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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} -- cgit v1.2.3