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
Copy file name to clipboardExpand all lines: docs/ide/get-started-linux-cmake.md
+37-30Lines changed: 37 additions & 30 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -66,25 +66,31 @@ As soon as you open the folder, your folder structure will be visible in the **S
66
66
67
67
This view shows you exactly what is on disk, not a logical or filtered view. By default, it doesn't show hidden files.
68
68
69
-
1. To see all the files in the folder, select the **Show all files** button.
69
+
2. Press the **Show all files** button to see all the files in the folder.
70
70
71
-

71
+

72
72
73
73
## Switch to targets view
74
74
75
-
When you open a folder that uses CMake, Visual Studio automatically generates the CMake cache. This operation might take a few moments, depending on the size of your project. The status is displayed in the output window. When the operation is complete, it says "Target info extraction done".
75
+
When you open a folder that uses CMake, Visual Studio automatically generates the CMake cache. This operation might take a few moments, depending on the size of your project.
76
+
77
+
1. Monitor the status of the cache generation process in the output window. When the operation is complete, it says "Target info extraction done".
76
78
77
79

78
80
79
-
After this operation completes, IntelliSense is configured, the project can build, and you can debug the application. Visual Studio also now understands the build targets that the CMake project produces and can now provide a logical view of the solution called CMake Targets View. Use the **Solutions and Folders** button in the **Solution Explorer** to switch to this view.
81
+
After this operation completes, IntelliSense is configured, the project can build, and you can debug the application. Visual Studio can now provide a logical view of the solution based on the targets specified in the CMakeLists files.
82
+
83
+
2. Use the **Solutions and Folders** button in the **Solution Explorer** to switch to CMake Targets View.
80
84
81
-

85
+

82
86
83
-
Here is what that view looks like for the Bullet SDK.
87
+
Here is what that view looks like for the Bullet SDK:
84
88
85
89

86
90
87
-
Targets view provides a more intuitive view of what is in this source base. You can see some targets are libraries and others are executables. You can expand these nodes and see the source that comprises them independent of how it's represented on disk.
91
+
Targets view provides a more intuitive view of what is in this source base. You can see some targets are libraries and others are executables.
92
+
93
+
3. Expand a node in CMake Targets View to see its source code files, wherever those files might be located on disk.
88
94
89
95
## Set a breakpoint, build, and run
90
96
@@ -93,52 +99,55 @@ In this step, we'll debug an example program that demonstrates the Bullet Physic
93
99
1. In **Solution Explorer**, select AppBasicExampleGui and expand it.
94
100
2. Open the file `BasicExample.cpp`.
95
101
3. Set a breakpoint that will be hit when you click in the running application. The click event is handled in a method within a helper class. To quickly get there
96
-
a. select CommonRigidBodyBase that the struct BasicExample is derived from around line 30.
97
-
b. right-click and choose Go to Definition. Now you are in the header CommonRigidBodyBase.h.
98
-
c. In the browser view above, your source you should see that you are in the CommonRigidBodyBase. To the right, you can select members to examine. Click the drop-down and select mouseButtonCallback to go to the definition of that function in the header.
102
+
a. select `CommonRigidBodyBase` that the struct `BasicExample` is derived from around line 30.
103
+
b. right-click and choose **Go to Definition**. Now you are in the header CommonRigidBodyBase.h.
104
+
c. In the browser view above, your source you should see that you are in the `CommonRigidBodyBase`. To the right, you can select members to examine. Click the drop-down and select `mouseButtonCallback` to go to the definition of that function in the header.
99
105
100
106

101
107
102
108
3. Place a breakpoint on the first line within this function. This will be hit when you click a mouse button within the window of the application when launched under the Visual Studio debugger.
103
109
104
-
4. To launch the application, select the launch drop-down with the play icon that says "Select Startup Item" in the toolbar. In the drop-down select AppBasicExampleGui.exe. The executable name now displays on the Launch button:
110
+
4. To launch the application, select the launch drop-down with the play icon that says "Select Startup Item" in the toolbar. In the drop-down select AppBasicExampleGui.exe. The executable name now displays on the launch button:
105
111
106
112

107
113
108
114
5. Press the launch button to build the application and necessary dependencies, then launch it with the Visual Studio debugger attached. After a few moments, the running application appears:
109
115
110
116

