Skip to content

Commit

Permalink
Cleanup cmake version info with more portable GetVersion
Browse files Browse the repository at this point in the history
Changes GetVersion.cmake to allow use from any build location, allowing for a cleaner
CMakeLists.txt for libAtomVM, and use of GetVersion to set the correct version in the esp32 image
header. Prevuiously the image header version was generated by the esp-idf fallback of using
`git describe` which only matches the AtomVM version for tagged releases. Development builds for
main branch (0.7.0-dev) have version of v0.6.5-${COMMITS_AHEAD}-${COMMIT_HASH} in the image header.

Signed-off-by: Winford <[email protected]>
  • Loading branch information
UncleGrumpy committed Mar 6, 2025
1 parent 8e9df41 commit 58e5038
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 19 deletions.
2 changes: 1 addition & 1 deletion CMakeModules/GetVersion.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
# SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later
#

include(${CMAKE_SOURCE_DIR}/version.cmake)
include(${CMAKE_CURRENT_LIST_DIR}/../version.cmake)

if (ATOMVM_DEV)
set(ATOMVM_GIT_REVISION "<unknown>")
Expand Down
19 changes: 1 addition & 18 deletions src/libAtomVM/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -251,24 +251,7 @@ gperf_generate(${CMAKE_CURRENT_SOURCE_DIR}/nifs.gperf nifs_hash.h)
add_custom_target(generated DEPENDS bifs_hash.h)
add_custom_target(generated-nifs-hash DEPENDS nifs_hash.h)

include(../../version.cmake)

if (ATOMVM_DEV)
set(ATOMVM_GIT_REVISION "<unknown>")
execute_process(
COMMAND git rev-parse --short HEAD
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT_VARIABLE ATOMVM_GIT_REVISION
OUTPUT_STRIP_TRAILING_WHITESPACE
)
if (NOT ATOMVM_GIT_REVISION STREQUAL "")
set(ATOMVM_VERSION "${ATOMVM_BASE_VERSION}+git.${ATOMVM_GIT_REVISION}")
else()
set(ATOMVM_VERSION ${ATOMVM_BASE_VERSION})
endif()
else()
set(ATOMVM_VERSION ${ATOMVM_BASE_VERSION})
endif()
include(GetVersion)

# Add include to directory where avm_version.h is generated so targets linking
# libAtomVM can access it
Expand Down
3 changes: 3 additions & 0 deletions src/platforms/esp32/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ endif()
# On Esp32, select is run in a loop in a dedicated task
set(AVM_SELECT_IN_TASK ON)

# Set project version before project so 'git describe' is not used by esp-idf
include(GetVersion)
set(PROJECT_VER ${ATOMVM_VERSION})
project(atomvm-esp32)

# esp-idf does not use compile_feature but instead sets version in
Expand Down

0 comments on commit 58e5038

Please sign in to comment.