<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Kushagra</title>
    <description>The latest articles on DEV Community by Kushagra (@kushagra10025).</description>
    <link>https://dev.to/kushagra10025</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F596556%2Fc5f32a55-b547-4ec0-bec6-fb261dafd12a.jpeg</url>
      <title>DEV Community: Kushagra</title>
      <link>https://dev.to/kushagra10025</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/kushagra10025"/>
    <language>en</language>
    <item>
      <title>Conan and CMake  Setup for C++ Development on VSCode</title>
      <dc:creator>Kushagra</dc:creator>
      <pubDate>Sun, 12 Sep 2021 18:38:47 +0000</pubDate>
      <link>https://dev.to/kushagra10025/conan-and-cmake-setup-for-c-development-on-vscode-1613</link>
      <guid>https://dev.to/kushagra10025/conan-and-cmake-setup-for-c-development-on-vscode-1613</guid>
      <description>&lt;p&gt;&lt;strong&gt;Hi There, Devs! 😇&lt;/strong&gt;&lt;br&gt;
We have come across various tutorials to either setup Conan or CMake with IDEs like Visual Studio or on the Terminal. These tutorials are great but for me personally I am not a big fan of Visual Studio but a very big fan of Visual Studio Code (as it is very lightweight and very much easy going for my PC).&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--yEPBRDIO--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i.ibb.co/KWD4WHR/VSCode-Meme.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--yEPBRDIO--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i.ibb.co/KWD4WHR/VSCode-Meme.jpg" alt="VSCode vs VS Meme"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I mean Microsoft did a great job on retaining people like me from using other editors and still using their product.&lt;/p&gt;

&lt;p&gt;Now for the main topic as to why we are still here...&lt;/p&gt;

&lt;p&gt;This is a barebones tutorial for setting up Conan and CMake on Visual Studio Code, with no packages and nothing. Just a structure which I personally follow and I believe you should follow too as I've had success with it till now and only very few errors.&lt;/p&gt;
&lt;h2&gt;
  
  
  🛠️Requirements
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://code.visualstudio.com/download"&gt;Visual Studio Code&lt;/a&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://marketplace.visualstudio.com/items?itemName=ms-vscode.cpptools"&gt;C/C++&lt;/a&gt; - Must Have&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://marketplace.visualstudio.com/items?itemName=reignofwebber.c-cpp-definition-generator"&gt;c/c++ definition generator&lt;/a&gt; - Recommended&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://marketplace.visualstudio.com/items?itemName=twxs.cmake"&gt;CMake&lt;/a&gt; - Must Have&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://marketplace.visualstudio.com/items?itemName=ms-vscode.cmake-tools"&gt;CMake Tools&lt;/a&gt; - Must Have&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://marketplace.visualstudio.com/items?itemName=Gruntfuggly.todo-tree"&gt;Todo Tree&lt;/a&gt; - Recommended&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.python.org/downloads/"&gt;Python&lt;/a&gt; - 3.7 or greater&lt;/li&gt;
&lt;li&gt;pip&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://cmake.org/download/"&gt;CMake&lt;/a&gt; - 3.20.0 or greater&lt;/li&gt;
&lt;li&gt;Python Dependencies

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://pypi.org/project/virtualenv/"&gt;virtualenv&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://pypi.org/project/conan/"&gt;conan&lt;/a&gt; in virtualenv&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;
  
  
  🔧Virtual Environment Setup for Conan Installation
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;a href="https://www.python.org/downloads/"&gt;Download and Install | Python&lt;/a&gt; (skip if already installed)&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.geeksforgeeks.org/download-and-install-pip-latest-version/"&gt;Download and Install | pip&lt;/a&gt; (skip if already installed)&lt;/li&gt;
&lt;li&gt;Make a directory for you Project, for example co-cpp-setup
&lt;/li&gt;
&lt;/ol&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;mkdir co-cpp-setup 
cd co-cpp-setup 
code . 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;ol&gt;
&lt;li&gt;Make a directory for the virtualenv, for example venv
&lt;/li&gt;
&lt;/ol&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;mkdir venv 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;ol&gt;
&lt;li&gt;Initialize a virtualenv in venv folder
&lt;/li&gt;
&lt;/ol&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;python -m venv venv 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;ol&gt;
&lt;li&gt;Activate the virtualenv
&lt;strong&gt;(For Windows)&lt;/strong&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.\venv\bin\activate
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;ol&gt;
&lt;li&gt;Install Conan Package Manager 

