[英]CMAKE not giving git hash under vscode
On a windows 10 machine, with CMake, Git and VSCode installed I have a settings.cmake file, containing the following code: On a windows 10 machine, with CMake, Git and VSCode installed I have a settings.cmake file, containing the following code:
# git git hash
execute_process(COMMAND git rev-parse HEAD OUTPUT_VARIABLE GIT_HASH)
IF (GIT_HASH)
string(STRIP "${GIT_HASH}" GIT_HASH)
MESSAGE(STATUS "${GIT_HASH}")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DCONFIG_GIT_HASH=${GIT_HASH}")
ENDIF()
This file is included in my CMakeLists.txt I use this to insert the git hash in my software该文件包含在我的 CMakeLists.txt 中
When running CMake from the commandline (Windows 10) this will result in a define of the CONFIG_GIT_HASH.从命令行 (Windows 10) 运行 CMake 时,这将导致定义 CONFIG_GIT_HASH。 When run from within VsCode CONFIG_GIT_HASH stays undefined.
从 VsCode 中运行时,CONFIG_GIT_HASH 保持未定义。
The actual problem was that Cmake was called with an almost empty "PATH" environment.实际问题是 Cmake 被调用时几乎是空的“PATH”环境。 The solution was adding
解决方案是添加
"cmake.configureEnvironment": {
"PATH": "C:\\Program Files\\Git\\cmd"
},
in the settings.json在设置中。json
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.