107 lines
3.3 KiB
CMake
107 lines
3.3 KiB
CMake
cmake_minimum_required(VERSION 3.14)
|
|
|
|
# set(CMAKE_BUILD_TYPE Release)
|
|
|
|
set(CMAKE_CXX_STANDARD 20)
|
|
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_FOUND FALSE )
|
|
if (NOT spdlog_FOUND)
|
|
message(STATUS "SPDLOG libarary was not found! Try to download it!")
|
|
|
|
include(FetchContent)
|
|
include(ExternalProject)
|
|
|
|
set(SPDLOG_USE_STD_FORMAT ON CACHE INTERNAL "Use of C++20 std::format")
|
|
set(SPDLOG_FMT_EXTERNAL OFF CACHE INTERNAL "Turn off external fmt library")
|
|
|
|
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 # turn off building
|
|
OVERRIDE_FIND_PACKAGE
|
|
)
|
|
# FetchContent_MakeAvailable(spdlog)
|
|
# FetchContent_GetProperties(spdlog_lib SOURCE_DIR spdlog_SOURCE_DIR)
|
|
find_package(spdlog CONFIG)
|
|
endif()
|
|
|
|
add_compile_definitions(SPDLOG_USE_STD_FORMAT)
|
|
add_compile_definitions(SPDLOG_FMT_EXTERNAL=0)
|
|
|
|
option(WITH_TESTS "Build tests" ON)
|
|
|
|
# Mount client-to-server communication protocol
|
|
# (extended LX200 protocol)
|
|
#
|
|
|
|
# set(CNTR_PROTO_LIB_SRC comm_proto.h comm_proto.cpp)
|
|
set(CNTR_PROTO_LIB_SRC
|
|
control_proto.h
|
|
control_proto.cpp
|
|
utils.h
|
|
)
|
|
|
|
set(CNTR_PROTO_LIB comm_proto)
|
|
add_library(${CNTR_PROTO_LIB} STATIC ${CNTR_PROTO_LIB_SRC})
|
|
|
|
set(MOUNT_SERVER_APP_SRC mount.h mount_server.cpp comm_server.h comm_server_endpoint.h)
|
|
set(MOUNT_SERVER_APP mount_server)
|
|
add_executable(${MOUNT_SERVER_APP} ${MOUNT_SERVER_APP_SRC}
|
|
comm_server_configfile.h)
|
|
target_link_libraries(${MOUNT_SERVER_APP} ${CNTR_PROTO_LIB} spdlog::spdlog_header_only)
|
|
|
|
if (WITH_TESTS)
|
|
set(CNTR_PROTO_TEST_APP cntr_proto_test)
|
|
add_executable(${CNTR_PROTO_TEST_APP} tests/cntr_proto_test.cpp)
|
|
target_link_libraries(${CNTR_PROTO_TEST_APP} ${CNTR_PROTO_LIB} spdlog::spdlog_header_only)
|
|
# target_link_libraries(${CNTR_PROTO_TEST_APP} ${CNTR_PROTO_LIB})
|
|
# target_include_directories(${CNTR_PROTO_TEST_APP} PUBLIC ${SPDLOG_INCLUDE_DIRS})
|
|
|
|
set(CFGFILE_TEST_APP configfile_test)
|
|
add_executable(${CFGFILE_TEST_APP} tests/configfile_test.cpp)
|
|
|
|
set(ASTROM_TEST_APP astrom_test)
|
|
add_executable(${ASTROM_TEST_APP} tests/astrom_test.cpp)
|
|
endif()
|