From e2110ddf4f4ab9abb7e8e2daf31335c1b66471ef Mon Sep 17 00:00:00 2001 From: portersky <24420859+portersky@users.noreply.github.com> Date: Tue, 5 May 2026 21:05:02 +0200 Subject: [PATCH] Inital commit --- .gitignore | 4 +++ AGENTS.md | 61 ++++++++++++++++++++++++++++++++++ CMakeLists.txt | 16 +++++++++ README.md | 30 +++++++++++++++++ cuber.cpp | 6 ++++ deps/Findfmt.cmake | 82 ++++++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 199 insertions(+) create mode 100644 .gitignore create mode 100644 AGENTS.md create mode 100644 CMakeLists.txt create mode 100644 README.md create mode 100644 cuber.cpp create mode 100644 deps/Findfmt.cmake diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..2895733 --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +build/ +*.exe +*.pdb +*.lib diff --git a/AGENTS.md b/AGENTS.md new file mode 100644 index 0000000..62fef8e --- /dev/null +++ b/AGENTS.md @@ -0,0 +1,61 @@ +# AGENTS.md + +## Project Overview + +`cuber` is a simple cube timer application. + +## Build System + +- **Generator:** Ninja +- **CMake minimum:** 3.21 +- **C++ standard:** C++23 + +### Commands + + ```bash + cmake -S . -B build -GNinja + ninja -C build + ./build/cuber.exe + ``` + +### Dependencies + +Dependencies are managed via custom `Find*.cmake` scripts in `deps/`. +These scripts use `FetchContent` under the hood to download and build +libraries automatically. They are shared with the `nerv` project. + +To add a new dependency: + +1. Copy the corresponding `Find.cmake` from `nerv/deps/` +2. Add `find_package( REQUIRED)` to `CMakeLists.txt` +3. Link with `::` in `target_link_libraries()` + +### CMake Module Path + +`deps/` is added to `CMAKE_MODULE_PATH` so `find_package()` resolves +to the custom scripts instead of system-installed packages. + +## Coding Conventions + +- **Language:** C++23 +- **Trailing return type** for function signatures +- **4-space indentation** +- **No semicolons after closing braces** for namespaces/classes +- `auto` for obvious types (e.g. `auto main(...) -> int`) + +## Source Layout + +``` +cuber/ + CMakeLists.txt # Build configuration + cuber.cpp # Entry point + deps/ # Custom Find*.cmake scripts + Findfmt.cmake # fmt library +``` + +## Platform Support + +The `nerv` project supports Windows, Linux, Emscripten, and Android via +`Platform.cmake` and `Flags.cmake`. These can be added to `cuber/deps/` +when cross-platform support is needed. + diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..24c27f1 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,16 @@ +cmake_minimum_required(VERSION 3.21) +project(cuber VERSION 0.1.0) + +set(CMAKE_EXPORT_COMPILE_COMMANDS ON) + +# Add the deps directory to the module path +# Required for find_package injection +list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/deps") + +# Dependencies +find_package(fmt REQUIRED) + +# Target setup +add_executable(cuber "cuber.cpp") +target_compile_features(cuber PRIVATE cxx_std_23) +target_link_libraries(cuber PRIVATE fmt::fmt) diff --git a/README.md b/README.md new file mode 100644 index 0000000..d98e5f7 --- /dev/null +++ b/README.md @@ -0,0 +1,30 @@ +# cuber + +`cuber` is a simple cube timer. + +## Requirements + +- CMake 3.21+ +- Ninja +- C++23 compiler + +## Development + +**Configure**: + +```sh +cmake -S . -B build -GNinja +``` + +**Build**: + +```sh +ninja -C build +``` + +**Run**: + +```bash +./build/cuber.exe +``` + diff --git a/cuber.cpp b/cuber.cpp new file mode 100644 index 0000000..f70fe58 --- /dev/null +++ b/cuber.cpp @@ -0,0 +1,6 @@ +#include + +auto main(int argc, char const* argv[]) -> int { + fmt::print("Hello, World!\n"); + return 0; +} diff --git a/deps/Findfmt.cmake b/deps/Findfmt.cmake new file mode 100644 index 0000000..b3512f9 --- /dev/null +++ b/deps/Findfmt.cmake @@ -0,0 +1,82 @@ +# ============================================================================== +# Find fmt +# ============================================================================== +# This module fetches the fmt formatting library. +# +# Targets provided: +# fmt::fmt - The fmt library target +# +# Variables set: +# fmt_FOUND - TRUE if fmt is available +# fmt_LIBRARIES - The fmt library target (fmt::fmt) +# fmt_INCLUDE_DIR - Include directories for fmt +# fmt_VERSION - Version of fmt (if available) +# ============================================================================== + +if (DEFINED _FINDFMT_INCLUDED) + return() +endif() +set(_FINDFMT_INCLUDED TRUE) + +# Use the version passed to find_package(), or default to 12.1.0 +if (DEFINED fmt_FIND_VERSION AND NOT fmt_FIND_VERSION STREQUAL "") + set(FMT_VERSION "${fmt_FIND_VERSION}") +else() + set(FMT_VERSION "12.1.0") +endif() + +message(STATUS "Fetching fmt ${FMT_VERSION}") + +include(FetchContent) + +find_program(GIT_EXECUTABLE git) +if (GIT_EXECUTABLE) + set(FMT_FETCH_METHOD "GIT") +else() + set(FMT_FETCH_METHOD "ZIP") +endif() + +if (FMT_FETCH_METHOD STREQUAL "GIT") + FetchContent_Declare( + fmt + GIT_REPOSITORY https://github.com/fmtlib/fmt.git + GIT_TAG ${FMT_VERSION} + ) +else() + FetchContent_Declare( + fmt + URL https://github.com/fmtlib/fmt/releases/download/${FMT_VERSION}/fmt-${FMT_VERSION}.zip + ) +endif() + +FetchContent_MakeAvailable(fmt) + +if (NOT TARGET fmt::fmt) + if (TARGET fmt) + add_library(fmt::fmt ALIAS fmt) + else() + message(FATAL_ERROR "Could not fetch fmt; no target fmt or fmt::fmt available") + endif() +endif() + +set(fmt_FOUND TRUE) +set(fmt_LIBRARIES fmt::fmt) +set(fmt_VERSION "${FMT_VERSION}") +get_target_property(_fmt_inc fmt::fmt INTERFACE_INCLUDE_DIRECTORIES) +set(fmt_INCLUDE_DIR "${_fmt_inc}") + +# Mark fmt includes as SYSTEM to suppress warnings from its headers +if (_fmt_inc AND TARGET fmt) + set_target_properties(fmt PROPERTIES + INTERFACE_SYSTEM_INCLUDE_DIRECTORIES "${_fmt_inc}" + ) +endif() + +# Suppress warnings from fmt's own compiled sources (third-party code) +if (TARGET fmt) + target_compile_options(fmt PRIVATE + $<$,$,$>:-Wno-unused-result> + ) +endif() + +set(FMT_LICENSE_FILE "${fmt_SOURCE_DIR}/LICENSE" CACHE FILEPATH "Path to fmt license file")