sled/CMakeLists.txt

114 lines
3.5 KiB
CMake
Raw Normal View History

2024-03-01 19:40:00 +08:00
cmake_minimum_required(VERSION 3.10)
project(sled VERSION 0.1.0 LANGUAGES C CXX)
2024-02-23 18:07:37 +08:00
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_STANDARD_EXTENSIONS OFF)
2024-02-28 15:43:32 +08:00
option(SLED_BUILD_BENCHMARK "Build benchmark" OFF)
2024-03-01 14:50:55 +08:00
option(SLED_BUILD_TESTS "Build tests" OFF)
2024-03-07 13:05:09 +08:00
option(SLED_LOCATION_PATH "" "sled/src/system/location.cc")
2024-02-28 15:43:32 +08:00
2024-02-23 18:07:37 +08:00
set(BUILD_STATIC ON)
set(BUILD_RTTR_DYNAMIC OFF)
set(BUILD_UNIT_TESTS OFF)
set(BUILD_EXAMPLES OFF)
add_library(sled STATIC "")
2024-03-13 18:11:02 +08:00
add_subdirectory(3party/protobuf-3.21.12 EXCLUDE_FROM_ALL)
2024-03-08 18:05:40 +08:00
if (NOT TARGET marl)
add_subdirectory(3party/marl EXCLUDE_FROM_ALL)
endif()
2024-03-07 10:10:16 +08:00
if (NOT TARGET rpc_core)
add_subdirectory(3party/rpc_core EXCLUDE_FROM_ALL)
endif()
if (NOT TARGET fmt)
add_subdirectory(3party/fmt EXCLUDE_FROM_ALL)
endif()
2024-03-07 13:05:09 +08:00
if (SLED_LOCATION_PATH)
target_compile_definitions(sled PRIVATE __SLED_LOCATION_PATH="${SLED_LOCATION_PATH}")
2024-03-07 12:43:25 +08:00
endif()
2024-02-23 18:07:37 +08:00
# add_subdirectory(3party/eigen EXCLUDE_FROM_ALL)
2024-03-14 20:50:17 +08:00
target_include_directories(sled PUBLIC 3party/eigen 3party/inja 3party/rxcpp)
2024-02-23 18:07:37 +08:00
target_sources(
sled
2024-03-03 12:30:15 +08:00
PRIVATE
src/filesystem/path.cc
src/log/log.cc
2024-02-23 18:07:37 +08:00
src/network/async_resolver.cc
src/network/ip_address.cc
src/network/null_socket_server.cc
src/network/physical_socket_server.cc
src/network/socket_address.cc
src/network/socket_server.cc
src/strings/base64.cc
2024-03-03 00:46:50 +08:00
src/strings/utils.cc
2024-02-23 18:07:37 +08:00
src/synchronization/event.cc
src/synchronization/mutex.cc
src/synchronization/sequence_checker_internal.cc
src/synchronization/thread_local.cc
2024-02-28 00:23:29 +08:00
src/system/location.cc
2024-03-14 17:55:44 +08:00
src/system/pid.cc
2024-02-23 18:07:37 +08:00
src/system/thread.cc
2024-03-11 14:24:15 +08:00
src/system/thread_pool.cc
2024-02-23 18:07:37 +08:00
src/task_queue/pending_task_safety_flag.cc
src/task_queue/task_queue_base.cc
2024-03-07 21:10:13 +08:00
src/timer/task_queue_timeout.cc
src/timer/timer.cc
2024-02-23 18:07:37 +08:00
src/units/time_delta.cc
src/units/timestamp.cc
src/operations_chain.cc
src/random.cc
src/sigslot.cc
src/status.cc
src/system_time.cc
src/time_utils.cc)
# set(BUILD_RTTR_DYNAMIC OFF) set(BUILD_UNIT_TESTS OFF)
# set(BUILD_WITH_STATIC_RUNTIME_LIBS ON) set(BUILD_WITH_DOCUMENTATION OFF)
# add_subdirectory(3party/rttr EXCLUDE_FROM_ALL)
target_include_directories(
sled
PUBLIC include
PRIVATE src)
2024-03-13 18:11:02 +08:00
target_link_libraries(sled PUBLIC rpc_core fmt marl protobuf::libprotobuf)
2024-02-24 10:31:28 +08:00
2024-02-28 15:43:32 +08:00
if(SLED_BUILD_BENCHMARK)
2024-03-13 18:11:02 +08:00
if (NOT TARGET benchmark)
find_package(benchmark REQUIRED)
endif()
2024-02-24 10:31:28 +08:00
2024-03-10 22:26:33 +08:00
add_executable(sled_benchmark
src/random_bench.cc
src/strings/base64_bench.cc
src/system/fiber/fiber_bench.cc
2024-03-11 14:24:15 +08:00
src/system/thread_pool_bench.cc
src/system_time_bench.cc)
2024-02-28 15:43:32 +08:00
target_link_libraries(sled_benchmark PRIVATE sled benchmark::benchmark
benchmark::benchmark_main)
endif(SLED_BUILD_BENCHMARK)
2024-03-01 14:50:55 +08:00
if(SLED_BUILD_TESTS)
2024-03-10 21:51:51 +08:00
include(FetchContent)
FetchContent_Declare(
googletest
URL https://github.com/google/googletest/archive/03597a01ee50ed33e9dfd640b249b4be3799d395.zip
)
FetchContent_MakeAvailable(googletest)
add_executable(sled_tests
src/filesystem/path_test.cc
src/strings/base64_test.cc
src/cleanup_test.cc
src/status_or_test.cc
src/system/fiber/fiber_test.cc
2024-03-11 14:24:15 +08:00
src/system/thread_pool_test.cc
2024-03-14 20:50:17 +08:00
src/rx_test.cc
2024-03-10 21:51:51 +08:00
)
target_link_libraries(sled_tests PRIVATE sled GTest::gtest GTest::gtest_main)
add_test(NAME sled_tests COMMAND sled_tests)
2024-03-01 14:50:55 +08:00
endif(SLED_BUILD_TESTS)