cmake: Add option to specify custom zoneinfo

Enables developers to use a different zoneinfo source than the included submodule.
This commit is contained in:
lat9nq 2024-01-17 16:16:04 -05:00
parent 14733f4575
commit 76de8f4115
2 changed files with 44 additions and 31 deletions

View File

@ -2,6 +2,8 @@ cmake_minimum_required(VERSION 3.10)
project(tzdb2nx VERSION 1.0)
option(TZDB2NX_ZONEINFO_DIR "Specify a custom zoneinfo directory containing time zone data you wish to use" "")
set(CMAKE_CXX_STANDARD 20)
if (APPLE)

View File

@ -1,15 +1,25 @@
set(TZ_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/tz" CACHE PATH "Time zone source directory")
set(TZ_DIR "${CMAKE_CURRENT_BINARY_DIR}/tz")
set(TZ_TMP_SOURCE_DIR "${CMAKE_CURRENT_BINARY_DIR}/tmpsrc")
set(TZ_ZONEINFO_DIR "${TZ_DIR}/usr/share/zoneinfo" CACHE PATH "Time zone info data directory")
set(TZIF_LIST_FILE "${CMAKE_CURRENT_BINARY_DIR}/tzif_list.txt" CACHE PATH "List of zone info files")
if (TZDB2NX_ZONEINFO_DIR)
set(TZ_ZONEINFO_DIR "${TZDB2NX_ZONEINFO_DIR}" CACHE PATH "Time zone info data directory")
else()
set(TZ_ZONEINFO_DIR "${TZ_DIR}/usr/share/zoneinfo" CACHE PATH "Time zone info data directory")
endif()
find_program(GNU_MAKE make)
if (NOT GNU_MAKE)
message(FATAL_ERROR "GNU make not found")
endif()
find_program(GIT_PROGRAM git)
if (NOT GIT_PROGRAM)
message(FATAL_ERROR "git program not found")
endif()
if (NOT EXISTS "${TZ_DIR}" OR NOT EXISTS "${TZIF_LIST_FILE}")
if (NOT TZDB2NX_ZONEINFO_DIR)
# tz's makefile can only build in-tree, so copy the whole source tree to a
# separate directory before building.
execute_process(
@ -42,6 +52,7 @@ if (NOT EXISTS "${TZ_DIR}" OR NOT EXISTS "${TZIF_LIST_FILE}")
# "${TZDB_LOCATION}"
# COMMAND_ERROR_IS_FATAL ANY
# )
endif()
execute_process(
COMMAND