Visual studio 2019下创建CMake项目

文章介绍了如何在IDE如VisualStudio中创建和打开CMake项目。首先,可以通过新建解决方案来创建项目。对于已有CMake项目,可以使用‘文件->打开->CMake’来加载含有CMakeLists.txt的目录。然而,在VisualStudio2019中,当尝试在一个解决方案下添加多个CMake项目时,可能会遇到CMakeLists.txt已存在导致无法添加的问题。

启动IDE

在这里插入图片描述

创建项目

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述这里选择 创建新解决方案,然后点击 创建。下面展示下在 Window电脑上及Visual Studio上的目录结构。
在这里插入图片描述
解决方案 就像是一个容器:里面可以 放 1到多个项目。
在这里插入图片描述

如何打开已有Cmake项目

由于cmake项目没有 .sln等文件,打开方式可按照下面的。

方式一

在这里插入图片描述
在这里插入图片描述
稍等片刻,就会在IDE中打开这个解决方案了。

方式二

文件–》打开–》CMake
在这里插入图片描述
在打开的对话框中 选中 CMakeLists.txt文件,然后点击打开。
在这里插入图片描述

存在的问题

在visual studio 2019上 在已有解决方案下,添加多个cmake项目时提示 CMakeLists.txt已存在。不让添加项目。暂未解决

### Visual Studio 2019 Compatible CMake Version Visual Studio 2019 provides robust support for CMake-based workflows, particularly in its later updates such as version 16.5 Preview 2. This update includes enhancements specifically tailored for Linux CMake development, enabling better integration with Windows Subsystem for Linux (WSL) during the separation of build systems from deployment environments[^1]. Additionally, there is an introduction of a command-line tool that interacts with the Connection Manager alongside notable performance improvements. The specific versions supported by Visual Studio can vary depending on the edition or preview release being used. In general, starting from Visual Studio 2019 v16.3 onwards, Microsoft began bundling newer versions of CMake within their releases to ensure compatibility between tools like IntelliSense and project configurations[^2]. For users who require precise information about which exact CMake version ships with each respective Visual Studio 2019 iteration, it would be advisable to consult official documentation detailing these changes per milestone—such details were referenced earlier regarding previews but may not always explicitly state every minor adjustment made across all components over time without direct mention unless documented thoroughly elsewhere outside provided excerpts here today. Here’s how you might configure basic settings programmatically using Python scripting if needed: ```python import subprocess def get_cmake_version(): try: result = subprocess.run(['cmake', '--version'], stdout=subprocess.PIPE) output = result.stdout.decode('utf-8') return output.splitlines()[0] except Exception as e: return f"Error retrieving CMake version: {e}" print(get_cmake_version()) ``` This script retrieves the currently installed CMake version via terminal commands executed through Python's `subprocess` module.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值