[英]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.