Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

vcpkg: recalling the CMake instructions shown after installing a package?

Tags:

c++

cmake

vcpkg

After installing packages with vcpkg, help text is shown, eg...

The package fmt:x64-windows provides CMake targets:

    find_package(fmt CONFIG REQUIRED)
    target_link_libraries(main PRIVATE fmt::fmt fmt::fmt-header-only)

... for the varying instructions needed for using them with CMake. Where do you get this information from if you want to recall it in the future and didn't write it down? Some libraries have more involved instructions than the above.

like image 464
PaulR Avatar asked Nov 22 '19 00:11

PaulR


People also ask

How do I use Cmake with Vcpkg?

The best way to use installed libraries with cmake is via the toolchain file scripts\buildsystems\vcpkg. cmake . To use this file, you simply need to add it onto your CMake command line as: -DCMAKE_TOOLCHAIN_FILE=D:\src\vcpkg\scripts\buildsystems\vcpkg.

Where are Vcpkg packages installed?

If installing globally, we recommend a short install path like: C:\src\vcpkg or C:\dev\vcpkg, since otherwise you may run into path issues for some port build systems. Make sure you are in the directory you want the tool installed to before doing this.


Video Answer


1 Answers

You can find the help text in files called 'usage'.

You can locate them in either in ports directory or if you are interested only for your packages, then they are in installed. You can search for them with the following command:

# VCPKG_ROOT denotes where is vcpkg installed
$ find $VCPKG_ROOT . -name usage
installed/x64-linux/share/openssl/usage
installed/x64-linux/share/gtest/usage

However some packages, including fmt, are not providing this information in a specific file, they are providing only targets. They are stored in $VCPKG_ROOT/installed/<YOUR_ARCHITECTURE>/share/fmt/fmt-targets.cmake.

vcpkg is then printing a list of targets after the installation. I don't know if there exists a better solution then finding the <package>-targets.cmake files and checks the content.

$ find $VCPKG_ROOT/installed -name *-targets.cmake 
installed/x64-linux/share/cxxopts/cxxopts-targets.cmake
installed/x64-linux/share/fmt/fmt-targets.cmake

So if you combine these two techniques, you should be able to find all the information that vcpkg is printing after installation.

like image 78
borievka Avatar answered Sep 20 '22 11:09

borievka