Skip to content

CMake Fallback

vix.app does not remove CMake.

It gives Vix a simpler project description for common C++ projects, while keeping CMake available for advanced projects.

txt
vix.app        -> simple path
CMakeLists.txt -> full control path

Resolution order

Vix resolves projects in this order:

txt
1. CMakeLists.txt
2. vix.app

This means:

txt
If CMakeLists.txt exists, Vix uses CMakeLists.txt.
If CMakeLists.txt does not exist but vix.app exists, Vix uses vix.app.

So a project like this uses CMake:

txt
myapp/
  CMakeLists.txt
  vix.app
  src/
    main.cpp

A project like this uses vix.app:

txt
myapp/
  vix.app
  src/
    main.cpp

Why CMake has priority

CMake has priority because it is the advanced compatibility path.

If a project already has a CMakeLists.txt, Vix assumes the project needs or wants that CMake configuration.

This avoids breaking existing projects.

txt
Existing CMake projects keep working.
vix.app is used only when no CMakeLists.txt exists.

How vix.app works internally

When Vix detects a vix.app project, it generates an internal CMake project.

The generated file is written under:

txt
.vix/generated/app/CMakeLists.txt

Then Vix builds that generated CMake project.

The flow is:

txt
vix.app
  -> .vix/generated/app/CMakeLists.txt
  -> cmake configure
  -> cmake build

Do not edit generated CMake

Do not edit this file manually:

txt
.vix/generated/app/CMakeLists.txt

It is generated by Vix.

If you need to change the build, edit:

txt
vix.app

The generated CMake file can be replaced the next time Vix regenerates the project.

Example vix.app project

Project layout:

txt
hello/
  vix.app
  src/
    main.cpp

vix.app:

ini
name = hello
type = executable
standard = c++20

sources = [
  src/main.cpp,
]

Build:

bash
vix build

Run:

bash
vix run

Vix generates:

txt
hello/.vix/generated/app/CMakeLists.txt

and builds the project from there.

Example CMake project

Project layout:

txt
hello/
  CMakeLists.txt
  src/
    main.cpp

CMakeLists.txt:

cmake
cmake_minimum_required(VERSION 3.24)

project(hello LANGUAGES CXX)

add_executable(hello
  src/main.cpp
)

target_compile_features(hello PRIVATE cxx_std_20)

Build:

bash
vix build

Run:

bash
vix run

Vix uses the existing CMakeLists.txt.

If both files exist

If your project has both:

txt
CMakeLists.txt
vix.app

Vix uses:

txt
CMakeLists.txt

The vix.app file is ignored for project resolution.

To test vix.app, rename the CMake file:

bash
mv CMakeLists.txt CMakeLists.txt.bak

Then run:

bash
vix build
vix run

Switching from vix.app to CMake

You can start with vix.app and move to CMake later.

For example, start with:

txt
myapp/
  vix.app
  src/
    main.cpp

Later, when you need full control, add:

txt
CMakeLists.txt

After that, Vix will use CMakeLists.txt.

No special command is needed.

Switching from CMake to vix.app

To switch a simple CMake project to vix.app, create a vix.app file and rename the old CMakeLists.txt.

Example:

bash
mv CMakeLists.txt CMakeLists.txt.bak
touch vix.app

Then write your manifest:

ini
name = hello
type = executable
standard = c++20

sources = [
  src/main.cpp,
]

Build:

bash
vix build

Why vix.app still generates CMake

vix.app is a simpler interface.

CMake is still the compatibility layer underneath.

This gives you:

txt
- simple project configuration
- compatibility with existing C++ build tools
- readable generated CMake for debugging
- a smooth migration path to full CMake

The user experience stays simple, while the ecosystem remains compatible.

vix.app is not a second CMake

vix.app is intentionally small.

It is not meant to support every CMake feature.

It supports common project needs:

txt
- one target
- sources
- include directories
- definitions
- links
- compile options
- link options
- packages
- resources
- output directory

For advanced logic, use CMakeLists.txt.

When CMake fallback is the right choice

Use CMakeLists.txt when your project needs:

txt
- multiple targets in one build file
- custom commands
- generated source files
- install rules
- CTest integration
- FetchContent
- CPM.cmake
- custom toolchains
- custom CMake functions
- platform-specific branches
- package export files
- advanced dependency logic

These are full build-system concerns.

They belong in CMake.

When vix.app is enough

Use vix.app when your project is simple and direct.

Good examples:

txt
- CLI applications
- simple examples
- small libraries
- demos
- prototypes
- learning projects
- small apps with a few dependencies

Example:

ini
name = myapp
type = executable
standard = c++20

