Modify git version generation in cmake
This commit is contained in:
parent
3f31acfada
commit
3381840bba
@ -27,11 +27,24 @@ if(NOT WIN32)
|
||||
set(BoldWhite "${Esc}[1;37m")
|
||||
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}
|
||||
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(HEXFILE ${PROJECT_NAME}.hex)
|
||||
set(LINKER_SCRIPT ${CMAKE_CURRENT_SOURCE_DIR}/stm32f407vet6_flash.ld)
|
||||
|
||||
add_compile_options(-Wall -Wextra -Wold-style-declaration -Wuninitialized -Wmaybe-uninitialized -Wunused-parameter)
|
||||
@ -45,21 +58,20 @@ 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)
|
||||
add_compile_options(-Og -g)
|
||||
add_definitions(-DDEBUGBUILD)
|
||||
add_compile_options(-Og -g)
|
||||
ELSE()
|
||||
add_compile_options(-O3 -g)
|
||||
add_link_options(-Wl,--gc-sections)
|
||||
add_compile_options(-O3 -g)
|
||||
add_link_options(-Wl,--gc-sections)
|
||||
ENDIF(CMAKE_BUILD_TYPE STREQUAL "Debug")
|
||||
|
||||
|
||||
if (DEFINED ENV{UART_ON_DEBUG_HEADER})
|
||||
if (UART_ON_DEBUG_HEADER)
|
||||
add_definitions(-DUART_ON_DEBUG_HEADER)
|
||||
message("UART forced to debug header")
|
||||
endif (DEFINED ENV{UART_ON_DEBUG_HEADER})
|
||||
message("${BoldRed}UART forced to debug header${ColorReset}")
|
||||
endif (UART_ON_DEBUG_HEADER)
|
||||
|
||||
add_subdirectory(base64-lib)
|
||||
|
||||
@ -89,3 +101,10 @@ target_link_options(${ELFFILE} PRIVATE -mlittle-endian -mthumb -mcpu=cortex-m4 -
|
||||
target_link_libraries(${ELFFILE} base64-lib)
|
||||
target_include_directories(${ELFFILE} PRIVATE "${CMAKE_CURRENT_BINARY_DIR}/updater/ram-code/include/")
|
||||
|
||||
|
||||
set(HEX_PATH "${CMAKE_CURRENT_BINARY_DIR}/${HEXFILE}")
|
||||
add_custom_target(update-image ALL DEPENDS ${HEX_PATH})
|
||||
add_custom_command(
|
||||
DEPENDS ${ELFFILE}
|
||||
OUTPUT ${HEX_PATH}
|
||||
COMMAND ${CMAKE_OBJCOPY} -O ihex ${ELFFILE} ${HEX_PATH})
|
||||
|
Loading…
Reference in New Issue
Block a user