CPack/NSIS: "Invalid escape sequence \P" Windows paths
Given -DMYINSTALLPATH="C:\Program Files\foo"
then I get an error above invalid escape sequences at CPackConfig.cmake:33. So I:
file(TO_CMAKE_PATH ${MYINSTALLPATH} MYINSTALLPATH)
Then in NSIS64 generator (CPack) it doesn't let me press "Next" because the slashes are in the wrong direction. So I:
string(REPLACE "/" "\\" MYINSTALLPATH "${MYINSTALLPATH}")
; which brings me back to the original error. I'm running 3.21.0 (with that minimum version required).
EDIT: This worked. But I'm guessing it's not the right solution
if (WIN32)
string(REPLACE "/" "\\\\" MYINSTALLPATH "${MYINSTALLPATH}")
endif()