Modify git version generation in cmake
This commit is contained in:
parent
3f31acfada
commit
cf35ba735f
@ -27,9 +27,21 @@ if(NOT WIN32)
|
|||||||
set(BoldWhite "${Esc}[1;37m")
|
set(BoldWhite "${Esc}[1;37m")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
execute_process(COMMAND bash -c "echo -n $(git describe --always --tags --dirty)"
|
find_package(Git)
|
||||||
|
if (GIT_FOUND)
|
||||||
|
message("Git found")
|
||||||
|
execute_process(
|
||||||
|
COMMAND ${GIT_EXECUTABLE} describe --always --tags --dirty
|
||||||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
||||||
OUTPUT_VARIABLE GIT_DESCRIBE)
|
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(ELFFILE ${PROJECT_NAME}.elf)
|
||||||
set(LINKER_SCRIPT ${CMAKE_CURRENT_SOURCE_DIR}/stm32f407vet6_flash.ld)
|
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)
|
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include)
|
||||||
|
|
||||||
message("${BoldGreen}Version: ${GIT_DESCRIBE}${ColorReset}")
|
|
||||||
|
|
||||||
IF(CMAKE_BUILD_TYPE STREQUAL "Debug")
|
IF(CMAKE_BUILD_TYPE STREQUAL "Debug")
|
||||||
add_definitions(-DDEBUGBUILD)
|
add_definitions(-DDEBUGBUILD)
|
||||||
@ -58,7 +69,7 @@ ENDIF(CMAKE_BUILD_TYPE STREQUAL "Debug")
|
|||||||
|
|
||||||
if (DEFINED ENV{UART_ON_DEBUG_HEADER})
|
if (DEFINED ENV{UART_ON_DEBUG_HEADER})
|
||||||
add_definitions(-DUART_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})
|
endif (DEFINED ENV{UART_ON_DEBUG_HEADER})
|
||||||
|
|
||||||
add_subdirectory(base64-lib)
|
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_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_link_libraries(${ELFFILE} base64-lib)
|
||||||
target_include_directories(${ELFFILE} PRIVATE "${CMAKE_CURRENT_BINARY_DIR}/updater/ram-code/include/")
|
target_include_directories(${ELFFILE} PRIVATE "${CMAKE_CURRENT_BINARY_DIR}/updater/ram-code/include/")
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user