111
117
112
-
6. Move your mouse into the application window, then click a button to trigger the breakpoint. This brings Visual Studio back to the foreground with the editor showing the line where execution is paused. You will be able to inspect the application variables, objects, threads, memory, and step through your code interactively using Visual Studio. You can click continue to let the application resume and exit it normally or cease execution within Visual Studio using the stop button.
113
-
114
-
What you have seen so far is by simply cloning a C++ repo from GitHub you can open the folder with Visual Studio and get an experience that provides IntelliSense, a file view, a logical view based on the build targets, source navigation, build, and debugging with no special configuration or Visual Studio specific project files. If you were to make changes to the source you would get a diff view from the upstream project, make commits, and push them back without leaving Visual Studio. There's more though. Let's use this project with Linux.
115
-
118
+
6. Move your mouse into the application window, then click a button to trigger the breakpoint. This brings Visual Studio back to the foreground with the editor showing the line where execution is paused. You will be able to inspect the application variables, objects, threads, and memory. You can step through your code interactively. You can click **Continue** to let the application resume and exit it normally or cease execution within Visual Studio using the stop button.
116
119
117
120
## Add a Linux configuration and connect to the remote machine
118
121
119
-
So far, you have been using the default x64-Debug configuration for our CMake project. Configurations are how Visual Studio understands what platform target it's going to use for CMake. The default configuration isn't represented on disk. When you explicitly add a configuration, a file called CMakeSettings.json is created that has parameters Visual Studio uses to control how CMake is run. To add a new configuration, select the Configuration drop-down in the toolbar and select **Manage Configurations…**
122
+
So far, you have been using the default **x64-Debug** configuration for Windows. Configurations are how Visual Studio understands what platform target it's going to use for CMake. The default configuration isn't represented on disk. When you explicitly add a configuration, Visual Studio creates a file called CMakeSettings.json that is populated with settings for all the configurations you specify.
123
+
124
+
1. Add a new configuration by clicking the the Configuration drop-down in the toolbar and selecting **Manage Configurations…**
The Add Configuration to CMakeSettings dialog will appear.
128
+
The **Add Configuration to CMakeSettings** dialog will appear.
124
129
125
130

126
131
127
-
Here you see Visual Studio has preconfigured options for many of the platforms Visual Studio can be configured to use with CMake. If you want to continue to use the default **x64-Debug** configuration that should be the first one you add. You want that for this tutorial so can switch back and forth between Windows and Linux configurations. Select **x64-Debug** and click **Select**. This creates the CMakeSettings.json file with a configuration for **x64-Debug** and switches Visual Studio to use that configuration instead of the default. You will see the configuration drop-down no longer says "(default)" as part of the name. You can use whatever names you like for your configurations by changing the name parameter in the CMakeSettings.json.
132
+
This dialog shows all the configurations that are included with Visual Studio, as well as any custom configurations that you might create. If you want to continue to use the default **x64-Debug** configuration, that should be the first one you add. By adding that configuration, you will be able to switch back and forth between Windows and Linux configurations. Select **x64-Debug** and click **Select**. This creates the CMakeSettings.json file with a configuration for **x64-Debug** and switches Visual Studio to use that configuration instead of the default. You will see the configuration drop-down no longer says "(default)" as part of the name. You can use whatever names you like for your configurations by changing the name parameter directly in CMakeSettings.json.
128
133
129
-
After you specify a configuration, Visual Studio adds a CMakeSettings.json file to the project where you can adjust values. To add a Linux configuration, right-click the CMakeSettings.json file in the **Solution Explorer** view and select **Add Configuration**. You see the same Add Configuration to CMakeSettings dialog as before. Select **Linux-Debug** this time, then save the CMakeSettings.json file. Now select **Linux-Debug** in the configuration drop-down.
134
+
2. Now add a Linux configuration. Right-click the CMakeSettings.json file in the **Solution Explorer** view and select **Add Configuration**. You see the same Add Configuration to CMakeSettings dialog as before. Select **Linux-Debug** this time, then save the CMakeSettings.json file.
135
+
3. Now select **Linux-Debug** in the configuration drop-down.
130
136
131
137

132
138
133
139
Since this is the first time you are connecting to a Linux system, the **Connect to Remote System** dialog will appear.
134
140
135
141

