cmake_minimum_required(VERSION 3.20) project(Rhiannon VERSION 1.0 LANGUAGES CXX) set(CMAKE_CXX_STANDARD 20) set(CMAKE_CXX_STANDARD_REQUIRED ON) option(RHIANNON_WITH_MIDI_OSC "Enable PortMIDI + liblo bridge" OFF) option(RHIANNON_WITH_WS "Enable WebSocket metrics (uWebSockets)" OFF) option(RHIANNON_WITH_METAL "Enable Metal on Apple platforms" OFF) option(RHIANNON_WITH_AVX2 "Enable AVX2 SIMD where supported" OFF) option(RHIANNON_ENABLE_TESTS "Build unit tests" ON) # Dependencies (header-only or optional) find_package(spdlog QUIET) find_package(nlohmann_json QUIET) include(FetchContent) if(NOT nlohmann_json_FOUND) FetchContent_Declare( nlohmann_json URL https://github.com/nlohmann/json/releases/download/v3.11.3/json.tar.xz ) FetchContent_MakeAvailable(nlohmann_json) endif() if(RHIANNON_WITH_WS) # uWebSockets is optional and can be toggled on when environment is ready. FetchContent_Declare( uwebsockets GIT_REPOSITORY https://github.com/uNetworking/uWebSockets.git GIT_TAG v20.44.0 ) FetchContent_MakeAvailable(uwebsockets) endif() if(RHIANNON_WITH_MIDI_OSC) find_package(PkgConfig QUIET) if(PkgConfig_FOUND) pkg_check_modules(PORTMIDI QUIET portmidi) pkg_check_modules(LIBLO QUIET liblo) endif() endif() # Global compile definitions if(RHIANNON_WITH_AVX2 AND CMAKE_SYSTEM_PROCESSOR MATCHES "(x86_64|AMD64)") add_compile_options(-mavx2) add_compile_definitions(RHIANNON_WITH_AVX2=1) endif() if(APPLE AND RHIANNON_WITH_METAL) find_library(METAL_FRAMEWORK Metal) find_library(FOUNDATION_FRAMEWORK Foundation) if(METAL_FRAMEWORK) add_compile_definitions(RHIANNON_WITH_METAL=1) endif() endif() add_subdirectory(src/agents) # Demo app (follows repo convention: apps/) add_executable(rhiannon_demo apps/rhiannon_demo/main.cpp) target_compile_features(rhiannon_demo PRIVATE cxx_std_20) target_link_libraries(rhiannon_demo PRIVATE rhiannon_lib) target_include_directories(rhiannon_demo PRIVATE include) if(spdlog_FOUND) target_link_libraries(rhiannon_demo PRIVATE spdlog::spdlog_header_only) endif() if(nlohmann_json_FOUND) target_link_libraries(rhiannon_demo PRIVATE nlohmann_json::nlohmann_json) endif() if(RHIANNON_WITH_WS) # uWebSockets is primarily header-only; ensure include path is present. if(TARGET uwebsockets) target_link_libraries(rhiannon_demo PRIVATE uwebsockets) endif() target_compile_definitions(rhiannon_demo PRIVATE RHIANNON_WITH_WS=1) endif() if(RHIANNON_WITH_MIDI_OSC) if(PORTMIDI_FOUND) target_include_directories(rhiannon_demo PRIVATE ${PORTMIDI_INCLUDE_DIRS}) target_link_libraries(rhiannon_demo PRIVATE ${PORTMIDI_LIBRARIES}) target_compile_definitions(rhiannon_demo PRIVATE RHIANNON_WITH_MIDI=1) endif() if(LIBLO_FOUND) target_include_directories(rhiannon_demo PRIVATE ${LIBLO_INCLUDE_DIRS}) target_link_libraries(rhiannon_demo PRIVATE ${LIBLO_LIBRARIES}) target_compile_definitions(rhiannon_demo PRIVATE RHIANNON_WITH_OSC=1) endif() endif() if(APPLE AND RHIANNON_WITH_METAL AND METAL_FRAMEWORK) target_link_libraries(rhiannon_demo PRIVATE ${METAL_FRAMEWORK} ${FOUNDATION_FRAMEWORK}) endif() enable_testing() if(RHIANNON_ENABLE_TESTS) FetchContent_Declare( googletest URL https://github.com/google/googletest/archive/refs/tags/v1.14.0.zip ) set(BUILD_GMOCK OFF CACHE BOOL "" FORCE) set(INSTALL_GTEST OFF CACHE BOOL "" FORCE) FetchContent_MakeAvailable(googletest) # Standard location under tests/ add_executable(rhiannon_tests tests/rhiannon_tests.cpp) target_compile_features(rhiannon_tests PRIVATE cxx_std_20) target_link_libraries(rhiannon_tests PRIVATE rhiannon_lib GTest::gtest_main) add_test(NAME rhiannon_tests COMMAND rhiannon_tests) endif()