{"id":815,"date":"2017-06-29T21:26:08","date_gmt":"2017-06-30T04:26:08","guid":{"rendered":"http:\/\/visualgdb.com\/w\/?p=815"},"modified":"2017-06-30T10:57:15","modified_gmt":"2017-06-30T17:57:15","slug":"importing-cmake-linux-projects-to-visualgdb","status":"publish","type":"post","link":"https:\/\/visualgdb.com\/tutorials\/linux\/cmake\/import\/","title":{"rendered":"Importing CMake Linux projects to VisualGDB"},"content":{"rendered":"<p>This tutorial shows how to import Linux CMake projects to VisualGDB. We will demonstrate this by downloading the <a href=\"http:\/\/dev.mysql.com\/downloads\/mysql\/\">MySql database engine source code<\/a>, building it with VisualGDB, debugging the client application and using Code Map and other IntelliSense features to explore the code.<\/p>\n<p>Before you begin install VisualGDB 5.3 or later, download MySql source code to your Linux machine and unpack it.<\/p>\n<ol>\n<li>Start Visual Studio and launch the VisualGDB Linux Project Wizard:<a href=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/10\/01-wizard.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-2881\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/10\/01-wizard.png\" alt=\"01-wizard\" width=\"941\" height=\"653\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/10\/01-wizard.png 941w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/10\/01-wizard-300x208.png 300w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/10\/01-wizard-392x272.png 392w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/10\/01-wizard-130x90.png 130w\" sizes=\"(max-width: 941px) 100vw, 941px\" \/><\/a><\/li>\n<li>In the Linux Project wizard select &#8220;Import a project -&gt; Import a CMake project&#8221; and check the &#8220;Use advanced CMake Project Subsystem&#8221; checkbox:<a href=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/10\/02-import-advanced.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-2882\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/10\/02-import-advanced.png\" alt=\"02-import-advanced\" width=\"822\" height=\"662\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/10\/02-import-advanced.png 822w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/10\/02-import-advanced-300x242.png 300w\" sizes=\"(max-width: 822px) 100vw, 822px\" \/><\/a><\/li>\n<li>On the next page select the computer where you have unpacked the MySql source code:<a href=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/10\/03-computer.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-2883\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/10\/03-computer.png\" alt=\"03-computer\" width=\"822\" height=\"662\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/10\/03-computer.png 822w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/10\/03-computer-300x242.png 300w\" sizes=\"(max-width: 822px) 100vw, 822px\" \/><\/a><\/li>\n<li>Then select &#8220;The sources are already on the Linux computer&#8221; and enter the source directory:<a href=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/10\/04-location.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-2884\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/10\/04-location.png\" alt=\"04-location\" width=\"1129\" height=\"740\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/10\/04-location.png 1129w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/10\/04-location-300x197.png 300w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/10\/04-location-1024x671.png 1024w\" sizes=\"(max-width: 1129px) 100vw, 1129px\" \/><\/a><\/li>\n<li>In this tutorial we will use the new direct SSH access feature that allows VisualGDB to access your source files directly on the Linux machine as if they were copied to the Windows side:<a href=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/10\/05-access.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-2886\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/10\/05-access.png\" alt=\"05-access\" width=\"822\" height=\"662\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/10\/05-access.png 822w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/10\/05-access-300x242.png 300w\" sizes=\"(max-width: 822px) 100vw, 822px\" \/><\/a><\/li>\n<li>The last page allows configuring the build directory that will be used for different configurations and additional CMake environment. Proceed with the default settings:<a href=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/10\/06-cmakeimport.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-2887\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/10\/06-cmakeimport.png\" alt=\"06-cmakeimport\" width=\"822\" height=\"662\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/10\/06-cmakeimport.png 822w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/10\/06-cmakeimport-300x242.png 300w\" sizes=\"(max-width: 822px) 100vw, 822px\" \/><\/a><\/li>\n<li>Click &#8220;Finish&#8221; to build the project then build it with Ctrl-Shift-B:<a href=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/10\/07-build1.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-2888\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/10\/07-build1.png\" alt=\"07-build\" width=\"1129\" height=\"740\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/10\/07-build1.png 1129w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/10\/07-build1-300x197.png 300w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/10\/07-build1-1024x671.png 1024w\" sizes=\"(max-width: 1129px) 100vw, 1129px\" \/><\/a>See how VisualGDB automatically queried the list of targets and sources from CMake and displayed them in Solution Explorer.<\/li>\n<li>If you don&#8217;t have MySql installed on that machine, install it manually by running the following commands in the build directory:\n<pre class=\"\">sudo make install\r\nmysqld --initialize\r\nmysqld<\/pre>\n<p>You can use the &#8220;Open Terminal Here&#8221; command to conveniently open an SSH terminal to your Linux machine:<a href=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/10\/08-term.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-2889\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/10\/08-term.png\" alt=\"08-term\" width=\"1129\" height=\"740\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/10\/08-term.png 1129w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/10\/08-term-300x197.png 300w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/10\/08-term-1024x671.png 1024w\" sizes=\"(max-width: 1129px) 100vw, 1129px\" \/><\/a><\/li>\n<li>Now we can debug the MySql client. Open VS Project Properties for the &#8220;mysql&#8221; target and set the command line arguments to &#8220;-u root -p&#8221; to connect as root:<a href=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/10\/09-debugargs.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-2890\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/10\/09-debugargs.png\" alt=\"09-debugargs\" width=\"1129\" height=\"740\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/10\/09-debugargs.png 1129w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/10\/09-debugargs-300x197.png 300w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/10\/09-debugargs-1024x671.png 1024w\" sizes=\"(max-width: 1129px) 100vw, 1129px\" \/><\/a><\/li>\n<li>Right-click on the &#8220;mysql&#8221; target and select Debug-&gt;Step into new instance:<a href=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/10\/10-stepinto.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-2891\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/10\/10-stepinto.png\" alt=\"10-stepinto\" width=\"1129\" height=\"740\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/10\/10-stepinto.png 1129w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/10\/10-stepinto-300x197.png 300w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/10\/10-stepinto-1024x671.png 1024w\" sizes=\"(max-width: 1129px) 100vw, 1129px\" \/><\/a><\/li>\n<li>VisualGDB will automatically launch the correct executable and step into its main() function:<a href=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/10\/11-debug.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-2892\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/10\/11-debug.png\" alt=\"11-debug\" width=\"1129\" height=\"740\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/10\/11-debug.png 1129w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/10\/11-debug-300x197.png 300w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/10\/11-debug-1024x671.png 1024w\" sizes=\"(max-width: 1129px) 100vw, 1129px\" \/><\/a><\/li>\n<li>If the imported project has too many auxiliary targets (e.g. libraries or unit tests), you can move the most important targets to a separate virtual folder for easier access. Right-click on the .vgdbsettings node and select Add-&gt;Virtual Target Folder:<a href=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/10\/12-vfolder.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-2893\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/10\/12-vfolder.png\" alt=\"12-vfolder\" width=\"1129\" height=\"740\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/10\/12-vfolder.png 1129w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/10\/12-vfolder-300x197.png 300w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/10\/12-vfolder-1024x671.png 1024w\" sizes=\"(max-width: 1129px) 100vw, 1129px\" \/><\/a><\/li>\n<li>Drag and drop the &#8220;mysql&#8221; target to the new virtual folder (or use Ctrl-X, Ctrl-V to cut &amp; paste it):<a href=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/10\/13-mysql.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-2894\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/10\/13-mysql.png\" alt=\"13-mysql\" width=\"1129\" height=\"740\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/10\/13-mysql.png 1129w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/10\/13-mysql-300x197.png 300w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/10\/13-mysql-1024x671.png 1024w\" sizes=\"(max-width: 1129px) 100vw, 1129px\" \/><\/a><\/li>\n<li>You can use the Visual Studio Properties window to quickly see basic information about each target or source file (e.g. where it is defined, its source\/binary directories and full path on the target):<a href=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/10\/14-explore.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-2895\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/10\/14-explore.png\" alt=\"14-explore\" width=\"1129\" height=\"740\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/10\/14-explore.png 1129w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/10\/14-explore-300x197.png 300w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/10\/14-explore-1024x671.png 1024w\" sizes=\"(max-width: 1129px) 100vw, 1129px\" \/><\/a><\/li>\n<li>Open VS properties for the .vgdbcmake project again and try changing various grouping setting. E.g. disable the &#8220;Group Targets by Paths&#8221; option:<a href=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/10\/15-paths.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-2896\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/10\/15-paths.png\" alt=\"15-paths\" width=\"1129\" height=\"740\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/10\/15-paths.png 1129w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/10\/15-paths-300x197.png 300w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/10\/15-paths-1024x671.png 1024w\" sizes=\"(max-width: 1129px) 100vw, 1129px\" \/><\/a><\/li>\n<li>See how all the targets from all CMakeLists.txt files are now displayed together:<a href=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/10\/16-nopaths.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-2897\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/10\/16-nopaths.png\" alt=\"16-nopaths\" width=\"1129\" height=\"740\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/10\/16-nopaths.png 1129w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/10\/16-nopaths-300x197.png 300w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/10\/16-nopaths-1024x671.png 1024w\" sizes=\"(max-width: 1129px) 100vw, 1129px\" \/><\/a><\/li>\n<li>You can use the normal Visual Studio debugging functionality to debug the code. If you are using the Clang IntelliSense engine, you can right-click in your code and select &#8220;Preprocess Selected Lines&#8221; to automatically see behind non-trivial preprocessor macros:<a href=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/10\/preprocess.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-2898\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/10\/preprocess.png\" alt=\"preprocess\" width=\"1129\" height=\"740\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/10\/preprocess.png 1129w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/10\/preprocess-300x197.png 300w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/10\/preprocess-1024x671.png 1024w\" sizes=\"(max-width: 1129px) 100vw, 1129px\" \/><\/a><\/li>\n<li>You can also use Code Map provided by the Clang IntelliSense engine to quickly visualize the relations between different parts of your code:<a href=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/10\/codemap1.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-2900\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/10\/codemap1.png\" alt=\"codemap\" width=\"1129\" height=\"740\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/10\/codemap1.png 1129w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/10\/codemap1-300x197.png 300w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/10\/codemap1-1024x671.png 1024w\" sizes=\"(max-width: 1129px) 100vw, 1129px\" \/><\/a><\/li>\n<\/ol>\n","protected":false},"excerpt":{"rendered":"<p>This tutorial shows how to import Linux CMake projects to VisualGDB. We will demonstrate this by downloading the MySql database<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[92],"tags":[77,41,33],"_links":{"self":[{"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/posts\/815"}],"collection":[{"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/comments?post=815"}],"version-history":[{"count":4,"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/posts\/815\/revisions"}],"predecessor-version":[{"id":2901,"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/posts\/815\/revisions\/2901"}],"wp:attachment":[{"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/media?parent=815"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/categories?post=815"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/tags?post=815"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}