{"id":17345,"date":"2017-11-01T11:55:34","date_gmt":"2017-11-01T18:55:34","guid":{"rendered":"https:\/\/blogs.msdn.microsoft.com\/vcblog\/?p=17345"},"modified":"2019-02-18T17:48:14","modified_gmt":"2019-02-18T17:48:14","slug":"cmake-support-in-visual-studio-import-your-cmake-cache","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/cppblog\/cmake-support-in-visual-studio-import-your-cmake-cache\/","title":{"rendered":"CMake Support in Visual Studio \u2013 Import Your CMake Cache"},"content":{"rendered":"<p><a href=\"https:\/\/blogs.msdn.microsoft.com\/c\/2017\/12\/08\/visual-studio-\u652f\u6301cmake-\u5bfc\u5165\u4f60\u7684cmake-cache\/\">\u70b9\u8fd9\u91cc\u770b\u4e2d\u6587\u7248<\/a><\/p>\n<p>Configuring a CMake project to build in just the way you want can often be a time intensive process, so in<a href=\"https:\/\/www.visualstudio.com\/vs\/preview\/\"> Visual Studio 2017 15.5 preview<\/a> we have made it easier than ever to import your existing CMake projects and cache configurations into the IDE.\u00a0 You can now import an existing CMakeCache.txt file and Visual Studio will automatically extract customized variables and create a pre-populated CMakeSettings.json file based on them.<\/p>\n<p>Please check out the preview and try out the latest CMake features.\u00a0 If you are just getting started with CMake, follow the link to\u00a0<a href=\"https:\/\/aka.ms\/cmake\">learn more about CMake support in Visual Studio<\/a>.\u00a0 We are looking forward to your feedback.<\/p>\n<h3>Importing a CMake Project<\/h3>\n<p>To get started, we have added a new entry point to open CMake files: File &gt; Open &gt; CMake.\u00a0 From here, you can open a CMake project directly (by selecting a CMakeLists.txt file) or import a CMake cache (by selecting a CMakeCache.txt file):<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/9\/2019\/02\/Open-CMake-Menu.png\"><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/9\/2019\/02\/Open-CMake-Menu.png\" alt=\"File &gt; Open &gt; CMake\" width=\"645\" height=\"381\" class=\"alignnone size-full wp-image-17346\" \/><\/a><\/p>\n<p>Navigating to a CMakeCache.txt file activates the import wizard:<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/9\/2019\/02\/Cache-Import-Dialog.png\"><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/9\/2019\/02\/Cache-Import-Dialog.png\" alt=\"Import CMake Cache\" width=\"436\" height=\"387\" class=\"alignnone size-full wp-image-17355\" \/><\/a><\/p>\n<p>When you import a CMake cache, we leave the original cache completely intact.\u00a0 As such, that cache should keep working from the command line or with whatever tool or IDE was used to generate it.<\/p>\n<p>Visual Studio extracts the command line parameters used to create the cache, such as CMake variables, and stores them in a <a href=\"https:\/\/blogs.msdn.microsoft.com\/vcblog\/2016\/10\/05\/cmake-support-in-visual-studio\/#configure-cmake\">CMakeSettings.json<\/a> file alongside the project\u2019s root CMakeLists.txt.\u00a0 This file is then used to generate a new cache that Visual Studio uses to build the project.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/9\/2019\/02\/CMake-Settings-JSON.png\"><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/9\/2019\/02\/CMake-Settings-JSON.png\" alt=\"CMake Settings JSON\" width=\"348\" height=\"454\" class=\"alignnone size-full wp-image-17356\" \/><\/a><\/p>\n<p>Keep in mind that not everything in the cache will be imported.\u00a0 Properties such as the generator and the location of the compilers are replaced with defaults known to work well with the IDE.<\/p>\n<p>Your feedback is a critical part of ensuring that we can deliver the best CMake experience.\u00a0 We would love to know how <a href=\"https:\/\/www.visualstudio.com\/vs\/preview\/\">Visual Studio 2017 Preview<\/a> is working for you.\u00a0 If you have any feedback specific to CMake Tools, please reach out to <a href=\"mailto:cmake@microsoft.com\">cmake@microsoft.com<\/a>.\u00a0 For general issues please <a href=\"https:\/\/docs.microsoft.com\/en-us\/visualstudio\/ide\/how-to-report-a-problem-with-visual-studio-2017\">Report a Problem<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u70b9\u8fd9\u91cc\u770b\u4e2d\u6587\u7248 Configuring a CMake project to build in just the way you want can often be a time intensive process, so in Visual Studio 2017 15.5 preview we have made it easier than ever to import your existing CMake projects and cache configurations into the IDE.\u00a0 You can now import an existing CMakeCache.txt file and [&hellip;]<\/p>\n","protected":false},"author":326,"featured_media":35994,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[266],"tags":[8,140,252,233,6,268],"class_list":["post-17345","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-cmake","tag-announcement","tag-c","tag-cmake","tag-cross-platform","tag-ide","tag-openfolder"],"acf":[],"blog_post_summary":"<p>\u70b9\u8fd9\u91cc\u770b\u4e2d\u6587\u7248 Configuring a CMake project to build in just the way you want can often be a time intensive process, so in Visual Studio 2017 15.5 preview we have made it easier than ever to import your existing CMake projects and cache configurations into the IDE.\u00a0 You can now import an existing CMakeCache.txt file and [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/posts\/17345","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/users\/326"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/comments?post=17345"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/posts\/17345\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/media\/35994"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/media?parent=17345"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/categories?post=17345"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/tags?post=17345"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}