Reactor/loop-pool engine with TCP/µTP/MSE transports, per-connection pipelining, priority-driven piece selection with endgame, and the Python FFI test harness. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
58 lines
1.7 KiB
CMake
58 lines
1.7 KiB
CMake
cmake_minimum_required(VERSION 3.16)
|
|
project(torrent_peer C)
|
|
|
|
set(CMAKE_C_STANDARD 11)
|
|
set(CMAKE_C_STANDARD_REQUIRED ON)
|
|
|
|
if(NOT CMAKE_BUILD_TYPE)
|
|
set(CMAKE_BUILD_TYPE Release)
|
|
endif()
|
|
|
|
# Fast by default; -march=native is great for local benchmarking. Disable with
|
|
# -DPEER_NATIVE=OFF for portable / CI builds.
|
|
option(PEER_NATIVE "Optimize for the build host (-march=native)" ON)
|
|
option(PEER_ASAN "Build with AddressSanitizer/UBSan" OFF)
|
|
|
|
add_library(torrentpeer SHARED
|
|
src/engine.c
|
|
src/loop.c
|
|
src/connection.c
|
|
src/transport.c
|
|
src/transport_mse.c
|
|
src/transport_utp.c
|
|
src/crypto.c
|
|
src/proto.c
|
|
src/scheduler.c
|
|
src/reqtab.c
|
|
src/ring.c
|
|
src/arena.c
|
|
src/peer_compat.c
|
|
)
|
|
target_include_directories(torrentpeer PUBLIC include)
|
|
|
|
target_compile_options(torrentpeer PRIVATE
|
|
-O3 -Wall -Wextra -Wno-unused-parameter
|
|
)
|
|
if(PEER_NATIVE AND NOT PEER_ASAN)
|
|
target_compile_options(torrentpeer PRIVATE -march=native)
|
|
endif()
|
|
if(PEER_ASAN)
|
|
target_compile_options(torrentpeer PRIVATE -O1 -g -fsanitize=address,undefined -fno-omit-frame-pointer)
|
|
target_link_options(torrentpeer PRIVATE -fsanitize=address,undefined)
|
|
endif()
|
|
|
|
find_package(Threads REQUIRED)
|
|
target_link_libraries(torrentpeer PRIVATE Threads::Threads)
|
|
|
|
# P3a: link-time optimization for release builds (skipped under ASan).
|
|
option(PEER_LTO "Enable link-time optimization" ON)
|
|
if(PEER_LTO AND NOT PEER_ASAN)
|
|
include(CheckIPOSupported)
|
|
check_ipo_supported(RESULT _ipo_ok OUTPUT _ipo_msg)
|
|
if(_ipo_ok)
|
|
set_target_properties(torrentpeer PROPERTIES INTERPROCEDURAL_OPTIMIZATION ON)
|
|
endif()
|
|
endif()
|
|
|
|
# Keep the .so name predictable for ctypes: libtorrentpeer.so
|
|
set_target_properties(torrentpeer PROPERTIES OUTPUT_NAME torrentpeer)
|