I have something such as this in my cmake:
set(MyLib_SRC $ENV{MyLib_DIR}/MyLib.cpp)
add_library(MyLibrary STATIC ${MyLib_SRC})
but when I r
The problem is that $ENV{MyLib_DIR}
expands the environment variable verbatim, including the backslashes used as path separators. These can then get re-interpreted as escape sequences.
What you want to do is convert the path to CMake's internal format before handling it in CMake code:
file(TO_CMAKE_PATH $ENV{MyLib_DIR} MyLib_DIR)
set(MyLib_SRC ${MyLib_DIR}/MyLib.cpp)
add_library(MyLibrary STATIC ${MyLib_SRC})