cmake: Add user specifiable version variable

Previously it was still using the submodule's version.
This commit is contained in:
lat9nq 2024-01-18 20:33:04 -05:00
parent 76de8f4115
commit d35fcb2558
2 changed files with 29 additions and 20 deletions

View File

@ -3,6 +3,11 @@ cmake_minimum_required(VERSION 3.10)
project(tzdb2nx VERSION 1.0) project(tzdb2nx VERSION 1.0)
option(TZDB2NX_ZONEINFO_DIR "Specify a custom zoneinfo directory containing time zone data you wish to use" "") option(TZDB2NX_ZONEINFO_DIR "Specify a custom zoneinfo directory containing time zone data you wish to use" "")
option(TZDB2NX_VERSION "Specify a custom zoneinfo version with the directory" "")
if ((TZDB2NX_ZONEINFO_DIR AND NOT TZDB2NX_VERSION) OR (TZDB2NX_VERSION AND NOT TZDB2NX_ZONEINFO_DIR))
message(FATAL_ERROR "Either TZDB2NX_ZONEINFO_DIR or TZDB2NX_VERSION but not both were defined.")
endif()
set(CMAKE_CXX_STANDARD 20) set(CMAKE_CXX_STANDARD 20)

View File

@ -13,6 +13,9 @@ set(NX_ZONEINFO_DIR "${NX_TZDB_DIR}/zoneinfo")
set(TZDB_VERSION_FILE ${TZ_SOURCE_DIR}/NEWS) set(TZDB_VERSION_FILE ${TZ_SOURCE_DIR}/NEWS)
if (NOT "${TZDB2NX_VERSION}" STREQUAL "")
set(TZDB_VERSION "${TZDB2NX_VERSION}\n")
else()
execute_process( execute_process(
COMMAND COMMAND
${GIT_PROGRAM} log --pretty=%at -n1 NEWS ${GIT_PROGRAM} log --pretty=%at -n1 NEWS
@ -36,6 +39,7 @@ execute_process(
OUTPUT_VARIABLE OUTPUT_VARIABLE
TZDB_VERSION TZDB_VERSION
COMMAND_ERROR_IS_FATAL ANY) COMMAND_ERROR_IS_FATAL ANY)
endif()
set(NX_VERSION_FILE ${NX_TZDB_DIR}/version.txt) set(NX_VERSION_FILE ${NX_TZDB_DIR}/version.txt)
file(WRITE ${NX_VERSION_FILE} "${TZDB_VERSION}") file(WRITE ${NX_VERSION_FILE} "${TZDB_VERSION}")