2018-12-31 20:04:05 +01:00
|
|
|
cmake_minimum_required(VERSION 3.0.2 FATAL_ERROR)
|
|
|
|
|
2019-07-06 13:29:15 +02:00
|
|
|
if (WIN32)
|
|
|
|
if (WINGETOPT_FOUND)
|
|
|
|
set(TD_HAVE_GETOPT 1)
|
|
|
|
endif()
|
|
|
|
else()
|
|
|
|
set(TD_HAVE_GETOPT 1)
|
|
|
|
endif()
|
|
|
|
|
2018-12-31 20:04:05 +01:00
|
|
|
if (NOT ZLIB_FOUND)
|
|
|
|
find_package(ZLIB)
|
|
|
|
endif()
|
|
|
|
if (ZLIB_FOUND)
|
|
|
|
set(TD_HAVE_ZLIB 1)
|
|
|
|
message(STATUS "Found ZLIB: ${ZLIB_INCLUDE_DIR} ${ZLIB_LIBRARIES}")
|
2018-02-17 22:24:34 +01:00
|
|
|
|
|
|
|
# OpenSSL internally depends on zlib
|
|
|
|
if (NOT OPENSSL_FOUND)
|
|
|
|
find_package(OpenSSL)
|
|
|
|
endif()
|
|
|
|
if (OPENSSL_FOUND)
|
|
|
|
set(TD_HAVE_OPENSSL 1)
|
|
|
|
endif()
|
2018-12-31 20:04:05 +01:00
|
|
|
endif()
|
|
|
|
|
2018-12-19 15:48:39 +01:00
|
|
|
if (CRC32C_FOUND)
|
|
|
|
set(TD_HAVE_CRC32C 1)
|
|
|
|
endif()
|
|
|
|
|
2019-07-06 13:29:15 +02:00
|
|
|
if (ABSL_FOUND)
|
|
|
|
set(TD_HAVE_ABSL 1)
|
|
|
|
endif()
|
|
|
|
|
2018-12-31 20:04:05 +01:00
|
|
|
configure_file(td/utils/config.h.in td/utils/config.h @ONLY)
|
|
|
|
|
|
|
|
add_subdirectory(generate)
|
|
|
|
|
|
|
|
# TDUTILS
|
|
|
|
set_source_files_properties(${TDMIME_AUTO} PROPERTIES GENERATED TRUE)
|
|
|
|
if (CLANG OR GCC)
|
|
|
|
set_property(SOURCE ${TDMIME_AUTO} APPEND_STRING PROPERTY COMPILE_FLAGS " -Wno-conversion")
|
|
|
|
elseif (MSVC)
|
|
|
|
set_property(SOURCE ${TDMIME_AUTO} APPEND_STRING PROPERTY COMPILE_FLAGS " /wd4267")
|
|
|
|
endif()
|
|
|
|
if (CLANG)
|
|
|
|
set_property(SOURCE ${TDMIME_AUTO} APPEND_STRING PROPERTY COMPILE_FLAGS " -Wno-deprecated-register")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
set(TDUTILS_SOURCE
|
2018-02-12 09:40:52 +01:00
|
|
|
td/utils/port/Clocks.cpp
|
2018-12-31 20:04:05 +01:00
|
|
|
td/utils/port/FileFd.cpp
|
|
|
|
td/utils/port/IPAddress.cpp
|
2019-07-06 13:29:15 +02:00
|
|
|
td/utils/port/MemoryMapping.cpp
|
2018-12-31 20:04:05 +01:00
|
|
|
td/utils/port/path.cpp
|
2018-09-10 01:37:05 +02:00
|
|
|
td/utils/port/PollFlags.cpp
|
2018-12-31 20:04:05 +01:00
|
|
|
td/utils/port/ServerSocketFd.cpp
|
|
|
|
td/utils/port/signals.cpp
|
|
|
|
td/utils/port/sleep.cpp
|
|
|
|
td/utils/port/SocketFd.cpp
|
2019-07-06 13:29:15 +02:00
|
|
|
td/utils/port/stacktrace.cpp
|
2018-12-31 20:04:05 +01:00
|
|
|
td/utils/port/Stat.cpp
|
2018-08-17 15:41:51 +02:00
|
|
|
td/utils/port/StdStreams.cpp
|
2018-12-31 20:04:05 +01:00
|
|
|
td/utils/port/thread_local.cpp
|
2018-09-07 02:41:21 +02:00
|
|
|
td/utils/port/UdpSocketFd.cpp
|
2018-12-31 20:04:05 +01:00
|
|
|
td/utils/port/wstring_convert.cpp
|
|
|
|
|
|
|
|
td/utils/port/detail/Epoll.cpp
|
|
|
|
td/utils/port/detail/EventFdBsd.cpp
|
|
|
|
td/utils/port/detail/EventFdLinux.cpp
|
|
|
|
td/utils/port/detail/EventFdWindows.cpp
|
2018-09-11 16:43:43 +02:00
|
|
|
td/utils/port/detail/Iocp.cpp
|
2018-12-31 20:04:05 +01:00
|
|
|
td/utils/port/detail/KQueue.cpp
|
2018-09-07 02:41:21 +02:00
|
|
|
td/utils/port/detail/NativeFd.cpp
|
2018-12-31 20:04:05 +01:00
|
|
|
td/utils/port/detail/Poll.cpp
|
|
|
|
td/utils/port/detail/Select.cpp
|
|
|
|
td/utils/port/detail/ThreadIdGuard.cpp
|
|
|
|
td/utils/port/detail/WineventPoll.cpp
|
|
|
|
|
|
|
|
${TDMIME_AUTO}
|
|
|
|
|
|
|
|
td/utils/base64.cpp
|
|
|
|
td/utils/BigNum.cpp
|
|
|
|
td/utils/buffer.cpp
|
2018-08-13 19:15:09 +02:00
|
|
|
td/utils/BufferedUdp.cpp
|
2019-02-12 16:45:14 +01:00
|
|
|
td/utils/check.cpp
|
2018-12-31 20:04:05 +01:00
|
|
|
td/utils/crypto.cpp
|
2018-08-16 15:56:16 +02:00
|
|
|
td/utils/FileLog.cpp
|
2018-12-31 20:04:05 +01:00
|
|
|
td/utils/filesystem.cpp
|
|
|
|
td/utils/find_boundary.cpp
|
|
|
|
td/utils/Gzip.cpp
|
|
|
|
td/utils/GzipByteFlow.cpp
|
|
|
|
td/utils/Hints.cpp
|
|
|
|
td/utils/HttpUrl.cpp
|
|
|
|
td/utils/JsonBuilder.cpp
|
|
|
|
td/utils/logging.cpp
|
2018-02-03 17:49:39 +01:00
|
|
|
td/utils/misc.cpp
|
2018-12-31 20:04:05 +01:00
|
|
|
td/utils/MimeType.cpp
|
2019-07-06 13:29:15 +02:00
|
|
|
td/utils/MpmcQueue.cpp
|
|
|
|
td/utils/OptionsParser.cpp
|
2018-12-31 20:04:05 +01:00
|
|
|
td/utils/Random.cpp
|
|
|
|
td/utils/StackAllocator.cpp
|
|
|
|
td/utils/Status.cpp
|
2018-02-03 17:49:39 +01:00
|
|
|
td/utils/StringBuilder.cpp
|
2018-12-19 21:35:13 +01:00
|
|
|
td/utils/tests.cpp
|
2018-12-31 20:04:05 +01:00
|
|
|
td/utils/Time.cpp
|
|
|
|
td/utils/Timer.cpp
|
|
|
|
td/utils/tl_parsers.cpp
|
2018-07-31 01:49:42 +02:00
|
|
|
td/utils/translit.cpp
|
2018-12-31 20:04:05 +01:00
|
|
|
td/utils/unicode.cpp
|
|
|
|
td/utils/utf8.cpp
|
|
|
|
|
|
|
|
td/utils/port/Clocks.h
|
|
|
|
td/utils/port/config.h
|
|
|
|
td/utils/port/CxCli.h
|
|
|
|
td/utils/port/EventFd.h
|
|
|
|
td/utils/port/EventFdBase.h
|
|
|
|
td/utils/port/FileFd.h
|
|
|
|
td/utils/port/IPAddress.h
|
2019-07-06 13:29:15 +02:00
|
|
|
td/utils/port/IoSlice.h
|
|
|
|
td/utils/port/MemoryMapping.h
|
2018-12-31 20:04:05 +01:00
|
|
|
td/utils/port/path.h
|
|
|
|
td/utils/port/platform.h
|
|
|
|
td/utils/port/Poll.h
|
|
|
|
td/utils/port/PollBase.h
|
2018-09-10 01:37:05 +02:00
|
|
|
td/utils/port/PollFlags.h
|
2018-12-31 20:04:05 +01:00
|
|
|
td/utils/port/RwMutex.h
|
|
|
|
td/utils/port/ServerSocketFd.h
|
|
|
|
td/utils/port/signals.h
|
|
|
|
td/utils/port/sleep.h
|
|
|
|
td/utils/port/SocketFd.h
|
2019-07-06 13:29:15 +02:00
|
|
|
td/utils/port/stacktrace.h
|
2018-12-31 20:04:05 +01:00
|
|
|
td/utils/port/Stat.h
|
2018-08-17 15:41:51 +02:00
|
|
|
td/utils/port/StdStreams.h
|
2018-12-31 20:04:05 +01:00
|
|
|
td/utils/port/thread.h
|
|
|
|
td/utils/port/thread_local.h
|
2018-08-13 19:15:09 +02:00
|
|
|
td/utils/port/UdpSocketFd.h
|
2018-12-31 20:04:05 +01:00
|
|
|
td/utils/port/wstring_convert.h
|
|
|
|
|
|
|
|
td/utils/port/detail/Epoll.h
|
|
|
|
td/utils/port/detail/EventFdBsd.h
|
|
|
|
td/utils/port/detail/EventFdLinux.h
|
|
|
|
td/utils/port/detail/EventFdWindows.h
|
2018-09-11 16:43:43 +02:00
|
|
|
td/utils/port/detail/Iocp.h
|
2018-12-31 20:04:05 +01:00
|
|
|
td/utils/port/detail/KQueue.h
|
2018-08-13 19:15:09 +02:00
|
|
|
td/utils/port/detail/NativeFd.h
|
2018-12-31 20:04:05 +01:00
|
|
|
td/utils/port/detail/Poll.h
|
2018-08-13 19:15:09 +02:00
|
|
|
td/utils/port/detail/PollableFd.h
|
2018-12-31 20:04:05 +01:00
|
|
|
td/utils/port/detail/Select.h
|
|
|
|
td/utils/port/detail/ThreadIdGuard.h
|
|
|
|
td/utils/port/detail/ThreadPthread.h
|
|
|
|
td/utils/port/detail/ThreadStl.h
|
|
|
|
td/utils/port/detail/WineventPoll.h
|
|
|
|
|
|
|
|
td/utils/AesCtrByteFlow.h
|
2018-12-19 22:57:56 +01:00
|
|
|
td/utils/as.h
|
2018-12-31 20:04:05 +01:00
|
|
|
td/utils/base64.h
|
|
|
|
td/utils/benchmark.h
|
|
|
|
td/utils/BigNum.h
|
2018-12-19 15:48:39 +01:00
|
|
|
td/utils/bits.h
|
2018-12-31 20:04:05 +01:00
|
|
|
td/utils/buffer.h
|
|
|
|
td/utils/BufferedFd.h
|
|
|
|
td/utils/BufferedReader.h
|
2018-09-07 02:41:21 +02:00
|
|
|
td/utils/BufferedUdp.h
|
2018-12-31 20:04:05 +01:00
|
|
|
td/utils/ByteFlow.h
|
2019-05-01 15:13:48 +02:00
|
|
|
td/utils/CancellationToken.h
|
2018-12-31 20:04:05 +01:00
|
|
|
td/utils/ChangesProcessor.h
|
2019-02-12 16:45:14 +01:00
|
|
|
td/utils/check.h
|
2018-12-31 20:04:05 +01:00
|
|
|
td/utils/Closure.h
|
|
|
|
td/utils/common.h
|
2019-07-06 13:29:15 +02:00
|
|
|
td/utils/ConcurrentHashTable.h
|
2018-12-31 20:04:05 +01:00
|
|
|
td/utils/Container.h
|
2018-08-13 19:15:09 +02:00
|
|
|
td/utils/Context.h
|
2018-12-31 20:04:05 +01:00
|
|
|
td/utils/crypto.h
|
2018-09-07 02:41:21 +02:00
|
|
|
td/utils/DecTree.h
|
2018-08-13 19:15:09 +02:00
|
|
|
td/utils/Destructor.h
|
2018-09-07 02:41:21 +02:00
|
|
|
td/utils/Enumerator.h
|
2019-07-06 13:29:15 +02:00
|
|
|
td/utils/EpochBasedMemoryReclamation.h
|
2018-08-16 15:56:16 +02:00
|
|
|
td/utils/FileLog.h
|
2018-12-31 20:04:05 +01:00
|
|
|
td/utils/filesystem.h
|
|
|
|
td/utils/find_boundary.h
|
|
|
|
td/utils/FloodControlFast.h
|
|
|
|
td/utils/FloodControlStrict.h
|
|
|
|
td/utils/format.h
|
|
|
|
td/utils/Gzip.h
|
|
|
|
td/utils/GzipByteFlow.h
|
2019-07-07 02:05:30 +02:00
|
|
|
td/utils/Hash.h
|
|
|
|
td/utils/HashMap.h
|
|
|
|
td/utils/HashSet.h
|
2018-12-31 20:04:05 +01:00
|
|
|
td/utils/HazardPointers.h
|
|
|
|
td/utils/Heap.h
|
|
|
|
td/utils/Hints.h
|
|
|
|
td/utils/HttpUrl.h
|
|
|
|
td/utils/int_types.h
|
|
|
|
td/utils/invoke.h
|
|
|
|
td/utils/JsonBuilder.h
|
|
|
|
td/utils/List.h
|
|
|
|
td/utils/logging.h
|
|
|
|
td/utils/MemoryLog.h
|
|
|
|
td/utils/MimeType.h
|
|
|
|
td/utils/misc.h
|
|
|
|
td/utils/MovableValue.h
|
|
|
|
td/utils/MpmcQueue.h
|
|
|
|
td/utils/MpmcWaiter.h
|
|
|
|
td/utils/MpscPollableQueue.h
|
|
|
|
td/utils/MpscLinkQueue.h
|
|
|
|
td/utils/Named.h
|
|
|
|
td/utils/ObjectPool.h
|
|
|
|
td/utils/Observer.h
|
|
|
|
td/utils/optional.h
|
|
|
|
td/utils/OptionsParser.h
|
|
|
|
td/utils/OrderedEventsProcessor.h
|
|
|
|
td/utils/overloaded.h
|
|
|
|
td/utils/Parser.h
|
|
|
|
td/utils/PathView.h
|
|
|
|
td/utils/queue.h
|
|
|
|
td/utils/Random.h
|
|
|
|
td/utils/ScopeGuard.h
|
2018-02-03 17:49:39 +01:00
|
|
|
td/utils/SharedObjectPool.h
|
2018-12-31 20:04:05 +01:00
|
|
|
td/utils/Slice-decl.h
|
|
|
|
td/utils/Slice.h
|
2018-08-13 19:15:09 +02:00
|
|
|
td/utils/Span.h
|
2018-12-31 20:04:05 +01:00
|
|
|
td/utils/SpinLock.h
|
|
|
|
td/utils/StackAllocator.h
|
|
|
|
td/utils/Status.h
|
|
|
|
td/utils/Storer.h
|
|
|
|
td/utils/StorerBase.h
|
|
|
|
td/utils/StringBuilder.h
|
|
|
|
td/utils/tests.h
|
2019-07-21 20:07:07 +02:00
|
|
|
td/utils/ThreadSafeCounter.h
|
2018-12-31 20:04:05 +01:00
|
|
|
td/utils/Time.h
|
|
|
|
td/utils/TimedStat.h
|
|
|
|
td/utils/Timer.h
|
|
|
|
td/utils/tl_helpers.h
|
|
|
|
td/utils/tl_parsers.h
|
|
|
|
td/utils/tl_storers.h
|
2018-07-31 01:49:42 +02:00
|
|
|
td/utils/translit.h
|
2018-12-31 20:04:05 +01:00
|
|
|
td/utils/type_traits.h
|
2018-12-19 22:18:53 +01:00
|
|
|
td/utils/UInt.h
|
2019-07-21 20:07:07 +02:00
|
|
|
td/utils/uint128.h
|
2018-12-31 20:04:05 +01:00
|
|
|
td/utils/unicode.h
|
2018-09-27 16:40:04 +02:00
|
|
|
td/utils/unique_ptr.h
|
2018-12-31 20:04:05 +01:00
|
|
|
td/utils/utf8.h
|
|
|
|
td/utils/Variant.h
|
2018-08-13 19:15:09 +02:00
|
|
|
td/utils/VectorQueue.h
|
2018-12-31 20:04:05 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
set(TDUTILS_TEST_SOURCE
|
2018-08-13 19:15:09 +02:00
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/test/buffer.cpp
|
2019-07-06 13:29:15 +02:00
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/test/ConcurrentHashMap.cpp
|
2019-07-21 20:07:07 +02:00
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/test/crypto.cpp
|
2018-03-06 14:25:36 +01:00
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/test/Enumerator.cpp
|
2019-07-06 13:29:15 +02:00
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/test/EpochBasedMemoryReclamation.cpp
|
2018-09-07 02:41:21 +02:00
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/test/filesystem.cpp
|
2018-12-31 20:04:05 +01:00
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/test/gzip.cpp
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/test/HazardPointers.cpp
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/test/heap.cpp
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/test/json.cpp
|
2018-09-07 02:41:21 +02:00
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/test/misc.cpp
|
2018-12-31 20:04:05 +01:00
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/test/MpmcQueue.cpp
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/test/MpmcWaiter.cpp
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/test/MpscLinkQueue.cpp
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/test/OrderedEventsProcessor.cpp
|
2018-08-13 19:15:09 +02:00
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/test/port.cpp
|
2018-12-31 20:04:05 +01:00
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/test/pq.cpp
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/test/SharedObjectPool.cpp
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/test/variant.cpp
|
|
|
|
PARENT_SCOPE
|
|
|
|
)
|
|
|
|
|
|
|
|
#RULES
|
|
|
|
#LIBRARIES
|
|
|
|
add_library(tdutils STATIC ${TDUTILS_SOURCE})
|
|
|
|
if (WIN32)
|
2018-02-22 19:13:33 +01:00
|
|
|
# find_library(WS2_32_LIBRARY ws2_32)
|
|
|
|
# find_library(MSWSOCK_LIBRARY Mswsock)
|
|
|
|
# target_link_libraries(tdutils PRIVATE ${WS2_32_LIBRARY} ${MSWSOCK_LIBRARY})
|
2018-05-18 15:13:35 +02:00
|
|
|
target_link_libraries(tdutils PRIVATE ws2_32 Mswsock Normaliz)
|
2018-12-31 20:04:05 +01:00
|
|
|
endif()
|
|
|
|
if (NOT CMAKE_CROSSCOMPILING)
|
|
|
|
add_dependencies(tdutils tdmime_auto)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if (DEFINED CMAKE_THREAD_LIBS_INIT)
|
|
|
|
target_link_libraries(tdutils PUBLIC ${CMAKE_THREAD_LIBS_INIT})
|
|
|
|
endif()
|
|
|
|
target_include_directories(tdutils PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}> $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>)
|
|
|
|
|
|
|
|
if (OPENSSL_FOUND)
|
2018-02-17 22:24:34 +01:00
|
|
|
target_link_libraries(tdutils PRIVATE ${OPENSSL_CRYPTO_LIBRARY} ${CMAKE_DL_LIBS} ${ZLIB_LIBRARIES})
|
2018-12-31 20:04:05 +01:00
|
|
|
target_include_directories(tdutils SYSTEM PRIVATE ${OPENSSL_INCLUDE_DIR})
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if (ZLIB_FOUND)
|
|
|
|
target_link_libraries(tdutils PRIVATE ${ZLIB_LIBRARIES})
|
|
|
|
target_include_directories(tdutils SYSTEM PRIVATE ${ZLIB_INCLUDE_DIR})
|
|
|
|
endif()
|
|
|
|
|
2018-12-19 15:48:39 +01:00
|
|
|
if (CRC32C_FOUND)
|
|
|
|
target_link_libraries(tdutils PRIVATE crc32c)
|
|
|
|
endif()
|
2019-07-06 13:29:15 +02:00
|
|
|
if (ABSL_FOUND)
|
2019-07-21 20:07:07 +02:00
|
|
|
target_link_libraries(tdutils PUBLIC absl::base absl::container absl::hash)
|
2019-07-06 13:29:15 +02:00
|
|
|
endif()
|
|
|
|
|
|
|
|
if (WIN32 AND WINGETOPT_FOUND)
|
|
|
|
target_link_libraries(tdutils PRIVATE wingetopt)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if (ANDROID)
|
|
|
|
target_link_libraries(tdutils PRIVATE log)
|
|
|
|
endif()
|
2018-12-19 15:48:39 +01:00
|
|
|
|
2019-08-02 18:06:53 +02:00
|
|
|
if (CMAKE_HOST_SYSTEM_NAME MATCHES "NetBSD")
|
|
|
|
target_link_libraries(tdutils PUBLIC /usr/pkg/gcc5/i486--netbsdelf/lib/libatomic.so)
|
|
|
|
endif()
|
|
|
|
|
2018-12-31 20:04:05 +01:00
|
|
|
install(TARGETS tdutils EXPORT TdTargets
|
|
|
|
LIBRARY DESTINATION lib
|
|
|
|
ARCHIVE DESTINATION lib
|
|
|
|
RUNTIME DESTINATION bin
|
|
|
|
INCLUDES DESTINATION include
|
|
|
|
)
|