Repository: conan-io/conan-center-index

Issue:
[package] poco/1.11.1: Incorrect option for Active Record and missing option for Active Record Compiler
**Incorrect option name: enable_active_record**

"enable_active_record" should be renamed to "enable_activerecord" to match the option name in the CMakeLists.txt.

The CMakeLists.txt contains the following option:
option(ENABLE_ACTIVERECORD "Enable ActiveRecord" ON)

**Missing option name: enable_activerecord_compiler**

Add the option "enable_activerecord_compiler" to allow the Active Record Compiler feature to be enabled/disabled.

The CMakeLists.txt contains the following option:
option(ENABLE_ACTIVERECORD_COMPILER "Enable ActiveRecord Compiler" ON)

It is not possible to enable or disable the Active Record Compiler from conan.

I believe the correct option should be:
"ActiveRecordCompiler": _PocoComponent("enable_activerecord_compiler", True, ["Util", "XML"], [], False),

The config_options() method should be updated to include:
```
        if tools.Version(self.version) < "1.11":
            del self.options.enable_activerecord
            del self.options.enable_activerecord_compiler
```
in stead of
```
        if tools.Version(self.version) < "1.11":
            del self.options.enable_active_record
```



Discussion:
> "enable_active_record" should be renamed to "enable_activerecord" to match the option name in the CMakeLists.txt.

Is it worth changing the name (breaking change in interface of the recipe) for an extra underscore?

> I believe the correct option should be:
> "ActiveRecordCompiler": _PocoComponent("enable_activerecord_compiler", True, ["Util", "XML"], [], False),

Well actually it should not be added like this in the recipe because it's a tool, not a library (or we should add an extra information) and there are various logic in this recipe based on this dictionnary. Moreover, it depends on Foundation, not XML: https://github.com/pocoproject/poco/blob/de61f0049175a941cc83c2615c3bdc5e947b89f9/ActiveRecord/Compiler/CMakeLists.txt#L17
Concerning enable_active_record: The way it is today, it simply does not work.

Setting poco:enable_active_record=False does nothing. The conan option is mapped directly to the CMake option thorugh "comp.option.upper()". 

I have no preference as to where the change should be made (conan or poco CMakeLists.txt), but it currently does not work. Since the current interface is wrong, I do not see a problem with changing it.

Concerning enable_activerecord_compiler: 

I thought that the last flag of the _PocoComponent tuple indicated whether the component was a library or not ("is_lib"). If that is not the case, then I guess that my line is incorrect.

As for the dependencies. Those are set by trial and error. Foundation is not an optional component - it is always built. Util depends on Foundation, so I figured that by specifying Util, I would get Foundation indirectly. Also, it does depend on XML. It may not be evident from the CMakeLists.txt file, but you cannot compile the Active Record Compiler tool unless you also enable XML.

This file references the XML component: https://github.com/pocoproject/poco/blob/poco-1.11.1/ActiveRecord/Compiler/src/Parser.cpp

The Active Record Compiler currently gets its dependency on XML from the Util component. But where the Util component can handle a disabled XML component, Active Record Compiler cannot.

If the last flag is indeed indicating whether the output is a library or not, I would argue that the component could be changed to this:
"ActiveRecordCompiler": _PocoComponent("enable_activerecord_compiler", True, ["Foundation", "Util", "XML"], [], False),

My goal is to be able to disable the Active Record component and the Active Record Compiler using the official recipe, and currently I cannot.

Regards

Lau
I see, so yes the typo in option name has side effect for this specific recipe due to how conan options and CMake options are mapped here. It comes from https://github.com/conan-io/conan-center-index/pull/6110.
My understanding of is_lib property in this dictionnary is to tell whether it's header only or not (mainly for `package_info()`), but it assumes that all components are "libraries". Maybe there should be an enumerate: lib, header_only, executable.
Ok, thank you.

I misunderstood the is_lib flag. 

I see why adding enable_activerecord_compiler is a bigger issue than I expected. 

Regards 
Lau 

Yes but it shouldn't be too hard to add it.
This should be an REAL issue. ActiveRecord module can't be disabled

Resolving patch:
diff --git a/recipes/poco/all/conanfile.py b/recipes/poco/all/conanfile.py
--- a/recipes/poco/all/conanfile.py
+++ b/recipes/poco/all/conanfile.py
@@ -25,11 +25,13 @@ class PocoConan(ConanFile):
         "shared": [True, False],
         "fPIC": [True, False],
         "enable_fork": [True, False],
+        "enable_active_record": [True, False, "deprecated"],
     }
     default_options = {
         "shared": False,
         "fPIC": True,
         "enable_fork": True,
+        "enable_active_record": "deprecated",
     }
 
     _PocoComponent = namedtuple("_PocoComponent", ("option", "default_option", "dependencies", "external_dependencies", "is_lib"))
@@ -61,7 +63,8 @@ class PocoConan(ConanFile):
         "Util": _PocoComponent("enable_util", True, ["Foundation", "XML", "JSON"], [], True),
         "XML": _PocoComponent("enable_xml", True, ["Foundation"], ["expat::expat"], True),
         "Zip": _PocoComponent("enable_zip", True, ["Util", "XML"], [], True),
-        "ActiveRecord": _PocoComponent("enable_active_record", True, ["Foundation", "Data"], [], True),
+        "ActiveRecord": _PocoComponent("enable_activerecord", True, ["Foundation", "Data"], [], True),
+        "ActiveRecordCompiler": _PocoComponent("enable_activerecord_compiler", False, ["Util", "XML"], [], False),
     }
 
     for comp in _poco_component_tree.values():
@@ -102,9 +105,12 @@ def config_options(self):
             del self.options.enable_data_postgresql
             del self.options.enable_jwt
         if tools.Version(self.version) < "1.11":
-            del self.options.enable_active_record
+            del self.options.enable_activerecord
+            del self.options.enable_activerecord_compiler
 
     def configure(self):
+        if self.options.enable_active_record != "deprecated":
+            self.output.warn("enable_active_record option is deprecated, use 'enable_activerecord' instead")
         if self.options.shared:
             del self.options.fPIC
         if not self.options.enable_xml:
@@ -120,19 +126,19 @@ def requirements(self):
         if self.options.enable_xml:
             self.requires("expat/2.4.8")
         if self.options.enable_data_sqlite:
-            self.requires("sqlite3/3.38.1")
+            self.requires("sqlite3/3.38.5")
         if self.options.enable_apacheconnector:
             self.requires("apr/1.7.0")
             self.requires("apr-util/1.6.1")
         if self.options.enable_netssl or self.options.enable_crypto or \
            self.options.get_safe("enable_jwt"):
-            self.requires("openssl/1.1.1n")
+            self.requires("openssl/1.1.1o")
         if self.options.enable_data_odbc and self.settings.os != "Windows":
             self.requires("odbc/2.3.9")
         if self.options.get_safe("enable_data_postgresql"):
             self.requires("libpq/14.2")
         if self.options.get_safe("enable_data_mysql"):
-            self.requires("libmysqlclient/8.0.25")
+            self.requires("libmysqlclient/8.0.29")
 
     def validate(self):
         if self.options.enable_apacheconnector:
@@ -206,6 +212,9 @@ def build(self):
         cmake = self._configure_cmake()
         cmake.build()
 
+    def package_id(self):
+        del self.info.options.enable_active_record
+
     def package(self):
         self.copy("LICENSE", dst="licenses", src=self._source_subfolder)
         cmake = self._configure_cmake()


Test patch: