Conan: Unknown MSVC compiler version

This error had been causing my team heartburn for a while.  Previously, we kicked the problem down the road using this in our main CMakeLists.txt:

set(MSVC_VERSION 1919)

But, finally, I ran into a situation which forced me to figure it out.  With the above workaround in place, I had started getting these errors from one of the Conan packages I was including:

The C compiler identification is unknown
The CXX compiler identification is unknown


When I dug into the CMake error log, I got a bit more specificity:

LINK : fatal error LNK1104: cannot open file 'MSVCRTD.lib'

The offending bit of code in CMakeLists.txt turned out to be this:

if(NOT EXISTS "${CMAKE_BINARY_DIR}/conan.cmake")
   message(STATUS "Downloading conan.cmake from https://github.com/conan-io/cmake-conan")
   file(DOWNLOAD "https://raw.githubusercontent.com/conan-io/cmake-conan/v0.9/conan.cmake"
                 "${CMAKE_BINARY_DIR}/conan.cmake")
endif()

This code, copied from the Conan docs, pulls down Conan-Cmake, but only if it has not been downloaded previously.  The issue for me was that Conan-CMake did not support Visual Studio 2019 until version 0.14.  Given that I had run this code previously, my machine never updated the conan.cmake file, and the errors above resulted from the inability of Conan-CMake to find my compiler.

The ideal solution is to replace the simple "if not exists" check with something more robust which perhaps determines the file version, but an immediate fix is simply to update the line to the latest version:


file(DOWNLOAD "https://raw.githubusercontent.com/conan-io/cmake-conan/v0.16.1/conan.cmake"

Comments

Popular posts from this blog

Fixing Conan Lock Issues

Dynamic Object Oriented programming in ArchestrA

Initialize With Care