...
This commit is contained in:
@@ -5,6 +5,12 @@ option(SNPLIB_BUILD_EXAMPLES "Build examples" ON)
|
||||
|
||||
option(SNPLIB_USE_SPDLOG "Use of spdlog library" ON)
|
||||
|
||||
option(
|
||||
SNPLIB_USE_ASIO
|
||||
"add network related implementation using ASIO library"
|
||||
ON
|
||||
)
|
||||
|
||||
if(SNPLIB_USE_SPDLOG)
|
||||
include(FetchContent)
|
||||
# find_package(spdlog CONFIG)
|
||||
@@ -45,8 +51,47 @@ set(LIB_HEADERS
|
||||
include/snipplib/containers/snplib_hvec.h
|
||||
include/snipplib/serialization/snplib_serialization.h
|
||||
include/snipplib/network/snplib_endpoint.h
|
||||
include/snipplib/network/snplib_network.h
|
||||
)
|
||||
|
||||
if(SNPLIB_USE_ASIO)
|
||||
find_package(PkgConfig REQUIRED)
|
||||
|
||||
pkg_check_modules(ASIOLIB IMPORTED_TARGET GLOBAL asio)
|
||||
|
||||
if(NOT ASIOLIB_FOUND)
|
||||
message(STATUS "\tfetch asio-lib ...")
|
||||
|
||||
FetchContent_Declare(
|
||||
asiolib_project
|
||||
PREFIX
|
||||
${CMAKE_BINARY_DIR}/asio
|
||||
GIT_REPOSITORY "https://github.com/chriskohlhoff/asio.git"
|
||||
GIT_TAG "asio-1-38-0"
|
||||
GIT_SHALLOW 1
|
||||
)
|
||||
|
||||
FetchContent_MakeAvailable(asiolib_project)
|
||||
|
||||
execute_process(
|
||||
WORKING_DIRECTORY ${asiolib_project_SOURCE_DIR}/asio
|
||||
COMMAND ./autogen.sh
|
||||
)
|
||||
|
||||
execute_process(
|
||||
WORKING_DIRECTORY ${asiolib_project_SOURCE_DIR}/asio
|
||||
COMMAND ./configure --prefix=${asiolib_project_SOURCE_DIR}/asio
|
||||
)
|
||||
|
||||
set(ENV{PKG_CONFIG_PATH} "${asiolib_project_SOURCE_DIR}/asio")
|
||||
pkg_check_modules(ASIOLIB IMPORTED_TARGET GLOBAL asio)
|
||||
|
||||
message(STATUS "ASIO INC PATHS: ${ASIOLIB_INCLUDE_DIRS}")
|
||||
endif()
|
||||
|
||||
list(APPEND LIB_HEADERS include/snipplib/network/snplib_network_asio.h)
|
||||
endif(SNPLIB_USE_ASIO)
|
||||
|
||||
add_library(${PROJECT_NAME} INTERFACE ${LIB_HEADERS})
|
||||
target_compile_features(${PROJECT_NAME} INTERFACE cxx_std_23)
|
||||
target_include_directories(
|
||||
@@ -55,6 +100,9 @@ target_include_directories(
|
||||
"$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/include>"
|
||||
"$<INSTALL_INTERFACE:include/${PROJECT_NAME}>"
|
||||
)
|
||||
|
||||
# add dependencies
|
||||
|
||||
if(SNPLIB_USE_SPDLOG)
|
||||
target_compile_definitions(
|
||||
${PROJECT_NAME}
|
||||
@@ -64,7 +112,11 @@ if(SNPLIB_USE_SPDLOG)
|
||||
SNPLIB_SPDLOGGER=1
|
||||
)
|
||||
target_link_libraries(${PROJECT_NAME} INTERFACE spdlog::spdlog_header_only)
|
||||
endif()
|
||||
endif(SNPLIB_USE_SPDLOG)
|
||||
|
||||
if(SNPLIB_USE_ASIO)
|
||||
target_link_libraries(${PROJECT_NAME} INTERFACE PkgConfig::ASIOLIB)
|
||||
endif(SNPLIB_USE_ASIO)
|
||||
|
||||
if(SNPLIB_BUILD_EXAMPLES)
|
||||
set(EXAM_STRING str_exam)
|
||||
|
||||
Reference in New Issue
Block a user