For paho-mqtt-c >= 1.3.4 the default value for shared should be False
For < 1.3.4 the default should remain True
Background:
https://github.com/conan-io/conan-center-index/pull/1888#pullrequestreview-430147184
https://github.com/conan-io/conan-center-index/issues/2566
https://github.com/conan-io/hooks/issues/217
So, can we change the values of default_options based on the recipe version without having to split them in two recipes?
init() does not work, because self.version isn't yet available if directly within the default_options dict does not work because version isn't available yetself.default_options["shared"] = True in config_options() has no effect - why exactly is this?configure() and later is too late as option values are setNo, the default value should be static, if you need a Windows special build, set it to dynamic in your profile.
Beside the fact that I have a hard time believing that the static build does not work on windows, since I am pretty sure I have build static libs of mqtt-c and mqtt-cpp on Windows, it is never good to make the edge case the default
No, the default value should be static, if you need a Windows special build, set it to dynamic in your profile.
shared = False is static 馃槃
Beside the fact that I have a hard time believing that the static build does not work on windows
Please read https://github.com/conan-io/conan-center-index/pull/1888#pullrequestreview-430147184. I think that the library author knows best 馃槂
setting self.default_options["shared"] = True in config_options() has no effect - why exactly is this?
Default options is loaded just after initializing the ConanFile instance, after that, Conan won't look again at default_options. Instead, it will consult self.options.
But you are able to change the default option, according the version:
from conans import ConanFile, tools
class MyPackage(ConanFile):
name = "package"
options = {"foo": [True, False]}
default_options = {"foo": True}
def config_options(self):
if tools.Version(self.version) >= "1.0.0":
self.options.foo = False
def configure(self):
print("FOO: %s" % self.options.foo)
As config_options is executed before processing the options, you can override its value. That will work as default_options. Whatever you pass by command line (e.g -o package:foo=True), will be processed only after config_options.
As config_options is executed before processing the options, you can override its value.
Ooops. I was thinking way too complicated. Thanks @uilianries!
No, the default value should be static, if you need a Windows special build, set it to dynamic in your profile.
shared = False is static 馃槃
Ok, as long as the right default is the default, that is always static, I am happy :-)
Beside the fact that I have a hard time believing that the static build does not work on windows
Please read #1888 (review). I think that the library author knows best 馃槂
Maybe, maybe not, looking at the cmake build scripts of libs like paho-mqtt-c and paho-mqtt-cpp ...but anyhow....
Just to mention that https://github.com/conan-io/conan-center-index/pull/2575 breaks paho-mqtt-cpp on Windows if paho-mqtt-cpp static (and paho-mqtt-cpp can't be shared on Windows...).
Why? Because:
paho-mqtt-cpp overrides shared option of paho-mqtt-c with its own value. (paho-mqtt-cpp static => paho-mqtt-c static).paho-mqtt-c also overrides its own shared option if version < "1.3.4", in order to be always shared but... in config_options (it's like a default option), which has not effect because paho-mqtt-cpp overriding in configure method takes precedence.paho-mqtt-c then raise a ConanInvalidConfiguration if shared=False and Windows and version < 1.3.4, and it raises obviously.From the paho-mqtt-cpp readme for v1.1:
The Paho C++ library requires the Paho C library, v1.3.1 or greater
https://github.com/eclipse/paho.mqtt.cpp/tree/v1.1#building-from-source
From the readme for 1.0.1:
The Paho C++ library requires the Paho C library, v1.2.1 or greater
https://github.com/eclipse/paho.mqtt.cpp/tree/v1.0.1
Assuming that it is indeed compatible, we can update the paho-mqtt-c version in paho-mqtt-cpp to 1.3.4 and it should be fine?
Makes me wondering why we have this switch in the first place