我在编译SeqAn框架时收到以下错误:
1> [CMake] CMake Error:
1> [CMake] Running
1> [CMake]
1> [CMake] 'C:/Program Files (x86)/Microsoft Visual Studio/2019/Professional/Common7/IDE/CommonExtensions/Microsoft/CMake/Ninja/ninja.exe' '-C' 'C:/Users/pc/source/repos/seqan/out/build/x64-Clang-Debug' '-t' 'recompact'
1> [CMake]
1> [CMake] failed with:
1> [CMake]
1> [CMake] ninja: error: build.ninja:152: bad $-escape (literal $ must be written as $$)
1> [CMake]
1> [CMake]
1> [CMake]
1> [CMake]
1> [CMake]
1> [CMake] CMake Generate step failed. Build files cannot be regenerated correctly.
1> 'C:\WINDOWS\system32\cmd.exe' '/c "%SYSTEMROOT%\System32\chcp.com 65001 >NUL && "C:\PROGRAM FILES (X86)\MICROSOFT VISUAL STUDIO\2019\PROFESSIONAL\COMMON7\IDE\COMMONEXTENSIONS\MICROSOFT\CMAKE\CMake\bin\cmake.exe" -G "Ninja" -DCMAKE_BUILD_TYPE:STRING="Debug" -DCMAKE_INSTALL_PREFIX:PATH="C:\Users\pc\Source\Repos\seqan\out\install\x64-Clang-Debug" -DCMAKE_CXX_COMPILER:FILEPATH="C:/Program Files/LLVM/bin/clang-cl.exe" -DCMAKE_MAKE_PROGRAM="C:\PROGRAM FILES (X86)\MICROSOFT VISUAL STUDIO\2019\PROFESSIONAL\COMMON7\IDE\COMMONEXTENSIONS\MICROSOFT\CMAKE\Ninja\ninja.exe" "C:\Users\pc\Source\Repos\seqan" 2>&1"' execution failed with error: ''C:\WINDOWS\system32\cmd.exe' '/c "%SYSTEMROOT%\System32\chcp.com 65001 >NUL && "C:\PROGRAM FILES (X86)\MICROSOFT VISUAL STUDIO\2019\PROFESSIONAL\COMMON7\IDE\COMMONEXTENSIONS\MICROSOFT\CMAKE\CMake\bin\cmake.exe" -G "Ninja" -DCMAKE_BUILD_TYPE:STRING="Debug" -DCMAKE_INSTALL_PREFIX:PATH="C:\Users\pc\Source\Repos\seqan\out\install\x64-Clang-Debug" -DCMAKE_CXX_COMPILER:FILEPATH="C:/Program Files/LLVM/bin/clang-cl.exe" -DCMAKE_MAKE_PROGRAM="C:\PROGRAM FILES (X86)\MICROSOFT VISUAL STUDIO\2019\PROFESSIONAL\COMMON7\IDE\COMMONEXTENSIONS\MICROSOFT\CMAKE\Ninja\ninja.exe" "C:\Users\pc\Source\Repos\seqan" 2>&1"' returned with exit code: 1'.
以下是我的CMakeSettings_schema.json文件:
{
"configurations": [
{
"name": "x64-Clang-Debug",
"generator": "Ninja",
"configurationType": "Debug",
"buildRoot": "${projectDir}\\out\\build\\${name}",
"installRoot": "${projectDir}\\out\\install\\${name}",
"cmakeCommandArgs": "",
"buildCommandArgs": "",
"ctestCommandArgs": "",
"inheritEnvironments": [ "clang_cl_x64_x64" ],
"variables": []
}
]
}
以下是我的 build.ninja 文件第 152 行的内容:
COMMAND = cmd.exe /C "cd /D C:\Users\pc\source\repos\seqan\out\build\x64-Clang-Debug && C:\Users\pc\source\repos\seqan\out\build\x64-Clang-Debug\bin\$(ConfigurationName)\alf.exe --write-ctd C:/Users/pc/source/repos/seqan/out/build/x64-Clang-Debug/workflow_plugin_dir/descriptors/alf.ctd"
我可以做什么来解决这个问题?
您现在可能已经解决了这个问题,但导致我的错误 $-escape 错误的原因是 PATH 环境变量中指定的路径之一中存在额外的 $。
我认为这在技术上是 CMake 中的一个错误。
例如,这应该有效:
cmake_minimum_required(VERSION 3.27)
project(foo)
set(foo_stamp_file "${CMAKE_CURRENT_BINARY_DIR}/foo.stamp")
add_custom_command(
VERBATIM
OUTPUT ${foo_stamp_file}
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
COMMAND $(foo).sh
COMMAND ${CMAKE_COMMAND} -E touch ${foo_stamp_file}
)
add_custom_target(foo_tgt DEPENDS ${foo_stamp_file})
(假设您有一个名为
$(foo).sh
的可执行脚本。)
但是它给了我这个错误:
CMake Error:
Running
'ninja' '-C' '/home/codasip.com/timothy.hutt/d1/build' '-t' 'recompact'
failed with:
ninja: error: build.ninja:78: bad $-escape (literal $ must be written as $$)
COMMAND = cd /home/......................../d1 && $(foo).sh && /home/c...
^ near here
我不确定为什么,但在这个小测试用例中,它在配置步骤中给出了错误,但在我的实际项目中,它在
ninja
步骤中给出了错误。但这是同样的错误。
显然,这是引用 Ninja 生成器输出时的一个错误。考虑到 CMake 和 Ninja 的设计,这并不奇怪 - 一切都是字符串类型和空格分隔的。保证引用错误。