diff --git a/stm-firmware/CMakeLists.txt b/stm-firmware/CMakeLists.txt index caddc9f..6226cab 100644 --- a/stm-firmware/CMakeLists.txt +++ b/stm-firmware/CMakeLists.txt @@ -27,9 +27,21 @@ if(NOT WIN32) set(BoldWhite "${Esc}[1;37m") endif() -execute_process(COMMAND bash -c "echo -n $(git describe --always --tags --dirty)" - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} - OUTPUT_VARIABLE GIT_DESCRIBE) +find_package(Git) +if (GIT_FOUND) + message("Git found") + execute_process( + COMMAND ${GIT_EXECUTABLE} describe --always --tags --dirty + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} + OUTPUT_VARIABLE GIT_DESCRIBE + OUTPUT_STRIP_TRAILING_WHITESPACE + ) + message("${BoldGreen}Git based version number: ${GIT_DESCRIBE}${ColorReset}") +else (GIT_FOUND) + set(GIT_DESCRIBE "v0.0.0-unknown") + message("${BoldRed}No git installation found. It is highly recommended using git to generate the version number") + message("Version is set to: ${GIT_DESCRIBE}${ColorReset}") +endif (GIT_FOUND) set(ELFFILE ${PROJECT_NAME}.elf) set(LINKER_SCRIPT ${CMAKE_CURRENT_SOURCE_DIR}/stm32f407vet6_flash.ld) @@ -45,7 +57,6 @@ add_subdirectory(updater/ram-code) include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include) -message("${BoldGreen}Version: ${GIT_DESCRIBE}${ColorReset}") IF(CMAKE_BUILD_TYPE STREQUAL "Debug") add_definitions(-DDEBUGBUILD) @@ -58,7 +69,7 @@ ENDIF(CMAKE_BUILD_TYPE STREQUAL "Debug") if (DEFINED ENV{UART_ON_DEBUG_HEADER}) add_definitions(-DUART_ON_DEBUG_HEADER) - message("UART forced to debug header") + message("${BoldRed}UART forced to debug header${ColorReset}") endif (DEFINED ENV{UART_ON_DEBUG_HEADER}) add_subdirectory(base64-lib) @@ -88,4 +99,3 @@ target_include_directories(${ELFFILE} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/shellm target_link_options(${ELFFILE} PRIVATE -mlittle-endian -mthumb -mcpu=cortex-m4 -mthumb-interwork -mfloat-abi=hard -mfpu=fpv4-sp-d16 --disable-newlib-supplied-syscalls -nostartfiles -T${LINKER_SCRIPT} -Wl,--print-memory-usage) target_link_libraries(${ELFFILE} base64-lib) target_include_directories(${ELFFILE} PRIVATE "${CMAKE_CURRENT_BINARY_DIR}/updater/ram-code/include/") -