Skip to content

Latest commit

 

History

History
111 lines (80 loc) · 2.54 KB

BUILDING.md

File metadata and controls

111 lines (80 loc) · 2.54 KB

Build Cortex.cpp from source

Firstly, clone the Cortex.cpp repository here and initialize the submodules:

git clone https://github.com/janhq/cortex.cpp
cd cortex.cpp
git submodule update --init --recursive

You also need to install CMake. On Linux and MacOS, you can install CMake via your package manager

sudo apt install cmake  # Ubuntu
brew install cmake  # MacOS

On Windows, you can download CMake from https://cmake.org/download/.

Windows

  1. Navigate to the engine folder.
  2. Configure the vpkg:
cd vcpkg
./bootstrap-vcpkg.bat
./vcpkg install
  1. Build the Cortex.cpp inside the engine/build folder (you can change -DCMAKE_TOOLCHAIN_FILE to use your own vcpkg):
mkdir build
cd build
cmake .. -DBUILD_SHARED_LIBS=OFF -DCMAKE_TOOLCHAIN_FILE=../vcpkg/scripts/buildsystems/vcpkg.cmake -DVCPKG_TARGET_TRIPLET=x64-windows-static
cmake --build . --config Release
  1. Verify that Cortex.cpp is installed correctly by getting help information.
cortex -h

Linux and MacOS

  1. Navigate to the engine folder.
  2. Configure the vpkg:
cd vcpkg
./bootstrap-vcpkg.sh
./vcpkg install
  1. Build the Cortex.cpp inside the engine/build folder (you can change -DCMAKE_TOOLCHAIN_FILE to use your own vcpkg):
mkdir build
cd build
cmake .. -DCMAKE_TOOLCHAIN_FILE=../vcpkg/scripts/buildsystems/vcpkg.cmake
make -j4
  1. Verify that Cortex.cpp is installed correctly by getting help information.
./cortex -h

Devcontainer / Codespaces

  1. Open Cortex.cpp repository in Codespaces or local devcontainer

    Open in GitHub Codespaces

    devcontainer up --workspace-folder .
  2. Configure vpkg in engine/vcpkg:

cd engine/vcpkg
export VCPKG_FORCE_SYSTEM_BINARIES="$([[ $(uname -m) == 'arm64' ]] && echo '1' || echo '0')"
./bootstrap-vcpkg.sh
  1. Build the Cortex.cpp inside the engine/build folder:
cd engine
mkdir -p build
cd build
cmake .. -DCMAKE_TOOLCHAIN_FILE=$(realpath ..)/vcpkg/scripts/buildsystems/vcpkg.cmake
make -j$(grep -c ^processor /proc/cpuinfo)
  1. Verify that Cortex.cpp is installed correctly by getting help information.
cd engine/build
./cortex -h
  1. Everytime a rebuild is needed, just run the commands above using oneliner
npx -y runme run --filename README.md -t devcontainer -y