ranczo-io/CMakeLists.txt
Bartosz Wieczorek 6da01a2f6b Add HTTP get
2025-12-12 16:57:05 +01:00

103 lines
3.2 KiB
CMake

cmake_minimum_required(VERSION 3.20)
project(Ranczo-IO)
set(CMAKE_CXX_STANDARD 23)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
# add_compile_options(-g -fsanitize=address,undefined,float-divide-by-zero,float-cast-overflow,null -fsanitize-address-use-after-scope -fno-sanitize-recover=all -fno-sanitize=alignment -fno-omit-frame-pointer)
# add_link_options(-g -fsanitize=address,undefined,float-divide-by-zero,float-cast-overflow,null -fsanitize-address-use-after-scope -fno-sanitize-recover=all -fno-sanitize=alignment -fno-omit-frame-pointer)
set(CMAKE_INSTALL_PREFIX "/usr" CACHE PATH "Install prefix" FORCE)
include(CheckIPOSupported)
check_ipo_supported(RESULT supported OUTPUT error)
add_compile_options(-march=native)
if( supported )
message(STATUS "IPO / LTO enabled")
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE)
else()
message(STATUS "IPO / LTO not supported: <${error}>")
endif()
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include)
include(FetchContent)
set(BOOST_INCLUDE_LIBRARIES asio assert core endian json mqtt5 fusion optional random range smart_ptr spirit type_traits url)
set(BOOST_ENABLE_CMAKE ON)
set(Boost_NO_SYSTEM_PATHS ON)
set(BOOST_ROOT /usr/local/boost-1.89)
find_package(Boost 1.89 REQUIRED COMPONENTS json mqtt5 url)
# spdlog
include(CheckCXXSourceCompiles)
set(CHECK_STD_FORMAT_SRC "
#include <format>
int main() { std::string s = std::format(\"{} {}\", 1, 2); return 0; } "
)
check_cxx_source_compiles("${CHECK_STD_FORMAT_SRC}" HAS_STD_FORMAT)
if (HAS_STD_FORMAT)
message(STATUS "Compiler supports <format> → SPDLOG_USE_STD_FORMAT=ON")
set(SPDLOG_USE_STD_FORMAT ON CACHE BOOL "" FORCE)
else()
message(STATUS "Compiler does NOT support <format> → SPDLOG_USE_STD_FORMAT=OFF")
set(SPDLOG_USE_STD_FORMAT OFF CACHE BOOL "" FORCE)
endif()
FetchContent_Declare(
spdlog
GIT_REPOSITORY https://github.com/gabime/spdlog
GIT_TAG v1.14.1
GIT_SHALLOW TRUE
)
set(EXPECTED_BUILD_TESTS FALSE)
FetchContent_Declare(
tl_expected
GIT_REPOSITORY https://github.com/TartanLlama/expected.git
GIT_TAG v1.1.0
)
FetchContent_Declare(date_src
URL https://github.com/HowardHinnant/date/archive/refs/tags/v3.0.3.zip
URL_MD5 0a21a588a31fb234202546deccea65e4
UPDATE_DISCONNECTED 1
)
# c++20 format library, super usefull, super fast
set(FMT_TEST OFF CACHE INTERNAL "disabling fmt tests")
set(FMT_FUZZ OFF CACHE INTERNAL "disabling fmt fuzz")
FetchContent_Declare(fmt
URL https://github.com/fmtlib/fmt/archive/refs/tags/10.2.1.zip
URL_MD5 1bba4e8bdd7b0fa98f207559ffa380a3
)
FetchContent_MakeAvailable(fmt spdlog tl_expected date_src)
include_directories(${CMAKE_CURRENT_SOURCE_DIR})
# add_compile_definitions(BOOST_ASIO_ENABLE_HANDLER_TRACKING)
add_subdirectory(libs)
add_subdirectory(services)
add_subdirectory(tests)
set(CPACK_GENERATOR "DEB")
# Nazwa "globalna" projektu
set(CPACK_PACKAGE_NAME "ranczo-io")
set(CPACK_PACKAGE_VENDOR "evlabs")
set(CPACK_PACKAGE_VERSION "1.0.0")
set(CPACK_PACKAGE_CONTACT "b.wieczorek@dx.net.pl")
# Używamy komponentów, żeby mieć osobne DEB-y
set(CPACK_DEB_COMPONENT_INSTALL ON)
set(CPACK_DEBIAN_FILE_NAME DEB-DEFAULT)
set(CPACK_COMPONENTS_ALL floorheating temperature) # później dodasz temperature itd.
include(CPack)