CMake is a cross-platform, open-source tool for defining build processes that run on multiple platforms. In diesem Artikel wird davon ausgegangen, dass Sie mit CMake vertraut sind. This article assumes you're familiar with CMake. CMake wurde in den letzten Releases immer mehr in Visual Studio integriert.

Author:Narr Mazusho
Country:El Salvador
Language:English (Spanish)
Published (Last):14 March 2004
PDF File Size:14.90 Mb
ePub File Size:15.73 Mb
Price:Free* [*Free Regsitration Required]

CMake is a cross-platform, open-source tool for defining build processes that run on multiple platforms. In diesem Artikel wird davon ausgegangen, dass Sie mit CMake vertraut sind. This article assumes you're familiar with CMake. CMake wurde in den letzten Releases immer mehr in Visual Studio integriert. CMake has become more and more integrated with Visual Studio over the past few releases.

To see the documentation for your preferred version of Visual Studio, use the Version selector control. Es befindet sich am Anfang des Inhaltsverzeichnisses auf dieser Seite. It's found at the top of the table of contents on this page.

Both Ninja and Visual Studio generators are supported. If you use a Visual Studio generator, it generates a temporary project file and passes it to msbuild. However, the project is never loaded for IntelliSense or browsing purposes. You can also import an existing CMake cache. For more information, see Cross-platform CMake projects. Der Projektmappen-Explorer zeigt die Ordnerstruktur und die Dateien an.

Solution Explorer displays the folder structure and files. Visual Studio runs cmake. In the background, Visual Studio starts to index the source files to enable IntelliSense, browsing information, refactoring, and so on. As you work, Visual Studio monitors changes in the editor and also on disk to keep its index in sync with the sources.

You can open folders containing any number of CMake projects. Visual Studio erkennt und konfiguriert alle CMakeLists. Visual Studio detects and configures all the "root" CMakeLists. You can also view your projects organized logically by targets. Visual Studio uses a configuration file called CMakeSettings. This file lets you define and store multiple build configurations, and conveniently switch between them in the IDE. A configuration is a Visual Studio construct that encapsulates settings that are specific to a given build type.

Die Einstellungen werden verwendet, um die Standardbefehlszeilenoptionen zu konfigurieren, die Visual Studio an cmake. The settings are used to configure the default command-line options that Visual Studio passes to cmake.

You can also specify additional CMake options here, and define any additional variables you like. All options are written to the CMake cache either as internal or external variables.

For more information, see Customize CMake settings. Use the CMakeLists. You can specify source files, find libraries, set compiler and linker options, and specify other build system-related information.

To pass arguments to an executable at debug time, you can use another file called launch. In einigen Szenarios werden diese Dateien von Visual Studio automatisch generiert. In some scenarios, Visual Studio automatically generates these files. You can edit them manually, or even create the file yourself.

Neither of these are relevant for CMake projects. Your custom or preferred tools have complete control over how CMake configures your project. Navigieren Sie dann zu einer vorhandenen CMakeCache. Then, navigate to an existing CMakeCache. You can add an existing CMake cache to an open project.

It's done the same way you'd add a new configuration. For more information, see our blog post on opening an existing cache in Visual Studio. In the General toolbar, find the Configurations dropdown.

It probably shows "xDebug" by default. Select the preferred configuration and press F5 , or click the Run green triangle button on the toolbar.

The project automatically builds first, just like a Visual Studio solution. Right click on CMakeLists. If you have multiple targets in your folder structure, you can choose to build all or only one specific target. Make sure that a CMake target is already selected in the Startup Item dropdown in the General toolbar.

As you would expect, build results are shown in the Output Window and Error List. To debug a CMake project, choose the preferred configuration and press F5 , or press the Run button in the toolbar. If the Run button says "Select Startup Item", select the dropdown arrow. Choose the target that you want to run. In a CMake project, the "Current document" option is only valid for. The Run or F5 commands first build the project if changes have been made since the previous build.

Changes to CMakeSettings. You can customize a CMake debugging session by setting properties in the launch. For more information, see Configure CMake debugging sessions. If you have installed vcpkg , CMake projects opened in Visual Studio automatically integrate the vcpkg toolchain file.

That means no additional configuration is required to use vcpkg with your CMake projects. This support works for both local vcpkg installations and vcpkg installations on remote systems that you're targeting.

This behavior is disabled automatically when you specify any other toolchain in your CMake Settings configuration. By default, most configuration messages are suppressed unless there's an error. Wenn Sie eine CMakeLists. To edit a CMakeLists. If you make changes to the file, a yellow status bar appears and informs you that IntelliSense will update. It gives you a chance to cancel the update operation. Weitere Informationen zu CMakeLists. For information about CMakeLists. Dieser zeigt Informationen im Ausgabefenster an.

As soon as you save the file, the configuration step automatically runs again and displays information in the Output window. Fehler und Warnungen werden in der Fehlerliste oder im Ausgabefenster angezeigt. Errors and warnings are shown in the Error List or Output window. When you make significant changes to the CMakeSettings. It's also used in build and debug operations. View Cache opens the CMakeCache. Any edits you make here to CMakeCache. To make changes that persist after the cache is cleaned, see Customize CMake settings.

Open Cache Folder opens an Explorer window to the build root folder. Clean Cache deletes the build root folder so that the next CMake configure step starts from a clean cache.

Generate Cache forces the generate step to run even if Visual Studio considers the environment up to date. Run the appropriate vsdevcmd. For more information, see Building on the Command Line. Wechseln Sie zu Ihrem Ausgabeordner. Switch to your output folder. You also can import an existing CMake cache. Visual Studio adds a CMake menu item to the main menu, with commands for viewing and editing CMake scripts.

Visual Studio runs CMake. Visual Studio uses a file called CMakeSettings. You can conveniently switch between them in the IDE. Verwenden Sie CMakeLists. Otherwise, use the CMakeLists. If you need to pass arguments to an executable at debug time, you can use another file called launch. Wenn Sie eine vorhandene CMakeLists. When you import an existing CMakeCache.

The original cache isn't modified in any way. It can still be used from the command line, or with whatever tool or IDE used to generate it. Die neue CMakeSettings.


Einf├╝hrung in das Buildsystem Cmake

Thank you very much. This was very useful. That was fantastic. Absolutely perfect for getting me started with cmake on hierarchical projects that use shared libraries. Thank you!! Give this man a cookie The best write up on cmake. Thanks again.


Introduction to CMake by Example




Related Articles