![]() If you installed all the Visual Studio Code extensions correctly, VSCode should pop up with fetch-content as your workspace. Once you downloaded the files to WSL, navigate cd into the fetch-content directory in the repository, then simply type code. Figure 1: Gif showing how to open a WSL directory as a workspace on VSCode. Therefore, if you would like to work with the same examples mentioned here, visit the link and download the project to your WSL. Opening The Test Project On VSCodeįor this example, we’re using the project created for the post about integrating Google Tests into CMake. For example, “how to install make on Manjaro” on Google may tell you to run sudo pacman -S make. However, I recommend googling “how to install X” for your Linux distribution, so you can get the right terminal command for the installation. You can similarly install the other tools in that way. For example, if you’re on Ubuntu, running sudo apt-get install gcc will install the compiler. Interestingly, each Linux distribution has a different way of installing packages. Make: build system to be used by CMake.GDB debugger: the equivalent debugger for your compiler.GCC/G++ compiler: the C++ compilation tools.If you haven’t already got them, install the tools shown in the list below so you can develop C++ applications on WSL. Similarly, you will also need to install a few tools in your Linux distribution on WSL. Interestingly, this extension pack contains all of the “nice to have” extensions for C++ development, such as CMake syntax highlighting, C++ syntax colour schemes, etc.įinally, if you haven’t installed extensions in VSCode before, simply click on the extension UI button, search for the extensions we mentioned, and install them! Tools Needed For Your WSL Installation C/C++ Extension Pack: Includes some of the extensions mentioned in this section, and a few more.C/C++: Enables C++ language support for Visual Studio Code (syntax highlighting, etc).CMake Tools: This Microsoft extension enables the support for CMake projects in VS Code, it will allow you to configure and build your CMake projects.Once installed, you can navigate to the directory you want in your WSL terminal, and simply type code. Remote WSL: This extension allows you to open workspaces from your WSL installation.For this reason, the list below contains the names of all extensions you need to install, and the reason for each one. Initially, if you haven’t used VSCode for C++ projects on WSL, you will need to install a few extensions, so everything runs smoothly. Once you make a debug build, you can run a debugger, such as gdb or lldb on it.Video: Debugging C/C++ CMake projects on WSL with VSCode.Īdditionally, the project used in the video, as well as the final contents of the launch.json file are shown in the sections below. There are distinct flags for this mode (variables ending in _DEBUG as opposed to _RELEASE), as well as a generator expression value CONFIG:Debug or CONFIG:Release. In multi-configuration generators, like many IDEs, you can pick the configuration in the IDE. Building in debug modeįor single-configuration generators, you can build your code with -DCMAKE_BUILD_TYPE=Debug to get debugging flags. If you add -trace-expand, the variables will be expanded into their values. There are related options as well, but they tend to bury you in output.įor example: cmake -S. ![]() Every line run in the file that you give will be echoed to the screen when it is run, letting you follow exactly what is happening. Have you wanted to watch exactly what happens in your CMake file, and when? The -trace-source="filename" feature is fantastic. If you want to print out a property, this is much, much nicer! Instead of getting the properties one by one of of each target (or other item with properties, such as SOURCES, DIRECTORIES, TESTS, or CACHE_ENTRIES - global properties seem to be missing for some reason), you can simply list them and get them printed directly: cmake_print_properties( ![]() However, a built in module makes this even easier: include(CMakePrintHelpers) The time honored method of print statements looks like this in CMake: message(STATUS "MY_VARIABLE=$") CMake debuggingįirst, let's look at ways to debug a CMakeLists or other CMake file. You might need to debug your CMake build, or debug your C++ code. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |