⚠ This repository is deprecated as of 12/11/2023. Please use https://github.com/aja-video/libajantv2 ⚠
Building the ajantv2 library with CMake and ninja build on Windows/macOS/Linux
-
Download and install CMake 3.10 or higher and place it in your PATH on the filesystem. CMake is available on all three major platforms supported by ajantv2 (Windows, macOS, Linux).
-
Windows - Download and install the CMake x64 .msi installer: https://github.com/Kitware/CMake/releases/download/v3.21.1/cmake-3.21.1-windows-x86_64.msi
-
macOS - Install the Homebrew package manager:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
Then, run:
brew install cmake
- Ubuntu Linux 20.04 - Install CMake via the apt package manager:
sudo apt update sudo apt install cmake
-
-
Download ninja build, unzip and place it somewhere within the PATH on your filesystem.
- The latest release (v1.10.2) for Windows, macOS and Linux can be downloaded from GitHub: https://github.com/ninja-build/ninja/releases/tag/v1.10.2
-
Clone the ntv2 git repository.
git clone git@github.com:aja-video/ntv2.git
-
cd
into thentv2
git repo directory. -
Create a temporary build directory where CMake will produce the build artifacts. For example:
mkdir cmake-build
-
cd
into the new build directory:cd cmake-build
-
Windows/MSVC-only: Run the
vcvarsall.bat
script within the VS2017 or 2019 installation to initialize the MSVC environment for x86 64-bit."c:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvarsall.bat" x64
-
Run
cmake
to generate the input files for build system to consume.CMake is a "meta-build" tool and as such it does not build the ajantv2 library itself. Rather, it generates input files that another build system consumes to build ajantv2. This tutorial uses the aformentioned "ninja build" system but other CMake build system "generators" are available on Windows, macOS and Linux. See https://cmake.org/cmake/help/latest/manual/cmake-generators.7.html for more information about CMake generators.
- Generating build files for the ajantv2 library:
cmake -DCMAKE_BUILD_TYPE=Debug -GNinja ..
NOTE: Specify
-DCMAKE_BUILD_TYPE=Release
to build the ajantv2 library in release mode with optimizations. -
Run ninja to build the ntv2 software:
ninja -f build.ninja
Binaries of the ajantv2 library can be found within your temporary build directory, under ajalibraries/ajantv2
.
These instructions assume that you have:
- Installed CMake 3.10 or higher.
- Installed either Visual Studio 2017 or 2019 and any Visual C++ dependencies required to build ntv2.
- Checked out the ntv2 git repository.
- Create temporary build directory:
mkdir cmake-build
cd
into the temporary build directory.- Run CMake to generate a Visual Studio Solution:
- VS 2017 (x64)
cmake -DCMAKE_BUILD_TYPE=Debug -G "Visual Studio 15 2017 Win64" ..
- VS 2019 (x64)
cmake -DCMAKE_BUILD_TYPE=Debug -G "Visual Studio 16 2019" -A Win64 ..
- Build the generated VS solution with MSBuild:
NOTE: The solution (ntv2.sln) file may also be opened in Visual Studio for building.
msbuild /p:Platform=x64 /p:Configuration=Debug /t:Clean,Build ntv2.sln
These instructions assume that you have:
- Installed CMake 3.10 or higher.
- Installed GCC or Clang on your macOS/Linux system.
- Checked out the ntv2 git repository.
- Create temporary build directory:
mkdir cmake-build
cd
into the temporary build directory.- Run CMake to generate Makefiles for ntv2:
cmake -DCMAKE_BUILD_TYPE=Debug -G Makefile ..
- Build the generated Makefiles:
make -j$(nproc)
The cmake --install
command can be used to deploy NTV2 sources and build artifacts to a destination path
specified with the CMAKE_INSTALL_PREFIX
variable. If this variable is not overridden at CMake build time,
the default system install paths will be used (/usr/local
on UNIX and c:/Program Files/${PROJECT_NAME}
on Windows).
See https://cmake.org/cmake/help/latest/variable/CMAKE_INSTALL_PREFIX.html for more information.
Run from the root of the ntv2 repo. CMake Install deploys output files to a sub-directory called ntv2-install
.
#!/bin/sh
NTV2_DIR=$PWD
BUILD_DIR=ntv2-build
INSTALL_DIR=ntv2-install
rm -rf ${INSTALL_DIR}
rm -rf ${BUILD_DIR}
cmake -S . -B${BUILD_DIR} \
-DCMAKE_BUILD_TYPE=Debug \
-DAJA_INSTALL_HEADERS=ON \
-DAJA_INSTALL_SOURCES=ON \
-DCMAKE_INSTALL_PREFIX="${NTV2_DIR}/${INSTALL_DIR}" \
-DAJA_DEPLOY_LIBS=ON \
-DAJA_BUILD_OPENSOURCE=ON
cmake --build ${BUILD_DIR} -- -j$(nproc>&1)
cmake --install ${BUILD_DIR}