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: add support for setting CMAKE_GENERATOR_INSTANCE #16229

Conversation

perseoGI
Copy link
Contributor

@perseoGI perseoGI commented May 9, 2024

Changelog: Feature: add support for setting CMAKE_GENERATOR_INSTANCE
Docs: conan-io/docs#3719
Closes: #16222

@CLAassistant
Copy link

CLAassistant commented May 9, 2024

CLA assistant check
All committers have signed the CLA.

@perseoGI
Copy link
Contributor Author

perseoGI commented May 9, 2024

As you can see, making some tests with @jcar87 we found a problem with quotation escaping.
Thus, calling strip is needed:

<str>.strip('\'').strip('"') if <str> is not None else None

It may be useful to add a this functionality to self._conanfile.conf.get in order to retrieve the stripped string.

# Test input from command line passing path between doble quotes
client.run('install . --profile:build=windows --profile:host=windows -c tools.cmake.cmaketoolchain:generator_instance="C:/Program Files (x86)/Microsoft Visual Studio/2017/BuildTools/"')
toolchain = client.load("conan_toolchain.cmake")
assert "set(CMAKE_GENERATOR_INSTANCE \"C:/Program Files (x86)/Microsoft Visual Studio/2017/BuildTools/\")" in toolchain
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use same assert in the 3 cases, not one with single quote without escaping, and the other asserts with double quotes and escaping. I'll copy the first one in the 3 cases.

@@ -955,14 +958,18 @@ def context(self):
result = self._get_winsdk_version(system_version, generator_platform)
system_version, winsdk_version, gen_platform_sdk_version = result

generator_instance = self._conanfile.conf.get("tools.cmake.cmaketoolchain:generator_instance")
generator_instance = generator_instance.strip('\'').strip('"') if generator_instance is not None else None
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the quoting management would be better addressed more homogeneusly with other confs/options, and not in isolation. If we allow quotes in profiles for this conf, but not for others, it can be confusing and error prone (other confs adding quotes will fail).

I suggest:

  • Remove this management of extra quotes in this PR
  • Use strings without quotes in profile files in the tests (similar to all other previous confs)

Then we can consider about possible alternatives to make this integrated with conf.get(), so other confs can use it too, but separately to this PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okey, strips removed, we will consider later if we want to support quotations in conan profiles

Copy link
Member

@RubenRBS RubenRBS left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have a a small general question: Couldn't this be set on an user toolchain so that vairables like this don't proliferate in the Conan conf??

Otherwise the code looks good :)

Edit: Nevermind, I just read #16222 (comment), it was already brought up!

@memsharded
Copy link
Member

I have a a small general question: Couldn't this be set on an user toolchain so that vairables like this don't proliferate in the Conan conf??

Yes, totally agree, I have already commented that with @perseoGI and @jcar87.
Lets close this PR and lets have a new one for any generic CMake variable.

@memsharded memsharded closed this May 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[feature] expose CMakeToolchain conf to be able to set CMAKE_GENERATOR_INSTANCE
5 participants