Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,37 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
---

## [Unreleased]
## v2.1.1

### Fixes

- fix(install): support `deps` fallback when loading package manifests
`vix install` now correctly resolves dependencies declared using both `dependencies` and `deps` fields, ensuring proper topological ordering.

- fix(cmake): stabilize dependency loading order in `.vix/vix_deps.cmake`
Prevents missing target errors when packages depend on each other (e.g. router → http).

### Improvements

- feat(cmake): registry-safe generated CMake for applications
Generated `CMakeLists.txt` now:
- safely includes `.vix/vix_deps.cmake` only when present
- allows adding registry packages without breaking builds
- introduces `vix_link_optional_targets(...)` helper for optional dependencies
- provides clear inline guidance for linking registry libraries

- improve(cmake): better resilience for mixed package formats
Ensures consistent behavior between `vix install`, `vix build`, and `vix run`.

### Notes

- This release improves reliability when using the Vix registry with CMake projects.
- Recommended to standardize on `"dependencies"` in package manifests, although `deps` remains supported.

---

Small release. Big stability upgrade.

## [v2.1.0]

This release focuses on performance, developer experience, and ecosystem maturity.
Expand Down
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,6 @@ Run C++ like a script:
vix run main.cpp
```

Open http://localhost:8080

## Why Vix.cpp

Most systems assume perfect conditions.
Expand Down
211 changes: 211 additions & 0 deletions docs/cmake_registry_guide.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,211 @@
# CMake Principles and Vix Registry Strategy

Deterministic. Composable. Registry-safe.

---

## Overview

Vix uses CMake as the integration layer between packages, local projects, and generated build scripts.

This document explains:

- CMake principles for package authors
- how the Vix registry resolves dependencies safely

Goal:

- packages must be easy to consume
- builds must be deterministic
- registry installs must behave consistently across:
- vix install
- vix build
- vix run

---

## Why this matters

A package in the Vix registry is never built in isolation.

It becomes part of a dependency graph.

Therefore it must be:

- composable
- non-invasive
- predictable
- safe to include

A package that works alone but pollutes CMake globally is NOT registry-safe.

---

## Core Principles

### 1. Packages must be dependency-safe

A package must work in all contexts:

- standalone
- add_subdirectory(...)
- vix_deps.cmake
- vix run generated CMake

Avoid global side effects.

---

### 2. Tests and examples must be OFF by default

```cmake
option(MY_PACKAGE_BUILD_TESTS "Build tests" OFF)
option(MY_PACKAGE_BUILD_EXAMPLES "Build examples" OFF)
```

---

### 3. Example targets must be prefixed

Bad:

```cmake
add_executable(server main.cpp)
```

Good:

```cmake
add_executable(cnerium_server_example_basic main.cpp)
```

---

### 4. Libraries must expose stable target names

```cmake
add_library(cnerium_http INTERFACE)
add_library(cnerium::http ALIAS cnerium_http)
```

---

### 5. Header-only packages must behave like real packages

```cmake
add_library(cnerium_router INTERFACE)
add_library(cnerium::router ALIAS cnerium_router)

target_include_directories(cnerium_router INTERFACE include)
target_link_libraries(cnerium_router INTERFACE cnerium::http)
```

---

### 6. Dependency resolution must be tolerant

```cmake
if(TARGET cnerium::http)
elseif(TARGET cnerium_http)
elseif(TARGET http::http)
elseif(TARGET http)
endif()
```

---

### 7. Packages should fail clearly

```cmake
message(FATAL_ERROR
"cnerium http target not found.
Run:
vix add @cnerium/http
vix install")
```

---

### 8. Use helper functions

```cmake
function(cnerium_add_example target file)
add_executable(${target} ${file})
target_link_libraries(${target} PRIVATE cnerium::server)
endfunction()
```

---

## Vix Registry Strategy

### What vix install does

- reads vix.lock
- resolves dependencies
- builds graph
- sorts packages
- generates `.vix/vix_deps.cmake`

---

### Dependency order

Correct:

json → http → router

---

### Metadata

```json
{
"dependencies": {
"cnerium/http": "0.7.0"
}
}
```

---

### vix_deps.cmake

- loads packages in order
- disables extras
- bridges aliases

---

### Alias bridging

Supports:

- cnerium::http
- cnerium_http
- http::http
- http

---

## Checklist

- tests OFF
- examples OFF
- canonical alias
- no collisions
- clear errors

---

## Rule

A package is ready when it integrates cleanly into another project.

---

## License

MIT License
Copyright (c) Gaspard Kirira

2 changes: 1 addition & 1 deletion modules/cli
2 changes: 1 addition & 1 deletion modules/db
Submodule db updated 0 files
Loading