cmake_minimum_required(VERSION 3.0)

project(tinyrpc)



set(CMAKE_CXX_STANDARD 17)

enable_language(CXX ASM)

add_compile_options(-g -Wall)

include_directories(includes/coroutine)
include_directories(includes/log)
include_directories(includes/net)
include_directories(includes/net/tcp)
include_directories(includes/net/tinypb)

aux_source_directory(${CMAKE_SOURCE_DIR}/src SRC_LIST)
aux_source_directory(${CMAKE_SOURCE_DIR}/src/coroutine COROUTINE_SRC_LIST)
aux_source_directory(${CMAKE_SOURCE_DIR}/src/net NET_SRC_LIST)
aux_source_directory(${CMAKE_SOURCE_DIR}/src/net/tcp TCP_SRC_LIST)
aux_source_directory(${CMAKE_SOURCE_DIR}/src/net/tinypb TINYPB_SRC_LIST)


set(ASM_FILES ${CMAKE_SOURCE_DIR}/src/coroutine/coctx_swap.S)

set(EXECUTABLE_OUTPUT_PATH ${CMAKE_SOURCE_DIR}/bin)
set(LIBRARY_OUTPUT_PATH  ${CMAKE_SOURCE_DIR}/bin)

# find_library(TINYRPC_LIB tinyrpc ${CMAKE_SOURCE_DIR}/lib)


add_library(tinyrpc 
        # ${SRC_LIST}
        ${COROUTINE_SRC_LIST}
        ${TCP_SRC_LIST}
        ${NET_SRC_LIST}
        ${TINYPB_SRC_LIST}
        ${ASM_FILES} 
)

aux_source_directory(${CMAKE_SOURCE_DIR}/test/returntest TEST_SRC_LIST)


add_executable(test_tinyrpc 
        ${TEST_SRC_LIST}
)

# 引入 abseil-cpp 子目录
add_subdirectory(./third_party/abseil-cpp absl)

set(ABSEL_LIBARARY
    absl::absl_check
    absl::absl_log
    absl::algorithm
    absl::base
    absl::bind_front
    absl::bits
    absl::btree
    absl::cleanup
    absl::cord
    absl::core_headers
    absl::debugging
    absl::die_if_null
    absl::dynamic_annotations
    absl::flags
    absl::flat_hash_map
    absl::flat_hash_set
    absl::function_ref
    absl::hash
    absl::layout
    absl::log_initialize
    absl::log_severity
    absl::memory
    absl::node_hash_map
    absl::node_hash_set
    absl::optional
    absl::span
    absl::status
    absl::statusor
    absl::strings
    absl::synchronization
    absl::time
    absl::type_traits
    absl::utility
    absl::variant
)

# 链接库
target_link_libraries(tinyrpc PRIVATE protobuf)  # 链接 Protobuf 库
target_link_libraries(tinyrpc PRIVATE ${ABSEL_LIBARARY})  # 链接 Protobuf 库
target_link_libraries(test_tinyrpc PRIVATE tinyrpc)




