Skip to content

Commit d8090e9

Browse files
Get version from git (#450)
* get version from git tag rather than hard coded in cmake
1 parent 75260f9 commit d8090e9

File tree

4 files changed

+7
-21
lines changed

4 files changed

+7
-21
lines changed

.github/workflows/build.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ jobs:
2222

2323
- name: Checkout
2424
uses: actions/checkout@v4
25+
with:
26+
fetch-depth: '0'
2527

2628
- name: Install packaged dependencies
2729
run: .github/install_dependencies

CMakeLists.txt

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
cmake_minimum_required (VERSION 3.1)
22
project (RTLSDR-Airband CXX)
33

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

98
set (CMAKE_CXX_STANDARD 11)
109
set (CXX_STANDARD_REQUIRED ON)
@@ -26,4 +25,3 @@ if(DEBUG_SQUELCH)
2625
endif()
2726

2827
add_subdirectory (src)
29-

src/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,7 @@ else()
248248
endif()
249249

250250
message(STATUS "RTLSDR-Airband configuration summary:\n")
251+
message(STATUS "- Version string:\t\t${RTL_AIRBAND_VERSION}")
251252
message(STATUS "- Build type:\t\t${CMAKE_BUILD_TYPE}")
252253
message(STATUS "- Operating system:\t\t${CMAKE_SYSTEM_NAME}")
253254
message(STATUS "- SDR drivers:")

src/CMakeModules/version.cmake

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,4 @@
1-
set (VERSION "char const *RTL_AIRBAND_VERSION=\"")
2-
execute_process(COMMAND git describe --always --tags --dirty
3-
OUTPUT_VARIABLE GIT_VERSION
4-
ERROR_QUIET
5-
OUTPUT_STRIP_TRAILING_WHITESPACE)
6-
7-
if ("${GIT_VERSION}" STREQUAL "")
8-
string(APPEND VERSION "${RTL_AIRBAND_VERSION}")
9-
elseif("${GIT_VERSION}" MATCHES ".+-g(.+)")
10-
string(APPEND VERSION "${RTL_AIRBAND_VERSION}-${CMAKE_MATCH_1}")
11-
elseif("${GIT_VERSION}" MATCHES "v(.+)")
12-
string(APPEND VERSION "${CMAKE_MATCH_1}")
13-
else()
14-
string(APPEND VERSION "${RTL_AIRBAND_VERSION}-${GIT_VERSION}")
15-
endif()
16-
string(APPEND VERSION "\";\n")
1+
set (VERSION "char const *RTL_AIRBAND_VERSION=\"${RTL_AIRBAND_VERSION}\";\n")
172

183
if(EXISTS ${CMAKE_CURRENT_BINARY_DIR}/version.cpp)
194
file(READ ${CMAKE_CURRENT_BINARY_DIR}/version.cpp VERSION_)

0 commit comments

Comments
 (0)