mehmetoguzderin / cmake-qt-vcpkg-vulkan

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

CMake + Qt + Vcpkg + Vulkan

Cloning

git clone --recurse-submodules https://github.com/mehmetoguzderin/cmake-qt-vcpkg-vulkan

Building

Prerequisites

  • CMake 3.20

  • C++20 compiler

  • Clangd

  • Clang-Format

  • Clang-Tidy

  • Conda

The following subsections only contain installs for packages that cause errors during build without clear instructions, especially from localization and windowing libraries. Please closely follow vcpkg outputs for any potential additional dependencies that may be necessary, as some packages can have specific requirements depending on the platform.

macOS

  • brew install autoconf-archive automake libtool

  • Vulkan SDK

    export CPATH=/usr/local/include:$CPATH
    export C_INCLUDE_PATH=/usr/local/include:$C_INCLUDE_PATH
    export CPLUS_INCLUDE_PATH=/usr/local/include:$CPLUS_INCLUDE_PATH
    ln -s "$(brew --prefix llvm)/bin/clang-tidy" "/usr/local/bin/clang-tidy"

Ubuntu

  • sudo apt install autoconf autoconf-archive automake libegl1-mesa-dev libgl-dev libgl1-mesa-dev libtool libvulkan-dev libvulkan1 libwayland-dev libx11-dev libx11-xcb-dev libxcb-randr0-dev libxcb-xinerama0-dev libxcb-xtest0-dev libxcb1 libxcb1-dev libxcursor-dev libxi-dev libxinerama-dev libxkbcommon-dev libxkbcommon-x11-dev libxrandr-dev xcb-proto

  • sudo apt-get install '^libxcb.*-dev' libx11-xcb-dev libglu1-mesa-dev libxrender-dev libx11\* libxi-dev libxkbcommon-dev libxkbcommon-x11-dev libegl1-mesa-dev

Configure

conda env create --prefix ./.conda -f environment.yml
conda activate ./.conda
cmake -G Ninja -DCMAKE_MAKE_PROGRAM=ninja -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_BUILD_TYPE=Release -S ./ -B ./build

Windows

The configuration can deprive the system of resources due to vcpkg builds during configuration and cause cryptic fail messages. On such occasions, please either try again directly or close other applications before trying again.

conda env create --prefix ./.conda -f environment.yml
conda activate ./.conda
cmake -A x64 -G "Visual Studio 17 2022" -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_BUILD_TYPE=Release -DVCPKG_TARGET_TRIPLET=x64-windows -S ./ -B ./build

Compile

cmake --build ./build --config Release

Run

./build/MainCxx

Install

cmake --install ./build --config Release --prefix $PWD/install/

Notes

  • Devcontainer configuration to run Docker with GPUs

    "runArgs": [
        "--gpus",
        "all"
    ]
  • Conda environment for versioning Python

    conda create --prefix .conda python=3.12
    conda activate ./.conda
    conda env export > environment.yml
    conda env create --prefix ./.conda -f environment.yml
    conda activate ./.conda
  • If there is a problematic package within transitive dependencies, you can check for it with the help of jq using the following command (please replace liblzma with the package name you are looking for):

    jq -r '.dependencies[] | if type == "object" then .name + (if .features then "[" + (.features | join(",")) + "]" else "" end) else . end' vcpkg.jsonc | while read pkg; do
        echo "Checking $pkg for liblzma dependency..."
        if ./vcpkg/vcpkg depend-info $pkg 2>&1 | grep -q 'liblzma'; then
            echo "$pkg directly or indirectly depends on liblzma."
        else
            echo "$pkg does not depend on liblzma."
        fi
    done
  • Reincorporation of following packages depends on liblzma to become available again:

    • boost[mpi]

    • boost-python

    • python3

    • tiff

About

License:Creative Commons Zero v1.0 Universal


Languages

Language:C++ 92.9%Language:CMake 4.4%Language:GLSL 2.3%Language:Python 0.4%