Visual Studio 2019 - CMake Linux - 在哪里获取宏列表?

问题描述 投票:0回答:1

在 Visual Studio 2019 中使用 CMake Linux 项目时,每个 json 文件(例如 task.vs.json、launch.vs.json)都会神奇地使用如下宏:

  • ${workspaceRoot}
  • ${env.xxx}
  • ${debugInfo.xxx}
  • ${cmake.xxx}

当文档稀缺并且 IntelliSense 没有帮助时,如何知道完整的选项列表?对于 MSBuild 的情况,通常会有一个窗口,其中包含所有可能的变量及其解析值。

顺便说一句,有没有一种方法可以在每个用户级别定义变量,以便像

launch.vs.json
这样的文件可以接受它?例如定义
targetAddr=192.168.1.2
,然后在json文件中使用${targetAddr}。一种方法是在 json 文件本身中定义变量,但我希望将该文件作为团队成员的“默认”提交,并让团队成员通过变量注入值,而不会使 json 文件变得“脏”。

linux visual-studio cmake visual-studio-2019
1个回答
0
投票

其中许多内容都记录在此处:

https://learn.microsoft.com/en-us/cpp/build/cmakesettings-reference

Macros
The following macros can be used in CMakeSettings.json:

${workspaceRoot} – the full path of the workspace folder
${workspaceHash} – hash of workspace location; useful for creating a unique identifier for the current workspace (for example, to use in folder paths)
${projectFile} – the full path of the root CMakeLists.txt file
${projectDir} – the full path of the folder containing the root CMakeLists.txt file
${projectDirName} – the name of the folder containing the root CMakeLists.txt file
${thisFile} – the full path of the CMakeSettings.json file
${name} – the name of the configuration
${generator} – the name of the CMake generator used in this configuration

重述 env.* 语法:

Environments 环境封装了环境变量集 在 Visual Studio 用于调用 CMake 的过程中。您可以使用 CMakeSettings.json 中的

env.{<variable_name>}
语法来引用 单独的环境变量,例如构建路径 文件夹。提供了以下预定义环境:

© www.soinside.com 2019 - 2024. All rights reserved.