&lt;code&gt;pip install conan&lt;/code&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;blockquote&gt;
&lt;p&gt;To &lt;strong&gt;Deactivate&lt;/strong&gt; the virtualenv&lt;br&gt;
&lt;br&gt;
 &lt;code&gt;deactivate&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;


&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  🔩CMakeProject on VSCode
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;a href="https://cmake.org/download/"&gt;Download and Install | CMake&lt;/a&gt; (skip if already installed)&lt;/li&gt;
&lt;li&gt;Make sure to have &lt;strong&gt;CMake&lt;/strong&gt; and &lt;strong&gt;CMake Tools&lt;/strong&gt; installed in your local VSCode Copy.&lt;/li&gt;
&lt;li&gt;Create the files required such that the folder structure for

&lt;code&gt;co-cpp-setup&lt;/code&gt;

Directory is as shown.
&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--8agoR-0h--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i.ibb.co/74TRHHd/folder-struct-1.png" alt="Folder Structure 1"&gt;
&lt;/li&gt;
&lt;li&gt;Add barebone minimum code

&lt;code&gt;int main()&lt;/code&gt;

to main.cpp and Reload the VSCode Window.&lt;/li&gt;
&lt;li&gt;With CMake Tools installed it automatically detects the project now as a CMake Project and asks you to select a Kit. 
&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--C45O-0D2--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i.ibb.co/ZHpNyd5/kit-selection.png" alt="Kit Selection Image"&gt;
&lt;/li&gt;
&lt;li&gt;Then Configure the project for the first time.

&lt;code&gt;Ctrl + Shift + P&lt;/code&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--iDauL0Sl--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i.ibb.co/Bf2KTyx/cmake-configure.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--iDauL0Sl--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i.ibb.co/Bf2KTyx/cmake-configure.png" alt="Configure the Project"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;If you have followed everything correctly till here, a new directory name build will appear in your folder structure, after a successful Configuration of an empty

&lt;code&gt;CMakeLists.txt&lt;/code&gt;

file.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  ⚙️Conan on VSCode
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;We already have installed

&lt;code&gt;conan&lt;/code&gt;

using

&lt;code&gt;pip&lt;/code&gt;

in a virtualenv.&lt;/li&gt;
&lt;li&gt;Now, we create a new txt file,

&lt;code&gt;conanfile.txt&lt;/code&gt;

, for getting packages from &lt;strong&gt;conancenter&lt;/strong&gt;.
3. Now the &lt;a href="https://docs.conan.io/en/latest/getting_started.html"&gt;Getting Started&lt;/a&gt; section from conan &lt;a href="https://docs.conan.io/en/latest/"&gt;documentation&lt;/a&gt; can be followed to go ahead with your projects, or you can go ahead with your packages for your projects.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  What's Next ❓
&lt;/h2&gt;

&lt;p&gt;➡️ This is Part 1 of Conan and CMake for CPP Development. In the next part we will see how to use this bare bone template for setting up a barebone OpenGL Project with GLEW, GLFW and ImGUI.&lt;/p&gt;

&lt;p&gt;➡️ Get this barebone setup on GitHub to be uploaded along with the Part2 tutorial.&lt;/p&gt;

&lt;p&gt;🔜 Very soon I'll upload a video on how to setup (Part 1) and how to use (Part 2) on YouTube and upload the links in this article.&lt;/p&gt;

&lt;p&gt;Thanks for your time and love from 🇮🇳 ! ✌️&lt;/p&gt;

</description>
      <category>tutorial</category>
      <category>vscode</category>
      <category>cpp</category>
      <category>packagemanagement</category>
    </item>
  </channel>
</rss>
