-
Notifications
You must be signed in to change notification settings - Fork 1
/
CMakeLists.txt
106 lines (80 loc) · 2.99 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
cmake_minimum_required(VERSION 3.20)
project(Kedge VERSION 0.0.2)
# specify the C++ standard
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
# set(CMAKE_BUILD_TYPE Debug)
set(CMAKE_BUILD_TYPE RelWithDebInfo)
option(build_shared "help string describing build_shared" OFF)
if(NOT build_shared)
message(STATUS "use static build")
set(CMAKE_FIND_LIBRARY_SUFFIXES ".a")
set(BUILD_SHARED_LIBS OFF)
set(Boost_USE_STATIC_LIBS ON)
set(Boost_USE_STATIC_RUNTIME ON)
# include_directories( ${BOOST_ROOT}/include )
set(BOOST_ROOT "/opt/boost")
set(LT_ROOT "/opt/lt12")
include_directories( ${LT_ROOT}/include )
link_directories( ${LT_ROOT}/lib )
add_library(ZLIB::ZLIB STATIC IMPORTED)
add_library(torrent-rasterbar STATIC IMPORTED)
else()
message(STATUS "use shared build")
endif()
set(Boost_USE_MULTITHREADED ON)
set(REQUIRED_BOOST_LIBRARIES
system
# filesystem
program_options
# date_time
json
# iostreams
# timer
thread
)
find_package(Boost 1.76 REQUIRED COMPONENTS ${REQUIRED_BOOST_LIBRARIES})
message(STATUS "Boost include dir: " ${Boost_INCLUDE_DIR})
message(STATUS "Boost libraries: " ${Boost_LIBRARIES})
configure_file(src/const.hpp.in ../include/const.hpp)
include_directories(${PROJECT_BINARY_BIN})
# include
include_directories( "include" "src" ${Boost_INCLUDE_DIRS}, "deps" "deps/plog/include")
find_package(ZLIB REQUIRED)
message(STATUS "ZLIB libraries: " ${ZLIB_LIBRARIES})
file(GLOB_RECURSE sources RELATIVE ${CMAKE_SOURCE_DIR} "src/*.cpp")
add_executable(kedge ${sources})
if(NOT build_shared)
set_property(TARGET torrent-rasterbar PROPERTY IMPORTED_LOCATION ${LT_ROOT}/lib/libtorrent-rasterbar.a)
if(TARGET ZLIB::ZLIB)
set_property(TARGET ZLIB::ZLIB PROPERTY IMPORTED_LOCATION ${ZLIB_LIBRARIES})
endif()
else()
find_package(LibtorrentRasterbar REQUIRED)
endif()
target_link_libraries(kedge PUBLIC ${Boost_LIBRARIES} torrent-rasterbar)
find_package(OpenSSL REQUIRED)
if(TARGET OpenSSL::SSL)
target_link_libraries(kedge PUBLIC OpenSSL::SSL)
target_compile_definitions(kedge PUBLIC TORRENT_USE_OPENSSL)
endif()
if(TARGET OpenSSL::Crypto)
target_link_libraries(kedge PUBLIC OpenSSL::Crypto)
target_compile_definitions(kedge PUBLIC TORRENT_USE_LIBCRYPTO)
endif()
# target_link_libraries(kedge PUBLIC ZLIB::ZLIB)
target_link_libraries(kedge PUBLIC ${ZLIB_LIBRARIES})
include(CheckCXXSymbolExists)
check_cxx_symbol_exists(std::filesystem::path::preferred_separator filesystem cxx17fs)
set(LLVM_STATIC_LINK_CXX_STDLIB ON)
set(LLVM_ENABLE_LIBCXX ON)
if (APPLE)
target_link_libraries(kedge PRIVATE "-framework CoreFoundation" "-framework SystemConfiguration" "-framework Security" )
else()
# set(CMAKE_EXE_LINKER_FLAGS "-static")
# include_directories("/usr/include/c++/8")
target_link_libraries(kedge PRIVATE stdc++fs "-static-libgcc" "-static-libstdc++" "-ldl")
endif()
# target_compile_features(kedge PUBLIC cxx_std_17)
add_definitions(-DBOOST_BEAST_USE_STD_STRING_VIEW -DBOOST_ASIO_HAS_STD_INVOKE_RESULT)
# add_definitions(-DTORRENT_DISABLE_ALERT_MSG)