'How to know the name of a library installed with vcpkg?

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.



Solution 1:[1]

  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

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Alexander Neumann