Inital commit
This commit is contained in:
@@ -0,0 +1,4 @@
|
||||
build/
|
||||
*.exe
|
||||
*.pdb
|
||||
*.lib
|
||||
@@ -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<name>.cmake` from `nerv/deps/`
|
||||
2. Add `find_package(<name> REQUIRED)` to `CMakeLists.txt`
|
||||
3. Link with `<name>::<name>` 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.
|
||||
|
||||
@@ -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)
|
||||
@@ -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
|
||||
```
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
#include <fmt/core.h>
|
||||
|
||||
auto main(int argc, char const* argv[]) -> int {
|
||||
fmt::print("Hello, World!\n");
|
||||
return 0;
|
||||
}
|
||||
Vendored
+82
@@ -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
|
||||
$<$<OR:$<CXX_COMPILER_ID:Clang>,$<CXX_COMPILER_ID:AppleClang>,$<CXX_COMPILER_ID:GNU>>:-Wno-unused-result>
|
||||
)
|
||||
endif()
|
||||
|
||||
set(FMT_LICENSE_FILE "${fmt_SOURCE_DIR}/LICENSE" CACHE FILEPATH "Path to fmt license file")
|
||||
Reference in New Issue
Block a user