Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[bug] CMake Presets Can Not Work Well with Clion Under Visual Studio 2022 17.11.5 #17281

Open
fancygit opened this issue Nov 6, 2024 · 7 comments

Comments

@fancygit
Copy link

fancygit commented Nov 6, 2024

Describe the bug

  1. os: Windows 11
  2. Conan: 2.9.1
  3. Compiler: Visual Studio 2022 17.11.5
  4. Coann Profile:
    [settings]
    arch=x86_64
    build_type=Release
    compiler=msvc
    compiler.cppstd=17
    compiler.runtime=dynamic
    compiler.version=194
    os=Windows

How to reproduce it

First I usually develop projects with IDE Clion. Conan is always my first choice of c++ package manager. And the generator is always visual studio.
Yesterday I update my visual studio vs2022 from 17.9.4 to 17.11.5. I found out that the clion can't reload the cmake project.
Here are the steps:

  1. "enable conan-default"
    image
  2. "check the toolset"
    image
  3. "Clions output there lines"
    Failed to launch CMake executable 'C:\Users\harry\AppData\Local\Programs\CLion Nova\bin\cmake\win\x64\bin\cmake.exe': Cannot load Visual C++ environment from C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat:
    command [C:\WINDOWS\system32\cmd.exe, /c, "call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" amd64 -vcvars_ver=14.3 1>&2 && "C:\Users\harry\AppData\Local\Programs\CLion Nova\jbr\bin\java" -cp "C:\Users\harry\AppData\Local\Programs\CLion Nova\lib\util_rt.jar" com.intellij.util.ReadEnv > C:\Users\harry\AppData\Local\Temp\intellij-cmd-env-data.13203864965847733922.tmp || exit /B %ERRORLEVEL%"], exit code: 0 Configure Disable profile
  4. When I re-execute the command: "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" amd64 -vcvars_ver=14.3 it shows the errors:
    [ERROR:vcvars.bat] Toolset directory for version '14.3' was not found.
    [ERROR:VsDevCmd.bat] *** VsDevCmd.bat encountered errors. Environment may be incomplete and/or incorrect. ***
    [ERROR:VsDevCmd.bat] In an uninitialized command prompt, please 'set VSCMD_DEBUG=[value]' and then re-run
    [ERROR:VsDevCmd.bat] vsdevcmd.bat [args] for additional details.
    [ERROR:VsDevCmd.bat] Where [value] is:
    [ERROR:VsDevCmd.bat] 1 : basic debug logging
    [ERROR:VsDevCmd.bat] 2 : detailed debug logging
    [ERROR:VsDevCmd.bat] 3 : trace level logging. Redirection of output to a file when using this level is recommended.
    [ERROR:VsDevCmd.bat] Example: set VSCMD_DEBUG=3
    [ERROR:VsDevCmd.bat] vsdevcmd.bat > vsdevcmd.trace.txt 2>&1
  5. "Check the toolset dir"
    image
  6. Try to solve this problem "I add a customed preset in CMakeUserPresets and cheange the toolset to 14.4" And It works.
    image
@fancygit
Copy link
Author

fancygit commented Nov 6, 2024

Another question : Do I really need to set up "compiler.cppstd" , it seems like this attribute can be compatible with "14" "17" "20"

@memsharded
Copy link
Member

Another question : Do I really need to set up "compiler.cppstd" , it seems like this attribute can be compatible with "14" "17" "20"

Yes, it is very recommended in Conan 2. The default compatibility.py plugin will implement a binary compatibility by default for different values, but this can be controlled for the cases that aren't really compatible.

@memsharded
Copy link
Member

I am not sure what is happening, but I tend to think there is a CLion bug. The v144 simply doesn't exist in VS, it is still the v143 toolset, even for toolset version v14.4X. I know it is confusing, but this is what Microsoft decided. Most tools in the C++ ecosystem we had to do small hacks to deal with this.

You might be able to test things without CLion, just with CMake in the command line and see for example how Conan will map the vcvars_vers=14.4 or something like that and it will work.

I think the problem is CLion trying to activate the environment is doing:

 -vcvars_ver=14.3

Because it might have a direct mapping from v14X toolset to v14.X toolset version, which is not correct for VS >= 17.10, which will be v143 toolset and v14.4X toolset version. I'd suggest to report this to CLion.

@fancygit
Copy link
Author

fancygit commented Nov 6, 2024

I am not sure what is happening, but I tend to think there is a CLion bug. The v144 simply doesn't exist in VS, it is still the v143 toolset, even for toolset version v14.4X. I know it is confusing, but this is what Microsoft decided. Most tools in the C++ ecosystem we had to do small hacks to deal with this.

You might be able to test things without CLion, just with CMake in the command line and see for example how Conan will map the vcvars_vers=14.4 or something like that and it will work.

I think the problem is CLion trying to activate the environment is doing:

 -vcvars_ver=14.3

Because it might have a direct mapping from v14X toolset to v14.X toolset version, which is not correct for VS >= 17.10, which will be v143 toolset and v14.4X toolset version. I'd suggest to report this to CLion.

You are right, I think may be it's Clion bug. I just don't know how to fix it .
It works well if I directly use cmake to build the whole project as well as it does when I opened the cmake project with visual studio 2022.

I just don't know how to report to Clion. Thanks.

@ah-meng
Copy link

ah-meng commented Nov 14, 2024

I'm experiencing the same issue.

@memsharded
Copy link
Member

Hi @ah-meng, as described above, this seems a limitation/bug in CLion/CMake, not in Conan.
The best approach would be to report in their issue tracker. Have you already reported there? If so, please share the link here, and then we could close this and follow in their issue tracker. Thanks for the feedback.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants