Issues with automatic VS environment setup via vcvarsall.bat
还没有人认领这个 Issue。
评估
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 新手友好度
- 35/100
- Issue 类型
- 缺陷
- 描述清晰度
- 需要澄清
- 活跃度
- 停滞
- 技术栈
- cmake
调研方向
定位运行 vcvarsall.bat 并将其环境传递到 CMake 的模板逻辑。在 Windows 上使用以反斜杠结尾的环境值重现报告,然后使用 Ninja 生成器进行配置并尝试构建。完成的标准是环境值保持不变,并且已配置的构建能够找到 MSVC 编译器和链接器,而无需重新运行 vcvarsall.bat。
由索引模型根据 Issue 内容生成。
描述
I believe there are some issues with the way this template attempts to automatically run vcvarsall.bat when compiling with MSVC on Windows.
First Issue: Trailing slashes in environment variables
The first issue is related to how CMake handles lists. After executing vcvarsall.bat, your cmake script copies the environment to string, makes some replacements, and then copies the environment to the current cmake environment. This works fine until an environment value has a trailing backslash at the end of its value (e.g JAVA_HOME).
When this happens, you end up with a list in CMake that looks something like this:
...;JAVA_HOME=C:\Path\To\Java\;LIB=list__sep__of__sep__lib__sep__paths
Because of the trailing backslash, when cmake iterates through the list, it tries to set the JAVA_HOME environment to C:\Path\To\Java;LIB=list;of;lib;paths. The only way I've found to work around this behavior is to also replace all slashes in the environment output with slash and restore them before setting the environment variable.
Second Issue: The VS Environment is lost after the configure step
Running cmake to configure the project works, since the script sets up the VS environment automatically (assuming you don't lose the LIB environment variable due to the previous issue like I did). The problem is the environment is lost again after the configure step, so trying to build will fail indicating it can't find the necessary compiler/link executable. This occurred while using the Ninja generator. I don't know if this occurs with the MSVC generator.
The only way to fix this is to manually run vcvarsall.bat again before executing the build step. I haven't figured out a way to avoid this problem.
At least that was my experience.
- 主要语言
- CMake
- 星标
- 1.8k
- 派生
- 205
- PR 合并指标
- 30 天内没有已合并 PR
环境准备
在浏览器里用你自己的 GitHub 账号启动这个项目的开发容器。
- 没有 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 没有贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
cpp-best-practices/cmake_template 的其他 Issue
-
Put back `-Wsign-conversion` for gcc in CompilerWarnings.cmake可能已有人在做 关联的 PR 仍在进行中或已合并。 未关闭
难度 2/5 1 小时以内 新手友好度 85/100
-
难度 2/5 1-3 小时 新手友好度 82/100
-
难度 4/5 3-5 天 新手友好度 45/100
cpp-best-practices/cmake_template#140 · 2 条评论 ·
-
From-scratch clone/build fails on `src/ftxui_sample/CMakeFiles/intro.dir/main.cpp.obj`可能已有人在做 @leftibot 于 195 天前认领。 未关闭
难度 3/5 1-2 天 新手友好度 48/100
cpp-best-practices/cmake_template#139 · 2 条评论 ·
-
难度 3/5 1-2 天 新手友好度 35/100
cpp-best-practices/cmake_template#91 · 2 条评论 ·
查看 cpp-best-practices/cmake_template 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 62/100
immortalwrt/immortalwrt#2522 ·
-
Font inlining cache is not created or reused可能已有人在做 @nagahara-naoki 今天认领。 未关闭area: @angular/build
难度 2/5 1-3 小时 新手友好度 82/100
angular/angular-cli#34719 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 72/100
osaurus-ai/osaurus#3422 ·
维护者通常 1 天内回复
-
enhancement
难度 2/5 1-3 小时 新手友好度 66/100
-
难度 2/5 1-3 小时 新手友好度 62/100
foundation/foundation-emails#2127 ·