[root@localhost vcpkg_learn]# ls CMakeLists.txt main.cpp [root@localhost vcpkg_learn]# cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_MAKE_PROGRAM=ninja -G Ninja -S . -B ./cmake-build-debug -- The C compiler identification is GNU 11.2.1 -- The CXX compiler identification is GNU 11.2.1 -- Detecting C compiler ABI info -- Detecting C compiler ABI info - done -- Check for working C compiler: /opt/rh/devtoolset-11/root/usr/bin/cc - skipped -- Detecting C compile features -- Detecting C compile features - done -- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info - done -- Check for working CXX compiler: /opt/rh/devtoolset-11/root/usr/bin/c++ - skipped -- Detecting CXX compile features -- Detecting CXX compile features - done -- Configuring done (0.4s) -- Generating done (0.0s) -- Build files have been written to: /root/vcpkg_learn/cmake-build-debug
[root@localhost vcpkg]# ./vcpkg search cryptopp cryptopp 8.8.0 Crypto++ is a free C++ class library of cryptographic schemes. cryptopp[pem-pack] Crypto++ with PEM pack The result may be outdated. Run `git pull` to get the latest results. If your port is not listed, please open an issue at and/or consider making a pull request. - https://github.com/Microsoft/vcpkg/issues
[root@localhost vcpkg]# ./vcpkg install cryptopp Computing installation plan... The following packages will be built and installed: cryptopp:x64-linux -> 8.8.0 * vcpkg-cmake:x64-linux -> 2023-05-04 * vcpkg-cmake-config:x64-linux -> 2022-02-06#1 Additional packages (*) will be modified to complete this operation. Detecting compiler hashfor triplet x64-linux... Restored 0 package(s) from /root/.cache/vcpkg/archives in 15.2 us. Use --debug to see more details. Installing 1/3 vcpkg-cmake:x64-linux... Building vcpkg-cmake:x64-linux... -- Installing: /root/vcpkg_learn/vcpkg/packages/vcpkg-cmake_x64-linux/share/vcpkg-cmake/vcpkg_cmake_configure.cmake -- Installing: /root/vcpkg_learn/vcpkg/packages/vcpkg-cmake_x64-linux/share/vcpkg-cmake/vcpkg_cmake_build.cmake -- Installing: /root/vcpkg_learn/vcpkg/packages/vcpkg-cmake_x64-linux/share/vcpkg-cmake/vcpkg_cmake_install.cmake -- Installing: /root/vcpkg_learn/vcpkg/packages/vcpkg-cmake_x64-linux/share/vcpkg-cmake/vcpkg-port-config.cmake -- Installing: /root/vcpkg_learn/vcpkg/packages/vcpkg-cmake_x64-linux/share/vcpkg-cmake/copyright -- Performing post-build validation Stored binaries in 1 destinations in 3.45 ms. Elapsed time to handle vcpkg-cmake:x64-linux: 17.2 ms Installing 2/3 vcpkg-cmake-config:x64-linux... Building vcpkg-cmake-config:x64-linux... -- Installing: /root/vcpkg_learn/vcpkg/packages/vcpkg-cmake-config_x64-linux/share/vcpkg-cmake-config/vcpkg_cmake_config_fixup.cmake -- Installing: /root/vcpkg_learn/vcpkg/packages/vcpkg-cmake-config_x64-linux/share/vcpkg-cmake-config/vcpkg-port-config.cmake -- Installing: /root/vcpkg_learn/vcpkg/packages/vcpkg-cmake-config_x64-linux/share/vcpkg-cmake-config/copyright -- Performing post-build validation Stored binaries in 1 destinations in 2.62 ms. Elapsed time to handle vcpkg-cmake-config:x64-linux: 15.9 ms Installing 3/3 cryptopp:x64-linux... Building cryptopp:x64-linux... -- Downloading https://github.com/abdes/cryptopp-cmake/archive/f857b775bcb4ff24e4993d85cce811587f8b0616.tar.gz -> abdes-cryptopp-cmake-f857b775bcb4ff24e4993d85cce811587f8b0616.tar.gz... -- Extracting source /root/vcpkg_learn/vcpkg/downloads/abdes-cryptopp-cmake-f857b775bcb4ff24e4993d85cce811587f8b0616.tar.gz -- Applying patch fix-git-branch.patch -- Using source at /root/vcpkg_learn/vcpkg/buildtrees/cryptopp/src/587f8b0616-6acbde05eb.clean -- Downloading https://github.com/weidai11/cryptopp/archive/4d0cad5401d1a2c998b314bc89288c9620d3021d.tar.gz -> weidai11-cryptopp-4d0cad5401d1a2c998b314bc89288c9620d3021d.tar.gz... -- Extracting source /root/vcpkg_learn/vcpkg/downloads/weidai11-cryptopp-4d0cad5401d1a2c998b314bc89288c9620d3021d.tar.gz -- Applying patch patch.patch -- Using source at /root/vcpkg_learn/vcpkg/buildtrees/cryptopp/src/9620d3021d-0989fd3960.clean -- Found external ninja('1.10.2'). -- Configuring x64-linux -- Building x64-linux-dbg -- Building x64-linux-rel -- Fixing pkgconfig file: /root/vcpkg_learn/vcpkg/packages/cryptopp_x64-linux/lib/pkgconfig/cryptopp.pc -- Fixing pkgconfig file: /root/vcpkg_learn/vcpkg/packages/cryptopp_x64-linux/debug/lib/pkgconfig/cryptopp.pc -- Performing post-build validation Stored binaries in 1 destinations in 2.2 s. Elapsed time to handle cryptopp:x64-linux: 1.2 min Total install time: 1.2 min cryptopp provides CMake targets:
# this is heuristically generated, and may not be correct find_package(cryptopp CONFIG REQUIRED) target_link_libraries(main PRIVATE cryptopp::cryptopp)
可以看到,依赖库安装在了项目目录的vcpkg/packages/里面。
列出已经安装的开源库:
1 2 3 4
[root@localhost vcpkg]# ./vcpkg list cryptopp:x64-linux 8.8.0 Crypto++ is a free C++ class library of cryptogr... vcpkg-cmake-config:x64-linux 2022-02-06#1 vcpkg-cmake:x64-linux 2023-05-04