diff --git a/.gitmodules b/.gitmodules index 87f07998f35..069cc2174c4 100644 --- a/.gitmodules +++ b/.gitmodules @@ -13,3 +13,6 @@ [submodule "contrib/librdkafka"] path = contrib/librdkafka url = https://github.com/edenhill/librdkafka.git +[submodule "contrib/cctz"] + path = contrib/cctz + url = https://github.com/google/cctz.git diff --git a/contrib/CMakeLists.txt b/contrib/CMakeLists.txt index f21bee5d979..fb8992e3750 100644 --- a/contrib/CMakeLists.txt +++ b/contrib/CMakeLists.txt @@ -49,7 +49,7 @@ if (USE_INTERNAL_ZLIB_LIBRARY) endif () if (USE_INTERNAL_CCTZ_LIBRARY) - add_subdirectory (libcctz) + add_subdirectory (cctz-cmake) endif () if (ENABLE_LIBTCMALLOC AND USE_INTERNAL_GPERFTOOLS_LIBRARY) diff --git a/contrib/cctz b/contrib/cctz new file mode 160000 index 00000000000..4f9776a310f --- /dev/null +++ b/contrib/cctz @@ -0,0 +1 @@ +Subproject commit 4f9776a310f4952454636363def82c2bf6641d5f diff --git a/contrib/cctz-cmake/CMakeLists.txt b/contrib/cctz-cmake/CMakeLists.txt new file mode 100644 index 00000000000..9c2f6d9a658 --- /dev/null +++ b/contrib/cctz-cmake/CMakeLists.txt @@ -0,0 +1,31 @@ +SET(LIBRARY_DIR ${ClickHouse_SOURCE_DIR}/contrib/cctz) + +add_library(cctz + ${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 + + ${LIBRARY_DIR}/src/time_zone_libc.h + ${LIBRARY_DIR}/src/time_zone_if.h + ${LIBRARY_DIR}/src/tzfile.h + ${LIBRARY_DIR}/src/time_zone_impl.h + ${LIBRARY_DIR}/src/time_zone_posix.h + ${LIBRARY_DIR}/src/time_zone_info.h + + ${LIBRARY_DIR}/include/cctz/time_zone.h + ${LIBRARY_DIR}/include/cctz/civil_time_detail.h + ${LIBRARY_DIR}/include/cctz/civil_time.h) + +if (CMAKE_SYSTEM MATCHES "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 () + +target_include_directories (cctz PUBLIC ${LIBRARY_DIR}/include) diff --git a/contrib/libcctz/CMakeLists.txt b/contrib/libcctz/CMakeLists.txt deleted file mode 100644 index e87a7da4c44..00000000000 --- a/contrib/libcctz/CMakeLists.txt +++ /dev/null @@ -1,27 +0,0 @@ - -add_library(cctz - src/time_zone_libc.cc - src/time_zone_posix.cc - src/time_zone_lookup.cc - src/time_zone_info.cc - src/time_zone_if.cc - src/time_zone_format.cc - src/time_zone_impl.cc - - src/time_zone_libc.h - src/time_zone_if.h - src/tzfile.h - src/time_zone_impl.h - src/time_zone_posix.h - src/time_zone_info.h - - include/time_zone.h - include/civil_time_detail.h - include/civil_time.h) - -if (CMAKE_SYSTEM MATCHES "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 () - -target_include_directories (cctz PUBLIC include) diff --git a/libs/libcommon/cmake/find_cctz.cmake b/libs/libcommon/cmake/find_cctz.cmake index a8a4d99521d..b123114abe3 100644 --- a/libs/libcommon/cmake/find_cctz.cmake +++ b/libs/libcommon/cmake/find_cctz.cmake @@ -1,5 +1,10 @@ option (USE_INTERNAL_CCTZ_LIBRARY "Set to FALSE to use system cctz library instead of bundled" ${NOT_UNBUNDLED}) +if (USE_INTERNAL_CCTZ_LIBRARY AND NOT EXISTS "${ClickHouse_SOURCE_DIR}/contrib/cctz/include/cctz/time_zone.h") + message (WARNING "submodule contrib/cctz is missing. to fix try run: \n git submodule update --init --recursive") + set (USE_INTERNAL_CCTZ_LIBRARY 0) +endif () + if (NOT USE_INTERNAL_CCTZ_LIBRARY) find_library (CCTZ_LIBRARY cctz) find_path (CCTZ_INCLUDE_DIR NAMES civil_time.h PATHS ${CCTZ_INCLUDE_PATHS}) @@ -8,7 +13,7 @@ endif () if (CCTZ_LIBRARY AND CCTZ_INCLUDE_DIR) else () set (USE_INTERNAL_CCTZ_LIBRARY 1) - set (CCTZ_INCLUDE_DIR "${ClickHouse_SOURCE_DIR}/contrib/libcctz/include") + set (CCTZ_INCLUDE_DIR "${ClickHouse_SOURCE_DIR}/contrib/cctz/include/cctz") set (CCTZ_LIBRARY cctz) endif ()