Packaging CMake projects using Vcpkg

Since the CEMU Wii U emulator has just gone open-source and should now technically build on Linux, I had a quick look at how difficult it is to package it for inclusion in nixpkgs.

Unfortunately, their CMake project seems to rely on Vcpkg, which complicates things in nix-land.

Is there a default strategy or a good example of dealing with CMake projects that use Vcpkg?

My initial strategy consisted simply of removing from the following lines from the CMake project, thereby not loading the Vcpkg toolchain file:

set(VCPKG_OVERLAY_PORTS "${CMAKE_CURRENT_LIST_DIR}/dependencies/vcpkg_overlay_ports")
set(CMAKE_TOOLCHAIN_FILE "${CMAKE_CURRENT_SOURCE_DIR}/dependencies/vcpkg/scripts/buildsystems/vcpkg.cmake" CACHE STRING "Vcpkg toolchain file")

But this caused (predictably) so many of issues with all the previously specified find_package declarations that I’m wondering if this is the right way to go about things.

Does anyone have any example packages they’ve worked on previously?

1 Like

One example I could find is

1 Like

This one was very interesting, thanks for pointing me in that direction!

1 Like

It looks like you can disable vcpkg with



1 Like

That’s actually a little bit handier than patching CMakeLists.txt :slight_smile:. Thanks!

There are actually more annoying issues though. From what I can tell, Vcpkg packages are often packaged a little differently from how certain libraries are usually packaged in traditional os-level packages or nixpkgs. So things aren’t always as straightfoward as turning off Vcpkg and passing in the correct buildInputs. For example, I’ve had issues with hos zstd is packaged on Vcpkg vs nixpkgs.

Depending on which software you’re trying to package, there is no real straightforward best practice I think unfortunately.