Skip to content

Commit d08b770

Browse files
authored
Update cmake req version and version handling (#74)
The version is now calculated from the current git tag. Matching the pattern vX.Y.Z. The latest patch in the branch will be used in the build. This change required the CI action to do a non-shallow checkout. Which should be fine. Also removed the 'dry-run' flag from the steam build vdf. Installs cmocka to enable test-runs in CI.
1 parent 1e8572e commit d08b770

File tree

9 files changed

+65
-12
lines changed

9 files changed

+65
-12
lines changed

‎.github/workflows/cmake-multi-platform.yml‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ jobs:
7373
- uses: actions/checkout@v4
7474
with:
7575
submodules: recursive
76+
fetch-depth: 0
7677

7778
- name: ccache
7879
uses: hendrikmuhs/ccache-action@v1.2
@@ -98,7 +99,9 @@ jobs:
9899
pkg-config \
99100
libopusfile-dev \
100101
libxmp-dev \
101-
fluidsynth
102+
fluidsynth \
103+
libcmocka-dev \
104+
cppcheck
102105
103106
- name: Set up Macos dependencies
104107
if: ${{ runner.os == 'macOS' }}

‎CMakeLists.txt‎

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,10 @@
1-
cmake_minimum_required (VERSION 3.6.0)
1+
cmake_minimum_required (VERSION 3.26)
22

33
SET(CMAKE_COLOR_MAKEFILE ON)
44

55
project(breakhack C)
66

77
set(breakhack_GAME_TITLE "BreakHack")
8-
set(breakhack_MAJOR_VERSION 4)
9-
set(breakhack_MINOR_VERSION 0)
10-
set(breakhack_PATCH_VERSION 3)
11-
set(breakhack_RELEASE_TYPE "")
128

139
# Checksums
1410
set(breakhack_STEAMAPI_DLL_CHECKSUM 0x1a4691a)
@@ -17,6 +13,13 @@ set(breakhack_STEAMAPI_SO_CHECKSUM 0x1a11b6d)
1713
include(build_deps/cmake/FindCCache.cmake)
1814
include(build_deps/cmake/FindCMocka.cmake)
1915
include(build_deps/cmake/Findcppcheck.cmake)
16+
include(build_deps/cmake/git_version.cmake)
17+
18+
get_version_from_git()
19+
set(breakhack_MAJOR_VERSION ${PROJECT_VERSION_MAJOR})
20+
set(breakhack_MINOR_VERSION ${PROJECT_VERSION_MINOR})
21+
set(breakhack_PATCH_VERSION ${PROJECT_VERSION_PATCH})
22+
set(breakhack_RELEASE_TYPE "")
2023

2124
configure_file(
2225
"${PROJECT_SOURCE_DIR}/src/config.h.in"

‎build_deps/cmake/git_version.cmake‎

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
function(get_version_from_git)
2+
find_package(Git QUIET)
3+
if(NOT Git_FOUND)
4+
message(WARNING "Git not found")
5+
return()
6+
endif()
7+
8+
execute_process(
9+
COMMAND ${GIT_EXECUTABLE} describe --tags --always
10+
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
11+
OUTPUT_VARIABLE GIT_TAG
12+
OUTPUT_STRIP_TRAILING_WHITESPACE
13+
RESULT_VARIABLE GIT_RESULT
14+
)
15+
16+
if(NOT GIT_RESULT EQUAL 0)
17+
message(WARNING "Failed to get git tag")
18+
return()
19+
endif()
20+
21+
execute_process(
22+
COMMAND ${GIT_EXECUTABLE} rev-parse --short=7 HEAD
23+
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
24+
OUTPUT_VARIABLE GIT_COMMIT_SHORT_HASH
25+
OUTPUT_STRIP_TRAILING_WHITESPACE
26+
)
27+
28+
string(REGEX REPLACE "^v" "" CLEAN_TAG "${GIT_TAG}")
29+
if(CLEAN_TAG MATCHES "^([0-9]+)\\.([0-9]+)\\.([0-9]+)(-.*)?$")
30+
31+
set(PROJECT_VERSION_MAJOR ${CMAKE_MATCH_1})
32+
set(PROJECT_VERSION_MAJOR ${CMAKE_MATCH_1} PARENT_SCOPE)
33+
set(PROJECT_VERSION_MINOR ${CMAKE_MATCH_2})
34+
set(PROJECT_VERSION_MINOR ${CMAKE_MATCH_2} PARENT_SCOPE)
35+
set(PROJECT_VERSION_PATCH ${CMAKE_MATCH_3})
36+
set(PROJECT_VERSION_PATCH ${CMAKE_MATCH_3} PARENT_SCOPE)
37+
38+
set(FULL_VERSION "${CMAKE_MATCH_1}.${CMAKE_MATCH_2}.${CMAKE_MATCH_3}+${GIT_COMMIT_SHORT_HASH}")
39+
set(FULL_VERSION "${CMAKE_MATCH_1}.${CMAKE_MATCH_2}.${CMAKE_MATCH_3}+${GIT_COMMIT_SHORT_HASH}" PARENT_SCOPE)
40+
set(PROJECT_VERSION "${CMAKE_MATCH_1}.${CMAKE_MATCH_2}.${CMAKE_MATCH_3}")
41+
set(PROJECT_VERSION "${CMAKE_MATCH_1}.${CMAKE_MATCH_2}.${CMAKE_MATCH_3}" PARENT_SCOPE)
42+
43+
message(STATUS "Found version: ${PROJECT_VERSION}, full: ${FULL_VERSION}")
44+
else()
45+
message(WARNING "Tag '${CLEAN_TAG}' does not match semver format")
46+
endif()
47+
endfunction()

‎lib/bh_random/CMakeLists.txt‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
cmake_minimum_required(VERSION 3.6)
1+
cmake_minimum_required(VERSION 3.26)
22
project(bh_random CXX)
33

44
add_definitions(-std=c++11)

‎lib/checksum/CMakeLists.txt‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
cmake_minimum_required(VERSION 3.6)
1+
cmake_minimum_required(VERSION 3.26)
22
project(checksum C)
33

44
if (NOT CMAKE_BUILD_TYPE)

‎lib/lua-5.3.5/CMakeLists.txt‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
cmake_minimum_required (VERSION 3.6)
1+
cmake_minimum_required (VERSION 3.26)
22

33
SET(CMAKE_COLOR_MAKEFILE ON)
44

‎lib/physfs-3.0/CMakeLists.txt‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
# compile, using preprocessor checks for platform-specific bits instead of
1010
# testing in here.
1111

12-
cmake_minimum_required(VERSION 3.6)
12+
cmake_minimum_required(VERSION 3.26)
1313

1414
project(PhysicsFS)
1515
set(PHYSFS_VERSION 3.0.1)

‎lib/steamworks_c_wrapper/CMakeLists.txt‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
cmake_minimum_required(VERSION 3.6)
1+
cmake_minimum_required(VERSION 3.26)
22
project(steamworks_c_wrapper CXX)
33

44
if (NOT CMAKE_BUILD_TYPE)

‎scripts/build_steam_release.sh‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ cat << EOT >> $STEAM_BUILD_DIR/app_build.vdf
8484
"AppID" "931040" // your AppID
8585
"Desc" "Vagrant provider:Docker, Ubuntu 24.04" // internal description for this build
8686
"verbose" "0" // spew more build details in console
87-
"preview" "1" // make this a preview build only, nothing is uploaded
87+
"preview" "0" // make this a preview build only, nothing is uploaded
8888
8989
"ContentRoot" "content\" // root content folder, relative to location of this file
9090
"BuildOutput" "output\" // build output folder for build logs and build cache files

0 commit comments

Comments
 (0)