Skip to content

Commit

Permalink
Get version from git (#450)
Browse files Browse the repository at this point in the history
* get version from git tag rather than hard coded in cmake
  • Loading branch information
charlie-foxtrot authored Jan 22, 2024
1 parent 75260f9 commit d8090e9
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 21 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ jobs:

- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: '0'

- name: Install packaged dependencies
run: .github/install_dependencies
Expand Down
8 changes: 3 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
cmake_minimum_required (VERSION 3.1)
project (RTLSDR-Airband CXX)

set (RTL_AIRBAND_VERSION_MAJOR 5)
set (RTL_AIRBAND_VERSION_MINOR 0)
set (RTL_AIRBAND_VERSION_PATCH 0)
set (RTL_AIRBAND_VERSION "${RTL_AIRBAND_VERSION_MAJOR}.${RTL_AIRBAND_VERSION_MINOR}.${RTL_AIRBAND_VERSION_PATCH}")
execute_process(COMMAND git describe --tags --abbrev --dirty --always
OUTPUT_VARIABLE RTL_AIRBAND_VERSION
OUTPUT_STRIP_TRAILING_WHITESPACE)

set (CMAKE_CXX_STANDARD 11)
set (CXX_STANDARD_REQUIRED ON)
Expand All @@ -26,4 +25,3 @@ if(DEBUG_SQUELCH)
endif()

add_subdirectory (src)

1 change: 1 addition & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,7 @@ else()
endif()

message(STATUS "RTLSDR-Airband configuration summary:\n")
message(STATUS "- Version string:\t\t${RTL_AIRBAND_VERSION}")
message(STATUS "- Build type:\t\t${CMAKE_BUILD_TYPE}")
message(STATUS "- Operating system:\t\t${CMAKE_SYSTEM_NAME}")
message(STATUS "- SDR drivers:")
Expand Down
17 changes: 1 addition & 16 deletions src/CMakeModules/version.cmake
Original file line number Diff line number Diff line change
@@ -1,19 +1,4 @@
set (VERSION "char const *RTL_AIRBAND_VERSION=\"")
execute_process(COMMAND git describe --always --tags --dirty
OUTPUT_VARIABLE GIT_VERSION
ERROR_QUIET
OUTPUT_STRIP_TRAILING_WHITESPACE)

if ("${GIT_VERSION}" STREQUAL "")
string(APPEND VERSION "${RTL_AIRBAND_VERSION}")
elseif("${GIT_VERSION}" MATCHES ".+-g(.+)")
string(APPEND VERSION "${RTL_AIRBAND_VERSION}-${CMAKE_MATCH_1}")
elseif("${GIT_VERSION}" MATCHES "v(.+)")
string(APPEND VERSION "${CMAKE_MATCH_1}")
else()
string(APPEND VERSION "${RTL_AIRBAND_VERSION}-${GIT_VERSION}")
endif()
string(APPEND VERSION "\";\n")
set (VERSION "char const *RTL_AIRBAND_VERSION=\"${RTL_AIRBAND_VERSION}\";\n")

if(EXISTS ${CMAKE_CURRENT_BINARY_DIR}/version.cpp)
file(READ ${CMAKE_CURRENT_BINARY_DIR}/version.cpp VERSION_)
Expand Down

0 comments on commit d8090e9

Please sign in to comment.