diff --git a/CMakeLists.txt b/CMakeLists.txt index e74a508..0220642 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -27,8 +27,21 @@ endif() # Add the compile definition add_compile_definitions(TILIQUA_HW_MAJOR=${TILIQUA_HW_MAJOR}) -# Add executable. Default name is the project name, version 0.1 +execute_process( + COMMAND git describe --tags --dirty + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} + OUTPUT_VARIABLE GIT_DESCRIBE + OUTPUT_STRIP_TRAILING_WHITESPACE + ERROR_QUIET +) +configure_file( + ${CMAKE_SOURCE_DIR}/version.h.in + ${CMAKE_BINARY_DIR}/version.h + @ONLY +) + +# Add executable. Default name is the project name, version 0.1 add_executable(dirtyJtag dirtyJtag.c usb_descriptors.c diff --git a/usb_descriptors.c b/usb_descriptors.c index 27ecc58..0877ad7 100644 --- a/usb_descriptors.c +++ b/usb_descriptors.c @@ -25,6 +25,7 @@ #include "dirtyJtagConfig.h" #include "tusb.h" +#include "version.h" #include "get_serial.h" #if ( USB_CDC_UART_BRIDGE ) @@ -124,11 +125,11 @@ char const *string_desc_arr[] = (const char[]){0x09, 0x04}, // 0: is supported language is English (0x0409) "apf.audio", // 1: Manufacturer #if (TILIQUA_HW_MAJOR == 2) - "Tiliqua R2 (dbg)", + "Tiliqua R2 " GIT_VERSION, #elif (TILIQUA_HW_MAJOR == 3) - "Tiliqua R3 (dbg)", + "Tiliqua R3 " GIT_VERSION, #elif (TILIQUA_HW_MAJOR == 4) - "Tiliqua R4 (dbg)", + "Tiliqua R4 " GIT_VERSION, #else #error "Unknown TILIQUA_HW_MAJOR" #endif diff --git a/version.h.in b/version.h.in new file mode 100644 index 0000000..28d75d1 --- /dev/null +++ b/version.h.in @@ -0,0 +1 @@ +#define GIT_VERSION "@GIT_DESCRIBE@"