cmake_minimum_required(VERSION 3.20) project(secsgem LANGUAGES CXX) set(CMAKE_CXX_STANDARD 20) set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_EXTENSIONS OFF) if(NOT CMAKE_BUILD_TYPE) set(CMAKE_BUILD_TYPE Release) endif() add_compile_options(-Wall -Wextra -Wpedantic) find_package(Threads REQUIRED) # --- Asio (standalone, header-only; from libasio-dev) --------------------- find_path(ASIO_INCLUDE_DIR asio.hpp) if(NOT ASIO_INCLUDE_DIR) message(FATAL_ERROR "asio.hpp not found. Install libasio-dev.") endif() add_library(asio INTERFACE) target_include_directories(asio INTERFACE ${ASIO_INCLUDE_DIR}) target_compile_definitions(asio INTERFACE ASIO_STANDALONE ASIO_NO_DEPRECATED) target_link_libraries(asio INTERFACE Threads::Threads) # --- Core library --------------------------------------------------------- add_library(secsgem src/secs2/item.cpp src/secs2/codec.cpp src/secs2/message.cpp src/hsms/header.cpp src/hsms/frame.cpp src/hsms/connection.cpp src/gem/control_state.cpp src/gem/data_model.cpp src/endpoint.cpp ) target_include_directories(secsgem PUBLIC include) target_link_libraries(secsgem PUBLIC asio) # --- Demo executables ----------------------------------------------------- add_executable(secs_server apps/secs_server.cpp) target_link_libraries(secs_server PRIVATE secsgem) add_executable(secs_client apps/secs_client.cpp) target_link_libraries(secs_client PRIVATE secsgem) # --- Tests ---------------------------------------------------------------- enable_testing() include(FetchContent) FetchContent_Declare( doctest GIT_REPOSITORY https://github.com/doctest/doctest.git GIT_TAG v2.4.11 ) FetchContent_MakeAvailable(doctest) add_executable(secsgem_tests tests/test_main.cpp tests/test_secs2.cpp tests/test_hsms.cpp tests/test_control_state.cpp tests/test_data_model.cpp tests/test_messages.cpp ) target_link_libraries(secsgem_tests PRIVATE secsgem doctest::doctest) add_test(NAME secsgem_tests COMMAND secsgem_tests)