[CMake] Invalid escape sequence in macro

Ramold, Felix Felix.Ramold at kuka.com
Mon Mar 11 11:19:48 EDT 2019


Hi,

today i ran into an error with escape characters in macros. Is this a known issue? Is this by design? How can I workaround?

Code:
function(f STRING)
   message(STATUS ${STRING})
endfunction()

macro(m STRING)
   message(STATUS ${STRING})
endmacro()

set(CONTENT "bla bla \/\/")
message(STATUS ${CONTENT})
f(${CONTENT})
m(${CONTENT})

Output:
ramold at xxx MINGW64 /c/Program Files/CMake/cmake-3.13.4-win64-x64/bin
$ ./cmake.exe -P test.cmake
CMake Warning (dev) at test.cmake:9 (set):
  Syntax error in cmake code at

    C:/Program Files/CMake/cmake-3.13.4-win64-x64/bin/test.cmake:9

  when parsing string

    bla bla \/\/

  Invalid escape sequence \/

  Policy CMP0010 is not set: Bad variable reference syntax is an error.  Run
  "cmake --help-policy CMP0010" for policy details.  Use the cmake_policy
  command to set the policy and suppress this warning.
This warning is for project developers.  Use -Wno-dev to suppress it.

-- bla bla \/\/
-- bla bla \/\/
CMake Warning (dev) at test.cmake:6 (message):
  Syntax error in cmake code at

    C:/Program Files/CMake/cmake-3.13.4-win64-x64/bin/test.cmake:6

  when parsing string

    bla bla \/\/

  Invalid escape sequence \/

  Policy CMP0010 is not set: Bad variable reference syntax is an error.  Run
  "cmake --help-policy CMP0010" for policy details.  Use the cmake_policy
  command to set the policy and suppress this warning.
Call Stack (most recent call first):
  test.cmake:12 (m)
This warning is for project developers.  Use -Wno-dev to suppress it.

-- bla bla \/\/

Regards,
Felix Ramold


More information about the CMake mailing list