File tree Expand file tree Collapse file tree 2 files changed +25
-1
lines changed Expand file tree Collapse file tree 2 files changed +25
-1
lines changed Original file line number Diff line number Diff line change 2
2
# Licensed under the MIT License.
3
3
4
4
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} )
6
29
7
30
set (CMAKE_CXX_STANDARD 17 )
8
31
Original file line number Diff line number Diff line change
1
+ 3.2.3
You can’t perform that action at this time.
0 commit comments