79eea2680e
Some checks failed
android / build (push) Waiting to run
linux-aarch64-cpu-gcc / linux-gcc-aarch64 (Debug) (push) Waiting to run
linux-aarch64-cpu-gcc / linux-gcc-aarch64 (Release) (push) Waiting to run
linux-arm-gcc / linux-gcc-arm (Debug) (push) Waiting to run
linux-arm-gcc / linux-gcc-arm (Release) (push) Waiting to run
linux-arm-gcc / linux-gcc-armhf (Debug) (push) Waiting to run
linux-arm-gcc / linux-gcc-armhf (Release) (push) Waiting to run
linux-mips-gcc / linux-gcc-mipsel (Debug) (push) Waiting to run
linux-mips-gcc / linux-gcc-mipsel (Release) (push) Waiting to run
linux-mips64-gcc / linux-gcc-mips64el (Debug) (push) Waiting to run
linux-mips64-gcc / linux-gcc-mips64el (Release) (push) Waiting to run
linux-riscv64-gcc / linux-gcc-riscv64 (Debug) (push) Waiting to run
linux-riscv64-gcc / linux-gcc-riscv64 (Release) (push) Waiting to run
linux-x64-gcc / linux-gcc (Debug) (push) Waiting to run
linux-x64-gcc / linux-gcc (Release) (push) Waiting to run
linux-x86-gcc / linux-gcc (Debug) (push) Waiting to run
linux-x86-gcc / linux-gcc (Release) (push) Waiting to run
android / build (pull_request) Successful in 6m12s
linux-aarch64-cpu-gcc / linux-gcc-aarch64 (Release) (pull_request) Failing after 5m45s
linux-aarch64-cpu-gcc / linux-gcc-aarch64 (Debug) (pull_request) Failing after 6m24s
linux-arm-gcc / linux-gcc-arm (Debug) (pull_request) Failing after 5m8s
linux-arm-gcc / linux-gcc-arm (Release) (pull_request) Failing after 6m58s
linux-mips64-gcc / linux-gcc-mips64el (Debug) (pull_request) Failing after 6m33s
linux-mips-gcc / linux-gcc-mipsel (Debug) (pull_request) Failing after 7m43s
linux-mips64-gcc / linux-gcc-mips64el (Release) (pull_request) Failing after 6m59s
linux-mips-gcc / linux-gcc-mipsel (Release) (pull_request) Failing after 7m27s
linux-riscv64-gcc / linux-gcc-riscv64 (Debug) (pull_request) Failing after 6m41s
linux-arm-gcc / linux-gcc-armhf (Debug) (pull_request) Failing after 10m35s
linux-arm-gcc / linux-gcc-armhf (Release) (pull_request) Failing after 11m9s
linux-riscv64-gcc / linux-gcc-riscv64 (Release) (pull_request) Failing after 6m42s
linux-x64-gcc / linux-gcc (Release) (pull_request) Successful in 5m5s
linux-x64-gcc / linux-gcc (Debug) (pull_request) Failing after 5m33s
linux-x86-gcc / linux-gcc (Debug) (pull_request) Failing after 6m24s
linux-x86-gcc / linux-gcc (Release) (pull_request) Failing after 6m38s
362 lines
14 KiB
CMake
362 lines
14 KiB
CMake
cmake_minimum_required(VERSION 3.12)
|
|
|
|
set(tile_VERSION_MAJOR 0)
|
|
set(tile_VERSION_MINOR 1)
|
|
set(tile_VERSION_PATCH 0)
|
|
|
|
project(
|
|
tile
|
|
VERSION ${tile_VERSION_MAJOR}.${tile_VERSION_MINOR}.${tile_VERSION_PATCH}
|
|
LANGUAGES C CXX ASM)
|
|
|
|
set(CMAKE_CXX_STANDARD 11)
|
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
|
set(CMAKE_CXX_EXTENSIONS OFF)
|
|
|
|
set(CMAKE_C_STANDARD 99)
|
|
set(CMAKE_C_STANDARD_REQUIRED ON)
|
|
|
|
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
|
|
|
|
option(TILE_BUILD_TESTS "Build tests" OFF)
|
|
option(TILE_BUILD_BENCHMARKS "Build tests" OFF)
|
|
option(TILE_WITH_OPENSSL "Build with openssl" OFF)
|
|
option(TILE_BUILD_SHARED "Build shared library" ON)
|
|
option(TILE_BUILD_STATIC "Build static library" ON)
|
|
|
|
if(NOT CMAKE_BUILD_TYPE)
|
|
set(CMAKE_BUILD_TYPE "Debug")
|
|
endif()
|
|
|
|
if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
|
|
# set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -static") set(CMAKE_C_FLAGS
|
|
# "${CMAKE_CXX_FLAGS} -static") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}
|
|
# -fsanitize=address ") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=address
|
|
# ")
|
|
|
|
set(WHOLE_ARCHIVE_PREFIX "-Wl,-force_load")
|
|
# set(NO_WHOLE_ARCHIVE_PREFIX "")
|
|
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang")
|
|
# set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -static") set(CMAKE_C_FLAGS
|
|
# "${CMAKE_CXX_FLAGS} -static")
|
|
|
|
set(WHOLE_ARCHIVE_PREFIX "-Wl,-force_load,")
|
|
# set(NO_WHOLE_ARCHIVE_PREFIX "")
|
|
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -static-libgcc -static-libstdc++")
|
|
set(CMAKE_C_FLAGS "${CMAKE_CXX_FLAGS} -static-libgcc -static-libstdc++")
|
|
|
|
set(WHOLE_ARCHIVE_PREFIX "-Wl,--whole-archive")
|
|
set(WHOLE_ARCHIVE_SUFFIX "-Wl,--no-whole-archive")
|
|
endif()
|
|
|
|
find_package(Threads REQUIRED)
|
|
|
|
# extern int getifaddrs(struct ifaddrs **ifap); extern void freeifaddrs(struct
|
|
# ifaddrs *ifa);
|
|
include(CheckSymbolExists)
|
|
include(cmake/BuildInfo.cmake)
|
|
|
|
check_symbol_exists("getifaddrs" "ifaddrs.h" TILE_HAVE_GETIFADDRS)
|
|
check_symbol_exists("freeifaddrs" "ifaddrs.h" TILE_HAVE_FREEIFADDRS)
|
|
|
|
get_git_commit_hash(GIT_COMMIT_HASH)
|
|
get_git_commit_date(GIT_COMMIT_DATE)
|
|
get_git_commit_subject(GIT_COMMIT_SUBJECT)
|
|
|
|
include_directories("third_party/json" "third_party/inja" "third_party/sigslot")
|
|
|
|
include_directories("${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include")
|
|
add_subdirectory("third_party/context")
|
|
add_subdirectory("third_party/zlib")
|
|
add_subdirectory("third_party/fmt")
|
|
add_subdirectory("third_party/googletest")
|
|
add_subdirectory("third_party/gflags")
|
|
set(GFLAGS_USE_TARGET_NAMESPACE ON)
|
|
set(gflags_DIR "${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags")
|
|
add_subdirectory("third_party/glog")
|
|
|
|
set(CURL_DISABLE_TESTS ON)
|
|
set(CURL_ENABLE_SSL
|
|
OFF
|
|
CACHE BOOL "" FORCE)
|
|
set(USE_LIBIDN2
|
|
OFF
|
|
CACHE BOOL "" FORCE)
|
|
set(CURL_USE_LIBPSL
|
|
OFF
|
|
CACHE BOOL "" FORCE)
|
|
set(CURL_USE_LIBSSH
|
|
OFF
|
|
CACHE BOOL "" FORCE)
|
|
set(CURL_USE_LIBSSH2
|
|
OFF
|
|
CACHE BOOL "" FORCE)
|
|
set(CURL_USE_GSSAPI
|
|
OFF
|
|
CACHE BOOL "" FORCE)
|
|
set(CURL_USE_RTMP
|
|
OFF
|
|
CACHE BOOL "" FORCE)
|
|
set(USE_OPENSSL_QUIC
|
|
OFF
|
|
CACHE BOOL "" FORCE)
|
|
set(USE_MSH3
|
|
OFF
|
|
CACHE BOOL "" FORCE)
|
|
set(CURL_DISABLE_LDAP
|
|
ON
|
|
CACHE BOOL "" FORCE)
|
|
set(ZLIB_FOUND ON)
|
|
set(ZLIB_INCLUDE_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/third_party/zlib")
|
|
set(ZLIB_LIBRARIES zlib)
|
|
add_subdirectory("third_party/curl")
|
|
# add_subdirectory("third_party/date")
|
|
if(TILE_WITH_OPENSSL)
|
|
add_subdirectory("third_party/openssl-cmake")
|
|
list(APPEND TILE_LINK_LIBS ssl crypto)
|
|
endif()
|
|
|
|
configure_file("tile/base/config.h.in"
|
|
"${CMAKE_CURRENT_BINARY_DIR}/tile/base/config.h" @ONLY)
|
|
# file(GLOB zlib_SRCS "${CMAKE_CURRENT_SOURCE_DIR}/third_party/zlib/zlib/*.c")
|
|
set(TILE_SRCS
|
|
"tile/base/buffer/builtin_buffer_block.cc"
|
|
"tile/base/buffer/compression_output_stream.cc"
|
|
"tile/base/buffer/polymorphic_buffer.cc"
|
|
"tile/base/buffer.cc"
|
|
"tile/base/chrono.cc"
|
|
"tile/base/compression.cc"
|
|
"tile/base/compression/compression.cc"
|
|
"tile/base/compression/gzip.cc"
|
|
"tile/base/compression/util.cc"
|
|
"tile/base/demangle.cc"
|
|
"tile/base/encoding/base64.cc"
|
|
"tile/base/encoding/detail/hex_chars.cc"
|
|
"tile/base/encoding/hex.cc"
|
|
"tile/base/encoding/percent.cc"
|
|
"tile/base/internal/background_task_host.cc"
|
|
"tile/base/internal/background_task_host.h"
|
|
"tile/base/internal/case_insensitive_hash_map.h"
|
|
"tile/base/internal/curl.cc"
|
|
"tile/base/internal/curl.h"
|
|
"tile/base/internal/early_init.h"
|
|
"tile/base/internal/index_alloc.cc"
|
|
"tile/base/internal/logging.cc"
|
|
"tile/base/internal/logging.h"
|
|
"tile/base/internal/thread_pool.cc"
|
|
"tile/base/internal/time_keeper.cc"
|
|
"tile/base/internal/time_keeper.h"
|
|
"tile/base/net/endpoint.cc"
|
|
"tile/base/object_pool/disabled.cc"
|
|
"tile/base/object_pool/global.cc"
|
|
"tile/base/object_pool/thread_local.cc"
|
|
"tile/base/option.cc"
|
|
"tile/base/option/gflags_provider.cc"
|
|
"tile/base/option/json_parser.cc"
|
|
"tile/base/option/key.cc"
|
|
"tile/base/option/option_provider.cc"
|
|
"tile/base/option/option_service.cc"
|
|
"tile/base/slice.cc"
|
|
"tile/base/status.cc"
|
|
"tile/base/string.cc"
|
|
"tile/base/thread/cond_var.cc"
|
|
"tile/base/thread/latch.cc"
|
|
"tile/base/thread/mutex.cc"
|
|
"tile/base/thread/rw_mutex.cc"
|
|
"tile/base/thread/scoped_lock.cc"
|
|
"tile/base/thread/spinlock.cc"
|
|
"tile/fiber/detail/fiber.cc"
|
|
"tile/io/detail/eintr_safe.cc"
|
|
"tile/io/native/acceptor.cc"
|
|
"tile/io/descriptor.cc"
|
|
"tile/io/event_loop.cc"
|
|
"tile/init.cc"
|
|
"tile/init/on_init.cc"
|
|
"tile/init/override_flag.cc"
|
|
"tile/net/http/http_headers.cc"
|
|
"tile/net/http/http_message.cc"
|
|
"tile/net/http/http_request.cc"
|
|
"tile/net/http/http_response.cc"
|
|
"tile/net/http/http_client.cc"
|
|
"tile/net/http/types.cc"
|
|
"tile/net/internal/http_task.cc"
|
|
"tile/net/internal/http_engine.cc"
|
|
"tile/testing/internal/random_string.cc"
|
|
"tile/rpc/protocol/http/buffer_io.cc"
|
|
"tile/rpc/protocol/message.cc"
|
|
# "tile/rpc/server.cc"
|
|
)
|
|
|
|
if((NOT TILE_HAVE_GETIFADDRS) OR (NOT TILE_HAVE_FREEIFADDRS))
|
|
list(APPEND TILE_SRCS "tile/base/net/detail/android/ifaddrs.c")
|
|
endif()
|
|
|
|
add_library(tile OBJECT ${TILE_SRCS})
|
|
set_target_properties(tile PROPERTIES VERSION ${PROJECT_VERSION}
|
|
SOVERSION "${tile_VERSION_MAJRO}")
|
|
# target_sources(tile PRIVATE ${TILE_SRCS})
|
|
target_include_directories(
|
|
tile
|
|
PUBLIC "${CMAKE_CURRENT_BINARY_DIR}"
|
|
"${CMAKE_CURRENT_SOURCE_DIR}/third_party/fmt/include"
|
|
"${CMAKE_CURRENT_BINARY_DIR}/third_party/glog"
|
|
"${CMAKE_CURRENT_SOURCE_DIR}/third_party/glog/src"
|
|
"${CMAKE_CURRENT_SOURCE_DIR}"
|
|
RPIVATE
|
|
"${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include")
|
|
|
|
target_link_libraries(
|
|
tile
|
|
PUBLIC # -Wl,--start-group
|
|
nova_context
|
|
zlib
|
|
gflags::gflags
|
|
glog::glog
|
|
# -Wl,--end-group
|
|
libcurl
|
|
fmt
|
|
Threads::Threads)
|
|
if((CMAKE_SYSTEM_PROCESSOR MATCHES "riscv64") OR (CMAKE_SYSTEM_PROCESSOR MATCHES
|
|
"mips*"))
|
|
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
|
|
target_link_libraries(tile PUBLIC atomic)
|
|
endif()
|
|
endif()
|
|
|
|
# set(LIB_NAMES tile)
|
|
#
|
|
# if(("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux") OR (MINGW) OR (HAIKU) OR
|
|
# ("${CMAKE_SYSTEM_NAME}" STREQUAL "FreeBSD") OR ("${CMAKE_SYSTEM_NAME}"
|
|
# STREQUAL "GNU") OR ("${CMAKE_SYSTEM_NAME}" STREQUAL "OpenBSD") OR
|
|
# ("${CMAKE_SYSTEM_NAME}" STREQUAL "Fuchsia") OR ("${CMAKE_SYSTEM_NAME}"
|
|
# STREQUAL "DragonFly") OR ("${CMAKE_SYSTEM_NAME}" STREQUAL "SunOS")) # FIXME:
|
|
# It should be "GNU ld # for elf" set(LIB_NAMES -Wl,--whole-archive ${LIB_NAMES}
|
|
# -Wl,--no-whole-archive) elseif("${CMAKE_SYSTEM_NAME}" STREQUAL "Darwin")
|
|
# set(LIB_NAMES -Wl,-all_load ${LIB_NAMES}) endif()
|
|
|
|
add_library(tile::tile ALIAS tile)
|
|
# add_library(tile SHARED $<TARGET_OBJECTS:tile>) target_include_directories(
|
|
# tile PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/third_party/fmt/include"
|
|
# "${CMAKE_CURRENT_BINARY_DIR}/third_party/glog"
|
|
# "${CMAKE_CURRENT_SOURCE_DIR}/third_party/glog/src"
|
|
# "${CMAKE_CURRENT_SOURCE_DIR}" RPIVATE
|
|
# "${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include")
|
|
# target_link_libraries( tile PRIVATE ${WHOLE_ARCHIVE_PREFIX} gflags::gflags
|
|
# glog::glog libcurl fmt::fmt ${NO_WHOLE_ARCHIVE_PREFIX})
|
|
|
|
if(TILE_BUILD_TESTS)
|
|
enable_testing()
|
|
|
|
add_executable(tile_test_all "tile/testing/main.cc")
|
|
target_link_libraries(tile_test_all PRIVATE gtest gmock tile::tile)
|
|
|
|
macro(tile_add_test test_name test_file)
|
|
add_executable(${test_name} ${test_file} "tile/testing/main.cc")
|
|
target_link_libraries(
|
|
${test_name} PUBLIC gtest gmock ${WHOLE_ARCHIVE_PREFIX} tile::tile
|
|
${WHOLE_ARCHIVE_SUFFIX})
|
|
add_test(NAME ${test_name} COMMAND ${test_name})
|
|
|
|
target_sources(${PROJECT_NAME}_test_all PRIVATE ${test_file})
|
|
endmacro()
|
|
|
|
tile_add_test(fiber_detail_fiber_test "tile/fiber/detail/fiber_test.cc")
|
|
|
|
tile_add_test(base_internal_meta_test "tile/base/internal/meta_test.cc")
|
|
# tile_add_test(net_internal_http_engine_test
|
|
# "tile/net/internal/http_engine_test.cc")
|
|
tile_add_test(net_internal_http_task_test
|
|
"tile/net/internal/http_task_test.cc")
|
|
tile_add_test(net_http_http_client_test "tile/net/http/http_client_test.cc")
|
|
tile_add_test(net_http_http_request_test "tile/net/http/http_reqeust_test.cc")
|
|
tile_add_test(net_http_http_response_test
|
|
"tile/net/http/http_response_test.cc")
|
|
tile_add_test(base_compression_util_test "tile/base/compression/util_test.cc")
|
|
tile_add_test(rpc_protocol_http_buffer_io_test
|
|
"tile/rpc/protocol/http/buffer_io_test.cc")
|
|
|
|
tile_add_test(base_compression_test "tile/base/compression_test.cc")
|
|
tile_add_test(base_casting_test "tile/base/casting_test.cc")
|
|
tile_add_test(base_future_future_test "tile/base/future/future_test.cc")
|
|
tile_add_test(base_future_boxed_test "tile/base/future/boxed_test.cc")
|
|
tile_add_test(base_option_option_service_test
|
|
"tile/base/option/option_service_test.cc")
|
|
tile_add_test(base_ref_ptr_test "tile/base/ref_ptr_test.cc")
|
|
tile_add_test(base_object_pool_disabled_test
|
|
"tile/base/object_pool/disabled_test.cc")
|
|
tile_add_test(base_object_pool_types_test
|
|
"tile/base/object_pool/types_test.cc")
|
|
tile_add_test(base_string_test "tile/base/string_test.cc")
|
|
tile_add_test(base_deferred_test "tile/base/deferred_test.cc")
|
|
tile_add_test(base_internal_singly_linked_list_test
|
|
"tile/base/internal/singly_linked_list_test.cc")
|
|
tile_add_test(base_internal_move_on_copy_test
|
|
"tile/base/internal/move_on_copy_test.cc")
|
|
tile_add_test(base_internal_thread_pool_test
|
|
"tile/base/internal/thread_pool_test.cc")
|
|
tile_add_test(base_internal_format_test "tile/base/internal/format_test.cc")
|
|
tile_add_test(base_internal_background_task_host_test
|
|
"tile/base/internal/background_task_host_test.cc")
|
|
tile_add_test(base_down_cast_test "tile/base/down_cast_test.cc")
|
|
tile_add_test(base_encoding_hex_test "tile/base/encoding/hex_test.cc")
|
|
tile_add_test(base_encoding_percent_test "tile/base/encoding/percent_test.cc")
|
|
tile_add_test(base_encoding_base64_test "tile/base/encoding/base64_test.cc")
|
|
tile_add_test(base_internal_case_insensitive_hash_map_test
|
|
"tile/base/internal/case_insensitive_hash_map_test.cc")
|
|
tile_add_test(net_http_http_headers_test "tile/net/http/http_headers_test.cc")
|
|
tile_add_test(base_demangle_test "tile/base/demangle_test.cc")
|
|
tile_add_test(base_option_json_parser_test
|
|
"tile/base/option/json_parser_test.cc")
|
|
tile_add_test(base_option_key_test "tile/base/option/key_test.cc")
|
|
tile_add_test(base_dependency_registry_test
|
|
"tile/base/dependency_registry_test.cc")
|
|
tile_add_test(base_maybe_owning_test "tile/base/maybe_owning_test.cc")
|
|
tile_add_test(base_status_test "tile/base/status_test.cc")
|
|
tile_add_test(base_net_endpoint_test "tile/base/net/endpoint_test.cc")
|
|
tile_add_test(base_handle_test "tile/base/handle_test.cc")
|
|
tile_add_test(base_thread_scoped_lock_test
|
|
"tile/base/thread/scoped_lock_test.cc")
|
|
tile_add_test(base_thread_spinlock_test "tile/base/thread/spinlock_test.cc")
|
|
tile_add_test(base_thread_unique_lock_test
|
|
"tile/base/thread/unique_lock_test.cc")
|
|
tile_add_test(base_thread_cond_var_test "tile/base/thread/cond_var_test.cc")
|
|
tile_add_test(base_thread_latch_test "tile/base/thread/latch_test.cc")
|
|
# tile_add_test(fiber_ucontext_test "tile/fiber/ucontext_test.cc")
|
|
|
|
tile_add_test(init_on_init_test "tile/init/on_init_test.cc")
|
|
tile_add_test(base_buffer_test "tile/base/buffer_test.cc")
|
|
tile_add_test(base_object_pool_thread_local_test
|
|
"tile/base/object_pool/thread_local_test.cc")
|
|
tile_add_test(base_internal_logging_test "tile/base/internal/logging_test.cc")
|
|
tile_add_test(base_chrono_test "tile/base/chrono_test.cc")
|
|
tile_add_test(init_override_flag_test "tile/init/override_flag_test.cc")
|
|
# tile_add_test(base_internal_time_keeper_test
|
|
# "tile/base/internal/time_keeper_test.cc")
|
|
endif(TILE_BUILD_TESTS)
|
|
|
|
if(TILE_BUILD_BENCHMARKS)
|
|
add_subdirectory("third_party/benchmark")
|
|
|
|
add_executable(tile_bm_all "tile/testing/bm_main.cc")
|
|
target_link_libraries(tile_bm_all PRIVATE benchmark::benchmark tile::tile)
|
|
|
|
macro(tile_add_bm benchmark_name benchmark_file)
|
|
add_executable(${benchmark_name} ${benchmark_file}
|
|
"tile/testing/bm_main.cc")
|
|
target_link_libraries(${benchmark_name} PRIVATE benchmark::benchmark
|
|
tile::tile)
|
|
|
|
target_sources(tile_bm_all PRIVATE ${benchmark_file})
|
|
endmacro()
|
|
|
|
tile_add_bm(fiber_detail_fiber_benchmark
|
|
"tile/fiber/detail/fiber_benchmark.cc")
|
|
tile_add_bm(base_casting_benchmark "tile/base/casting_benchmark.cc")
|
|
tile_add_bm(base_thread_mutex_benchmark "tile/base/thread/mutex_benchmark.cc")
|
|
tile_add_bm(base_encoding_benchmark "tile/base/encoding_benchmark.cc")
|
|
tile_add_bm(base_internal_time_keeper_benchmark
|
|
"tile/base/internal/time_keeper_benchmark.cc")
|
|
tile_add_bm(base_chrono_benchmark "tile/base/chrono_benchmark.cc")
|
|
endif(TILE_BUILD_BENCHMARKS)
|