CMake compiler detection fails when CMAKE_DIR contains GLOB characters.
On Windows, if your CMake installation path contains GLOB characters like:
C:/App[3]/CMake/Win32/ ...
CMake will fail with:
CMake Error at Tools/CMake/Win32/share/cmake-3.14/Modules/CMakeCompilerIdDetection.cmake:26 (list): list sub-command REMOVE_ITEM requires two or more arguments. Call Stack (most recent call first): Tools/CMake/Win32/share/cmake-3.14/Modules/CMakeDetermineCompilerId.cmake:151 (compiler_id_detection) Tools/CMake/Win32/share/cmake-3.14/Modules/CMakeDetermineCompilerId.cmake:170 (CMAKE_DETERMINE_COMPILER_ID_WRITE) Tools/CMake/Win32/share/cmake-3.14/Modules/CMakeDetermineCompilerId.cmake:31 (CMAKE_DETERMINE_COMPILER_ID_BUILD) Tools/CMake/Win32/share/cmake-3.14/Modules/CMakeDetermineCCompiler.cmake:113 (CMAKE_DETERMINE_COMPILER_ID) CMakeLists.txt:23 (project)
Since GLOB parsing will erase the brackets from the path.
I implemented a quick workaround/hack/fix, there are probably more instances in CMake code where user paths are fed into GLOB parsing functions.
(https://gitlab.kitware.com/cmake/cmake/blob/master/Modules/CMakeCompilerIdDetection.cmake) starting at line 14
function(escape_glob_characters invar outvar)
string(REPLACE "*" "\\*" tmpvar ${invar})
string(REPLACE "?" "\\?" tmpvar ${tmpvar})
string(REPLACE "[" "\\[" tmpvar ${tmpvar})
string(REPLACE "!(" "\\!(" tmpvar ${tmpvar})
string(REPLACE "+(" "\\+(" tmpvar ${tmpvar})
string(REPLACE "@(" "\\@(" tmpvar ${tmpvar})
set(${outvar} ${tmpvar} PARENT_SCOPE)
endfunction()
function(compiler_id_detection outvar lang)
if (NOT lang STREQUAL Fortran AND NOT lang STREQUAL CSharp)
escape_glob_characters(${CMAKE_ROOT} escaped_cmake_root)
file(GLOB lang_files
"${escaped_cmake_root}/Modules/Compiler/*-DetermineCompiler.cmake")
set(nonlang CXX)
if (lang STREQUAL CXX)
set(nonlang C)
endif()
file(GLOB nonlang_files
"${escaped_cmake_root}/Modules/Compiler/*-${nonlang}-DetermineCompiler.cmake")
escape_glob_characters(${nonlang_files} escaped_nonlang_files)
list(REMOVE_ITEM lang_files ${escaped_nonlang_files})
endif()
...
There is another issue where the path to CMake in a Visual Studio(2017) project's .vcxproj file custom command is not properly quoted. So having characters like spaces, brackets or others in your cmake installation path will break the compilation. I will make another issue for that.