2022-01-18 06:48:24 +00:00
|
|
|
set(LIBRARY_DIR "${ClickHouse_SOURCE_DIR}/contrib/cctz")
|
|
|
|
|
|
|
|
set (SRCS
|
|
|
|
"${LIBRARY_DIR}/src/civil_time_detail.cc"
|
|
|
|
"${LIBRARY_DIR}/src/time_zone_fixed.cc"
|
|
|
|
"${LIBRARY_DIR}/src/time_zone_format.cc"
|
|
|
|
"${LIBRARY_DIR}/src/time_zone_if.cc"
|
|
|
|
"${LIBRARY_DIR}/src/time_zone_impl.cc"
|
|
|
|
"${LIBRARY_DIR}/src/time_zone_info.cc"
|
|
|
|
"${LIBRARY_DIR}/src/time_zone_libc.cc"
|
|
|
|
"${LIBRARY_DIR}/src/time_zone_lookup.cc"
|
|
|
|
"${LIBRARY_DIR}/src/time_zone_posix.cc"
|
|
|
|
"${LIBRARY_DIR}/src/zone_info_source.cc"
|
|
|
|
)
|
|
|
|
|
2022-01-20 14:11:06 +00:00
|
|
|
add_library (_cctz ${SRCS})
|
|
|
|
target_include_directories (_cctz PUBLIC "${LIBRARY_DIR}/include")
|
2022-01-18 06:48:24 +00:00
|
|
|
|
|
|
|
if (OS_FREEBSD)
|
|
|
|
# yes, need linux, because bsd check inside linux in time_zone_libc.cc:24
|
2022-01-20 14:11:06 +00:00
|
|
|
target_compile_definitions (_cctz PRIVATE __USE_BSD linux _XOPEN_SOURCE=600)
|
2017-11-02 18:55:52 +00:00
|
|
|
endif ()
|
|
|
|
|
2022-01-18 06:48:24 +00:00
|
|
|
# Related to time_zones table:
|
2023-07-23 03:25:14 +00:00
|
|
|
# TimeZones.generated.cpp is autogenerated each time during a build
|
|
|
|
set(TIMEZONES_FILE "${CMAKE_CURRENT_BINARY_DIR}/TimeZones.generated.cpp")
|
2022-01-18 06:48:24 +00:00
|
|
|
# remove existing copies so that its generated fresh on each build.
|
2023-07-23 03:25:14 +00:00
|
|
|
file(REMOVE ${TIMEZONES_FILE})
|
2022-01-18 06:48:24 +00:00
|
|
|
|
|
|
|
# get the list of timezones from tzdata shipped with cctz
|
|
|
|
set(TZDIR "${LIBRARY_DIR}/testdata/zoneinfo")
|
|
|
|
file(STRINGS "${LIBRARY_DIR}/testdata/version" TZDATA_VERSION)
|
|
|
|
set_property(GLOBAL PROPERTY TZDATA_VERSION_PROP "${TZDATA_VERSION}")
|
|
|
|
message(STATUS "Packaging with tzdata version: ${TZDATA_VERSION}")
|
|
|
|
|
|
|
|
# each file in that dir (except of tab and localtime) store the info about timezone
|
|
|
|
execute_process(COMMAND
|
|
|
|
bash -c "cd ${TZDIR} && find * -type f -and ! -name '*.tab' -and ! -name 'localtime' | LC_ALL=C sort | paste -sd ';' -"
|
|
|
|
OUTPUT_STRIP_TRAILING_WHITESPACE
|
|
|
|
OUTPUT_VARIABLE TIMEZONES)
|
|
|
|
|
2023-07-23 03:25:14 +00:00
|
|
|
file(APPEND ${TIMEZONES_FILE} "// autogenerated by ClickHouse/contrib/cctz-cmake/CMakeLists.txt\n")
|
|
|
|
file(APPEND ${TIMEZONES_FILE} "#include <incbin.h>\n")
|
2022-01-18 06:48:24 +00:00
|
|
|
|
2023-07-23 03:25:14 +00:00
|
|
|
set (COUNTER 1)
|
2022-01-18 06:48:24 +00:00
|
|
|
foreach(TIMEZONE ${TIMEZONES})
|
2023-07-23 03:25:14 +00:00
|
|
|
file(APPEND ${TIMEZONES_FILE} "INCBIN(resource_timezone${COUNTER}, \"${TIMEZONE}\");\n")
|
|
|
|
MATH(EXPR COUNTER "${COUNTER}+1")
|
2022-01-18 06:48:24 +00:00
|
|
|
endforeach(TIMEZONE)
|
2023-07-23 03:25:14 +00:00
|
|
|
|
|
|
|
file(APPEND ${TIMEZONES_FILE} "#include <cstddef>\n")
|
|
|
|
file(APPEND ${TIMEZONES_FILE} "struct TimeZone { const char * name; const unsigned char * data; size_t size; };\n")
|
|
|
|
file(APPEND ${TIMEZONES_FILE} "TimeZone auto_time_zones[] {\n" )
|
|
|
|
|
|
|
|
set (COUNTER 1)
|
|
|
|
foreach(TIMEZONE ${TIMEZONES})
|
|
|
|
file(APPEND ${TIMEZONES_FILE} " {\"${TIMEZONE}\", gresource_timezone${COUNTER}Data, gresource_timezone${COUNTER}Size},\n")
|
|
|
|
MATH(EXPR COUNTER "${COUNTER}+1")
|
|
|
|
endforeach(TIMEZONE)
|
|
|
|
|
|
|
|
file(APPEND ${TIMEZONES_FILE} " {nullptr, nullptr, 0}};\n")
|
|
|
|
|
|
|
|
add_library (tzdata ${TIMEZONES_FILE})
|
|
|
|
target_link_libraries(tzdata ch_contrib::incbin)
|
|
|
|
target_include_directories(tzdata PRIVATE ${TZDIR})
|
|
|
|
target_link_libraries(_cctz tzdata)
|
2022-01-18 06:48:24 +00:00
|
|
|
|
2022-01-20 14:11:06 +00:00
|
|
|
add_library(ch_contrib::cctz ALIAS _cctz)
|