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.

KcFnMi
  • 5,516
  • 10
  • 62
  • 136
  • Either from the module name in CMake distribution (or if you created some modules yourself) or -config provided by the library – ixSci Apr 04 '22 at 08:39
  • What "module name in CMake"? Does CMake have a list of modules? – KcFnMi Apr 04 '22 at 09:54
  • [Yes](https://cmake.org/cmake/help/latest/manual/cmake-modules.7.html#find-modules) – ixSci Apr 04 '22 at 09:59
  • Does this answer your question? [How to retrieve cmake target names from vcpkg?](https://stackoverflow.com/questions/64454052/how-to-retrieve-cmake-target-names-from-vcpkg) – Alex Reinking Apr 04 '22 at 10:00
  • No, see question update – KcFnMi Apr 04 '22 at 10:19
  • @ixSci from where can I get the list of cmake modules? – KcFnMi Apr 04 '22 at 10:20
  • I posted the link in my comment above. – ixSci Apr 04 '22 at 10:29
  • But `OpenCV` is not on that list, so from where it comes from? – KcFnMi Apr 04 '22 at 10:45
  • 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. – ixSci Apr 04 '22 at 11:04
  • How some packages end up among CMake modules and others (OpenCV) not? – KcFnMi Apr 04 '22 at 12:29
  • 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. – ixSci Apr 04 '22 at 14:03
  • Interesting. So while using vcpkg and cmake it might happen that a library is available through both? – KcFnMi Apr 04 '22 at 14:21
  • 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. – ixSci Apr 05 '22 at 05:24

1 Answers1

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
Alexander Neumann
  • 1,479
  • 8
  • 17