{"id":3634,"date":"2017-12-14T13:14:39","date_gmt":"2017-12-14T21:14:39","guid":{"rendered":"https:\/\/visualgdb.com\/w\/?p=3634"},"modified":"2017-12-14T13:14:39","modified_gmt":"2017-12-14T21:14:39","slug":"importing-cmake-based-android-studio-projects-in-visualgdb","status":"publish","type":"post","link":"https:\/\/visualgdb.com\/tutorials\/android\/cmake\/","title":{"rendered":"Importing CMake-based Android Studio projects in VisualGDB"},"content":{"rendered":"<p>This tutorial shows how to import CMake-based Android Studio projects into VisualGDB using the new Advanced CMake Project Subsystem. VisualGDB will fully understand the structure of your CMakeLists.txt files and map the changes made in Visual Studio GUI back to them. It will also automatically configure the Clang IntelliSense based on the precise configuration reported by CMake.<\/p>\n<p>Before you begin, install Android Studio 3.0 or later and VisualGDB 5.3R8 or later.<\/p>\n<ol>\n<li>Start Android Studio and begin creating a new project:<a href=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2017\/12\/01-newprj.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-3635\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2017\/12\/01-newprj.png\" alt=\"01-newprj\" width=\"668\" height=\"487\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2017\/12\/01-newprj.png 668w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2017\/12\/01-newprj-300x219.png 300w\" sizes=\"(max-width: 668px) 100vw, 668px\" \/><\/a><\/li>\n<li>Select the location for your project and enable the &#8220;Include C++ Support&#8221; checkbox:<a href=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2017\/12\/02-type.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-3636\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2017\/12\/02-type.png\" alt=\"02-type\" width=\"902\" height=\"682\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2017\/12\/02-type.png 902w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2017\/12\/02-type-300x227.png 300w\" sizes=\"(max-width: 902px) 100vw, 902px\" \/><\/a><\/li>\n<li>Select the SDK versions you want to target:<a href=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2017\/12\/03-phone.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-3637\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2017\/12\/03-phone.png\" alt=\"03-phone\" width=\"902\" height=\"682\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2017\/12\/03-phone.png 902w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2017\/12\/03-phone-300x227.png 300w\" sizes=\"(max-width: 902px) 100vw, 902px\" \/><\/a><\/li>\n<li>Select to add a basic activity to the project:<a href=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2017\/12\/04-basic.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-3638\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2017\/12\/04-basic.png\" alt=\"04-basic\" width=\"902\" height=\"682\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2017\/12\/04-basic.png 902w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2017\/12\/04-basic-300x227.png 300w\" sizes=\"(max-width: 902px) 100vw, 902px\" \/><\/a><\/li>\n<li>Proceed with the default activity name:<a href=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2017\/12\/05-act.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-3639\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2017\/12\/05-act.png\" alt=\"05-act\" width=\"907\" height=\"710\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2017\/12\/05-act.png 907w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2017\/12\/05-act-300x235.png 300w\" sizes=\"(max-width: 907px) 100vw, 907px\" \/><\/a><\/li>\n<li>Finally press &#8220;Finish&#8221; to create the project:<a href=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2017\/12\/06-toolchain.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-3640\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2017\/12\/06-toolchain.png\" alt=\"06-toolchain\" width=\"907\" height=\"710\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2017\/12\/06-toolchain.png 907w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2017\/12\/06-toolchain-300x235.png 300w\" sizes=\"(max-width: 907px) 100vw, 907px\" \/><\/a><\/li>\n<li>If you have just installed Android Studio, ensure to install CMake via File-&gt;Settings-&gt;Android SDK-&gt;SDK Tools-&gt;CMake:<a href=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2017\/12\/07-cmake.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-3641\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2017\/12\/07-cmake.png\" alt=\"07-cmake\" width=\"1024\" height=\"694\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2017\/12\/07-cmake.png 1024w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2017\/12\/07-cmake-300x203.png 300w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><\/li>\n<li>Build the project and ensure it doesn&#8217;t report any errors:<a href=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2017\/12\/08-build.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-3642\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2017\/12\/08-build.png\" alt=\"08-build\" width=\"1024\" height=\"652\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2017\/12\/08-build.png 1024w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2017\/12\/08-build-300x191.png 300w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><\/li>\n<li>Now we will show how to import the project into Visual Studio with VisualGDB. Start Visual Studio and open the VisualGDB Android Project Wizard:<a href=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2017\/12\/09-app.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-3643\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2017\/12\/09-app.png\" alt=\"09-app\" width=\"941\" height=\"653\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2017\/12\/09-app.png 941w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2017\/12\/09-app-300x208.png 300w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2017\/12\/09-app-392x272.png 392w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2017\/12\/09-app-130x90.png 130w\" sizes=\"(max-width: 941px) 100vw, 941px\" \/><\/a><\/li>\n<li>If you are importing your first project, click &#8220;Configure SDK\/NDK locations&#8221; and specify the locations of the Android tools. It is recommended to use the SDK\/NDK versions installed by Android Studio to maximize compatibility:<a href=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2017\/12\/10-apps.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-3644\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2017\/12\/10-apps.png\" alt=\"10-apps\" width=\"626\" height=\"286\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2017\/12\/10-apps.png 626w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2017\/12\/10-apps-300x137.png 300w\" sizes=\"(max-width: 626px) 100vw, 626px\" \/><\/a><\/li>\n<li>In the wizard select &#8220;Import Android Studio, Gradle\/CMake or Eclipse Project&#8221;:<a href=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2017\/12\/11-import.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-3645\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2017\/12\/11-import.png\" alt=\"11-import\" width=\"795\" height=\"642\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2017\/12\/11-import.png 795w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2017\/12\/11-import-300x242.png 300w\" sizes=\"(max-width: 795px) 100vw, 795px\" \/><\/a><\/li>\n<li>Specify the directory where the imported project is located:<a href=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2017\/12\/12-path.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-3646\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2017\/12\/12-path.png\" alt=\"12-path\" width=\"795\" height=\"642\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2017\/12\/12-path.png 795w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2017\/12\/12-path-300x242.png 300w\" sizes=\"(max-width: 795px) 100vw, 795px\" \/><\/a><\/li>\n<li>Select the Android platform you would like to use:<a href=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2017\/12\/13-platforms.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-3647\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2017\/12\/13-platforms.png\" alt=\"13-platforms\" width=\"795\" height=\"642\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2017\/12\/13-platforms.png 795w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2017\/12\/13-platforms-300x242.png 300w\" sizes=\"(max-width: 795px) 100vw, 795px\" \/><\/a><\/li>\n<li>Press &#8220;Finish&#8221; to create the project. VisualGDB will automatically recognize that the imported project is using CMake and will import it using the Advanced CMake Project Subsystem (the project icon in Solution Explorer should be the CMake icon):<a href=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2017\/12\/14-imported.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-3648\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2017\/12\/14-imported.png\" alt=\"14-imported\" width=\"1024\" height=\"652\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2017\/12\/14-imported.png 1024w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2017\/12\/14-imported-300x191.png 300w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><\/li>\n<li>Advanced CMake projects integrate the Solution Explorer view with CMakeLists.txt files. E.g. right-click on libnative-lib.so and select &#8220;Go To Definition&#8221;:<a href=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2017\/12\/15-gotodef.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-3649\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2017\/12\/15-gotodef.png\" alt=\"15-gotodef\" width=\"1024\" height=\"652\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2017\/12\/15-gotodef.png 1024w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2017\/12\/15-gotodef-300x191.png 300w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a>VisualGDB will open the CMakeLists.txt file defining the library.<\/li>\n<li>Try adding a new source file to the library:<a href=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2017\/12\/16-newitem.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-3650\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2017\/12\/16-newitem.png\" alt=\"16-newitem\" width=\"1024\" height=\"652\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2017\/12\/16-newitem.png 1024w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2017\/12\/16-newitem-300x191.png 300w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><\/li>\n<li>Proceed with the default file location:<a href=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2017\/12\/17-another.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-3651\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2017\/12\/17-another.png\" alt=\"17-another\" width=\"1024\" height=\"652\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2017\/12\/17-another.png 1024w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2017\/12\/17-another-300x191.png 300w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><\/li>\n<li>VisualGDB will automatically edit the CMakeLists.txt file for you reflecting the changes you made via Solution Explorer:<a href=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2017\/12\/18-added.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-3652\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2017\/12\/18-added.png\" alt=\"18-added\" width=\"1024\" height=\"652\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2017\/12\/18-added.png 1024w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2017\/12\/18-added-300x191.png 300w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><\/li>\n<li>VisualGDB will also map VS Project Properties to CMakeLists.txt contents. E.g. set the &#8220;Additional Include Directories&#8221; value to automatically create or update the target_include_directories() statement:<a href=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2017\/12\/19-settings.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-3653\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2017\/12\/19-settings.png\" alt=\"19-settings\" width=\"1024\" height=\"652\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2017\/12\/19-settings.png 1024w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2017\/12\/19-settings-300x191.png 300w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><\/li>\n<li>Ensure the startup debugging is enabled. Then connect your Android device, set a breakpoint in the function and press F5 to begin debugging:<a href=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2017\/12\/20-startup.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-3654\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2017\/12\/20-startup.png\" alt=\"20-startup\" width=\"1024\" height=\"652\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2017\/12\/20-startup.png 1024w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2017\/12\/20-startup-300x191.png 300w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><\/li>\n<li>VisualGDB will stop at a breakpoint, letting you examine the program state:<a href=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2017\/12\/21-debug.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-3655\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2017\/12\/21-debug.png\" alt=\"21-debug\" width=\"1024\" height=\"652\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2017\/12\/21-debug.png 1024w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2017\/12\/21-debug-300x191.png 300w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><\/li>\n<\/ol>\n","protected":false},"excerpt":{"rendered":"<p>This tutorial shows how to import CMake-based Android Studio projects into VisualGDB using the new Advanced CMake Project Subsystem. VisualGDB<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[11],"tags":[31,77,41],"_links":{"self":[{"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/posts\/3634"}],"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=3634"}],"version-history":[{"count":1,"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/posts\/3634\/revisions"}],"predecessor-version":[{"id":3656,"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/posts\/3634\/revisions\/3656"}],"wp:attachment":[{"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/media?parent=3634"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/categories?post=3634"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/tags?post=3634"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}