From 6f3719b0f74b3704e6f2c0119106af8e9a5635bd Mon Sep 17 00:00:00 2001 From: Melroy van den Berg Date: Mon, 19 Feb 2024 02:50:20 +0100 Subject: [PATCH] Use version.txt if present (eg. when it's a source code archive) --- CMakeLists.txt | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 45f576c2..d00fe306 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,7 @@ cmake_minimum_required (VERSION 3.20) +set(PROJECT_NAME libreweb-browser) + option(DOXYGEN "Build Doxygen documentation" ON) option(UNITTEST "Build unit tests") option(PACKAGE "Build packages in release mode" OFF) @@ -7,10 +9,26 @@ set(CMAKE_OSX_DEPLOYMENT_TARGET "11.0" CACHE STRING "Minimum macOS deployment ve list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake") -include(GitVersion) +# If we have a git folder, get GIT_TAG_VERSION from most recent git tag +if(EXISTS "${CMAKE_SOURCE_DIR}/.git") + include(GitVersion) + set(LOCAL_PROJECT_VERSION ${GIT_TAG_VERSION}) +else() + # In source archives there is no .git folder present. + # If CUSTOM_PROJECT_VERSION is defined use it as version. + if(DEFINED CUSTOM_PROJECT_VERSION) + set(LOCAL_PROJECT_VERSION "${CUSTOM_PROJECT_VERSION}") + elseif(EXISTS "${CMAKE_SOURCE_DIR}/version.txt") + # Read version from version.txt file + file(READ "version.txt" LOCAL_PROJECT_VERSION) + else() + # Fallback to version 1.0.0 + set(LOCAL_PROJECT_VERSION "1.0.0") + endif() +endif() -project(libreweb-browser - VERSION ${GIT_TAG_VERSION} +project({PROJECT_NAME} + VERSION ${LOCAL_PROJECT_VERSION} DESCRIPTION "LibreWeb Browser - Decentralized Web-Browser" LANGUAGES C CXX)