project(... LANGUAGES C CXX RC) causes "Recursive call not allowed"
After upgrading from CMake 3.5.2 to 3.6.2, we are now experiencing an error
-- The C compiler identification is MSVC 19.0.23918.0
CMake Error at cmake-3.6.0-rc1-win64-x64/share/cmake-3.6/Modules/Platform/Windows-MSVC.cmake:326 (enable_language):
Language 'RC' is currently being enabled. Recursive call not allowed.
Call Stack (most recent call first):
cmake-3.6.0-rc1-win64-x64/share/cmake-3.6/Modules/Platform/Windows-MSVC-C.cmake:5 (__windows_compiler_msvc)
cmake-3.6.0-rc1-win64-x64/share/cmake-3.6/Modules/CMakeCInformation.cmake:58 (include)
CMakeLists.txt:2 (project)
This appears even in a minimized sample project
project(foo LANGUAGES C CXX RC)
I have reproduced it as far back as 3.6.0-rc1; in 3.5.2 and earlier, our project works fine. My guess from skimming the history is that this regression begins after #15999 (closed)/72e0dc58, though I haven't recompiled CMake to prove it.
I am not using any custom toolchain; the error seems to be independent of Generator, but the exact messages above are from the default "Visual Studio 14 2015". From the backtrace, it appears the Platform/Windows-MSVC.cmake is at fault.
Our project is explicitly enabling the RC language because we are also building for with g++ and winelib. On that platform we do use a toolchain file, which sets up wrc as the RC_COMPILER. But it does not enable_language, we let the projects that use .rc files do it.
SET(CMAKE_RC_COMPILER "${WINE_WRC}")
SET(CMAKE_RC_OUTPUT_EXTENSION .res)
SET(CMAKE_RC_SOURCE_FILE_EXTENSIONS .rc)