Remove unbundled cctz support

This commit is contained in:
Azat Khuzhin 2022-01-18 09:48:24 +03:00
parent 08efa1e75d
commit 8b692b607c
2 changed files with 59 additions and 106 deletions

View File

@ -40,10 +40,6 @@ else ()
target_compile_definitions(common PUBLIC WITH_COVERAGE=0)
endif ()
if (USE_INTERNAL_CCTZ)
set_source_files_properties(DateLUTImpl.cpp PROPERTIES COMPILE_DEFINITIONS USE_INTERNAL_CCTZ)
endif()
target_include_directories(common PUBLIC .. "${CMAKE_CURRENT_BINARY_DIR}/..")
if (OS_DARWIN AND NOT MAKE_STATIC_LIBRARIES)
@ -60,7 +56,7 @@ target_link_libraries (common
Poco::Util
Poco::Foundation
replxx
cctz
ch_contrib::cctz
fmt
magic_enum
)

View File

@ -1,106 +1,63 @@
option (USE_INTERNAL_CCTZ_LIBRARY "Use internal cctz library" ON)
include(${ClickHouse_SOURCE_DIR}/cmake/embed_binary.cmake)
set(LIBRARY_DIR "${ClickHouse_SOURCE_DIR}/contrib/cctz")
if (NOT USE_INTERNAL_CCTZ_LIBRARY)
find_library (LIBRARY_CCTZ cctz)
find_path (INCLUDE_CCTZ NAMES cctz/civil_time.h)
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"
)
if (LIBRARY_CCTZ AND INCLUDE_CCTZ)
set (EXTERNAL_CCTZ_LIBRARY_FOUND 1)
add_library (cctz ${SRCS})
target_include_directories (cctz PUBLIC "${LIBRARY_DIR}/include")
set(CMAKE_REQUIRED_LIBRARIES ${LIBRARY_CCTZ})
set(CMAKE_REQUIRED_INCLUDES ${INCLUDE_CCTZ})
check_cxx_source_compiles(
"
#include <cctz/civil_time.h>
int main() {
cctz::civil_day date;
}
"
EXTERNAL_CCTZ_LIBRARY_WORKS
)
if (NOT EXTERNAL_CCTZ_LIBRARY_WORKS)
message (${RECONFIGURE_MESSAGE_LEVEL} "External cctz is not working: ${LIBRARY_CCTZ} ${INCLUDE_CCTZ}")
else()
add_library (cctz UNKNOWN IMPORTED)
set_property (TARGET cctz PROPERTY IMPORTED_LOCATION ${LIBRARY_CCTZ})
set_property (TARGET cctz PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${INCLUDE_CCTZ})
endif()
set(SYSTEM_STORAGE_TZ_FILE "${CMAKE_BINARY_DIR}/src/Storages/System/StorageSystemTimeZones.generated.cpp")
file(REMOVE ${SYSTEM_STORAGE_TZ_FILE})
file(APPEND ${SYSTEM_STORAGE_TZ_FILE} "// autogenerated by ClickHouse/contrib/cctz-cmake/CMakeLists.txt\n")
file(APPEND ${SYSTEM_STORAGE_TZ_FILE} "const char * auto_time_zones[] {nullptr};\n" )
else()
set (EXTERNAL_CCTZ_LIBRARY_FOUND 0)
message (${RECONFIGURE_MESSAGE_LEVEL} "Can't find system cctz")
endif()
endif()
if (NOT EXTERNAL_CCTZ_LIBRARY_FOUND OR NOT EXTERNAL_CCTZ_LIBRARY_WORKS)
include(${ClickHouse_SOURCE_DIR}/cmake/embed_binary.cmake)
set(USE_INTERNAL_CCTZ_LIBRARY 1)
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"
)
add_library (cctz ${SRCS})
target_include_directories (cctz SYSTEM PUBLIC "${LIBRARY_DIR}/include")
if (OS_FREEBSD)
# yes, need linux, because bsd check inside linux in time_zone_libc.cc:24
target_compile_definitions (cctz PRIVATE __USE_BSD linux _XOPEN_SOURCE=600)
endif ()
# Related to time_zones table:
# StorageSystemTimeZones.generated.cpp is autogenerated each time during a build
# data in this file will be used to populate the system.time_zones table, this is specific to OS_LINUX
# as the library that's built using embedded tzdata is also specific to OS_LINUX
set(SYSTEM_STORAGE_TZ_FILE "${CMAKE_BINARY_DIR}/src/Storages/System/StorageSystemTimeZones.generated.cpp")
# remove existing copies so that its generated fresh on each build.
file(REMOVE ${SYSTEM_STORAGE_TZ_FILE})
# 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}")
set(TIMEZONE_RESOURCE_FILES)
# 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)
file(APPEND ${SYSTEM_STORAGE_TZ_FILE} "// autogenerated by ClickHouse/contrib/cctz-cmake/CMakeLists.txt\n")
file(APPEND ${SYSTEM_STORAGE_TZ_FILE} "const char * auto_time_zones[] {\n" )
foreach(TIMEZONE ${TIMEZONES})
file(APPEND ${SYSTEM_STORAGE_TZ_FILE} " \"${TIMEZONE}\",\n")
list(APPEND TIMEZONE_RESOURCE_FILES "${TIMEZONE}")
endforeach(TIMEZONE)
file(APPEND ${SYSTEM_STORAGE_TZ_FILE} " nullptr};\n")
clickhouse_embed_binaries(
TARGET tzdata
RESOURCE_DIR "${TZDIR}"
RESOURCES ${TIMEZONE_RESOURCE_FILES}
)
add_dependencies(cctz tzdata)
target_link_libraries(cctz INTERFACE "-Wl,${WHOLE_ARCHIVE} $<TARGET_FILE:tzdata> -Wl,${NO_WHOLE_ARCHIVE}")
if (OS_FREEBSD)
# yes, need linux, because bsd check inside linux in time_zone_libc.cc:24
target_compile_definitions (cctz PRIVATE __USE_BSD linux _XOPEN_SOURCE=600)
endif ()
message (STATUS "Using cctz")
# Related to time_zones table:
# StorageSystemTimeZones.generated.cpp is autogenerated each time during a build
# data in this file will be used to populate the system.time_zones table, this is specific to OS_LINUX
# as the library that's built using embedded tzdata is also specific to OS_LINUX
set(SYSTEM_STORAGE_TZ_FILE "${CMAKE_BINARY_DIR}/src/Storages/System/StorageSystemTimeZones.generated.cpp")
# remove existing copies so that its generated fresh on each build.
file(REMOVE ${SYSTEM_STORAGE_TZ_FILE})
# 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}")
set(TIMEZONE_RESOURCE_FILES)
# 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)
file(APPEND ${SYSTEM_STORAGE_TZ_FILE} "// autogenerated by ClickHouse/contrib/cctz-cmake/CMakeLists.txt\n")
file(APPEND ${SYSTEM_STORAGE_TZ_FILE} "const char * auto_time_zones[] {\n" )
foreach(TIMEZONE ${TIMEZONES})
file(APPEND ${SYSTEM_STORAGE_TZ_FILE} " \"${TIMEZONE}\",\n")
list(APPEND TIMEZONE_RESOURCE_FILES "${TIMEZONE}")
endforeach(TIMEZONE)
file(APPEND ${SYSTEM_STORAGE_TZ_FILE} " nullptr};\n")
clickhouse_embed_binaries(
TARGET tzdata
RESOURCE_DIR "${TZDIR}"
RESOURCES ${TIMEZONE_RESOURCE_FILES}
)
add_dependencies(cctz tzdata)
target_link_libraries(cctz INTERFACE "-Wl,${WHOLE_ARCHIVE} $<TARGET_FILE:tzdata> -Wl,${NO_WHOLE_ARCHIVE}")
add_library(ch_contrib::cctz ALIAS cctz)