Compiler detection code tries to use path to compiler executable from the PATH variable as is with backslashes (Windows)
Platform: Windows 7 x64
CMake: 3.14.3
x64
...\share\cmake-3.14\Modules\CMakeDetermineCompilerId.cmake
, line 277:
set(id_PostBuildEvent_Command "for %%i in (${id_cl}) do %40echo CMAKE_${lang}_COMPILER=%%~$PATH:i")
...\share\cmake-3.14\Modules\CompilerId\VS-7.vcproj.in
, line 44:
CommandLine="for %%i in (@id_cl@) do @echo CMAKE_@id_lang@_COMPILER=%%~$PATH:i"
...\share\cmake-3.14\Modules\CompilerId\VS-Intel.vfproj.in
, line 32:
CommandLine="for %%i in (@id_cl@) do @echo CMAKE_@id_lang@_COMPILER=%%~$PATH:i"
...\share\cmake-3.14\Modules\CompilerId\VS-NsightTegra.vcxproj.in
, line 37:
for %%i in ($(ToolchainPrebuiltRoot)\bin\*@id_gcc@.exe) do (
@echo CMAKE_@id_lang@_COMPILER=%%i
goto :done
)
All these would produce an error:
CMake Error at .../build/CMakeFiles/3.14.3/CMakeCCompiler.cmake:1 (set):
Syntax error in cmake code at
.../build/CMakeFiles/3.14.3/CMakeCCompiler.cmake:1
when parsing string
C:\Program Files\Microsoft Visual Studio 2015\VC\bin\cl.exe
Invalid character escape '\P'.
I suggest the fix to replace all backslashes inplace:
set(id_PostBuildEvent_Command "setlocal ENABLEDELAYEDEXPANSION %26 for %%i in (${id_cl}) do %40( set \"CMAKE_${lang}_COMPILER=%%~$PATH:i\" %26 set \"CMAKE_${lang}_COMPILER=!CMAKE_${lang}_COMPILER:\\=/!\" %26 echo CMAKE_${lang}_COMPILER=!CMAKE_${lang}_COMPILER!)")
CommandLine="setlocal ENABLEDELAYEDEXPANSION & for %%i in (${id_cl}) do @( set "CMAKE_${lang}_COMPILER=%%~$PATH:i" & set "CMAKE_${lang}_COMPILER=!CMAKE_${lang}_COMPILER:\=/!" & echo.CMAKE_${lang}_COMPILER=!CMAKE_${lang}_COMPILER!)"