mirror of
https://github.com/aaronpo97/the-biergarten-app.git
synced 2026-05-31 17:53:59 +00:00
153 lines
5.6 KiB
CMake
153 lines
5.6 KiB
CMake
cmake_minimum_required(VERSION 3.24)
|
|
project(biergarten-pipeline)
|
|
|
|
# Boost.DI still declares a very old minimum CMake version, which newer CMake
|
|
# releases reject unless a policy version floor is provided.
|
|
set(CMAKE_POLICY_VERSION_MINIMUM 3.5 CACHE STRING "" FORCE)
|
|
|
|
# =============================================================================
|
|
# 1. Platform & GPU Detection (Windows explicitly NOT supported)
|
|
# =============================================================================
|
|
if(WIN32)
|
|
message(FATAL_ERROR "[biergarten] Windows is currently not supported. Please use Linux (Fedora 43) or macOS (M1 Pro).")
|
|
endif()
|
|
|
|
if(APPLE)
|
|
if(CMAKE_SYSTEM_PROCESSOR MATCHES "arm64")
|
|
message(STATUS "[biergarten] Apple Silicon detected — enabling Metal acceleration.")
|
|
set(GGML_METAL ON CACHE BOOL "Enable Metal for Apple Silicon" FORCE)
|
|
else()
|
|
message(STATUS "[biergarten] Intel Mac detected — using CPU / Accelerate framework.")
|
|
set(GGML_METAL OFF CACHE BOOL "Disable Metal for Intel Macs" FORCE)
|
|
endif()
|
|
elseif(UNIX AND NOT APPLE)
|
|
find_package(CUDAToolkit QUIET)
|
|
find_package(HIP QUIET)
|
|
|
|
if(CUDAToolkit_FOUND)
|
|
message(STATUS "[biergarten] NVIDIA GPU detected — enabling CUDA acceleration.")
|
|
set(GGML_CUDA ON CACHE BOOL "Enable CUDA for NVIDIA GPUs" FORCE)
|
|
set(CMAKE_CUDA_ARCHITECTURES native)
|
|
elseif(HIP_FOUND OR EXISTS "/opt/rocm")
|
|
message(STATUS "[biergarten] AMD GPU detected — enabling HIP/ROCm acceleration.")
|
|
set(GGML_HIPBLAS ON CACHE BOOL "Enable HIP for AMD GPUs" FORCE)
|
|
else()
|
|
message(STATUS "[biergarten] No NVIDIA or AMD GPU found — falling back to CPU.")
|
|
endif()
|
|
endif()
|
|
|
|
# =============================================================================
|
|
# 2. Project-wide Settings (Standard & Optimization)
|
|
# =============================================================================
|
|
|
|
# Downgrade to C++20 as per Google Style Guide
|
|
set(CMAKE_CXX_STANDARD 20)
|
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
|
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
|
|
|
# GCC/Clang specific settings (warnings as errors)
|
|
add_compile_options(-Wall -Wextra -Werror -Wpedantic)
|
|
|
|
# Release Build Optimization: Aggressive (-O3), Arch-specific, and LTO
|
|
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O3 -march=native -flto")
|
|
|
|
# Debug Build Optimization: Fast and debuggable (-Og)
|
|
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Og -g")
|
|
|
|
# =============================================================================
|
|
# 3. Dependencies
|
|
# =============================================================================
|
|
include(FetchContent)
|
|
|
|
find_package(CURL QUIET)
|
|
if(NOT CURL_FOUND)
|
|
message(FATAL_ERROR "[biergarten] libcurl not found. Install it (e.g. 'sudo dnf install libcurl-devel').")
|
|
endif()
|
|
|
|
# Require system Boost for JSON and Program Options to speed up build times
|
|
find_package(Boost REQUIRED COMPONENTS json program_options)
|
|
|
|
FetchContent_Declare(
|
|
llama-cpp
|
|
GIT_REPOSITORY https://github.com/ggml-org/llama.cpp.git
|
|
GIT_TAG b8739
|
|
)
|
|
FetchContent_MakeAvailable(llama-cpp)
|
|
|
|
FetchContent_Declare(
|
|
boost-di
|
|
GIT_REPOSITORY https://github.com/boost-ext/di.git
|
|
GIT_TAG v1.3.0
|
|
)
|
|
FetchContent_MakeAvailable(boost-di)
|
|
if(TARGET Boost.DI AND NOT TARGET boost::di)
|
|
add_library(boost::di ALIAS Boost.DI)
|
|
endif()
|
|
|
|
FetchContent_Declare(
|
|
spdlog
|
|
GIT_REPOSITORY https://github.com/gabime/spdlog.git
|
|
GIT_TAG v1.15.3
|
|
)
|
|
FetchContent_MakeAvailable(spdlog)
|
|
|
|
# =============================================================================
|
|
# 4. Sources
|
|
# =============================================================================
|
|
set(SOURCES
|
|
src/main.cpp
|
|
src/biergarten_data_generator/biergarten_data_generator.cpp
|
|
src/biergarten_data_generator/run.cpp
|
|
src/biergarten_data_generator/query_cities_with_countries.cpp
|
|
src/biergarten_data_generator/generate_breweries.cpp
|
|
src/biergarten_data_generator/log_results.cpp
|
|
src/services/wikipedia/wikipedia_service.cpp
|
|
src/services/wikipedia/get_summary.cpp
|
|
src/services/wikipedia/fetch_extract.cpp
|
|
src/web_client/curl_global_state.cpp
|
|
src/web_client/curl_web_client.cpp
|
|
src/web_client/curl_web_client_download_to_file.cpp
|
|
src/web_client/curl_web_client_get.cpp
|
|
src/web_client/curl_web_client_utils.cpp
|
|
src/web_client/curl_web_client_url_encode.cpp
|
|
src/data_generation/llama/llama_generator.cpp
|
|
src/data_generation/llama/generate_brewery.cpp
|
|
src/data_generation/llama/generate_user.cpp
|
|
src/data_generation/llama/helpers.cpp
|
|
src/data_generation/llama/infer.cpp
|
|
src/data_generation/llama/load.cpp
|
|
src/data_generation/llama/load_brewery_prompt.cpp
|
|
src/data_generation/mock/data.cpp
|
|
src/data_generation/mock/deterministic_hash.cpp
|
|
src/data_generation/mock/generate_brewery.cpp
|
|
src/data_generation/mock/generate_user.cpp
|
|
src/json_handling/json_loader.cpp
|
|
)
|
|
|
|
# =============================================================================
|
|
# 5. Target
|
|
# =============================================================================
|
|
add_executable(${PROJECT_NAME} ${SOURCES})
|
|
target_include_directories(${PROJECT_NAME} PRIVATE
|
|
includes
|
|
${llama-cpp_SOURCE_DIR}/include
|
|
${llama-cpp_SOURCE_DIR}/common
|
|
)
|
|
target_link_libraries(${PROJECT_NAME} PRIVATE
|
|
llama
|
|
boost::di
|
|
Boost::json
|
|
Boost::program_options
|
|
spdlog::spdlog
|
|
CURL::libcurl
|
|
)
|
|
|
|
# =============================================================================
|
|
# 6. Runtime Assets
|
|
# =============================================================================
|
|
configure_file(
|
|
${CMAKE_SOURCE_DIR}/locations.json
|
|
${CMAKE_BINARY_DIR}/locations.json
|
|
COPYONLY
|
|
)
|