You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
12
11
13
12
## Consuming libraries downloaded via vcpkg
14
13
15
-
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/).
14
+
To consume a library that you have downloaded by using the **vcpkg** package manager, you can ignore the instructions below. For more information, see:
15
+
-[vcpkg in CMake projects](/vcpkg/users/buildsystems/cmake-integration)
16
+
-[Install and use packages with CMake in Visual Studio](/vcpkg/get_started/get-started-vs)
17
+
-[vcpkg in MSBuild projects](/vcpkg/users/buildsystems/msbuild-integration)
18
+
-[Tutorial: Install and use packages with MSBuild in Visual Studio](/vcpkg/get_started/get-started-msbuild)
Copy file name to clipboardExpand all lines: docs/build/cmake-projects-in-visual-studio.md
+9-5Lines changed: 9 additions & 5 deletions
Original file line number
Diff line number
Diff line change
@@ -3,7 +3,6 @@ title: "CMake projects in Visual Studio"
3
3
description: "How to create and build C++ projects using CMake in Visual Studio."
4
4
ms.date: 02/14/2022
5
5
helpviewer_keywords: ["CMake in Visual C++"]
6
-
ms.assetid: 444d50df-215e-4d31-933a-b41841f186f8
7
6
---
8
7
# CMake projects in Visual Studio
9
8
@@ -177,7 +176,7 @@ You can add an existing CMake cache to an open project. It's done the same way y
177
176
178
177
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/).
179
178
180
-
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:
179
+
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:
@@ -221,7 +220,10 @@ In Visual Studio 2019 version 16.9 and later, Visual Studio automatically config
221
220
222
221
## Vcpkg integration
223
222
224
-
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/).
223
+
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:
224
+
225
+
-[Install and use packages with CMake in Visual Studio](/vcpkg/get_started/get-started-vs)
226
+
-[vcpkg in CMake projects](/vcpkg/users/buildsystems/cmake-integration)
225
227
226
228
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.
227
229
@@ -346,7 +348,7 @@ As soon as you save the file, the configuration step automatically runs again an
346
348
347
349
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.
348
350
349
-
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.
351
+
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.
350
352
351
353

352
354
@@ -399,4 +401,6 @@ In Visual Studio 2015, Visual Studio users can use a [CMake generator](https://c
Copy file name to clipboardExpand all lines: docs/build/creating-and-managing-visual-cpp-projects.md
+7-1Lines changed: 7 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -53,7 +53,13 @@ Add source code files, icons, or any other items to your project by right-clicki
53
53
54
54
## Add third-party libraries to a project
55
55
56
-
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.
56
+
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.
57
+
58
+
For more information about consuming a library that you have downloaded by using the **vcpkg** package manager, see:
59
+
-[vcpkg in CMake projects](/vcpkg/users/buildsystems/cmake-integration)
60
+
-[Install and use packages with CMake in Visual Studio](/vcpkg/get_started/get-started-vs)
61
+
-[vcpkg in MSBuild projects](/vcpkg/users/buildsystems/msbuild-integration)
62
+
-[Tutorial: Install and use packages with MSBuild in Visual Studio](/vcpkg/get_started/get-started-msbuild)
57
63
58
64
They're also commercial third-party libraries that you can install. Follow their installation instructions.
Copy file name to clipboardExpand all lines: docs/build/walkthrough-using-msbuild-to-create-a-visual-cpp-project.md
+5-13Lines changed: 5 additions & 13 deletions
Original file line number
Diff line number
Diff line change
@@ -14,19 +14,15 @@ This walkthrough demonstrates how to use MSBuild in a command prompt to build a
14
14
This walkthrough illustrates these tasks:
15
15
16
16
- Creating the C++ source files for your project.
17
-
18
17
- Creating the XML MSBuild project file.
19
-
20
18
- Using MSBuild to build your project.
21
-
22
19
- Using MSBuild to customize your project.
23
20
24
21
## Prerequisites
25
22
26
23
You need these prerequisites to complete this walkthrough:
27
24
28
25
- A copy of Visual Studio with the **Desktop development with C++** workload installed.
29
-
30
26
- A general understanding of the MSBuild system.
31
27
32
28
::: moniker range="msvc-140"
@@ -57,7 +53,6 @@ In this walkthrough, you'll create a project that has a source file and a header
57
53
### To create the C++ source files for your project
58
54
59
55
1. Create a folder for your project.
60
-
61
56
1. Create a file named *`main.cpp`* and add this code to the file:
62
57
63
58
```cpp
@@ -83,9 +78,7 @@ In this walkthrough, you'll create a project that has a source file and a header
83
78
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:
84
79
85
80
- Three item group tags (`<ItemGroup>`) that specify project configuration and platform, source file name, and header file name.
86
-
87
81
- Three import tags (`<Import>`) that specify the location of Microsoft Visual C++ settings.
88
-
89
82
- A property group tag (`<PropertyGroup>`) that specifies project settings.
90
83
91
84
### To create the MSBuild project file
@@ -209,13 +202,9 @@ The application should display "Hello, from MSBuild!" in the console window.
209
202
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:
210
203
211
204
- Using MSBuild with build targets.
212
-
213
205
- Using MSBuild with build properties.
214
-
215
206
- Using MSBuild with the 64-bit compiler and tools.
216
-
217
207
- Using MSBuild with different toolsets.
218
-
219
208
- Adding MSBuild customizations.
220
209
221
210
### Using MSBuild with Build Targets
@@ -277,7 +266,10 @@ To rebuild your project with the Visual C++ 11.0 Windows XP toolset, enter this
277
266
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:
278
267
279
268
-[How to: Add a Custom Build Step to MSBuild Projects](how-to-add-a-custom-build-step-to-msbuild-projects.md)
280
-
281
269
-[How to: Add Custom Build Tools to MSBuild Projects](how-to-add-custom-build-tools-to-msbuild-projects.md)
282
-
283
270
-[How to: Use Build Events in MSBuild Projects](how-to-use-build-events-in-msbuild-projects.md)
271
+
272
+
## See also
273
+
274
+
-[vcpkg in MSBuild projects](/vcpkg/users/buildsystems/msbuild-integration)
275
+
-[Tutorial: Install and use packages with MSBuild in Visual Studio](/vcpkg/get_started/get-started-msbuild)
0 commit comments