Skip to content

Repo sync for protected branch #4801

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Nov 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions docs/build/adding-references-in-visual-cpp-projects.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,18 @@ title: "Consuming libraries and components in C++ projects"
ms.date: 12/18/2020
f1_keywords: ["VC.Project.References"]
helpviewer_keywords: ["Add References Dialog Box (C++)", ".NET Framework (C++), Add References Dialog Box"]
ms.assetid: 12b8f571-0f21-40b3-9404-5318a57e9cb5
---
# Consuming libraries and components

C++ projects often need to call functions or access data in a binary file such as static library (LIB files), DLL, Windows Runtime component, COM component, or .NET assembly. In these cases, you have to configure the project so that it can find that binary at build time. The specific steps depend on the type of your project, the type of the binary, and whether the binary gets built in the same solution as your project.

## Consuming libraries downloaded via vcpkg

To consume a library that you have downloaded by using the **vcpkg** package manager, you can ignore the instructions below. For more information, see [vcpkg.io](https://vcpkg.io/).
To consume a library that you have downloaded by using the **vcpkg** package manager, you can ignore the instructions below. For more information, see:
- [vcpkg in CMake projects](/vcpkg/users/buildsystems/cmake-integration)
- [Install and use packages with CMake in Visual Studio](/vcpkg/get_started/get-started-vs)
- [vcpkg in MSBuild projects](/vcpkg/users/buildsystems/msbuild-integration)
- [Tutorial: Install and use packages with MSBuild in Visual Studio](/vcpkg/get_started/get-started-msbuild)

## Consuming static libraries

Expand Down
14 changes: 9 additions & 5 deletions docs/build/cmake-projects-in-visual-studio.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ title: "CMake projects in Visual Studio"
description: "How to create and build C++ projects using CMake in Visual Studio."
ms.date: 02/14/2022
helpviewer_keywords: ["CMake in Visual C++"]
ms.assetid: 444d50df-215e-4d31-933a-b41841f186f8
---
# CMake projects in Visual Studio

Expand Down Expand Up @@ -177,7 +176,7 @@ You can add an existing CMake cache to an open project. It's done the same way y

Visual Studio uses the CMake [file-based API](https://cmake.org/cmake/help/latest/manual/cmake-file-api.7.html) (in versions 3.14 and later) to populate the editor with information specific to your project structure. For more information, see the C++ team blog post on [multi-root workspaces and file-based API](https://devblogs.microsoft.com/cppblog/visual-studio-code-cmake-tools-extension-multi-root-workspaces-and-file-based-api/).

Before generating the CMake cache, your custom or preferred tools may need to create a query file named *`.cmake/api/v1/query/client-MicrosoftVS/query.json`* in your build output folder (the folder that contains *`CMakeCache.txt`*). The query file should contain this content:
Before generating the CMake cache, your custom or preferred tools might need to create a query file named *`.cmake/api/v1/query/client-MicrosoftVS/query.json`* in your build output folder (the folder that contains *`CMakeCache.txt`*). The query file should contain this content:

```json
{"requests":[{"kind":"cache","version":2},{"kind":"cmakeFiles","version":1},{"kind":"codemodel","version":2}]}
Expand Down Expand Up @@ -221,7 +220,10 @@ In Visual Studio 2019 version 16.9 and later, Visual Studio automatically config

## Vcpkg integration

CMake projects opened in Visual Studio integrate with vcpkg, a cross-platform C/C++ dependency manager. Before using vcpkg with Visual Studio, you must run `vcpkg integrate install`. For instructions and more information on vcpkg, see the [vcpkg documentation](https://vcpkg.io/).
CMake projects opened in Visual Studio integrate with vcpkg, a cross-platform C/C++ dependency manager. Before using vcpkg with Visual Studio, you must run `vcpkg integrate install`. For instructions and more information about vcpkg, see:

- [Install and use packages with CMake in Visual Studio](/vcpkg/get_started/get-started-vs)
- [vcpkg in CMake projects](/vcpkg/users/buildsystems/cmake-integration)

If *`CMakeSettings.json`* is your active configuration file, Visual Studio automatically passes the vcpkg toolchain file (`vcpkg.cmake`) to CMake. This behavior is disabled automatically when you specify any other toolchain in your CMake Settings configuration.

Expand Down Expand Up @@ -346,7 +348,7 @@ As soon as you save the file, the configuration step automatically runs again an

When significant changes are made to the *`CMakeSettings.json`* or to *`CMakeLists.txt`* files, Visual Studio automatically reruns the CMake configure step. If the configure step finishes without errors, the information that's collected is available in C++ IntelliSense and language services. It's also used in build and debug operations.

Multiple CMake projects may use the same CMake configuration name (for example, x86-Debug). All of them are configured and built (in their own build root folder) when that configuration is selected. You can debug the targets from all of the CMake projects that participate in that CMake configuration.
Multiple CMake projects might use the same CMake configuration name (for example, x86-Debug). All of them are configured and built (in their own build root folder) when that configuration is selected. You can debug the targets from all of the CMake projects that participate in that CMake configuration.

![CMake Build Only menu item.](media/cmake-build-only.png "CMake Build Only menu item")

Expand Down Expand Up @@ -399,4 +401,6 @@ In Visual Studio 2015, Visual Studio users can use a [CMake generator](https://c
[`CMakeSettings.json` schema reference](cmakesettings-reference.md)\
[Configure CMake debugging sessions](configure-cmake-debugging-sessions.md)\
[Deploy, run, and debug your Linux project](../linux/deploy-run-and-debug-your-linux-project.md)\
[CMake predefined configuration reference](cmake-predefined-configuration-reference.md)
[CMake predefined configuration reference](cmake-predefined-configuration-reference.md)\
[vcpkg in CMake projects](/vcpkg/users/buildsystems/cmake-integration)\
[Install and use packages with CMake in Visual Studio](/vcpkg/get_started/get-started-vs)
8 changes: 7 additions & 1 deletion docs/build/creating-and-managing-visual-cpp-projects.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,13 @@ Add source code files, icons, or any other items to your project by right-clicki

## Add third-party libraries to a project

Over 900 C++ open source libraries are available via the [vcpkg](https://vcpkg.io/) package manager. Run the Visual Studio integration step to set up the paths to that library when you reference it from any Visual Studio project.
Over 900 C++ open source libraries are available via the [vcpkg](/vcpkg/) package manager. Run the Visual Studio integration step to set up the paths to that library when you reference it from any Visual Studio project.

For more information about consuming a library that you have downloaded by using the **vcpkg** package manager, see:
- [vcpkg in CMake projects](/vcpkg/users/buildsystems/cmake-integration)
- [Install and use packages with CMake in Visual Studio](/vcpkg/get_started/get-started-vs)
- [vcpkg in MSBuild projects](/vcpkg/users/buildsystems/msbuild-integration)
- [Tutorial: Install and use packages with MSBuild in Visual Studio](/vcpkg/get_started/get-started-msbuild)

They're also commercial third-party libraries that you can install. Follow their installation instructions.

Expand Down
3 changes: 2 additions & 1 deletion docs/build/get-started-linux-cmake.md
Original file line number Diff line number Diff line change
Expand Up @@ -207,4 +207,5 @@ Learn more about configuring and debugging CMake projects in Visual Studio:
> [Configure CMake debugging sessions](configure-cmake-debugging-sessions.md)<br/><br/>
> [Deploy, run, and debug your Linux project](../linux/deploy-run-and-debug-your-linux-project.md)<br/><br/>
> [CMake predefined configuration reference](cmake-predefined-configuration-reference.md)
>
> [vcpkg in CMake projects](/vcpkg/users/buildsystems/cmake-integration)
> [Install and use packages with CMake in Visual Studio](/vcpkg/get_started/get-started-vs)
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,15 @@ This walkthrough demonstrates how to use MSBuild in a command prompt to build a
This walkthrough illustrates these tasks:

- Creating the C++ source files for your project.

- Creating the XML MSBuild project file.

- Using MSBuild to build your project.

- Using MSBuild to customize your project.

## Prerequisites

You need these prerequisites to complete this walkthrough:

- A copy of Visual Studio with the **Desktop development with C++** workload installed.

- A general understanding of the MSBuild system.

::: moniker range="msvc-140"
Expand Down Expand Up @@ -57,7 +53,6 @@ In this walkthrough, you'll create a project that has a source file and a header
### To create the C++ source files for your project

1. Create a folder for your project.

1. Create a file named *`main.cpp`* and add this code to the file:

```cpp
Expand All @@ -83,9 +78,7 @@ In this walkthrough, you'll create a project that has a source file and a header
An MSBuild project file is an XML file that contains a project root element (`<Project>`). In the example project you'll build, the `<Project>` element contains seven child elements:

- Three item group tags (`<ItemGroup>`) that specify project configuration and platform, source file name, and header file name.

- Three import tags (`<Import>`) that specify the location of Microsoft Visual C++ settings.

- A property group tag (`<PropertyGroup>`) that specifies project settings.

### To create the MSBuild project file
Expand Down Expand Up @@ -209,13 +202,9 @@ The application should display "Hello, from MSBuild!" in the console window.
MSBuild enables you to execute predefined build targets, apply user-defined properties, and use custom tools, events, and build steps. This section illustrates these tasks:

- Using MSBuild with build targets.

- Using MSBuild with build properties.

- Using MSBuild with the 64-bit compiler and tools.

- Using MSBuild with different toolsets.

- Adding MSBuild customizations.

### Using MSBuild with Build Targets
Expand Down Expand Up @@ -277,7 +266,10 @@ To rebuild your project with the Visual C++ 11.0 Windows XP toolset, enter this
MSBuild provides various ways to customize your build process. These articles show how to add custom build steps, tools, and events to your MSBuild project:

- [How to: Add a Custom Build Step to MSBuild Projects](how-to-add-a-custom-build-step-to-msbuild-projects.md)

- [How to: Add Custom Build Tools to MSBuild Projects](how-to-add-custom-build-tools-to-msbuild-projects.md)

- [How to: Use Build Events in MSBuild Projects](how-to-use-build-events-in-msbuild-projects.md)

## See also

- [vcpkg in MSBuild projects](/vcpkg/users/buildsystems/msbuild-integration)
- [Tutorial: Install and use packages with MSBuild in Visual Studio](/vcpkg/get_started/get-started-msbuild)
Loading