How to know the name of a library installed with vcpkg?
Asked Answered
S

1

0

In my simple app which I build with cmake I use opencv, which is installed with vcpkg.

On CMakeLists.txt I have to find_package(OpenCV REQUIRED), replacing OpenCV by opencv will fail the build.

From vcpkg list I see opencv is installed.

So from where should I get the correct spelling, OpenCV?

Executing the command to install the package again does not help for opencv.

./vcpkg install opencv        
Computing installation plan...
The following packages are already installed:
    opencv[core,default-features]:x64-osx -> 4.5.5
Package opencv:x64-osx is already installed
Restored 0 packages from /Users/user/.cache/vcpkg/archives in 2.309 us. Use --debug to see more details.

Total elapsed time: 4.752 ms

user@users-MacBook-Pro vcpkg % ./vcpkg install opencv --debug
[DEBUG] Feature flag 'binarycaching' unset
[DEBUG] Feature flag 'manifests' unset
[DEBUG] Feature flag 'compilertracking' unset
[DEBUG] Feature flag 'registries' unset
[DEBUG] Feature flag 'versions' unset
[DEBUG] Failed to open: /Users/user/vcpkg/vcpkg-bundle.json
[DEBUG] Bundle config: readonly=0, usegitregistry=0, embeddedsha=nullopt
[DEBUG] Using builtin-ports: /Users/user/vcpkg/ports
[DEBUG] Using installed-root: /Users/user/vcpkg/installed
[DEBUG] Using buildtrees-root: /Users/user/vcpkg/buildtrees
[DEBUG] Using packages-root: /Users/user/vcpkg/packages
[DEBUG] Using scripts-root: /Users/user/vcpkg/scripts
[DEBUG] Using vcpkg-root: /Users/user/vcpkg
[DEBUG] Using scripts-root: /Users/user/vcpkg/scripts
[DEBUG] Using builtin-registry: /Users/user/vcpkg/versions
[DEBUG] Using downloads-root: /Users/user/vcpkg/downloads
[DEBUG] Default binary cache path is: /Users/user/.cache/vcpkg/archives
Computing installation plan...
The following packages are already installed:
    opencv[core,default-features]:x64-osx -> 4.5.5
Package opencv:x64-osx is already installed
Restored 0 packages from /Users/user/.cache/vcpkg/archives in 2.227 us. Use --debug to see more details.

Total elapsed time: 5.909 ms

[DEBUG] /Users/runner/work/1/s/src/vcpkg/install.cpp(1229): 
[DEBUG] Time in subprocesses: 3284 us
[DEBUG] Time in parsing JSON: 1094 us
[DEBUG] Time in JSON reader: 577 us
[DEBUG] Time in filesystem: 903 us
[DEBUG] Time in loading ports: 2630 us
[DEBUG] Exiting after 9.574 ms (5984 us)

It just mentions opencv every time, not OpenCV.

Stet answered 4/4, 2022 at 8:20 Comment(13)
Either from the module name in CMake distribution (or if you created some modules yourself) or <PackageName>-config provided by the libraryIsaisaac
What "module name in CMake"? Does CMake have a list of modules?Stet
YesIsaisaac
Does this answer your question? How to retrieve cmake target names from vcpkg?Galacto
No, see question updateStet
@Isaisaac from where can I get the list of cmake modules?Stet
I posted the link in my comment above.Isaisaac
But OpenCV is not on that list, so from where it comes from?Stet
Like I said, if it isn't among CMake modules then it is a config file provided with the library. In your case it is the OpenCVConfig.cmake file located somewhere within OpenCV package.Isaisaac
How some packages end up among CMake modules and others (OpenCV) not?Stet
Kitware manages what goes to the modules and what not. You should expect to less be included with CMake and more with libraries as it is a preferable way of doing things. Modules are from the era when CMake was just a Kitware tool and hardly anyone else cared about it outside it.Isaisaac
Interesting. So while using vcpkg and cmake it might happen that a library is available through both?Stet
Modules in CMake provides the way to find libraries they don't contain libraries themselves. So you need to get the library and then find it. vcpckg helps with the first.Isaisaac
G
0
  1. CMake module/config name is not equivalent to the vcpkg port name
  2. vcpkg might print a usage message (if your vcpkg is new enough and the heuristics kick in.)
  3. find_package is not always case insensitive as stated in the docs how the CONFIG lookup works:

In this mode, CMake searches for a file called <lowercasePackageName>-config.cmake or <PackageName>Config.cmake.

-> As such I deduce that OpenCV installs a config file which is named OpenCVConfig.cmake which is backed up by the vcpkg file list:

opencv4:x64-windows:/share/opencv/OpenCVConfig-version.cmake
opencv4:x64-windows:/share/opencv/OpenCVConfig.cmake
Grassi answered 22/4, 2022 at 22:42 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.