add depedencies to cxx/CMakeLists.txt (ASIO and spdlog)
This commit is contained in:
parent
aefdf3912c
commit
407a805c30
27
cmake/FindASIO.cmake
Normal file
27
cmake/FindASIO.cmake
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
#
|
||||||
|
# ASIO
|
||||||
|
#
|
||||||
|
|
||||||
|
set(ASIO_FOUND FALSE)
|
||||||
|
|
||||||
|
find_package(Threads REQUIRED)
|
||||||
|
|
||||||
|
find_path(ASIO_DIR asio.hpp HINTS ${ASIO_INSTALL_DIR} PATH_SUFFIXES include)
|
||||||
|
|
||||||
|
if (NOT ASIO_DIR)
|
||||||
|
message(WARNING "Cannot find ASIO library headers!")
|
||||||
|
set(ASIO_FOUND FALSE)
|
||||||
|
else()
|
||||||
|
message(STATUS "Found ASIO: TRUE (${ASIO_DIR})")
|
||||||
|
|
||||||
|
# ASIO is header-only library so it is IMPORTED target
|
||||||
|
add_library(ASIO::ASIO INTERFACE IMPORTED GLOBAL)
|
||||||
|
|
||||||
|
# set standalone version (do not use Boost)
|
||||||
|
set_target_properties(ASIO::ASIO PROPERTIES INTERFACE_COMPILE_DEFINITIONS "ASIO_STANDALONE" INTERFACE_INCLUDE_DIRECTORIES "${ASIO_DIR}")
|
||||||
|
|
||||||
|
target_link_libraries(ASIO::ASIO INTERFACE Threads::Threads)
|
||||||
|
set(ASIO_FOUND TRUE)
|
||||||
|
|
||||||
|
endif()
|
||||||
|
|
||||||
@ -3,6 +3,67 @@ cmake_minimum_required(VERSION 3.14)
|
|||||||
set(CMAKE_CXX_STANDARD 20)
|
set(CMAKE_CXX_STANDARD 20)
|
||||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||||
|
|
||||||
|
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake")
|
||||||
|
|
||||||
|
find_package(ASIO QUIET)
|
||||||
|
if (ASIO_FOUND)
|
||||||
|
# message(STATUS "ASIO library was found")
|
||||||
|
else()
|
||||||
|
message(STATUS "ASIO library was not found! Try to download it!")
|
||||||
|
|
||||||
|
include(FetchContent)
|
||||||
|
include(ExternalProject)
|
||||||
|
|
||||||
|
FetchContent_Declare(asio_lib
|
||||||
|
SOURCE_DIR ${CMAKE_BINARY_DIR}/asio_lib
|
||||||
|
BINARY_DIR ${CMAKE_BINARY_DIR}
|
||||||
|
GIT_REPOSITORY "https://github.com/chriskohlhoff/asio"
|
||||||
|
GIT_TAG "asio-1-32-0"
|
||||||
|
GIT_SHALLOW TRUE
|
||||||
|
GIT_SUBMODULES ""
|
||||||
|
GIT_PROGRESS TRUE
|
||||||
|
)
|
||||||
|
FetchContent_MakeAvailable(asio_lib)
|
||||||
|
# FetchContent_GetProperties(asio_lib SOURCE_DIR asio_SOURCE_DIR)
|
||||||
|
|
||||||
|
set(ASIO_INSTALL_DIR ${CMAKE_BINARY_DIR}/asio_lib/asio)
|
||||||
|
find_package(ASIO)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
find_package(spdlog CONFIG)
|
||||||
|
# set(SPDLOG_USE_STD_FORMAT ON)
|
||||||
|
# set(SPDLOG_FMT_EXTERNAL OFF )
|
||||||
|
# set(SPDLOG_MASTER_PROJECT OFF)
|
||||||
|
# set(SPDLOG_BUILD_EXAMPLE OFF)
|
||||||
|
|
||||||
|
set(spdlog_FOUND FALSE )
|
||||||
|
if (NOT spdlog_FOUND)
|
||||||
|
message(STATUS "SPDLOG libarary was not found! Try to download it!")
|
||||||
|
|
||||||
|
include(FetchContent)
|
||||||
|
include(ExternalProject)
|
||||||
|
|
||||||
|
# FetchContent_Declare(spdlog
|
||||||
|
ExternalProject_Add(spdlog
|
||||||
|
# SOURCE_DIR ${CMAKE_BINARY_DIR}/spdlog_lib
|
||||||
|
# BINARY_DIR ${CMAKE_BINARY_DIR}/spdlog_lib/build
|
||||||
|
GIT_REPOSITORY "https://github.com/gabime/spdlog.git"
|
||||||
|
GIT_TAG "v1.15.1"
|
||||||
|
GIT_SHALLOW TRUE
|
||||||
|
GIT_SUBMODULES ""
|
||||||
|
GIT_PROGRESS TRUE
|
||||||
|
CMAKE_ARGS "-DSPDLOG_USE_STD_FORMAT=ON -DSPDLOG_FMT_EXTERNAL=OFF"
|
||||||
|
# CONFIGURE_COMMAND ""
|
||||||
|
# BUILD_COMMAND ""
|
||||||
|
INSTALL_COMMAND ""
|
||||||
|
# UPDATE_COMMAND ""
|
||||||
|
# SOURCE_SUBDIR cmake
|
||||||
|
)
|
||||||
|
# FetchContent_MakeAvailable(spdlog)
|
||||||
|
# FetchContent_GetProperties(spdlog_lib SOURCE_DIR spdlog_SOURCE_DIR)
|
||||||
|
# find_package(spdlog REQUIRED)
|
||||||
|
endif()
|
||||||
|
|
||||||
option(WITH_TESTS "Build tests" ON)
|
option(WITH_TESTS "Build tests" ON)
|
||||||
|
|
||||||
# Mount client-to-server communication protocol
|
# Mount client-to-server communication protocol
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user