From f19b8c4d82380ae0defb6c6041270d815164b0d2 Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Mon, 25 Feb 2013 07:01:28 +0100 Subject: Rewrite 'git describe' version support to update the version whenever needed --- src/CMakeLists.txt | 13 +++++++++++++ src/types.h | 1 + 2 files changed, 14 insertions(+) (limited to 'src') diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 916a726..0b45153 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -36,4 +36,17 @@ add_executable(fastd set_target_properties(fastd PROPERTIES COMPILE_FLAGS -pthread ${UECC_CFLAGS_OTHER} LINK_FLAGS -pthread ${UECC_LDFLAGS_OTHER}) target_link_libraries(fastd rt ${CAP_LIBRARY} ${UECC_LIBRARIES} ${NACL_LIBRARY}) +add_custom_target( + version + COMMAND echo "#ifndef _FASTD_VERSION_H_" > ${CMAKE_CURRENT_BINARY_DIR}/version.h.new + COMMAND echo "#define _FASTD_VERSION_H_" >> ${CMAKE_CURRENT_BINARY_DIR}/version.h.new + COMMAND sh -c "echo \"#define FASTD_VERSION \\\"\$(git describe --dirty || echo ${FASTD_VERSION})\\\"\"" >> ${CMAKE_CURRENT_BINARY_DIR}/version.h.new + COMMAND echo "#endif /* _FASTD_VERSION_H_ */" >> ${CMAKE_CURRENT_BINARY_DIR}/version.h.new + COMMAND cmp -s ${CMAKE_CURRENT_BINARY_DIR}/version.h.new ${CMAKE_CURRENT_BINARY_DIR}/version.h && rm ${CMAKE_CURRENT_BINARY_DIR}/version.h.new || mv ${CMAKE_CURRENT_BINARY_DIR}/version.h.new ${CMAKE_CURRENT_BINARY_DIR}/version.h + WORKING_DIRECTORY "${FASTD_SOURCE_DIR}" + VERBATIM +) + +add_dependencies(fastd version) + install(TARGETS fastd RUNTIME DESTINATION bin) diff --git a/src/types.h b/src/types.h index 4cd48e6..1a0b791 100644 --- a/src/types.h +++ b/src/types.h @@ -34,6 +34,7 @@ #define _FASTD_TYPES_H_ #include +#include typedef enum fastd_mode { -- cgit v1.2.3