ranczo-io/CMakeLists.txt
Bartosz Wieczorek 11b4517d5d working listener
2025-08-05 11:41:57 +02:00

94 lines
2.7 KiB
CMake

cmake_minimum_required(VERSION 3.20)
project(Ranczo-IO)
set(CMAKE_CXX_STANDARD 23)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
# find_package(Protobuf REQUIRED)
# include_directories(${Protobuf_INCLUDE_DIRS})
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include)
set(BOOST_ROOT /usr/local)
find_package(Boost REQUIRED COMPONENTS system json)
include(FetchContent)
# Create a Boost-style interface target for a header-only library
function(create_boost_header_only_target target_name)
string(TOLOWER ${target_name} target_key)
set(interface_target ${target_key}_interface)
set(header_subdir ${target_key})
if(NOT TARGET Boost::${target_name})
message(STATUS "Creating Boost::${target_name} as header-only interface target")
add_library(${interface_target} INTERFACE)
# Add include dir if not explicitly set
if(DEFINED Boost_INCLUDE_DIRS)
target_include_directories(${interface_target} INTERFACE ${Boost_INCLUDE_DIRS})
else()
message(WARNING "Boost_INCLUDE_DIRS not defined when creating Boost::${target_name}")
endif()
# Optional preprocessor tweaks per library
if(${target_name} STREQUAL "asio")
target_compile_definitions(${interface_target} INTERFACE BOOST_ASIO_NO_DEPRECATED)
endif()
# Create alias for consistency with imported targets
add_library(Boost::${target_name} ALIAS ${interface_target})
else()
message(STATUS "Boost::${target_name} already exists")
endif()
endfunction()
create_boost_header_only_target(asio)
create_boost_header_only_target(assert)
create_boost_header_only_target(core)
create_boost_header_only_target(endian)
create_boost_header_only_target(fusion)
create_boost_header_only_target(optional)
create_boost_header_only_target(random)
create_boost_header_only_target(range)
create_boost_header_only_target(smart_ptr)
create_boost_header_only_target(spirit)
create_boost_header_only_target(type_traits)
# spdlog
FetchContent_Declare(
spdlog
GIT_REPOSITORY https://github.com/gabime/spdlog
GIT_TAG v1.14.1
GIT_SHALLOW TRUE
)
FetchContent_GetProperties(spdlog)
if(NOT spdlog_POPULATED)
FetchContent_Populate(spdlog)
# set(SPDLOG_FMT_EXTERNAL_HO ON)
set(SPDLOG_USE_STD_FORMAT ON)
endif()
add_subdirectory(
${spdlog_SOURCE_DIR}
${spdlog_BINARY_DIR}
)
FetchContent_Declare(
asyncmqtt5
GIT_REPOSITORY https://github.com/mireo/async-mqtt5
GIT_TAG master
GIT_SHALLOW TRUE
)
set(MQTT_BUILD_TESTS OFF)
set(MQTT_BUILD_EXAMPLES OFF)
set(async-mqtt5_INCLUDES_WITH_SYSTEM OFF)
FetchContent_MakeAvailable(asyncmqtt5)
include_directories(${CMAKE_CURRENT_SOURCE_DIR})
add_subdirectory(libs)
add_subdirectory(services)
add_subdirectory(tests)