Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 24 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,30 @@
# Licensed under the MIT License.

cmake_minimum_required(VERSION 3.8.2)
project(cppgraphqlgen VERSION 3.2.0)

# Default to the last updated version from version.txt.
file(TO_CMAKE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/version.txt" VERSION_FILE)
file(READ "${VERSION_FILE}" LATEST_VERSION)

if(IS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/.git")
# Get the latest release tag from git if possible.
execute_process(COMMAND git describe --tags --long
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
OUTPUT_VARIABLE LATEST_VERSION_TAG
ERROR_QUIET
OUTPUT_STRIP_TRAILING_WHITESPACE)

if(LATEST_VERSION_TAG MATCHES "^v([0-9]+\\.[0-9]+\\.[0-9]+)-[0-9]+-[0-9a-z]+$"
AND CMAKE_MATCH_1 VERSION_GREATER LATEST_VERSION)
# The latest tag matched the pattern we expected and it's newer, so use that as the latest version.
set(LATEST_VERSION "${CMAKE_MATCH_1}")

# Update version.txt so source archives without the release tags still get the same version.
file(WRITE "${VERSION_FILE}" "${LATEST_VERSION}")
endif()
endif()

project(cppgraphqlgen VERSION ${LATEST_VERSION})

set(CMAKE_CXX_STANDARD 17)

Expand Down
1 change: 1 addition & 0 deletions cmake/version.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.2.3