mirror of
https://github.com/starr-dusT/tzdb_to_nx
synced 2024-03-05 21:18:52 -08:00
Merge pull request #17 from lat9nq/custom_tzdb
cmake: Add option to specify custom zoneinfo
This commit is contained in:
commit
80994fc409
@ -2,6 +2,13 @@ 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" "")
|
||||
option(TZDB2NX_VERSION "Specify a custom zoneinfo version with the directory" "")
|
||||
|
||||
if (TZDB2NX_ZONEINFO_DIR AND NOT TZDB2NX_VERSION)
|
||||
message(FATAL_ERROR "TZDB2NX_ZONEINFO_DIR was specified but TZDB2NX_VERSION was left undefined.")
|
||||
endif()
|
||||
|
||||
set(CMAKE_CXX_STANDARD 20)
|
||||
|
||||
if (APPLE)
|
||||
|
71
externals/tz/CMakeLists.txt
vendored
71
externals/tz/CMakeLists.txt
vendored
@ -1,44 +1,59 @@
|
||||
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 ("${GNU_MAKE}" STREQUAL "GNU_MAKE-NOTFOUND")
|
||||
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}")
|
||||
# tz's makefile can only build in-tree, so copy the whole source tree to a
|
||||
# separate directory before building.
|
||||
file(COPY ${TZ_SOURCE_DIR}/ DESTINATION ${TZ_TMP_SOURCE_DIR})
|
||||
if (NOT TZDB2NX_ZONEINFO_DIR) # If a custom zoneinfo directory was specified
|
||||
# tz's makefile can only build in-tree, so copy the whole source tree to a
|
||||
# separate directory before building.
|
||||
execute_process(
|
||||
COMMAND
|
||||
${GIT_PROGRAM} clone --depth 1 "file://${TZ_SOURCE_DIR}" "${TZ_TMP_SOURCE_DIR}"
|
||||
COMMAND_ERROR_IS_FATAL ANY
|
||||
)
|
||||
|
||||
if (APPLE)
|
||||
set(TZ_MAKEFLAGS "LDLIBS=${Intl_LIBRARY}")
|
||||
else()
|
||||
set(TZ_MAKEFLAGS)
|
||||
if (APPLE)
|
||||
set(TZ_MAKEFLAGS "LDLIBS=${Intl_LIBRARY}")
|
||||
else()
|
||||
set(TZ_MAKEFLAGS)
|
||||
endif()
|
||||
|
||||
execute_process(
|
||||
COMMAND
|
||||
${GNU_MAKE} DESTDIR=${TZ_DIR} ${TZ_MAKEFLAGS} install
|
||||
WORKING_DIRECTORY
|
||||
${TZ_TMP_SOURCE_DIR}
|
||||
COMMAND_ERROR_IS_FATAL ANY
|
||||
)
|
||||
|
||||
unset(TZ_MAKEFLAGS)
|
||||
|
||||
# Step taken by Arch Linux packaging, but Nintendo apparently skips it
|
||||
# execute_process(
|
||||
# COMMAND
|
||||
# "${TZDB_LOCATION}/zic" -b fat -d ${TZDB_ZONEINFO} africa antarctica asia australasia europe northamerica southamerica etcetera backward factory
|
||||
# WORKING_DIRECTORY
|
||||
# "${TZDB_LOCATION}"
|
||||
# COMMAND_ERROR_IS_FATAL ANY
|
||||
# )
|
||||
endif()
|
||||
|
||||
execute_process(
|
||||
COMMAND
|
||||
${GNU_MAKE} DESTDIR=${TZ_DIR} ${TZ_MAKEFLAGS} install
|
||||
WORKING_DIRECTORY
|
||||
${TZ_TMP_SOURCE_DIR}
|
||||
COMMAND_ERROR_IS_FATAL ANY
|
||||
)
|
||||
|
||||
unset(TZ_MAKEFLAGS)
|
||||
|
||||
# Step taken by Arch Linux packaging, but Nintendo apparently skips it
|
||||
# execute_process(
|
||||
# COMMAND
|
||||
# "${TZDB_LOCATION}/zic" -b fat -d ${TZDB_ZONEINFO} africa antarctica asia australasia europe northamerica southamerica etcetera backward factory
|
||||
# WORKING_DIRECTORY
|
||||
# "${TZDB_LOCATION}"
|
||||
# COMMAND_ERROR_IS_FATAL ANY
|
||||
# )
|
||||
|
||||
execute_process(
|
||||
COMMAND
|
||||
${CMAKE_COMMAND} -P ${PROJECT_SOURCE_DIR}/CMakeModules/list_directory.cmake false ON
|
||||
|
@ -1,10 +1,10 @@
|
||||
find_program(GIT_PROGRAM git)
|
||||
if ("${GIT_PROGRAM}" STREQUAL "GIT_PROGRAM-NOTFOUND")
|
||||
if (NOT GIT_PROGRAM)
|
||||
message(FATAL_ERROR "git program not found")
|
||||
endif()
|
||||
|
||||
find_program(GNU_DATE date)
|
||||
if ("${GNU_DATE}" STREQUAL "GNU_DATE-NOTFOUND")
|
||||
if (NOT GNU_DATE)
|
||||
message(FATAL_ERROR "date program not found")
|
||||
endif()
|
||||
|
||||
@ -13,29 +13,33 @@ set(NX_ZONEINFO_DIR "${NX_TZDB_DIR}/zoneinfo")
|
||||
|
||||
set(TZDB_VERSION_FILE ${TZ_SOURCE_DIR}/NEWS)
|
||||
|
||||
execute_process(
|
||||
COMMAND
|
||||
${GIT_PROGRAM} log --pretty=%at -n1 NEWS
|
||||
OUTPUT_VARIABLE
|
||||
TZ_COMMIT_TIME
|
||||
WORKING_DIRECTORY
|
||||
${TZ_SOURCE_DIR}
|
||||
COMMAND_ERROR_IS_FATAL ANY)
|
||||
if (NOT "${TZDB2NX_VERSION}" STREQUAL "")
|
||||
set(TZDB_VERSION "${TZDB2NX_VERSION}\n")
|
||||
else()
|
||||
execute_process(
|
||||
COMMAND
|
||||
${GIT_PROGRAM} log --pretty=%at -n1 NEWS
|
||||
OUTPUT_VARIABLE
|
||||
TZ_COMMIT_TIME
|
||||
WORKING_DIRECTORY
|
||||
${TZ_SOURCE_DIR}
|
||||
COMMAND_ERROR_IS_FATAL ANY)
|
||||
|
||||
string(REPLACE "\n" "" TZ_COMMIT_TIME "${TZ_COMMIT_TIME}")
|
||||
string(REPLACE "\n" "" TZ_COMMIT_TIME "${TZ_COMMIT_TIME}")
|
||||
|
||||
if (APPLE OR CMAKE_SYSTEM_NAME MATCHES "DragonFly|FreeBSD|NetBSD|OpenBSD")
|
||||
set(VERSION_COMMAND ${GNU_DATE} -r ${TZ_COMMIT_TIME} +%y%m%d)
|
||||
else ()
|
||||
set(VERSION_COMMAND ${GNU_DATE} +%y%m%d --date=@${TZ_COMMIT_TIME})
|
||||
endif ()
|
||||
if (APPLE OR CMAKE_SYSTEM_NAME MATCHES "DragonFly|FreeBSD|NetBSD|OpenBSD")
|
||||
set(VERSION_COMMAND ${GNU_DATE} -r ${TZ_COMMIT_TIME} +%y%m%d)
|
||||
else ()
|
||||
set(VERSION_COMMAND ${GNU_DATE} +%y%m%d --date=@${TZ_COMMIT_TIME})
|
||||
endif ()
|
||||
|
||||
execute_process(
|
||||
COMMAND
|
||||
${VERSION_COMMAND}
|
||||
OUTPUT_VARIABLE
|
||||
TZDB_VERSION
|
||||
COMMAND_ERROR_IS_FATAL ANY)
|
||||
execute_process(
|
||||
COMMAND
|
||||
${VERSION_COMMAND}
|
||||
OUTPUT_VARIABLE
|
||||
TZDB_VERSION
|
||||
COMMAND_ERROR_IS_FATAL ANY)
|
||||
endif()
|
||||
|
||||
set(NX_VERSION_FILE ${NX_TZDB_DIR}/version.txt)
|
||||
file(WRITE ${NX_VERSION_FILE} "${TZDB_VERSION}")
|
||||
|
Loading…
Reference in New Issue
Block a user