From c636713a4331691d83f101c0967a4fa02d865479 Mon Sep 17 00:00:00 2001 From: Misa Date: Thu, 11 Jul 2024 12:32:16 -0700 Subject: [PATCH] Use add_custom_command over add_custom_target This fixes an issue where the CentOS CI kept failing because it couldn't find the generated InterimVersion output file. It seems like using the BYPRODUCTS statement in add_custom_target didn't work because BYPRODUCTS was only added in CMake 3.2, so then add_custom_target never ran, which is obviously a problem. The solution is to use add_custom_command instead, and to solve the problem that the interim version needs to be regenerated every time no matter what (which is what BYPRODUCTS was supposed to do) we just add a dummy output instead. --- desktop_version/CMakeLists.txt | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/desktop_version/CMakeLists.txt b/desktop_version/CMakeLists.txt index 3660941b..0aec895e 100644 --- a/desktop_version/CMakeLists.txt +++ b/desktop_version/CMakeLists.txt @@ -217,10 +217,9 @@ if(NOT OFFICIAL_BUILD) set(VERSION_INPUT_FILE ${CMAKE_CURRENT_SOURCE_DIR}/src/InterimVersion.in.c) set(VERSION_OUTPUT_FILE ${CMAKE_CURRENT_SOURCE_DIR}/src/InterimVersion.out.c) - add_custom_target( - GenerateVersion ALL - # This BYPRODUCTS line is required for this to be ran every time - BYPRODUCTS ${VERSION_OUTPUT_FILE} + add_custom_command( + # This OUTPUT line is required for this to be ran every time + OUTPUT ${VERSION_OUTPUT_FILE} ${CMAKE_CURRENT_SOURCE_DIR}/src/_dummy.c COMMAND ${CMAKE_COMMAND} # These args have to be passed through, otherwise the script can't see them # Also, these args have to come BEFORE `-P`! (Otherwise it fails with an unclear error) @@ -229,8 +228,6 @@ if(NOT OFFICIAL_BUILD) -P ${CMAKE_CURRENT_SOURCE_DIR}/version.cmake ) - add_dependencies(VVVVVV GenerateVersion) - target_compile_definitions(VVVVVV PRIVATE -DINTERIM_VERSION_EXISTS) add_library(InterimVersion STATIC src/InterimVersion.out.c)