diff options
| author | nicole mazzuca <mazzucan@outlook.com> | 2020-07-07 10:53:14 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-07-07 10:53:14 -0700 |
| commit | ee218d30651d5ddafb2829938b862bafac9ad2d6 (patch) | |
| tree | 6bf49129ab4e803a4ec47a6af8ee4900649950cd | |
| parent | e1285b4a280b540c191fed5fbfbcd3626de1fc30 (diff) | |
| download | vcpkg-ee218d30651d5ddafb2829938b862bafac9ad2d6.tar.gz vcpkg-ee218d30651d5ddafb2829938b862bafac9ad2d6.zip | |
[vcpkg docs] new README/Quick Start guide (#12093)
* [vcpkg docs] new README/Quick Start guide
* some CRs
* add VS+CMake instructions
* add CLion instructions
* Update chinese readme, add link url.
* Update README_zh_CN.md
Co-authored-by: Phoebe <20694052+PhoebeHui@users.noreply.github.com>
* Update README_zh_CN.md
Co-authored-by: Phoebe <20694052+PhoebeHui@users.noreply.github.com>
* Update README_zh_CN.md
Co-authored-by: Phoebe <20694052+PhoebeHui@users.noreply.github.com>
* Update README_zh_CN.md
Co-authored-by: Phoebe <20694052+PhoebeHui@users.noreply.github.com>
* Update README_zh_CN.md
Co-authored-by: Phoebe <20694052+PhoebeHui@users.noreply.github.com>
* Update README_zh_CN.md
Co-authored-by: Phoebe <20694052+PhoebeHui@users.noreply.github.com>
* Update README_zh_CN.md
Co-authored-by: Phoebe <20694052+PhoebeHui@users.noreply.github.com>
* Update README_zh_CN.md
Co-authored-by: Phoebe <20694052+PhoebeHui@users.noreply.github.com>
* Update README_zh_CN.md
Co-authored-by: Phoebe <20694052+PhoebeHui@users.noreply.github.com>
* Update README_zh_CN.md
Co-authored-by: Phoebe <20694052+PhoebeHui@users.noreply.github.com>
* CRs
* Fix some describe and link
* Re-fix url link
* Re-fix url link
* Re-fix url link
Co-authored-by: JackBoosY <yuzaiyang@beyondsoft.com>
Co-authored-by: Jack·Boos·Yu <47264268+JackBoosY@users.noreply.github.com>
Co-authored-by: Phoebe <20694052+PhoebeHui@users.noreply.github.com>
| -rw-r--r-- | README.md | 391 | ||||
| -rw-r--r-- | README_zh_CN.md | 365 |
2 files changed, 677 insertions, 79 deletions
@@ -1,9 +1,14 @@ -# Vcpkg +# Vcpkg: Overview +[中文总览](README_zh_CN.md) -## Overview -Vcpkg helps you manage C and C++ libraries on Windows, Linux and MacOS. This tool and ecosystem are constantly evolving; your involvement is vital to its success! +Vcpkg helps you manage C and C++ libraries on Windows, Linux and MacOS. +This tool and ecosystem are constantly evolving, and we always appreciate contributions! -For short description of available commands, run `vcpkg help`. +If you've never used vcpkg before, or if you're trying to figure out how to use vcpkg, +check out our [Getting Started](#getting-started) section for how to start using vcpkg. + +For short description of available commands, once you've installed vcpkg, +you can run `vcpkg help`, or `vcpkg help [command]` for command-specific help. * Github: [https://github.com/microsoft/vcpkg](https://github.com/microsoft/vcpkg) * Slack: [https://cppalliance.org/slack/](https://cppalliance.org/slack/), the #vcpkg channel @@ -12,74 +17,378 @@ For short description of available commands, run `vcpkg help`. [](https://dev.azure.com/vcpkg/public/_build/latest?definitionId=29&branchName=master) -## Quick Start + +# Table of Contents + +- [Vcpkg: Overview](#vcpkg-overview) +- [Table of Contents](#table-of-contents) +- [Getting Started](#getting-started) + - [Quick Start: Windows](#quick-start-windows) + - [Quick Start: Unix](#quick-start-unix) + - [Installing Linux Developer Tools](#installing-linux-developer-tools) + - [Installing macOS Developer Tools](#installing-macos-developer-tools) + - [Installing GCC for macOS before 10.15](#installing-gcc-for-macos-before-1015) + - [Using vcpkg with CMake](#using-vcpkg-with-cmake) + - [Visual Studio Code with CMake Tools](#visual-studio-code-with-cmake-tools) + - [Vcpkg with Visual Studio CMake Projects](#vcpkg-with-visual-studio-cmake-projects) + - [Vcpkg with CLion](#vcpkg-with-clion) + - [Vcpkg as a Submodule](#vcpkg-as-a-submodule) + - [Quick Start: Manifests](#quick-start-manifests) +- [Tab-Completion/Auto-Completion](#tab-completionauto-completion) +- [Examples](#examples) +- [Contributing](#contributing) +- [License](#license) +- [Telemetry](#telemetry) + +# Getting Started + +First, follow the quick start guide for either +[Windows](#quick-start-windows), or [macOS and Linux](#quick-start-unix), +depending on what you're using. + +For more information, see [Installing and Using Packages][getting-vcpkg:using-a-package]. +If a library you need is not present in the vcpkg catalog, +you can [open an issue on the GitHub repo][getting-vcpkg:open-issue] +where the vcpkg team and community can see it, +and potentially add the port to vcpkg. + +After you've gotten vcpkg installed and working, +you may wish to add [tab completion](#tab-completionauto-completion) to your shell. + +Finally, if you're interested in the future of vcpkg, +check out the [manifest](#quick-start-manifest) guide! +This is an experimental feature and will likely have bugs, +so try it out and [open all the issues][contributing:submit-issue]! + +## Quick Start: Windows + Prerequisites: -- Windows 10, 8.1, 7, Linux, or MacOS -- Visual Studio 2015 Update 3 or newer (on Windows) -- Git -- gcc >= 7 or equivalent clang (on Linux) -- *Optional:* CMake 3.12.4 +- Windows 7 or newer +- [Git][quick-start:git] +- [Visual Studio][quick-start:visual-studio] 2015 Update 3 or greater with the English language pack + +First, download and bootstrap vcpkg itself; it can be installed anywhere, +but generally we recommend using vcpkg as a submodule for CMake projects, +and installing it globally for Visual Studio projects. +We recommend somewhere like `C:\src\vcpkg` or `C:\dev\vcpkg`, +since otherwise you may run into path issues for some port build systems. + +```cmd +> git clone https://github.com/microsoft/vcpkg +> .\vcpkg\bootstrap-vcpkg.bat +``` + +To install the libraries for your project, run: + +```cmd +> .\vcpkg\vcpkg install [packages to install] +``` + +You can also search for the libraries you need with the `search` subcommand: + +```cmd +> .\vcpkg\vcpkg search [search term] +``` + +In order to use vcpkg with Visual Studio, +run the following command (may require administrator elevation): + +```cmd +> .\vcpkg\vcpkg integrate install +``` + +After this, you can now create a New non-CMake Project (or open an existing one). +All installed libraries are immediately ready to be `#include`'d and used +in your project without additional configuration. + +If you're using CMake with Visual Studio, +continue [here](#vcpkg-with-visual-studio-cmake-projects). + +In order to use vcpkg with CMake outside of an IDE, +you can use the toolchain file: + +``` +> cmake -B [build directory] -S . -DCMAKE_TOOLCHAIN_FILE=[path to vcpkg]/scripts/buildsystems/vcpkg.cmake +> cmake --build [build directory] +``` + +With CMake, you will still need to `find_package` and the like to use the libraries. +Check out the [CMake section](#using-vcpkg-with-cmake) for more information, +including on using CMake with an IDE. + +For any other tools, including Visual Studio Code, +check out the [integration guide][quick-start:integration]. + +## Quick Start: Unix + +Prerequisites for Linux: +- [Git][quick-start:git] +- [g++][quick-start:linux-gcc] >= 6 + +Prerequisites for macOS: +- [Apple Developer Tools][quick-start:apple-developer-tools] +- On macOS 10.14 or below, you will also need: + - [Homebrew][quick-start:homebrew] + - [g++][quick-start:macos-gcc] >= 6 from Homebrew + +First, download and bootstrap vcpkg itself; it can be installed anywhere, +but generally we recommend using vcpkg as a submodule for CMake projects. + +```sh +$ git clone https://github.com/microsoft/vcpkg +$ ./vcpkg/bootstrap-vcpkg.sh +``` + +To install the libraries for your project, run: + +```sh +$ ./vcpkg/vcpkg install [packages to install] +``` + +You can also search for the libraries you need with the `search` subcommand: + +```sh +$ ./vcpkg/vcpkg search [search term] +``` + +In order to use vcpkg with CMake, you can use the toolchain file: + +``` +> cmake -B [build directory] -S . -DCMAKE_TOOLCHAIN_FILE=[path to vcpkg]/scripts/buildsystems/vcpkg.cmake +> cmake --build [build directory] +``` + +With CMake, you will still need to `find_package` and the like to use the libraries. +Check out the [CMake section](#using-vcpkg-with-cmake) +for more information on how best to use vcpkg with CMake, +and CMake Tools for VSCode. + +For any other tools, check out the [integration guide][quick-start:integration]. + +## Installing Linux Developer Tools -To get started: +Across the different distros of Linux, there are different packages you'll +need to install: + +- Debian, Ubuntu, popOS, and other Debian-based distributions: + +```sh +$ sudo apt-get update +$ sudo apt-get install build-essential tar curl zip unzip ``` -> git clone https://github.com/Microsoft/vcpkg.git -> cd vcpkg -PS> .\bootstrap-vcpkg.bat -Linux:~/$ ./bootstrap-vcpkg.sh +- CentOS + +```sh +$ sudo yum install centos-release-scl +$ sudo yum install devtoolset-7 +$ scl enable devtoolset-7 bash ``` -Then, to hook up user-wide [integration](docs/users/integration.md), run (note: requires admin on first use) +For any other distributions, make sure you're installing g++ 6 or above. +If you want to add instructions for your specific distro, +[please open a PR][contributing:submit-pr]! + +## Installing macOS Developer Tools + +On macOS 10.15, the only thing you should need to do is run the following in your terminal: + +```sh +$ xcode-select --install ``` -PS> .\vcpkg integrate install -Linux:~/$ ./vcpkg integrate install + +Then follow along with the prompts in the windows that comes up. + +On macOS 10.14 and previous, you'll also need to install g++ from homebrew; +follow the instructions in the following section. + +### Installing GCC for macOS before 10.15 + +This will _only_ be necessary if you're using a macOS version from before 10.15. +Installing homebrew should be very easy; check out <brew.sh> for more information, +but at its simplest, run the following command: + +```sh +$ /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)" ``` -Install any packages with +Then, in order to grab an up-to-date version of gcc, run the following: + +```sh +$ brew install gcc ``` -PS> .\vcpkg install sdl2 curl -Linux:~/$ ./vcpkg install sdl2 curl + +You'll then be able to bootstrap vcpkg along with the [quick start guide](#quick-start-unix) + +## Using vcpkg with CMake + +If you're using vcpkg with CMake, the following may help! + +### Visual Studio Code with CMake Tools + +Adding the following to your workspace `settings.json` will make +CMake Tools automatically use vcpkg for libraries: + +```json +{ + "cmake.configureSettings": { + "CMAKE_TOOLCHAIN_FILE": "[vcpkg root]/scripts/buildsystems/vcpkg.cmake" + } +} ``` -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=[vcpkg root]\scripts\buildsystems\vcpkg.cmake`. +### Vcpkg with Visual Studio CMake Projects + +Open the CMake Settings Editor, and under `CMake toolchain file`, +add the path to the vcpkg toolchain file: -In Visual Studio, you can create a New Project (or open an existing one). All installed libraries are immediately ready to be `#include`'d and used in your project without additional configuration. +``` +[vcpkg root]/scripts/buildsystems/vcpkg.cmake +``` -For more information, see our [using a package](docs/examples/installing-and-using-packages.md) example for the specifics. If your library is not present in vcpkg catalog, you can open an [issue on the GitHub repo](https://github.com/microsoft/vcpkg/issues) where the dev team and the community can see it and potentially create the port file for this library. +### Vcpkg with CLion -Additional notes on macOS and Linux support can be found in the [official announcement](https://blogs.msdn.microsoft.com/vcblog/2018/04/24/announcing-a-single-c-library-manager-for-linux-macos-and-windows-vcpkg/). +Open the Toolchains settings +(File > Settings on Windows and Linux, CLion > Preferences on macOS), +and go to the CMake settings (Build, Execution, Deployment > CMake). +Finally, in `CMake options`, add the following line: -## Tab-Completion / Auto-Completion -`vcpkg` supports auto-completion of commands, package names, options etc in Powershell and bash. To enable tab-completion, use one of the following: ``` -PS> .\vcpkg integrate powershell -Linux:~/$ ./vcpkg integrate bash +-DCMAKE_TOOLCHAIN_FILE=C:/Users/nimazzuc/src/vcpkg/scripts/buildsystems/vcpkg.cmake ``` -and restart your console. +Unfortunately, you'll have to add this to each profile. + +### Vcpkg as a Submodule + +When using vcpkg as a submodule of your project, +you can add the following to your CMakeLists.txt before the first `project()` call, +instead of passing `CMAKE_TOOLCHAIN_FILE` to the cmake invocation. + +```cmake +set(CMAKE_TOOLCHAIN_FILE ${CMAKE_CURRENT_SOURCE_DIR}/vcpkg/scripts/buildsystems/vcpkg.cmake + CACHE STRING "Vcpkg toolchain file") +``` -## Examples -See the [documentation](docs/index.md) for specific walkthroughs, including [installing and using a package](docs/examples/installing-and-using-packages.md), [adding a new package from a zipfile](docs/examples/packaging-zipfiles.md), and [adding a new package from a GitHub repo](docs/examples/packaging-github-repos.md). +This will still allow people to not use vcpkg, +by passing the `CMAKE_TOOLCHAIN_FILE` directly, +but it will make the configure-build step slightly easier. + +## Quick Start: Manifests + +So, you want to look at what the future of vcpkg is going to be like! +We really appreciate it 😄. First, though, a warning: +manifest support in vcpkg is still in beta! Mostly, it should just work, +but there are no guarantees and it's likely you'll hit at least a bug or two +while you're using vcpkg in this mode. Additionally, +we will likely break behavior before stabilizing, so be forewarned. +Please [open issues][contributing:submit-issue] if you hit any bugs! + +First, install vcpkg as normal for [Windows](#quick-start-windows) or +[Unix](#quick-start-unix). +You may wish to install vcpkg in a central place, +as the installed directory exists locally, +and it's fine to run multiple vcpkg commands from the same +vcpkg directory at the same time. + +Then, we must turn on the `manifests` vcpkg feature flag by adding +`manifests` to the comma-separated `--feature-flags` option, +or by adding it to the comma-separated `VCPKG_FEATURE_FLAGS` +environment variable. + +You may also want to add vcpkg to the `PATH`. + +Then, all one has to do is create a manifest; +create a file called `vcpkg.json`, and type the following: + +```json +{ + "name": "<name of your project>", + "version-string": "<version of your project>", + "dependencies": [ + "abseil", + "boost" + ] +} +``` + +The libraries will be installed into the `vcpkg_installed` +directory, in the same directory as your `vcpkg.json`. +If you can use the regular CMake toolchain, +or the Visual Studio/MSBuild integration, +it will install the dependencies automatically, +although you will need to set `VcpkgManifestEnabled` to `On` for MSBuild. +If you wish to install your dependencies without using either CMake or MSBuild, +you may use a simple `vcpkg install --feature-flags=manifests` + +For more information, check out the [manifest][getting-started:manifest-spec] +specification. + +[getting-started:using-a-package]: docs/examples/intalling-and-using-packages.md +[getting-started:git]: https://git-scm.com/downloads +[getting-started:cmake-tools]: https://marketplace.visualstudio.com/items?itemName=ms-vscode.cmake-tools +[getting-started:linux-gcc]: #installing-linux-developer-tools +[getting-started:macos-dev-tools]: #installing-macos-developer-tools +[getting-started:macos-brew]: #installing-gcc-on-macos +[getting-started:macos-gcc]: #installing-gcc-on-macos +[getting-started:visual-studio]: https://visualstudio.microsoft.com/ +[getting-started:manifest-spec]: docs/specifications/manifests.md + +# Tab-Completion/Auto-Completion + +`vcpkg` supports auto-completion of commands, package names, +and options in both powershell and bash. +To enable tab-completion in the shell of your choice, run: + +```pwsh +> .\vcpkg integrate powershell +``` + +or + +```sh +$ ./vcpkg integrate bash +``` + +depending on the shell you use, then restart your console. + + +# Examples + +See the [documentation](docs/index.md) for specific walkthroughs, +including [installing and using a package](docs/examples/installing-and-using-packages.md), +[adding a new package from a zipfile](docs/examples/packaging-zipfiles.md), +and [adding a new package from a GitHub repo](docs/examples/packaging-github-repos.md). Our docs are now also available online at ReadTheDocs: <https://vcpkg.readthedocs.io/>! See a 4 minute [video demo](https://www.youtube.com/watch?v=y41WFKbQFTw). -## Contributing -Vcpkg is built with your contributions. Here are some ways you can contribute: +# Contributing + +Vcpkg is an open source project, and is thus built with your contributions. +Here are some ways you can contribute: + +* [Submit Issues][contributing:submit-issue] in vcpkg or existing packages +* [Submit Fixes and New Packages][contributing:submit-pr] -* [Submit Issues](https://github.com/Microsoft/vcpkg/issues) in vcpkg or existing packages -* [Submit Fixes and New Packages](https://github.com/Microsoft/vcpkg/pulls) +Please refer to our [Contributing Guide](CONTRIBUTING.md) for more details. -Please refer to our [Contribution guidelines](CONTRIBUTING.md) for more details. +This project has adopted the [Microsoft Open Source Code of Conduct][contributing:coc]. +For more information see the [Code of Conduct FAQ][contributing:coc-faq] +or email [opencode@microsoft.com](mailto:opencode@microsoft.com) +with any additional questions or comments. -This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments. +[contributing:submit-issue]: https://github.com/microsoft/vcpkg/issues/new/choose +[contributing:submit-pr]: https://github.com/microsoft/vcpkg/pulls +[contributing:coc]: https://opensource.microsoft.com/codeofconduct/ +[contributing:coc-faq]: https://opensource.microsoft.com/codeofconduct/ -## License +# License -Code licensed under the [MIT License](LICENSE.txt). +The code in this repository is licensed under the [MIT License](LICENSE.txt). -## Telemetry +# Telemetry vcpkg collects usage data in order to help us improve your experience. The data collected by Microsoft is anonymous. diff --git a/README_zh_CN.md b/README_zh_CN.md index ab53d7180..1521c702a 100644 --- a/README_zh_CN.md +++ b/README_zh_CN.md @@ -1,72 +1,361 @@ -# Vcpkg +# Vcpkg 总览 ## 概要 -Vcpkg 可帮助您在 Windows、Linux 和 MacOS 上管理 C 和 C++ 库。这个工具和生态系统正在不断发展,您的参与对它的成功至关重要! +Vcpkg 可帮助您在 Windows、 Linux 和 MacOS 上管理 C 和 C++ 库。 +这个工具和生态链正在不断发展,我们一直期待您的贡献! -如需获取有关可用命令的简短描述, 请执行 `vcpkg help`。 +若您从未使用过vcpkg或希望了解如何使用vcpkg,请查阅[快速开始](#getting-started)章节。 + +如需获取有关可用命令的简短描述,请在编译vcpkg后执行 `vcpkg help` 或执行 `vcpkg help [command]` 来获取具体的帮助信息。 + +* Github: [https://github.com/microsoft/vcpkg](https://github.com/microsoft/vcpkg) +* Slack: [https://cppalliance.org/slack/](https://cppalliance.org/slack/), #vcpkg 频道 +* Discord: [\#include \<C++\>](https://www.includecpp.org), #🌏vcpkg 频道 +* 文档: [Documentation](docs/index.md) + +[](https://dev.azure.com/vcpkg/public/_build/latest?definitionId=29&branchName=master) + +# 目录 + +- [Vcpkg 总览](#vcpkg-总览) + * [概要](#概要) +- [目录](#目录) +- [入门](#入门) + * [快速开始: Windows](#快速开始-windows) + * [快速开始: Unix](#快速开始-unix) + * [安装 Linux Developer Tools](#安装-linux-developer-tools) + * [安装 macOS Developer Tools](#安装-macos-developer-tools) + + [在 macOS 10.15 之前版本中安装 GCC](#在-macos-1015-之前版本中安装-gcc) + * [在 CMake 中使用 vcpkg](#在-cmake-中使用-vcpkg) + + [Visual Studio Code 中的 CMake Tools](#visual-studio-code-中的-cmake-tools) + + [Visual Studio CMake 工程中使用 vcpkg](#visual-studio-cmake-工程中使用-vcpkg) + + [CLion 中使用 vcpkg](#clion-中使用-vcpkg) + + [将 vcpkg 作为一个子模块](#将-vcpkg-作为一个子模块) + * [快速开始: 清单](#快速开始-清单) +- [Tab补全/自动补全](#tab补全自动补全) + * [示例](#示例) + * [贡献者](#贡献者) +- [License](#license) +- [数据收集](#数据收集) + +# 入门 + +首先,请遵循以下任一方面的快速入门指南: +[Windows](#quick-start-windows) 或 [macOS和Linux](#quick-start-unix), +这取决于您使用的是什么平台。 + +有关更多信息,请参见 [安装和使用软件包] [getting-vcpkg:using-a-package]。 +如果vcpkg目录中没有您需要的库, +您可以 [在GitHub上打开问题] [getting-vcpkg:open-issue] +vcpkg团队和社区可以看到它的地方, +并可能将这个库添加到vcpkg。 + +安装并运行vcpkg后, +您可能希望将 [TAB补全](#tab-completionauto-completion) 添加到您的Shell中。 + +最后,如果您对vcpkg的未来感兴趣,请查看 [清单](#quick-start-manifest)! +这是一项实验性功能,可能会出现错误。 +因此,请尝试一下并[打开所有问题][contributing:submit-issue]! + +## 快速开始: Windows -## 快速开始 需求: -- Windows 10、8.1、7、Linux、或 MacOS -- Visual Studio 2015 Update 3 或更新的版本 (Windows 中) -- Git -- *可选:* CMake 3.12.4 +- Windows 7 或更新的版本 +- [Git][quick-start:git] +- [Visual Studio][quick-start:visual-studio] 2015 Update 3 或更新的版本(包含英文语言包) + +首先,请下载vcpkg并执行bootstrap.bat脚本。 +它可以安装在任何地方,但是通常我们建议您使用 vcpkg 作为 CMake 项目的子模块,并为 Visual Studio 项目在全局安装它。 +我们建议您使用例如 `C:\src\vcpkg` 或 `C:\dev\vcpkg` 的安装目录,否则您可能遇到某些库构建系统的路径问题。 + +```cmd +> git clone https://github.com/microsoft/vcpkg +> .\vcpkg\bootstrap-vcpkg.bat +``` + +使用以下命令为您的项目安装需要的库: + +```cmd +> .\vcpkg\vcpkg install [packages to install] +``` + +您也可以使用 `search` 子命令来查找vcpkg中集成的库: + +```cmd +> .\vcpkg\vcpkg search [search term] +``` + +若您希望在 Visual Studio 中使用vcpkg,请运行以下命令 (首次启动需要管理员权限) + +```cmd +> .\vcpkg\vcpkg integrate install +``` + +在此之后, 您可以创建一个非cmake项目 (或打开已有的项目)。 +在您的项目中,所有已安装的库均可立即使用 `#include` 包含您需使用的库的头文件并无需添加额外配置。 + +若您在 Visual Studio 中使用cmake工程,请查阅[这里](#vcpkg-with-visual-studio-cmake-projects)。 + +为了在IDE以外在cmake中使用vcpkg, 您需要使用以下工具链文件: + +``` +> cmake -B [build directory] -S . -DCMAKE_TOOLCHAIN_FILE=[path to vcpkg]/scripts/buildsystems/vcpkg.cmake +> cmake --build [build directory] +``` + +在cmake中,您仍需通过 `find_package` 来使用第三方库。 +请查阅 [CMake 章节](#using-vcpkg-with-cmake) 获取更多信息,其中包含了在IDE中使用cmake的内容。 + +对于其他工具 (包括Visual Studio Code),请查阅 [集成指南][quick-start:integration]。 + +## 快速开始: Unix + +Linux平台的使用需求: +- [Git][quick-start:git] +- [g++][quick-start:linux-gcc] >= 6 + +macOS平台的使用需求: +- [Apple Developer Tools][quick-start:apple-developer-tools] +- macOS 10.14 或更低版本中,您也需要: + - [Homebrew][quick-start:homebrew] + - Homebrew 中 [g++][quick-start:macos-gcc] >= 6 + +首先,请下载vcpkg并执行bootstrap.sh脚本。 +我们总体上建议您将vcpkg作为cmake项目的子模块使用。 + +```sh +$ git clone https://github.com/microsoft/vcpkg +$ ./vcpkg/bootstrap-vcpkg.sh +``` + +使用以下命令安装任意包: + +```sh +$ ./vcpkg/vcpkg install [packages to install] +``` + +您也可以使用 `search` 子命令来查找vcpkg中集成的库: + +```sh +$ ./vcpkg/vcpkg search [search term] +``` + +为了在cmake中使用vcpkg, 您需要使用以下工具链文件: + +``` +> cmake -B [build directory] -S . -DCMAKE_TOOLCHAIN_FILE=[path to vcpkg]/scripts/buildsystems/vcpkg.cmake +> cmake --build [build directory] +``` + +在cmake中,您仍需通过 `find_package` 来使用第三方库。 +为了您更好的在cmake或 VSCode CMake Tools 中使用vcpkg, +请查阅 [CMake 章节](#using-vcpkg-with-cmake) 获取更多信息, +其中包含了在IDE中使用cmake的内容。 + +对于其他工具,请查阅 [集成指南][quick-start:integration]。 + +## 安装 Linux Developer Tools -如何开始: +在Linux的不同发行版中,您需要安装不同的工具包: + +- Debian, Ubuntu, popOS, 或其他基于 Debian 的发行版: + +```sh +$ sudo apt-get update +$ sudo apt-get install build-essential tar curl zip unzip +``` + +- CentOS + +```sh +$ sudo yum install centos-release-scl +$ sudo yum install devtoolset-7 +$ scl enable devtoolset-7 bash +``` + +对于其他的发行版,请确保已安装 g++ 6 或更新的版本。 +若您希望添加特定发行版的说明, [请提交一个 PR][contributing:submit-pr]! + +## 安装 macOS Developer Tools + +在 macOS 10.15 中,唯一需要做的是在终端中运行以下命令: + +```sh +$ xcode-select --install +``` + +然后按照出现的窗口中的提示进行操作。 + +在 macOS 10.14 及先前版本中,您也需要使用 homebrew 安装 g++。 +请遵循以下部分中的说明: + +### 在 macOS 10.15 之前版本中安装 GCC + +此条_只_在您的macOS版本低于 10.15 时是必须的。 +安装homebrew应当很轻松, 请查阅 <brew.sh> 以获取更多信息。 +为了更简便,请使用以下命令: + +```sh +$ /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)" +``` + +然后,为了获取最新版本的gcc,请运行以下命令: + +```sh +$ brew install gcc +``` + +此时,您就可以使用 bootstarp.sh 编译vcpkg了。 请参阅 [quick start guide](#quick-start-unix) + +## 在 CMake 中使用 vcpkg + +若您希望在CMake中使用vcpkg, 以下内容可能帮助您: + +### Visual Studio Code 中的 CMake Tools + +将以下内容添加到您的工作区 `settings.json` 中将使CMake Tools自动使用vcpkg中的第三方库: + +```json +{ + "cmake.configureSettings": { + "CMAKE_TOOLCHAIN_FILE": "[vcpkg root]/scripts/buildsystems/vcpkg.cmake" + } +} ``` -> git clone https://github.com/Microsoft/vcpkg.git -> cd vcpkg -PS> .\bootstrap-vcpkg.bat -Linux:~/$ ./bootstrap-vcpkg.sh +### Visual Studio CMake 工程中使用 vcpkg + +打开CMake设置选项,将 vcpkg toolchain 文件路径在 `CMake toolchain file` 中: + +``` +[vcpkg root]/scripts/buildsystems/vcpkg.cmake ``` -然后,[集成](docs/users/integration.md)至本机环境中,执行 (注意: 首次启动需要管理员权限) +### CLion 中使用 vcpkg + +打开 Toolchains 设置 +(File > Settings on Windows and Linux, CLion > Preferences on macOS), +并打开 CMake 设置 (Build, Execution, Deployment > CMake)。 +最后在 `CMake options` 中添加以下行: + ``` -PS> .\vcpkg integrate install -Linux:~/$ ./vcpkg integrate install +-DCMAKE_TOOLCHAIN_FILE=C:/Users/nimazzuc/src/vcpkg/scripts/buildsystems/vcpkg.cmake ``` -使用以下命令安装任意包 +遗憾的是, 您必须手动将此选项加入每个项目配置文件中。 + +### 将 vcpkg 作为一个子模块 + +当您希望将vcpkg作为一个子模块加入到您的工程中时, +您可以在第一个 `project()` 调用之前将以下内容添加到 CMakeLists.txt 中, +而无需将 `CMAKE_TOOLCHAIN_FILE` 传递给cmake调用。 + +```cmake +set(CMAKE_TOOLCHAIN_FILE ${CMAKE_CURRENT_SOURCE_DIR}/vcpkg/scripts/buildsystems/vcpkg.cmake + CACHE STRING "Vcpkg toolchain file") ``` -PS> .\vcpkg install sdl2 curl -Linux:~/$ ./vcpkg install sdl2 curl + +这仍然允许您不通过直接传递 `CMAKE_TOOLCHAIN_FILE` 来使用vcpkg,但这会使配置构建步骤稍微容易一些。 + +## 快速开始: 清单 + +如果您期待vcpkg在未来会更好,我们真的很感激😄。 +但是,首先要警告: vcpkg中的清单支持仍处于beta中! +通常,它应该可以正常工作,但您很可能会在这种模式下使用vcpkg时遇到至少一个或两个错误。 +另外,我们可能会在稳定之前破坏行为,因此请提前警告。 +如果您遇到任何错误,请 [提交一个issue][contributing:submit-issue]! + +首先,为 [Windows](#quick-start-windows) 正常安装vcpkg或 [Unix](#quick-start-unix)。 +您可能希望将vcpkg安装在常用的位置,由于安装的目录位于本地,并且可以从同一vcpkg目录中同时运行多个vcpkg命令。 + +然后,您必须通过将 `manifests` 添加到以逗号分隔的 `--feature-flags` 选项中来打开 `manifests` vcpkg功能标记, +或将其添加到以逗号分隔的 `VCPKG_FEATURE_FLAGS` 环境变量中。 + +您也可能希望添加vcpkg路径至环境变量 `PATH` 中。 +这时,我们要做的就是创建清单。 +创建一个名为 `vcpkg.json` 的文件,然后添加以下内容: + +```json +{ + "name": "<name of your project>", + "version-string": "<version of your project>", + "dependencies": [ + "abseil", + "boost" + ] +} ``` -与CMake一起使用已安装库的最佳方法是通过工具链文件 `scripts\buildsystems\vcpkg.cmake`。要使用此文件,您只需将 `-DCMAKE_TOOLCHAIN_FILE=[vcpkg root]\scripts\buildsystems\vcpkg.cmake` 作为参数添加到CMake命令行中。 +您所安装的库将生成在 `vcpkg_installed` 文件夹中,并与您的 `vcpkg.json` 所在的文件夹相同。 +如果您可以使用常规的CMake toolchain 或 Visual Studio / MSBuild 集成, +它将自动安装依赖项,尽管您需要将MSBuild的 `VcpkgManifestEnabled` 设置为 `On`。 +如果您希望不使用CMake或MSBuild来安装依赖项,您可以使用命令 `vcpkg install --feature-flags = manifests` 。 + +请查阅 [清单][getting-started:manifest-spec] 获取更多信息。 + +[getting-started:using-a-package]: docs/examples/intalling-and-using-packages.md +[getting-started:git]: https://git-scm.com/downloads +[getting-started:cmake-tools]: https://marketplace.visualstudio.com/items?itemName=ms-vscode.cmake-tools +[getting-started:linux-gcc]: #installing-linux-developer-tools +[getting-started:macos-dev-tools]: #installing-macos-developer-tools +[getting-started:macos-brew]: #installing-gcc-on-macos +[getting-started:macos-gcc]: #installing-gcc-on-macos +[getting-started:visual-studio]: https://visualstudio.microsoft.com/ +[getting-started:manifest-spec]: docs/specifications/manifests.md + +# Tab补全/自动补全 -在Visual Studio中,您可以创建一个新项目(或打开一个已有项目)。所有已安装的库都可以使用 `#include` 在您的项目中使用,而无需进行其他配置。 +`vcpkg` 支持命令,包名称,以及 Powershell 和 Bash 中的选项。 +要在您选择的 shell 中启用Tab补全功能,请运行: -若需获取更多信息,请查看[使用一个包](docs/examples/installing-and-using-packages.md)具体示例。 若您需要使用的库不在vcpkg中,请[在GitHub上创建一个issue](https://github.com/microsoft/vcpkg/issues) ,开发团队和贡献者会看到它,并有可能为此库创建端口文件。 +```pwsh +> .\vcpkg integrate powershell +``` -有关 macOS 和 Linux 支持的其他说明,请参见[官方公告](https://blogs.msdn.microsoft.com/vcblog/2018/04/24/announcing-a-single-c-library-manager-for-linux-macos-and-windows-vcpkg/)。 +或 -## Tab补全/自动补全 -`vcpkg`支持在 Powershell 和 bash 中自动补全命令、程序包名称、选项等。如需启用自动补全功能,请使用以下命令: ``` -PS> .\vcpkg integrate powershell -Linux:~/$ ./vcpkg integrate bash +$ ./vcpkg integrate bash ``` -并重启您的控制台。 +这依据您使用的shell,然后重新启动控制台。 ## 示例 -请查看[文档](docs/index.md)获取具体示例,其包含[安装并使用包](docs/examples/installing-and-using-packages.md),[使用压缩文件添加包](docs/examples/packaging-zipfiles.md),和[从GitHub源中添加一个包](docs/examples/packaging-github-repos.md)。 -我们的文档现在也可以从[ReadTheDocs](https://vcpkg.readthedocs.io/)在线获取。 +请查看 [文档](docs/index.md)获取具体示例, +其包含 [安装并使用包](docs/examples/installing-and-using-packages.md), +[使用压缩文件添加包](docs/examples/packaging-zipfiles.md), +与 [从GitHub源中添加一个包](docs/examples/packaging-github-repos.md)。 + +我们的文档现在也可以从 [ReadTheDocs](https://vcpkg.readthedocs.io/) 在线获取。 -观看4分钟[demo视频](https://www.youtube.com/watch?v=y41WFKbQFTw)。 +观看4分钟 [demo视频](https://www.youtube.com/watch?v=y41WFKbQFTw)。 ## 贡献者 -Vcpkg通过您的贡献不断发展。下面是一些您可以贡献的方式: -* 创建一个关于vcpkg或已支持包的[新issue](https://github.com/Microsoft/vcpkg/issues) -* [创建修复PR和创建新包](https://github.com/Microsoft/vcpkg/pulls) +Vcpkg是一个开源项目,并通过您的贡献不断发展。 +下面是一些您可以贡献的方式: + +* [提交一个关于vcpkg或已支持包的新issue][contributing:submit-issue] +* [提交修复PR和创建新包][contributing:submit-pr] + +请参阅我们的 [贡献准则](CONTRIBUTING.md) 了解更多详细信息。 + +该项目采用了 [Microsoft开源行为准则][contributing:coc]。 +获取更多信息请查看 [行为准则FAQ][contributing:coc-faq] 或联系 [opencode@microsoft.com](mailto:opencode@microsoft.com)提出其他问题或意见。 + +[contributing:submit-issue]: https://github.com/microsoft/vcpkg/issues/new/choose +[contributing:submit-pr]: https://github.com/microsoft/vcpkg/pulls +[contributing:coc]: https://opensource.microsoft.com/codeofconduct/ +[contributing:coc-faq]: https://opensource.microsoft.com/codeofconduct/ -请参阅我们的[贡献准则](CONTRIBUTING.md)了解更多详细信息。 +# License -该项目采用了[Microsoft开源行为准则](https://opensource.microsoft.com/codeofconduct/)。获取更多信息请查看 [行为准则FAQ](https://opensource.microsoft.com/codeofconduct/faq/)或联系[opencode@microsoft.com](mailto:opencode@microsoft.com)提出其他问题或意见。 +在此存储库中使用的代码均遵循 [MIT License](LICENSE.txt)。 -## License +# 数据收集 -使用的代码 License 为[MIT License](LICENSE.txt)。 +vcpkg会收集使用情况数据,以帮助我们改善您的体验。 +Microsoft收集的数据是匿名的。 +您也可以通过使用 `-disableMetrics` 、在命令行上将`--disable-metrics`传递给vcpkg,或通过设置环境变量 `VCPKG_DISABLE_METRICS` 并重新运行 bootstrap-vcpkg 脚本来选择禁用数据收集。 +请在 [privacy.md](docs/about/privacy.md) 中了解有关 vcpkg 数据收集的更多信息。 |
