Skip to content

Commit 2ad47d2

Browse files
author
mikeblome
committed
more improvements to tutorial topic
1 parent e8a1123 commit 2ad47d2

File tree

1 file changed

+37
-30
lines changed

1 file changed

+37
-30
lines changed

docs/ide/get-started-linux-cmake.md

Lines changed: 37 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -66,25 +66,31 @@ As soon as you open the folder, your folder structure will be visible in the **S
6666

6767
This view shows you exactly what is on disk, not a logical or filtered view. By default, it doesn't show hidden files.
6868

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.
7070

71-
![Visual Studio Solution Explorer Show All FIles button](media/cmake-bullet3-show-all-files.png)
71+
![Visual Studio Solution Explorer Show All Files button](media/cmake-bullet3-show-all-files.png)
7272

7373
## Switch to targets view
7474

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".
7678

7779
![Visual Studio Output window showing output from CMake](media/cmake-bullet3-output-window.png)
7880

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.
8084

81-
![Solutions and Folders button in the Solution Explorer to show CMake targets vie](media/cmake-bullet3-show-targets.png)
85+
![Solutions and Folders button in the Solution Explorer to show CMake targets view](media/cmake-bullet3-show-targets.png)
8286

83-
Here is what that view looks like for the Bullet SDK.
87+
Here is what that view looks like for the Bullet SDK:
8488

8589
![Solution Explorer CMake targets view](media/cmake-bullet3-targets-view.png)
8690

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.
8894

8995
## Set a breakpoint, build, and run
9096

@@ -93,52 +99,55 @@ In this step, we'll debug an example program that demonstrates the Bullet Physic
9399
1. In **Solution Explorer**, select AppBasicExampleGui and expand it.
94100
2. Open the file `BasicExample.cpp`.
95101
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.
99105

100106
![Visual Studio member list toolbar](media/cmake-bullet3-member-list-toolbar.png)
101107

102108
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.
103109

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:
105111

106112
![Visual Studio toolbar launch drop-down for Select Startup Item](media/cmake-bullet3-launch-button.png)
107113

108114
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:
109115

110116
![Visual Studio debugging a Windows application](media/cmake-bullet3-launched.png)
111117

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.
116119

117120
## Add a Linux configuration and connect to the remote machine
118121

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…**
120125

121126
![Manage Configuration drop-down](media/cmake-bullet3-manage-configurations.png)
122127

123-
The Add Configuration to CMakeSettings dialog will appear.
128+
The **Add Configuration to CMakeSettings** dialog will appear.
124129

125130
![Add Configuration to CMakeSettings dialog](media/cmake-bullet3-add-configuration-x64-debug.png)
126131

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.
128133

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.
130136

131137
![Launch configuration drop-down with X64-Debug and Linux-Debug options](media/cmake-bullet3-linux-configuration-item.png)
132138

133139
Since this is the first time you are connecting to a Linux system, the **Connect to Remote System** dialog will appear.
134140

135141
![Visual Studio Connect to Remote System dialog](media/cmake-bullet3-connection-manager.png)
136142

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.
138144

139145
## Set breakpoint, build and run on Linux
140146

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.
142151

143152
```cmd
144153
echo $DISPLAY
@@ -148,18 +157,15 @@ In the configuration for AppBasicExampleGui there is a parameter array "pipeArgs
148157
```cmd
149158
"export DISPLAY=:1;${debuggerCommand}",
150159
```
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.
152161

153-
<!--![Linux application launched from Visual Studio](media/browser.png)-->
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.
156163

157164
![Visual Studio Linux Console Window](media/cmake-bullet3-linux-console.png)
158165

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.
162167

168+
6. Look at the Call Stack window and view the Calls to `x11OpenGLWindow` since Visual Studio launched the application on Linux.
163169

164170
![Call Stack window showing Linux call stack](media/cmake-bullet3-linux-callstack.png)
165171

@@ -169,9 +175,10 @@ So now you have seen the same code base, cloned directly from GitHub, build, run
169175

170176
## Next steps
171177

172-
Advance to the next article to learn how to create...
178+
Learn more about the CMakeSettings and launch.vs.json file schemas:
173179
> [!div class="nextstepaction"]
174-
> <!--[Next steps button](contribute-get-started-mvc.md)-->
180+
> [Configure CMake debugging sessions](configure-cmake-debugging-sessions.md)
181+
> [CMake predefined configuration reference](cmake-predefined-configuration-reference.md)
175182
176183
<!--- Required:
177184
Tutorials should always have a Next steps H2 that points to the next

0 commit comments

Comments
 (0)