Open adamryczkowski opened 1 month ago
Thanks for the issue. As far as I can read, the issue is that dep/scripts/buildsystems/vcpkg.cmake
does not exist, which would make any project()
command fail (CMakeExtraUtils
is being hit because it also includes a project()
in it and it's first in line). Can you try with your project and static version, and let me know if it works by itself?
vcpkg
might be a bit tricky overall and I am still figuring out my way around it. I might need to package this there in order to be available via find_package
or FetchContent(FIND_PACKAGE_ARGS)
Many thanks for such a quick reply!! :-)
As far as I can read, the issue is that dep/scripts/buildsystems/vcpkg.cmake does not exist, which would make any project()
Of course it exists, it is just relative path to the repo root. CMake claims it is legal to put relative paths there: https://cmake.org/cmake/help/latest/manual/cmake-presets.7.html, :
toolchainFile
An optional string representing the path to the toolchain file. This field supports [macro expansion](https://cmake.org/cmake/help/latest/manual/cmake-presets.7.html#macro-expansion). If a relative path is specified, it is calculated relative to the build directory, and if not found, relative to the source directory. This field takes precedence over any [CMAKE_TOOLCHAIN_FILE](https://cmake.org/cmake/help/latest/variable/CMAKE_TOOLCHAIN_FILE.html#variable:CMAKE_TOOLCHAIN_FILE) value. It is allowed in preset files specifying version 3 or above.
After putting the full path into the CMakePresets.json
, I get another error:
/usr/bin/cmake --preset exported -G Ninja -S <repo root> -B <repo root>/cmake-build-debug
[0/7] Performing update step for 'cmakeextrautils-populate'
error: pathspec 'master' did not match any file(s) known to git
CMake Error at <repo root>/_deps/cmakeextrautils-subbuild/cmakeextrautils-populate-prefix/tmp/cmakeextrautils-populate-gitupdate.cmake:188 (execute_process):
execute_process failed command indexes:
1: "Child return code: 1"
FAILED: cmakeextrautils-populate-prefix/src/cmakeextrautils-populate-stamp/cmakeextrautils-populate-update <repo root>/cmake-build-debug/_deps/cmakeextrautils-subbuild/cmakeextrautils-populate-prefix/src/cmakeextrautils-populate-stamp/cmakeextrautils-populate-update
cd <repo root>/cmake-build-debug/_deps/cmakeextrautils-src && /usr/bin/cmake -Dcan_fetch=YES -P <repo root>/cmake-build-debug/_deps/cmakeextrautils-subbuild/cmakeextrautils-populate-prefix/tmp/cmakeextrautils-populate-gitupdate.cmake
ninja: build stopped: subcommand failed.
Preset CMake variables:
CMAKE_TOOLCHAIN_FILE="<repo root>/dep/scripts/buildsystems/vcpkg.cmake"
VCPKG_MANIFEST_MODE="false"
CMake Error at /usr/share/cmake-3.29/Modules/FetchContent.cmake:1714 (message):
Build step for cmakeextrautils failed: 1
Call Stack (most recent call first):
/usr/share/cmake-3.29/Modules/FetchContent.cmake:1854:EVAL:2 (__FetchContent_directPopulate)
/usr/share/cmake-3.29/Modules/FetchContent.cmake:1854 (cmake_language)
/usr/share/cmake-3.29/Modules/FetchContent.cmake:2081 (FetchContent_Populate)
CMakeLists.txt:10 (FetchContent_MakeAvailable)
-- Configuring incomplete, errors occurred!
Please note, that the CMakeExtraUtils cloned repo runs through CMake successfully, in particular it detects the git
without any issues.
I didn't run the CMake of the CMakeExtraUtils/test/DynamicVersion
folder though.
EDIT: correction, in fact I did it implicitly, because the CMAKEEXTRAUTILS_TESTS variable is "ON" by default.
Here're a file that will let you replicate the issue. Put it in the repo root.
vcpkg.json
. The actual package should not matter, but here's what I've used:
{
"name": "mypoc",
"version-string": "0.0.1",
"license": "MIT",
"dependencies": [
{
"name": "google-cloud-cpp",
"version>=": "2.26.0#1"
},
{
"name": "protobuf",
"version>=": "4.25.1"
}
],
"builtin-baseline": "5312e9f976e89b256954f571433e34f783dd2d12"
}
If you shallow-clone vcpkg, don't use my builtin-baseline as that would not be avilable locally. Just use sha-1 of the existing commit of the main vcpkg repo.
First time you will need to use the vcpkg preset to build the repo. Afterwards, type
vcpkg export --zip --output-dir=. --triplet x64-linux
to get the zip file with the dependencies. Extract it into the <repo root>/dep
folder in such way, that the following file exists: dep/scripts/buildsystems/vcpkg.cmake
.
I hope it helps.
Of course it exists, it is just relative path to the repo root. CMake claims it is legal to put relative paths there
Ah, yes it is, but the path will be relative to the cwd. You can use ${sourceDir}
to take it relative to the top-level project.
[0/7] Performing update step for 'cmakeextrautils-populate' error: pathspec 'master' did not match any file(s) known to git
Interesting, I do not enforce master
branch checking and I don't use that convention. My suspicion is that vcpkg.cmake
contains a Dependency provider
for vcpkg
that overrides the FetchContnet
logic (it should still fallthrough if it fails though). Can you share the vcpkg.cmake
file?
I didn't run the CMake of the
CMakeExtraUtils/test/DynamicVersion
folder though.
I am using tmt
and beakerlib
so it's a bit tricky to run them, mostly you can follow the script there as a bash script to test manually.
EDIT: correction, in fact I did it implicitly, because the CMAKEEXTRAUTILS_TESTS variable is "ON" by default.
I only have packaging test enabled there, so you can safely disable it for now. You should not be enabling the third-party project tests, those are primarily for upstream to run.
Here're a file that will let you replicate the issue. Put it in the repo root.
Can you walk me through a bit more? I need to add that to a new project? Can you make a demo repo/gist so I can navigate through it? If you can setup a github action using lukka/run-cmake
, lukka/run-vcpkg
that will help a lot since I don't have a vcpkg
environment and I don't know the steps to get started with that.
Let me start with written instructions.
dep
folder. CMakeLists.txt
, vcpkg.json
(or one with a simplier dependency. Google-cpp-cloud takes about 30 min to compile, and many GB of hard drive space) and the CMakePresets.json
in the root. You may not bother about the actual C++ sources/targets, because the issue is triggered before it starts to matter.cmake .. --preset vcpkg
. Wait for the dependencies to build during the configure time. vcpkg export --zip --output-dir=. --triplet x64-linux
dep
folder in such way, that dep/scripts/buildsystems/vcpkg.cmake
exists.cmake .. --preset exported
and observe the error.@adamryczkowski Can you help me a bit more to understand. Here is a dockerfile so we can have a common environment to work from:
If you're not familiar here is how to build and then get a shell environment inside it (podman
and docker
should be equivalent here)
$ podman build -t cmake-extra-utils:issue-39 -f Dockerfile
$ podman run -ti cmake-extra-utils:issue-39
Try to make a reproducible from there and add on top of the dockerfile there. I am still a bit lost for the dep
folder part
PS: when using presets
, do not create a build directory because that is handled by binaryDir
. It would otherwise make build/test presets unusable. cmake .. --preset vcpkg
is equivalent with cmake -S .. -B . --preset vcpkg
but that is very fragile.
Hi!
We have a project with large dependencies produced by
vcpkg export
. We use that with CMake presets, defined asWe build with
cmake .. --preset exported
. Here's the CMakeLists.txt:We get the following error on Ubuntu 22.04: