Cmake error: Invalid escape sequence \U

2019-04-21 10:54发布

While running my OpenCL code in VC++ 10 by using CMake I am getting the following error:

CMake Error at CMakeLists.txt:6 (set): Syntax error in cmake code at
C:/Users/Shreedhar/Desktop/testCL/CMakeLists.txt:6

when parsing string
C:\Users\Shreedhar\Desktop\test_CL\CMakeLists
Invalid escape sequence \U

标签: path cmake
3条回答
霸刀☆藐视天下
2楼-- · 2019-04-21 11:07

For those who receive this error under Windows:

CMake Error at C:/Dev/cmake/share/cmake-3.8/Modules/FindBoost.cmake:903 (list):
Syntax error in cmake code at

C:/Dev/cmake/share/cmake-3.8/Modules/FindBoost.cmake:903

when parsing string

C:\Dev\mongodb\src\boost/lib${_arch_suffix}-msvc-15.0

Invalid character escape '\D'. Call Stack (most recent call first): C:/Dev/cmake/share/cmake-3.8/Modules/FindBoost.cmake:1379 (_Boost_UPDATE_WINDOWS_LIBRARY_SEARCH_DIRS_WITH_PREBUILT_PATHS)
src/bsoncxx/CMakeLists.txt:100 (find_package)

Don't set the BOOST_ROOT environment variable to a backslash-ended value.

查看更多
兄弟一词,经得起流年.
3楼-- · 2019-04-21 11:16

Use forward slashes / in your paths

C:/Users/Shreedhar/Desktop/test_CL/CMakeLists
查看更多
聊天终结者
4楼-- · 2019-04-21 11:20

If you are reading user input like environment variables then you'll need to do this by character replacement feature of string method.

string(REPLACE "\\" "/" outputVar ${_inputVar})
查看更多
登录 后发表回答