C++ project package manager
Comparison
- Read thoes detail at Reddit
- vcpkg
- Conan
- build2
Install vcpkg
Install Windows
git clone https://github.com/microsoft/vcpkg
cd vcpkg
bootstrap-vcpkg.bat
install package
Check Installed package
vcpkg list
Using vcpkg with cmake under Visual studio 2019
- For windows Visual studio 2019
vcpkg install sqlite3:x64-windows
vcpkg integrate install
cmake_minimum_required (VERSION 3.8)
project (vs_cmake CXX)
find_package(unofficial-sqlite3 CONFIG REQUIRED)
find_package(fmt REQUIRED)
find_package(range-v3 REQUIRED)
find_package(cxxopts REQUIRED)
add_executable (vs_cmake "vs_cmake.cpp" "vs_cmake.h")
target_compile_features(vs_cmake PRIVATE cxx_std_20)
target_link_libraries(vs_cmake
PRIVATE
fmt::fmt
range-v3::range-v3
cxxopts::cxxopts
unofficial::sqlite3::sqlite3)
project
指定项目名
find_package
指定项目依赖
add_executable
指定编译后的可执行程序
target_compile_features
指定编译版本cxx_std_20
, 使用/std:c++20
作为编译版本
target_link_libraries
为项目指定链接库
- add
"cmakeToolchain": "\path\to\vcpkg\\scripts\\buildsystems\\vcpkg.cmake"
at CMakeSettings.json
- or use
-DCMAKE_TOOL_CHAIN=
at command line