From 4586c36778f00297086db1ffd23d963885c86887 Mon Sep 17 00:00:00 2001 From: Toni Uhlig Date: Wed, 15 Mar 2023 15:42:52 +0100 Subject: [PATCH] Generate `git_version.h` via CMake if necessary. Signed-off-by: Toni Uhlig --- CMakeLists.txt | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index c0cf214..e599f2d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -6,6 +6,12 @@ set(CMAKE_EXPORT_COMPILE_COMMANDS ON) set(CMAKE_CXX_STANDARD 11) +add_custom_target(git_version DEPENDS "${CMAKE_SOURCE_DIR}/git_version.h") +add_custom_command( + OUTPUT "${CMAKE_SOURCE_DIR}/git_version.h" + COMMAND ${CMAKE_MAKE_PROGRAM} -C ${CMAKE_SOURCE_DIR} git_version +) + set(SOURCE_FILES main.cpp log.cpp @@ -27,6 +33,7 @@ set(CMAKE_CXX_FLAGS "-Wall -Wextra -Wno-unused-variable -Wno-unused-parameter -W #target_include_directories(speederv2 PRIVATE .) #set(CMAKE_LINK_LIBRARY_FLAG "-lrt") add_executable(speederv2 ${SOURCE_FILES}) +add_dependencies(speederv2 git_version) target_link_libraries(speederv2 rt) target_link_libraries(speederv2 pthread) include_directories(SYSTEM "libev")