Closed vadi2 closed 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.
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?
@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:
run-vcpkg
step, drop the input runVcpkgInstall:true
(so the default is false
, which means vcpkg is only setup but not run vcpkg
yet.vcpkg.json
side by side with CMakePresets.json
, so that vcpkg.cmake
"spots" the file and uses manifest mode.run-cmake
will then spawn cmake
, which eventually, using vcpkg.cmake
, will use manifest mode and use correct search paths.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.
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 -
Can run-cmake work with a default preset as well, or am I missing something else here entirely?
@vadi2 great to hear about making progress on this! Regarding your questions:
run-cmake
requires the name of the build preset, otherwise it won't build, the same behavior holds for all presets, that is the name of the preset is required or it is skipped. /path/to/cmake --build /path/to/binarydirectory/builds/ninja-multi-vcpkg --target all
.
Since using CMakePresets.json is beneficial to have reproducible builds (e.g. to match the local build on dev machines with the CI build on build agents), I'd recommend adding a build preset (which I think you have already) and specifying its name in the buildPreset
input of run-cmake
.Let me know if this helps to migrate the build to fully embrace CMakePresets and vcpkg.json, thanks.
Thanks, got it working now.
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:
run-cmake is only searching in the former directory and not the latter according to debug logs.
What could be the problem here?