26
votes

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
3

3 Answers

42
votes

Use forward slashes / in your paths

C:/Users/Shreedhar/Desktop/test_CL/CMakeLists
12
votes

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})
3
votes

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.