Skip to content

Commit

Permalink
wip build shared libnexus.so
Browse files Browse the repository at this point in the history
( using system installation of liblsquic.so , libssl.so, libcrypto.so )
  • Loading branch information
amdfxlucas committed Nov 23, 2023
1 parent fdb8573 commit 872b47f
Show file tree
Hide file tree
Showing 3 changed files with 81 additions and 5 deletions.
13 changes: 11 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,13 @@ set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

add_subdirectory(dependency)
set(OPENSSL_ROOT_DIR /usr/local/boringssl)
find_package(OpenSSL REQUIRED)

#list(APPEND CMAKE_PREFIX_PATH /usr/local/share/lsquic )
#find_package(lsquic CONFIG REQUIRED)

#add_subdirectory(dependency)

add_library(address-sanitizer INTERFACE)
target_compile_options(address-sanitizer INTERFACE "-fsanitize=address,undefined")
Expand All @@ -19,7 +25,10 @@ target_link_libraries(thread-sanitizer INTERFACE "-fsanitize=thread")

add_library(nexus-headers INTERFACE)
target_include_directories(nexus-headers INTERFACE include)
target_link_libraries(nexus-headers INTERFACE asio)
#target_link_libraries(nexus-headers INTERFACE asio)

target_compile_definitions(nexus-headers INTERFACE -DASIO_NO_TS_EXECUTORS)

install(DIRECTORY include/nexus DESTINATION include)
install(FILES FindNexus.cmake DESTINATION "${CMAKE_INSTALL_PREFIX}/lib/cmake/nexus" )

Expand Down
70 changes: 68 additions & 2 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,72 @@ set(nexus-srcs
stream.cc
stream_state.cc)

add_library(nexus ${nexus-srcs})
target_link_libraries(nexus PUBLIC nexus-headers lsquic)

#find_library(SSL_LIB NAMES ssl HINTS /usr/local/boringssl/lib )
set(SSL_LIB /usr/local/boringssl/lib/libssl.so )


find_path( SSL_INCLUDE_DIR
NAMES openssl/ssl.hpp
HINTS "/usr/local/boringssl/include"
)

include(FindPackageHandleStandardArgs)

find_package_handle_standard_args(
ssl
DEFAULT_MSG
SSL_LIB
SSL_INCLUDE_DIR
)

mark_as_advanced( SSL_INCLUDE_DIR SSL_LIB)

if(NOT TARGET ssl::ssl )
add_library( ssl::ssl SHARED IMPORTED GLOBAL)
set_target_properties( ssl::ssl PROPERTIES
IMPORTED_LOCATION "${SSL_LIB}"
INTERFACE_INCLUDE_DIRECTORIES "${SSL_INCLUDE_DIR}"
IMPORTED_LINK_INTERFACE_LANGUAGES "CXX"
)
endif()
############################################
find_library(CRYPTO_LIB NAMES crypto HINTS
/usr/local/boringssl/lib)


##############################################

add_library( lsquic SHARED IMPORTED GLOBAL)

#find_library(LSQUIC_LIB NAMES lsquic HINTS /usr/local/lib)


find_path( LSQUIC_INCLUDE_DIR
NAMES lsquic/lsquic.h
HINTS /usr/local/include
)

set(LSQUIC_LIB /usr/local/lib/liblsquic.so )

find_package_handle_standard_args(
lsquic
DEFAULT_MSG
LSQUIC_LIB
LSQUIC_INCLUDE_DIR
)

mark_as_advanced( LSQUIC_INCLUDE_DIR LSQUIC_LIB)
set_target_properties( lsquic PROPERTIES
IMPORTED_LOCATION "${LSQUIC_LIB}"
INTERFACE_INCLUDE_DIRECTORIES "${LSQUIC_INCLUDE_DIR}"
IMPORTED_LINK_INTERFACE_LANGUAGES "CXX"
)


########################################################

add_library(nexus SHARED ${nexus-srcs})
target_link_libraries(nexus PUBLIC nexus-headers OpenSSL::SSL OpenSSL::Crypto lsquic)
target_include_directories( nexus PUBLIC /usr/local/include/lsquic )
install(TARGETS nexus LIBRARY DESTINATION ${CMAKE_INSTALL_PREFIX}/lib/nexus)
3 changes: 2 additions & 1 deletion src/socket.cc
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ static udp::socket bind_socket(const boost::asio::any_io_executor& ex,
void socket_impl::bind( const udp::endpoint& local_endp)
{
local_addr = local_endp;
*socket = bind_socket(engine.get_executor() ,local_endp,true);
//*socket = bind_socket(engine.get_executor() ,local_endp,true);
socket.construct( bind_socket(engine.get_executor() ,local_endp,true) );
}

void socket_impl::listen( const udp::endpoint& local_endp, int backlog )
Expand Down

0 comments on commit 872b47f

Please sign in to comment.