Installation#
Installing UNIT#
UNIT can be installed via Git and CMake:
1git clone https://github.com/ZeroIntensity/unit && cd unit
2cmake -B build -DCMAKE_BUILD_TYPE=Release
3cmake --build build
4sudo cmake --install build
This installs the library and headers to your system’s default prefix
(on Linux, this is /usr/local). To install elsewhere, pass the
CMAKE_INSTALL_PREFIX setting:
1cmake -B build -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=$HOME/.local
2cmake --build build
3cmake --install build
Python bindings#
If you plan on using the Python bindings, you can install the unit-compiler
package from PyPI. UNIT is under heavy development, so it is recommended that
you install the development package:
pip install --pre -i https://test.pypi.org/simple/ unit-compiler
Alternatively, if you cloned UNIT and built from source, you can simply install from the root directory:
cd unit
pip install .
Using UNIT in your project#
find_package(unit REQUIRED)
target_link_libraries(my_program PRIVATE unit::unit)
unit_dep = dependency('unit')
executable('my_program', 'main.c', dependencies: unit_dep)
gcc -o my_program main.c $(pkg-config --cflags --libs unit)
CFLAGS := $(shell pkg-config --cflags unit)
LDFLAGS := $(shell pkg-config --libs unit)
gcc -o my_program main.c -lunit
cl /I path\to\unit\include main.c /link path\to\unit\lib\unit.lib