136
142
137
-
Provide the connection information to your Linux machine and click **Connect**. Visual Studio adds that machine as to CMakeSettings.json as your default for **Linux-Debug**. It will also pull down the headers from your remote machine so that you get IntelliSense specific to that machine when you use it. Now Visual Studio will send your files to the remote machine, then generate the CMake cache there, and when that is done Visual Studio will be configured for using the same source base with that remote Linux machine. These steps may take some time depending on the speed of your network and power of your remote machine. You will know this is complete when the message "Target info extraction done" appears in the CMake output window.
143
+
4.Provide the connection information to your Linux machine and click **Connect**. Visual Studio adds that machine as to CMakeSettings.json as your default for **Linux-Debug**. It will also pull down the headers from your remote machine so that you get IntelliSense specific to that machine when you use it. Now Visual Studio will send your files to the remote machine, then generate the CMake cache there, and when that is done Visual Studio will be configured for using the same source base with that remote Linux machine. These steps may take some time depending on the speed of your network and power of your remote machine. You will know this is complete when the message "Target info extraction done" appears in the CMake output window.
138
144
139
145
## Set breakpoint, build and run on Linux
140
146
141
-
Because this is a desktop application, you need to provide some additional configuration information to the debug configuration. In the CMake Targets view, right-click AppBasicExampleGui and choose Debug and Launch settings to open `launch.vs.json` that is in the hidden `.vs` subfolder. This file is local to your development environment. You can move it into the root of your project if you wish to check it in and save it with your team. In this file a configuration has been added for AppBasicExampleGui. These default settings work in most cases, as this is a desktop application you need to provide some additional information to launch the program in a way you can see it on our Linux machine. You need to know the value of the environment variable `DISPLAY` on your Linux machine, run this command to get it.
147
+
Because this is a desktop application, you need to provide some additional configuration information to the debug configuration.
148
+
149
+
1. In the CMake Targets view, right-click AppBasicExampleGui and choose **Debug and Launch Settings** to open the launch.vs.json file that is in the hidden **.vs** subfolder. This file is local to your development environment. You can move it into the root of your project if you wish to check it in and save it with your team. In this file a configuration has been added for AppBasicExampleGui. These default settings work in most cases, but because this is a desktop application you need to provide some additional information to launch the program in a way you can see it on our Linux machine.
150
+
2. You need to know the value of the environment variable `DISPLAY` on your Linux machine, run this command to get it.
142
151
143
152
```cmd
144
153
echo $DISPLAY
@@ -148,18 +157,15 @@ In the configuration for AppBasicExampleGui there is a parameter array "pipeArgs
148
157
```cmd
149
158
"export DISPLAY=:1;${debuggerCommand}",
150
159
```
151
-
Now in order to launch and debug our application, choose the **Select Startup Item** drop-down in the toolbar and choose AppBasicExampleGui. Now press that button or hit **F5**. This will build the application and its dependencies on the remote Linux machine then launch it with the Visual Studio debugger attached. On your remote Linux machine, you should see an application window appear with the same falling bunch of cubes arranged as a single block.
160
+
3.Now in order to launch and debug our application, choose the **Select Startup Item** drop-down in the toolbar and choose AppBasicExampleGui. Now press that button or hit **F5**. This will build the application and its dependencies on the remote Linux machine then launch it with the Visual Studio debugger attached. On your remote Linux machine, you should see an application window appear.
152
161
153
-
<!---->
154
-
155
-
Move your mouse into the application window, click a button, and the breakpoint will be hit. Program execution pauses, Visual Studio comes back to the foreground, and you will be at your breakpoint. You should also see a Linux Console Window appear in Visual Studio. This window provides output from the remote Linux machine, and it can also accept input for `stdin`. Like any Visual Studio window, it can be docked where you prefer to see it and its position will be persisted in future sessions.
162
+
4. Move your mouse into the application window, click a button, and the breakpoint will be hit. Program execution pauses, Visual Studio comes back to the foreground, and you will be at your breakpoint. You should also see a Linux Console Window appear in Visual Studio. This window provides output from the remote Linux machine, and it can also accept input for `stdin`. Like any Visual Studio window, it can be docked where you prefer to see it and its position will be persisted in future sessions.
156
163
157
164

158
165
159
-
You can inspect the application variables, objects, threads, memory, and step through your code interactively using Visual Studio. But this time on a remote Linux machine instead of your local Windows environment. You can click continue to let the application resume and exit normally, or you can press the stop button, just as with local execution.
160
-
161
-
Look at the Call Stack window and you will see this time the Calls to x11OpenGLWindow since Visual Studio has launched the application on Linux.
166
+
5. You can inspect the application variables, objects, threads, memory, and step through your code interactively using Visual Studio. But this time you are doing all this on a remote Linux machine instead of your local Windows environment. You can click **Continue** to let the application resume and exit normally, or you can press the stop button, just as with local execution.
162
167
168
+
6. Look at the Call Stack window and view the Calls to `x11OpenGLWindow` since Visual Studio launched the application on Linux.
163
169
164
170

165
171
@@ -169,9 +175,10 @@ So now you have seen the same code base, cloned directly from GitHub, build, run
169
175
170
176
## Next steps
171
177
172
-
Advance to the next article to learn how to create...
178
+
Learn more about the CMakeSettings and launch.vs.json file schemas:
0 commit comments