Vcpkg: [v8] Could not find package configuration file

Created on 12 Sep 2020  路  16Comments  路  Source: microsoft/vcpkg

I have successfully installed v8:x64-windows and am trying to use the package in a CMake project in VS 2019. Running vcpkg list shows the package fine and there were no errors during the install:

icu:x64-windows                                    67.1-3           Mature and widely used Unicode and localization ...
v8:x64-windows                                     8.3.110.13       Google Chrome's JavaScript engine
zlib:x64-windows                                   1.2.11#9         A compression library

vcpkg is used as a Git submodule. CMakeLists.txt has the following:

cmake_minimum_required (VERSION 3.8)

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

project ("HelloWorldV8_vcpkg")

find_package(v8 CONFIG REQUIRED)

CMake reports this error:

1> [CMake] CMake Error at vcpkg/scripts/buildsystems/vcpkg.cmake:478 (_find_package):
1> [CMake]   Could not find a package configuration file provided by "v8" with any of
1> [CMake]   the following names:
1> [CMake] 
1> [CMake]     v8Config.cmake
1> [CMake]     v8-config.cmake
1> [CMake] 
1> [CMake]   Add the installation prefix of "v8" to CMAKE_PREFIX_PATH or set "v8_DIR" to
1> [CMake]   a directory containing one of the above files.  If "v8" provides a separate
1> [CMake]   development package or SDK, be sure it has been installed.

The vcpkg directory tree does not contain either v8Config.cmake or v8-config.cmake.

When installing the package, output ends with the "Total elapsed time" line, there is no "The package provides CMake targets..." like in other packages.

Contrary to what's mentioned in https://github.com/microsoft/vcpkg/pull/12687#issue-461463078 the package's tools folder does not exist.

/cc @Kwizatz

port-bug

All 16 comments

Hi @mganss , the original PR was changed a lot, all manual generation of import targets was removed in favour of a pkg-config configuration, what you need to do instead is something like this:

find_package(PkgConfig)
pkg_check_modules(V8 REQUIRED IMPORTED_TARGET GLOBAL v8 v8_libplatform)
target_link_libraries(<target> PkgConfig::V8)

The tools folder was probably removed with the manual imported targets as well, do you need a specific executable?

Edit: I though vcpkg supported pkg-config out of the box, that does not seem to be the case yet. I find it odd that the find_package(PkgConfig) call is failing for me where it did not before, so that is strange. I am looking for a workaround, but it seems like the one workaround would be installing a Windows pkg-config version.

find_package(PkgConfig) is failing for me as well. I don't need tools, just found it suspicious that they were missing. What's needed, though, is the snapshot_blob.bin file. I can see this only in the buildtrees directory.

find_package(PkgConfig) is failing for me as well. I don't need tools, just found it suspicious that they were missing. What's needed, though, is the snapshot_blob.bin file. I can see this only in the buildtrees directory.

Right, I don't see it as part of the portfile either 馃槖.

I have a new PR to update to version 8.5, I'll address these issues in there, In the meantime, I think you can recover the snapshot from buildtrees, use find_library() to get v8, v8_libbase and v8_libplatform and then add "-DV8_COMPRESS_POINTERS -DV8_31BIT_SMIS_ON_64BIT_ARCH" to your compile flags.

Sorry for the inconvenience, and thanks for your feedback 馃榿

@Kwizatz wish your PR can fix this.

Hi @JackBoosY, It does, as it is it supports the shared build, but I still need to add support for the static versions.

find_package(V8 CONFIG REQUIRED)

Should provide V8::V8, V8::V8LIBBASE and V8::V8LIBPLATFORM targets as well as some other cmake variables.

@Kwizatz
I also just installed v8 with vcpkg.exe install v8:x86-windows-static
and get the error as @mganss is there any easy was to fix pkg-config tool not found ?
I thought that vcpkg will automatically download pkg-config if required.

Hi @S0PEX , easiest fix would be to cherry pick the PR from #13355, that PR is ready to merge but for some reason there's been no action from the vcpkg side.

You can see examples on how to detect v8 from cmake here, you probably will just need to use find_package(V8 REQUIRED) and then add the targets V8::V8, V8::V8LIBBASE and V8::V8LIBPLATFORM to your target_link_libraries.

@Kwizatz
Thanks for your help.
I just rebuild v8 with your port files and are now getting an error:

1> [CMake]   Could NOT find V8 (missing: V8_LIBRARY V8_COMPILE_DEFINITIONS)
1> [CMake] CMake Error at D:/Git/vcpkg/scripts/buildsystems/vcpkg.cmake:496 (_find_package):
1> [CMake]   Found package configuration file:
1> [CMake] 
1> [CMake]     D:/Git/vcpkg/installed/x86-windows-static/share/v8/V8Config.cmake
1> [CMake] 
1> [CMake]   but it set V8_FOUND to FALSE so package "V8" is considered to be NOT FOUND.`

which is weird as the .lib files are existing in /lib/v8_monolith.lib and /debug/lib/v8_monolith.lib do you have any ideas why this error occurs ?

@S0PEX did you set VCPKG_TARGET_TRIPLET to x86-windows-static?

cmake -DVCPKG_TARGET_TRIPLET:string=x86-windows-static

So, there is a problem with the portfile.
Just so you don't have to rebuild the whole thing, copy V8Config-static.cmake to vcpkg\installed\x86-windows-static\share\v8\V8Config.cmake, overwriting it. Then open the file and change set(V8_COMPILE_DEFINITIONS "") to set(V8_COMPILE_DEFINITIONS " ") notice the space, that should fix it, I'll fix the PR.

It mostly works for me now. I've found that V8_SNAPSHOT_BLOB is not set correctly because CMAKE_BUILD_TYPE is assumed to be uppercase here:

set(V8_SNAPSHOT_BLOB ${V8_SNAPSHOT_BLOB_${CMAKE_BUILD_TYPE}})

I assume that even if this works correctly you'll still need the call to configure_file() to copy the snapshot blob to the output directory?

Hi @mganss , I'll take a look, it should not be much problem to get the build type all uppercase, though I recall it working as is for me.

I assume that even if this works correctly you'll still need the call to configure_file() to copy the snapshot blob to the output directory?

Yes, you'll have to copy it over to where your binaries are, I suggest using a cmake custom target or execute process using

${CMAKE_COMMAND} -E copy ${V8_SNAPSHOT_BLOB} ${CMAKE_BINARY_PATH}

as your COMMAND, this way it will properly update when you run a build in case you upgrade v8, or change build type and so on. This way you can also add it as a dependency for your targets.

Also note that you can just find_file(SNAPSHOT_BLOB snapshot_blob.bin) and that should work.

@S0PEX did you set VCPKG_TARGET_TRIPLET to x86-windows-static?

cmake -DVCPKG_TARGET_TRIPLET:string=x86-windows-static

Hey, yeah I have the target_triplet set. For some reason he doesn't find the library right now.
When I applied your changes and now I am getting V8_LIBRARY is missing.
Did you changed something in the V8Config.cmake after your commit in PR ?

@S0PEX I fixed the PR yesterday, I also posted a fix so you don't have to rebuild the whole thing, it does work for me now.

@Kwizatz
The issue was that, v8 was written capital and therefore failed. Thanks for your help.

Fixed in #13355.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

spindensity picture spindensity  路  3Comments

F0I0l0I0P picture F0I0l0I0P  路  3Comments

grandprixgp picture grandprixgp  路  3Comments

husseinalihazime picture husseinalihazime  路  3Comments

tzbo picture tzbo  路  3Comments