简体   繁体   English

将 CMake.txt 转换为 .vcxproj 文件 C++ Visual Studio 项目

[英]Convert CMake.txt to .vcxproj file C++ Visual Studio project

It is any tool or possibility to convert a C++ CMake project into a C++ Visual Studio project with a .vcxproj file?是否有任何工具或可能性将 C++ CMake项目转换为带有.vcxproj文件的 C++ Visual Studio 项目?

I need this because we want to offer CMake support at the project I'm working for, but we need to make this conversion first.我需要这个是因为我们想在我工作的项目中提供 CMake 支持,但我们需要先进行这个转换。 I searched a lot and didn't find anything about this conversion, at least not yet.我搜索了很多,但没有找到有关此转换的任何信息,至少目前还没有。

Any opinion or suggestion is highly appreciated.任何意见或建议都非常感谢。 Thank you!谢谢!

This is what cmake does, generates projects for almost any IDE or build manager. 这就是cmake工作,几乎可以为任何IDE或构建管理器生成项目。

So for VS 2017 it can be used like this: 因此对于VS 2017,可以这样使用:

cd "<path where CMakeLists.txt is located>"
mkdir build
cd build
cmake -DCMAKE_CONFIGURATION_TYPES="Debug;Release" -DCMAKE_GENERATOR_PLATFORM=x64 -G "Visual Studio 15 2017" ..
cmake --open .

CMake can natively generate VS solutions. CMake 可以原生生成 VS 解决方案。

If you have visual studio installed CMake will use that as the default.如果您安装了 Visual Studio,CMake 将使用它作为默认设置。

cd "<path where CMakeLists.txt is located>"

# Creates build folder if it doesn't already exist
# Assuming I only have VS2022 installed it will just use that by default
# If you want to be explicit you can use do `-G "Visual Studio 17 2022"`
cmake -B build/

# Open IDE (works for XCode/Visual Studio)
cmake --open build

Alternatively, Visual Studio also now natively reads CMake as well:或者,Visual Studio 现在也可以本地读取 CMake:

https://devblogs.microsoft.com/cppblog/whats-new-for-c-cross-platform-developers-in-visual-studio-2022/ https://devblogs.microsoft.com/cppblog/whats-new-for-c-cross-platform-developers-in-visual-studio-2022/

So you can use Visual Studio as your editor, Ninja for building, and CMake to manage it.因此,您可以使用 Visual Studio 作为编辑器,使用 Ninja 进行构建,并使用 CMake 进行管理。 They have lots of great features for cross-platform development.它们具有许多用于跨平台开发的强大功能。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使用Visual Studio 2008打开vcxproj(Visual C ++项目) - How to open vcxproj (visual c++ project) with visual studio 2008 如果我无法创建 vcxproj 文件,我可以使用 MSBuild 作为带有 Visual Studio 代码的 C++ 编译器吗? - Could I use MSBuild as C++ compiler with Visual Studio code if I can't create the vcxproj file? 将 Visual Studio C++ 项目迁移到 Linux 和 CMake - Migrating a Visual Studio C++ Project to Linux and CMake 列出由cmake生成的Visual Studio C ++项目中的头文件 - Listing header files in Visual Studio C++ project generated by cmake Visual Studio构建托管在GitHub中的C ++ / CMake项目 - Visual Studio to build C++/CMake project hosted in GitHub 使用CMake生成Visual Studio C ++项目文件 - Using CMake to generate Visual Studio C++ project files 如何将cmake项目转换为Visual Studio等效项? - How to convert a cmake project into a Visual Studio equivalent? 无法在 Visual Studio Community 2019 中读取项目文件“project.vcxproj”。找到了意外的令牌“s”? - Unable to read Project file “project.vcxproj” in Visual Studio Community 2019. unexpected token 's' was found? 使用CMake为Visual Studio项目配置txx文件 - Configuring txx file with CMake for visual studio project C ++ visual studio,txt文件中的i / o - C++ visual studio, i/o in txt file
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM