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

[feature] configurePresets.cmakeExecutable in CMakePresets.json should be filled in #15427

Closed
1 task done
Ext3h opened this issue Jan 9, 2024 · 5 comments · Fixed by #15447
Closed
1 task done

[feature] configurePresets.cmakeExecutable in CMakePresets.json should be filled in #15427

Ext3h opened this issue Jan 9, 2024 · 5 comments · Fixed by #15447
Assignees
Milestone

Comments

@Ext3h
Copy link

Ext3h commented Jan 9, 2024

What is your suggestion?

In CMakePresets.json, you can set configurePresets.cmakeExecutable to set a specific CMake binary.
While this doesn't work at alll with Visual Studio (stupid IDE insists on using built-in, outdated CMake version), it does work for IDEs like Visual Studio Code and similar ones.

This avoids a nasty issue when working a "hybrid" model between IDE with CMake integration mixed with conan commands in the same workspace.

Why you would want to do that?... E.g. because the initial configuration of the CMake cache is something which still behaves somewhat different between doing it within the IDE vs doing it in Conan. Stuff like environment variables required for compiler detection not being correctly set in the CMakePresets.json, and loads of other similar (environment related) issues.

When you have such a workflow, and you are working in a setup where CMake is distributed as a Conan dependency (and not installed system wide like in Conan Center), then you end up with Conan and the IDE trying to use different CMake versions on the same cache with guaranteed conflicts.

Specifying the CMake version conan would use in the presets ensures that configuration of the workspace with Conan, but subsequent work without Conan is possible in the first place.

While at it, also have a look at configurePreset.environment please, that's yet another thing Conan isn't filling in, leaving you in an odd situation where IDEs invoking CMake will do something entirely different from what Conan had prepared as an environment.

Worst case they pick up an entirely different compiler toolchain. E.g. trying to use Ninja together with MSVC and VSCode is something which should work out of the box, but absolutely doesn't when Conan is in the mix so you have to start re-wire commands just to make sure at least VCVars is eventually called before CMake.

Have you read the CONTRIBUTING guide?

  • I've read the CONTRIBUTING guide
@memsharded
Copy link
Member

Hi @Ext3h

Thanks for your suggestion.
This looks interesting, we knew that there was a gap when tool_requires("cmake/...") for certain cases when we recently added the env environment variables to the CMakePresets. But we didn't think about cmakeExecutable. If this can help for some setups/IDEs, it might be worth checking it. cc @czoido

@Ext3h
Copy link
Author

Ext3h commented Jan 9, 2024

Never mind the rambling about env - looks like something about #11666 doesn't work for me in 1.61 when I inject the generator via profile, and not specify in the recipe itself.

@Ext3h
Copy link
Author

Ext3h commented Jan 10, 2024

Okay, figured that out as well. conf::tools.cmake.cmaketoolchain:toolset_arch is used as the only source of configurePresets.toolset.value.

But that's wrong... settings::compiler.toolset also needs to be included in configurePresets.toolset.value. That's why #13136 popped up / isn't handled by #11666 as is.

It's wrong in both Conan 1.x and 2.x, as far as I can tell.

@czoido
Copy link
Contributor

czoido commented Jan 11, 2024

Hi @Ext3h

Thanks for your suggestion. This looks interesting, we knew that there was a gap when tool_requires("cmake/...") for certain cases when we recently added the env environment variables to the CMakePresets. But we didn't think about cmakeExecutable. If this can help for some setups/IDEs, it might be worth checking it. cc @czoido

Yes, I think it would make sense to add that variable to our presets, I'll make some tests with that.

@czoido
Copy link
Contributor

czoido commented Jan 26, 2024

Closed by #15447

@Ext3h beginning in 2.1.0 Conan will set that field in the CMakePresets, thanks a lot for the feedback.

@czoido czoido closed this as completed Jan 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants