conan-io / conan

Conan - The open-source C and C++ package manager
https://conan.io
MIT License
8.11k stars 960 forks source link

[question] Is it possible to unset value in [settings] section of profile? #16624

Open Nekto89 opened 1 month ago

Nekto89 commented 1 month ago

What is your question?

Hi,

After upgrading OS/Xcode/CMake on Macos machine CMake started to initializing CMAKE_OSX_DEPLOYMENT_TARGET that leads to initialization of "os.version" in conan-cmake. I have old recipe for prebuilt binaries that wasn't ready for this. It doesn't delete settings.os.version.

def package_id(self):
        del self.info.settings.compiler
        del self.info.settings.build_type

Is it possible to unset os.version through profile for one specific package? I've found some documentation for different sections and tried using =!, =None, just =, but nothing seems to be working for settings.

[settings]
mylibrary/*:os.version=!

Have you read the CONTRIBUTING guide?

memsharded commented 1 month ago

Hi @Nekto89

Thanks for your question.

The settings don't have the possibility of unsetting them if they have already been set.

Maybe just modifying your conan_provider.cmake is the easiest to avoid this?

Do you have more info on the change of CMAKE_OSX_DEPLOYMENT_TARGET, is there a known policy for this? It is not common that CMake will change behavior this way without a policy.

Nekto89 commented 1 month ago

Hi @Nekto89

Thanks for your question.

The settings don't have the possibility of unsetting them if they have already been set.

Maybe just modifying your conan_provider.cmake is the easiest to avoid this?

Do you have more info on the change of CMAKE_OSX_DEPLOYMENT_TARGET, is there a known policy for this? It is not common that CMake will change behavior this way without a policy.

It's probably caused by newer Xcode that has new SDK. I've installed Xcode 14.2 - the latest one that is available for that old mac machine with macOS Monterey (12.7.5). CMake initializes CMAKE_OSX_DEPLOYMENT_TARGET with 12.7.

"If the automatically selected SDK is newer than the host OS version and no deployment version has been set then adjust the deployment version to the host OS version. Otherwise the user won't be able to launch the executables on the build host."

https://gitlab.kitware.com/cmake/cmake/-/commit/24aafbde115647b7e599d112d0bcc4f03c3e9b88

I think that it's ok to have os.version for all the other packages. There is only 1 that I just don't want to repack. But I'll have to duplicate binaries with updated recipe if conan doesn't support this case.

memsharded commented 2 weeks ago

Should we move this to cmake-conan repo? The question to the Conan client is responded, I think, summary:

Note that negative patterns are possible. If you want to set os.version to all packages except mylibrary, you can do:

[settings]
!mylibrary*:os.version=xxxx

Note the initial ! to negate the pattern.