Output Directory
vix.app supports output_dir to control where the built target is placed inside the build tree.
This is useful when you want a predictable output layout such as:
build-ninja/bin/myappBasic usage
name = hello
type = executable
standard = c++20
output_dir = bin
sources = [
src/main.cpp,
]Build:
vix buildThe executable can be placed under:
build-ninja/bin/helloRun:
vix runWhat output_dir means
output_dir is relative to the CMake build directory.
Example:
output_dir = binmeans:
${CMAKE_BINARY_DIR}/binSo with the default Vix build directory:
build-ninja/the final output becomes:
build-ninja/bin/Default output location
If you do not set output_dir, the output location depends on the generated CMake project and the selected build system.
Example without output_dir:
name = hello
type = executable
standard = c++20
sources = [
src/main.cpp,
]The executable may be produced under:
build-ninja/helloor another CMake-managed location depending on the target type and generator.
For predictable output, use:
output_dir = binRecommended app layout
Project:
hello/
vix.app
src/
main.cppvix.app:
name = hello
type = executable
standard = c++20
output_dir = bin
sources = [
src/main.cpp,
]After build:
hello/
build-ninja/
bin/
hellooutput_dir with resources
resources are copied next to the built target.
So if you use:
output_dir = binand:
resources = [
assets,
]the output can look like this:
build-ninja/
bin/
myapp
assets/Complete example:
name = myapp
type = executable
standard = c++20
output_dir = bin
sources = [
src/main.cpp,
]
resources = [
assets,
]Example with config files
Project layout:
config_app/
vix.app
src/
main.cpp
config/
app.jsonvix.app:
name = config_app
type = executable
standard = c++20
output_dir = bin
sources = [
src/main.cpp,
]
resources = [
config,
]After build:
build-ninja/
bin/
config_app
config/
app.jsonRunning manually
If you want to run the executable manually:
./build-ninja/bin/config_appIf your program reads files using relative paths, remember that the current working directory matters.
For example:
std::ifstream file("config/app.json");will look for config/app.json relative to the process working directory, not always relative to the executable file.
vix run and output_dir
vix run tries to resolve the built executable automatically.
For a manifest like this:
name = myapp
type = executable
standard = c++20
output_dir = bin
sources = [
src/main.cpp,
]vix run can find common executable locations such as:
build-ninja/myapp
build-ninja/bin/myapp
build-ninja/src/myappSo you can usually run:
vix runwithout manually typing the executable path.
output_dir for static libraries
You can also use output_dir with static libraries.
Example:
name = mathlib
type = static
standard = c++20
output_dir = lib
sources = [
src/add.cpp,
src/mul.cpp,
]
include_dirs = [
include,
]The static library output can be placed under:
build-ninja/lib/output_dir for shared libraries
For shared libraries:
name = plugin
type = shared
standard = c++20
output_dir = lib
sources = [
src/plugin.cpp,
]
include_dirs = [
include,
]The shared library output can be placed under:
build-ninja/lib/Depending on the platform, the final file may look like:
libplugin.solibplugin.dylibplugin.dllMultiple presets
Vix uses different build directories depending on the preset.
Default development build:
vix buildusually uses:
build-ninja/Release build:
vix build --preset releaseuses:
build-release/So with:
output_dir = binyou can get:
build-ninja/bin/myappand:
build-release/bin/myappoutput_dir is not an install directory
output_dir controls where the target is placed inside the build directory.
It is not the same as an install prefix.
This:
output_dir = bindoes not install your application globally.
It only affects the build output layout.
For advanced install rules, use a normal CMakeLists.txt.
Avoid absolute output paths
Prefer relative paths:
output_dir = binAvoid absolute paths:
output_dir = /usr/local/binvix.app is designed for local project builds.
Use install tools or CMake install rules when you need system-wide installation.
Recommended values
For applications:
output_dir = binFor libraries:
output_dir = libFor tests:
output_dir = binExamples:
name = myapp
type = executable
output_dir = binname = mathlib
type = static
output_dir = libname = mathlib_tests
type = executable
output_dir = binComplete executable example
name = server
type = executable
standard = c++20
output_dir = bin
sources = [
src/main.cpp,
src/server.cpp,
]
include_dirs = [
include,
]
resources = [
public,
config,
]After build:
build-ninja/
bin/
server
public/
config/Complete library example
name = mathlib
type = static
standard = c++20
output_dir = lib
sources = [
src/add.cpp,
src/mul.cpp,
]
include_dirs = [
include,
]After build:
build-ninja/
lib/
libmathlib.aThe exact library file name depends on the platform and toolchain.
Complete test example
name = mathlib_tests
type = executable
standard = c++20
output_dir = bin
sources = [
test_math.cpp,
../src/add.cpp,
../src/mul.cpp,
]
include_dirs = [
../include,
]
resources = [
data,
]After build from the tests/ folder:
tests/
build-ninja/
bin/
mathlib_tests
data/Run:
vix runCommon mistakes
Expecting output_dir to be relative to the source directory
Incorrect expectation:
output_dir = bincreates:
project/bin/myappActual behavior:
project/build-ninja/bin/myappoutput_dir is relative to the build directory.
Expecting output_dir to install the binary
output_dir does not install binaries into system paths.
It only controls the build output location.
Use CMake install rules for installation workflows.
Forgetting resources move with output_dir
If you set:
output_dir = binand:
resources = [
assets,
]then check:
build-ninja/bin/assets/not:
build-ninja/assets/Running manually from the wrong directory
If your app expects:
config/app.jsonand the file is under:
build-ninja/bin/config/app.jsonthen running from the project root may not find it unless your app resolves paths relative to the executable.
Troubleshooting
Executable not found
Check the target name:
name = myappThen check common output locations:
build-ninja/myapp
build-ninja/bin/myapp
build-release/bin/myappResource not found
Check whether you set output_dir.
With:
output_dir = binresources are copied near:
build-ninja/bin/Wrong preset directory
If you built with:
vix build --preset releasecheck:
build-release/not:
build-ninja/Summary
Use output_dir when you want predictable build outputs.
For applications:
output_dir = binFor libraries:
output_dir = libRemember:
output_dir is relative to the build directory.
resources are copied next to the built target.
vix run can usually find the executable automatically.Next steps
Continue with: