
Open a Terminal window and enter the following command: cmake -version See if CMake is already installed on your system. For best results, use CMake version 3.15 or greater.
#Cmake install path code
The VS Code CMake Tools extension does its work by using CMake installed on your system.
#Cmake install path install
You'll also need to install CMake, a compiler, a debugger, and build tools. Install the CMake Tools extension by searching for 'CMake tools' in the Extensions view ( ⇧⌘X (Windows, Linux Ctrl+Shift+X)). Install the C/C++ extension by searching for 'c++' in the Extensions view ( ⇧⌘X (Windows, Linux Ctrl+Shift+X)).ĬMake Tools extension for VS Code. To complete this tutorial on Ubuntu, install the following:Ĭ++ extension for VS Code. Also, for more information about CMake Tools in general, see CMake Tools for Visual Studio Code documentation Prerequisites If you have any trouble, please file an issue for this tutorial in the VS Code documentation repository. Aside from installing CMake, your compiler, debugger, and build tools, the steps in this tutorial apply generally to how you'd use CMake on other platforms, like Windows. In this tutorial, you'll use the CMake Tools extension for Visual Studio Code to configure, build, and debug a simple C++ CMake project on Linux. The CMake Tools extension integrates Visual Studio Code and CMake to make it easy to configure, build, and debug your C++ project.

# Any extra setup # Add the targets file include( "$/MyLibConfigVersion.cmake" # Capturing values from configure (optional) set(my-config-var Same syntax as find_package The contents that look like this: include(CMakeFindDependencyMacro) in file, and you will want to use the syntax. If you want to capture configure time variables, you can use a. Then write a custom MyLibConfig.cmake file in your source tree somewhere. If you have no dependencies, just use MyLibConfig.cmake instead of MyLibTargets.cmake here. This file will take the targets you exported and put them in a file. The later option is what you'll need if you have any dependencies, even just OpenMP, so I'll illustrate that method.įirst, make an install targets file (very similar to the one you made in the build directory): install( EXPORT MyLibTargets You need to make a MyLibConfig.cmake, but you can do it either by exporting your targets directly to it, or by writing it by hand, then including the targets file. That looks like this: include(CMakePackageConfigHelpers)

It's usually a good idea to give CMake access to the version, so that find_package can have a version specified. It only sets the includes destination on the exported target (which is often already set by target_include_directories, so check the MyLibTargets file and make sure you don't have the include directory included twice if you want clean cmake files). The includes destination is special since a target does not install includes. The various destinations are only needed if you have a library, static library, or program to install. Your basic target install command looks like this: install(TARGETS MyLib Install commands cause a file or target to be "installed" into the install tree when you make install.
