conan icon indicating copy to clipboard operation
conan copied to clipboard

[bug] Conan generate the wrong CMake Presets when building for MSVC 194

Open elvisdukaj opened this issue 4 months ago • 4 comments

Describe the bug

After updating Visual Studio my conan projects based on Conan broke during the building because the Visual C++ runtime was not found. The new Visual C++ toolset is v194 but when calling conan install the generated CMakePreset.json still refers to the older toolchain:

"toolset": {
  "value": "v143",
  "strategy": "external"
},

Trying to call cmake with the preset results in the following error:

-- The CXX compiler identification is unknown
CMake Error at CMakeLists.txt:2 (project):
  No CMAKE_CXX_COMPILER could be found.

  Tell CMake where to find the compiler by setting either the environment
  variable "CXX" or the CMake cache entry CMAKE_CXX_COMPILER to the full path
  to the compiler, or to the compiler name if it is in the PATH.


-- Configuring incomplete, errors occurred!

In CLion, instead the fails to load the cmake configuration because is passing -vcvars_ver=14.3 instead of vcvarsall.bat" amd64 -vcvars_ver=14.4

On CLion, if I manually changing the toolset value in the generated cmake user preset to v194, the configuration works again. This is not true when calling cmake --preset conan-release.

-- Using Conan toolchain: C:/xrsw/repos/projects/test_vc194/t2/build/Release/generators/conan_toolchain.cmake
-- Conan toolchain: Setting CMAKE_MSVC_RUNTIME_LIBRARY=$<$<CONFIG:Release>:MultiThreadedDLL>
-- Conan toolchain: C++ Standard 23 with extensions OFF
-- The CXX compiler identification is MSVC 19.41.34120.0
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: C:/Program Files/Microsoft Visual Studio/2022/Professional/VC/Tools/MSVC/14.41.34120/bin/Hostx64/x64/cl.exe - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Configuring done (2.4s)
-- Generating done (0.2s)
-- Build files have been written to: C:/xrsw/repos/projects/test_vc194/t2/build/Release

[Finished]

How to reproduce it

  1. Install the latest Visual C++ toolchain (_MSC_VER 1941) coming with Visual Studio 17.11.4.

  2. Use the following profile:

    [settings]
    arch=x86_64
    build_type=Release
    compiler=msvc
    compiler.cppstd=23
    compiler.runtime=dynamic
    compiler.runtime_type=Release
    compiler.version=194
    os=Windows
    [conf]
    tools.cmake.cmaketoolchain:generator=Ninja
    
  3. Create a project with conan new cmake_exe -d name=msvc194 -d version=1

  4. Call conan install: conan install . -s compiler.version=194

  5. Calling cmake with the preset: cmake --preset conan-release

elvisdukaj avatar Oct 04 '24 07:10 elvisdukaj