Skip to content

Commit f43fbf4

Browse files
authored
Merge pull request #110 from wravery/master
Update to v3.2.3 and keep the version in sync with release tags
2 parents d6bf786 + 49f7c86 commit f43fbf4

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

CMakeLists.txt

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,30 @@
22
# Licensed under the MIT License.
33

44
cmake_minimum_required(VERSION 3.8.2)
5-
project(cppgraphqlgen VERSION 3.2.0)
5+
6+
# Default to the last updated version from version.txt.
7+
file(TO_CMAKE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/version.txt" VERSION_FILE)
8+
file(READ "${VERSION_FILE}" LATEST_VERSION)
9+
10+
if(IS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/.git")
11+
# Get the latest release tag from git if possible.
12+
execute_process(COMMAND git describe --tags --long
13+
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
14+
OUTPUT_VARIABLE LATEST_VERSION_TAG
15+
ERROR_QUIET
16+
OUTPUT_STRIP_TRAILING_WHITESPACE)
17+
18+
if(LATEST_VERSION_TAG MATCHES "^v([0-9]+\\.[0-9]+\\.[0-9]+)-[0-9]+-[0-9a-z]+$"
19+
AND CMAKE_MATCH_1 VERSION_GREATER LATEST_VERSION)
20+
# The latest tag matched the pattern we expected and it's newer, so use that as the latest version.
21+
set(LATEST_VERSION "${CMAKE_MATCH_1}")
22+
23+
# Update version.txt so source archives without the release tags still get the same version.
24+
file(WRITE "${VERSION_FILE}" "${LATEST_VERSION}")
25+
endif()
26+
endif()
27+
28+
project(cppgraphqlgen VERSION ${LATEST_VERSION})
629

730
set(CMAKE_CXX_STANDARD 17)
831

cmake/version.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
3.2.3

0 commit comments

Comments
 (0)