sources = [
  src/main.cpp,
  src/app.cpp,
]

include_dirs = [
  include,
]

Debugging generated CMake

If a vix.app project fails to configure or build, inspect the generated CMake file:

txt
.vix/generated/app/CMakeLists.txt

You can also run:

bash
vix build -v

or:

bash
vix build --cmake-verbose

Use --cmake-verbose when you need raw CMake configure output.

Passing CMake arguments

You can pass extra CMake arguments after --.

Example:

bash
vix build -- -DCMAKE_PREFIX_PATH=/path/to/prefix

This is useful when packages are installed in custom locations.

Example with a custom package prefix:

bash
vix build -- -DCMAKE_PREFIX_PATH=$HOME/local

Package fallback

If a package cannot be found from vix.app, the problem is usually still a CMake package discovery issue.

Example:

ini
packages = [
  fmt:REQUIRED,
]

links = [
  fmt::fmt,
]

If CMake cannot find fmt, you may need:

bash
vix build -- -DCMAKE_PREFIX_PATH=/path/to/fmt

or a normal CMakeLists.txt if the package needs custom setup.

CMake fallback and packages

Remember:

txt
packages -> find_package(...)
links    -> target_link_libraries(...)

packages only finds packages.

It does not link imported targets automatically.

Correct:

ini
packages = [
  fmt:REQUIRED,
]

links = [
  fmt::fmt,
]

Incorrect:

ini
packages = [
  fmt:REQUIRED,
]

CMake fallback and resources

For simple resource copying, use:

ini
resources = [
  assets,
  "data/config.json=config/config.json",
]

For complex resource workflows, use CMake.

Examples that may need CMake:

txt
- generated assets
- compressed resources
- embedded binary data
- custom copy commands
- platform-specific resource logic

CMake fallback and tests

For simple tests, use a separate tests/vix.app.

Example:

txt
mathlib/
  vix.app
  tests/
    vix.app
    test_math.cpp

For advanced test infrastructure, use CMake.

Examples:

txt
- CTest
- GoogleTest discovery
- many test targets
- generated test data
- custom fixtures

CMake fallback and multiple targets

vix.app describes one target.

For multiple targets, use one of these approaches:

txt
- one folder with one vix.app per target
- one normal CMakeLists.txt for the full project

Example with one manifest per target:

txt
workspace/
  apps/
    server/
      vix.app
    client/
      vix.app
  libs/
    mathlib/
      vix.app

Example with full CMake control:

txt
workspace/
  CMakeLists.txt
  apps/
    server/
  libs/
    mathlib/

Generated CMake location

For a vix.app project, generated files live under:

txt
.vix/generated/app/

Typical generated file:

txt
.vix/generated/app/CMakeLists.txt

This folder is internal build metadata.

You usually should not commit it.

Should .vix/generated be committed?

Usually, no.

Recommended .gitignore entry:

txt
.vix/generated/

You should commit:

txt
vix.app

You should not commit:

txt
.vix/generated/app/CMakeLists.txt

unless you are debugging or intentionally snapshotting generated output.

Build directories

vix.app still uses normal Vix build directories.

Examples:

txt
build-ninja/
build-dev/
build-release/

Release build:

bash
vix build --preset release

With:

ini
output_dir = bin

you may get:

txt
build-release/bin/myapp

Common mistakes

Expecting vix.app to be used while CMakeLists.txt exists

If this exists:

txt
CMakeLists.txt

Vix uses it.

To use vix.app, rename the CMake file:

bash
mv CMakeLists.txt CMakeLists.txt.bak

Editing generated CMake manually

Do not edit:

txt
.vix/generated/app/CMakeLists.txt

Edit:

txt
vix.app

Trying to express complex CMake logic in vix.app

If the build needs advanced CMake logic, use CMakeLists.txt.

Do not force vix.app to become a second CMake language.

This is not enough:

ini
packages = [
  fmt:REQUIRED,
]

Correct:

ini
packages = [
  fmt:REQUIRED,
]

links = [
  fmt::fmt,
]

Use this rule when choosing between vix.app and CMake:

txt
If the build is simple, use vix.app.
If the build needs custom logic, use CMakeLists.txt.

Another way to think about it:

txt
vix.app is the simple path.
CMakeLists.txt is the compatibility path.

Summary

vix.app is a simple project manifest.

CMake remains available for full control.

Resolution order:

txt
1. CMakeLists.txt
2. vix.app

Generated CMake path:

txt
.vix/generated/app/CMakeLists.txt

Do not edit generated files manually.

Use CMakeLists.txt when your project becomes too complex for a small manifest.

Next steps

Continue with:

Released under the MIT License.