@@ -36,6 +36,7 @@ option(PHOTON_ENABLE_RSOCKET "enable rsocket" OFF)
3636option (PHOTON_ENABLE_LIBCURL "enable libcurl" ON )
3737set (PHOTON_DEFAULT_LOG_LEVEL "0" CACHE STRING "default log level" )
3838option (PHOTON_BUILD_OCF_CACHE "enable ocf cache" OFF )
39+ option (PHOTON_ENABLE_KCP "enable kcp" OFF )
3940
4041option (PHOTON_BUILD_DEPENDENCIES "" OFF )
4142set (PHOTON_AIO_SOURCE "https://pagure.io/libaio/archive/libaio-0.3.113/libaio-0.3.113.tar.gz" CACHE STRING "" )
@@ -60,6 +61,7 @@ set(PHOTON_RAPIDYAML_SOURCE "https://github.com/biojppm/rapidyaml/releases/downl
6061# It's not recommended to build rdmacore from source because it has too many dependencies. Install it to local host.
6162# The release version we use is https://github.com/linux-rdma/rdma-core/releases/download/v58.0/rdma-core-58.0.tar.gz
6263set (PHOTON_RDMACORE_SOURCE "" CACHE STRING "" )
64+ set (PHOTON_KCP_SOURCE "https://github.com/skywind3000/kcp/archive/refs/tags/2.1.1.tar.gz" CACHE STRING "" )
6365
6466if (NOT (CMAKE_SYSTEM_PROCESSOR STREQUAL x86_64) AND NOT (CMAKE_SYSTEM_PROCESSOR STREQUAL aarch64) AND NOT (CMAKE_SYSTEM_PROCESSOR STREQUAL arm64))
6567 message (FATAL_ERROR "Unknown CPU architecture ${CMAKE_SYSTEM_PROCESSOR } " )
@@ -180,6 +182,9 @@ endif ()
180182if (PHOTON_ENABLE_LIBCURL)
181183 LIST (APPEND dependencies curl)
182184endif ()
185+ if (PHOTON_ENABLE_KCP)
186+ LIST (APPEND dependencies kcp)
187+ endif ()
183188if (PHOTON_BUILD_TESTING)
184189 LIST (APPEND dependencies gflags googletest)
185190endif ()
@@ -188,7 +193,11 @@ FOREACH (dep ${dependencies})
188193 message (STATUS "Checking dependency ${dep} " )
189194 string (TOUPPER ${dep} DEP)
190195 set (source_url "${PHOTON_${DEP} _SOURCE}" )
191- if (PHOTON_BUILD_DEPENDENCIES AND (NOT source_url STREQUAL "" ))
196+ if (dep STREQUAL "kcp" )
197+ message (STATUS "Will build ${dep} from source" )
198+ message (STATUS " URL: ${source_url} " )
199+ build_from_src (dep )
200+ elseif (PHOTON_BUILD_DEPENDENCIES AND (NOT source_url STREQUAL "" ))
192201 message (STATUS "Will build ${dep} from source" )
193202 message (STATUS " URL: ${source_url} " )
194203 build_from_src (dep )
@@ -282,6 +291,9 @@ if (PHOTON_ENABLE_ECOSYSTEM)
282291 file (GLOB ECOSYSTEM_SRC ecosystem/*.cpp )
283292 list (APPEND PHOTON_SRC ${ECOSYSTEM_SRC} )
284293endif ()
294+ if (NOT PHOTON_ENABLE_KCP)
295+ list (REMOVE_ITEM PHOTON_SRC net/kcp.cpp)
296+ endif ()
285297if (PHOTON_ENABLE_RSOCKET)
286298 list (APPEND PHOTON_SRC net/rsocket/rsocket.cpp)
287299endif ()
@@ -338,6 +350,10 @@ endif()
338350if (PHOTON_DEFAULT_LOG_LEVEL)
339351 target_compile_definitions (photon_obj PRIVATE DEFAULT_LOG_LEVEL=${PHOTON_DEFAULT_LOG_LEVEL} )
340352endif ()
353+ if (PHOTON_ENABLE_KCP)
354+ target_include_directories (photon_obj PRIVATE ${kcp_SOURCE_DIR } )
355+ target_compile_definitions (photon_obj PRIVATE PHOTON_KCP=on )
356+ endif ()
341357
342358if (actually_built)
343359 add_dependencies (photon_obj ${actually_built} )
@@ -397,6 +413,10 @@ if (PHOTON_BUILD_OCF_CACHE)
397413endif ()
398414list (APPEND static_deps ${OPENSSL_LIBRARIES} ${ZLIB_LIBRARIES} )
399415
416+ if (PHOTON_ENABLE_KCP)
417+ list (APPEND static_deps ${kcp_static} )
418+ endif ()
419+
400420
401421# Find out dynamic libs and append to `shared_deps`.
402422# Because if not built from source, we won't know the local packages are static or shared.
0 commit comments