lukka / run-cmake

GitHub Action to build C++ applications with CMake (CMakePresets.json), Ninja and vcpkg on GitHub.
MIT License
171 stars 19 forks source link

Artifacts produced by manifest mode from run-vcpkg not found #110

Closed vadi2 closed 1 year ago

vadi2 commented 1 year ago

I switched over to modern run-vcpkg + manifest mode, added a preset, and the libraries installed by run-vcpkg are no longer found by run-cmake.

The issue seems to be that manifest mode has a different location compared to the classic mode for package installation:

The root of the tree in Classic mode is \/installed. The root of the tree in Manifest mode is \/vcpkg_installed.

run-cmake is only searching in the former directory and not the latter according to debug logs.

What could be the problem here?

lukka commented 1 year ago

@vadi2 I'd start to understand the problem by first finding the right set of commands to run locally to make your project building fine with vcpkg's Manifest mode along with CMake's presets. This sample project shows a minimal C++ project template to start from: https://github.com/lukka/CppCMakeVcpkgTemplate Note that run-cmake does not try to help searching for binaries, it is all up to CMakePresets.json's content to do that, where usually the vcpkg's toolchain file is being specified.

vadi2 commented 1 year ago

Note that run-cmake does not try to help searching for binaries

I'm a bit confused by this, because before upgrading to manifest mode I did not specify the location of vcpkg's installed artifacts and run-cmake was able to find them.

Additionally, run-cmake's source code does include vcpkg search paths, exactly the one mentioned in official documentation: https://github.com/lukka/run-cmake/blob/main/dist/index.js#L6091-L6095C2. Why would vcpkg know about the search paths if it is not the tool's job to help in searching them?

lukka commented 1 year ago

@vadi2 the work to determine which binary paths to search for is done by vcpkg.cmake, that is the toolchain which must be told to cmake to use when running. In your case, I believe the problem is that your workflow is using the "vcpkg manifest mode" when running vcpkg install (which is done in your workflow at the run-vcpkg step). Later on, when using run-cmake, cmake runs with the presets and the toolchain, but the latter won't find the vcpkg.json file, hence it uses classical mode (rather than manifest mode), and fails at finding the previously built packages. My suggestions would be:

Please try all the sequence of commands locally first: if it works locally, then the GH workflow should match it, which is easily achievable by either using the same commands in the workflow file, or by using run-vcpkg and run-cmake, as the C++ project template is showing.

vadi2 commented 1 year ago

I'd love to get rid of runVcpkgInstall:true, but as far as I see it is necessary because one of the libraries installed by vcpkg, and needed prior to compilation, can't see the location of the files properly.

I've now gotten to the point where the configure preset step using run-cmake runs okay, but the build step itself is not run. I have not specified a build preset, since from my understanding of the documentation - that cmake has a default preset built-in that should do the job. This default build preset works in VSCode -

image

Can run-cmake work with a default preset as well, or am I missing something else here entirely?

lukka commented 1 year ago

@vadi2 great to hear about making progress on this! Regarding your questions:

Let me know if this helps to migrate the build to fully embrace CMakePresets and vcpkg.json, thanks.

vadi2 commented 1 year ago

Thanks, got it working now.