Repository: conan-io/conan-center-index

Issue:
[package] open62541/1.3.4: Option single_header yields to CMake errors
### Description

If option `single_header==True` the generated package info contains invalid include paths `include/open62541/plugin` and `include/open62541/win32`.
This leads to CMake errors when adding a dependency to the `open62541::open62541` target generated by `CMakeDeps` generator:

```
[build] CMake Error in CMakeLists.txt:
[build]   Imported target "open62541::open62541" includes non-existent path
[build] 
[build]     "C:/conan/61c4f3/1/include/open62541/plugin"
[build] 
[build]   in its INTERFACE_INCLUDE_DIRECTORIES.  Possible reasons include:
[build] 
[build]   * The path was deleted, renamed, or moved to another location.
[build] 
[build]   * An install or uninstall procedure did not complete successfully.
[build] 
[build]   * The installation package was faulty and references files it does not
[build]   provide.
```

### Package and Environment Details

* Package Name/Version: **open62541/1.3.4**
* Operating System+version: **Windows 10**
* Compiler+version: **GCC 8**
* Conan version: **conan 1.59.0**
* Python version: **Python 3.10.7**


### Conan profile

[settings]
os=Windows
arch=x86_64
compiler=gcc
compiler.version=8.1
compiler.libcxx=libstdc++11
build_type=Release

### Steps to reproduce

conan install open62541/1.3.4@ -osingle_header=True -g CMakeDeps
cmake -B build -S .
cmake --build build

### Logs

<details><summary>Click to expand log</summary>

```
[build] CMake Error in CMakeLists.txt:
[build]   Imported target "open62541::open62541" includes non-existent path
[build] 
[build]     "C:/conan/61c4f3/1/include/open62541/plugin"
[build] 
[build]   in its INTERFACE_INCLUDE_DIRECTORIES.  Possible reasons include:
[build] 
[build]   * The path was deleted, renamed, or moved to another location.
[build] 
[build]   * An install or uninstall procedure did not complete successfully.
[build] 
[build]   * The installation package was faulty and references files it does not
[build]   provide.
```

</details>



Discussion:

Resolving patch:
diff --git a/recipes/open62541/all/conanfile.py b/recipes/open62541/all/conanfile.py
--- a/recipes/open62541/all/conanfile.py
+++ b/recipes/open62541/all/conanfile.py
@@ -1,7 +1,7 @@
 from conan import ConanFile
 from conan.tools.cmake import cmake_layout, CMake, CMakeToolchain, CMakeDeps
 from conan.tools.scm import Version
-from conan.tools.files import apply_conandata_patches, collect_libs, export_conandata_patches, rename, rm, rmdir, get
+from conan.tools.files import apply_conandata_patches, collect_libs, export_conandata_patches, copy, rm, rmdir, get
 from conan.errors import ConanInvalidConfiguration
 import glob
 import os
@@ -12,7 +12,7 @@
 
 class Open62541Conan(ConanFile):
     name = "open62541"
-    license = "MPLv2"
+    license = ("MPL-2.0", "CC0-1.0")
     homepage = "https://open62541.org/"
     url = "https://github.com/conan-io/conan-center-index"
     description = "open62541 is an open source and free implementation of OPC UA " \
@@ -24,10 +24,11 @@ class Open62541Conan(ConanFile):
                   "All platform-specific functionality is implemented via exchangeable " \
                   "plugins. Plugin implementations are provided for the major operating systems."
     topics = (
-        "opc ua", "open62541", "sdk", "server/client", "c", "iec-62541",
+        "opc ua", "sdk", "server/client", "c", "iec-62541",
         "industrial automation", "tsn", "time sensitive networks", "publish-subscirbe", "pubsub"
     )
 
+    package_type = "library"
     settings = "os", "compiler", "build_type", "arch"
     options = {
         "fPIC": [True, False],
@@ -181,7 +182,7 @@ def requirements(self):
         if self.options.encryption == "mbedtls":
             self.requires("mbedtls/2.25.0")
         elif self.options.encryption == "openssl":
-            self.requires("openssl/1.1.1s")
+            self.requires("openssl/[>=1.1 <4]")
         if self.options.web_socket:
             self.requires("libwebsockets/4.3.2")
         if self.options.discovery == "With Multicast" or "multicast" in str(self.options.discovery):
@@ -214,9 +215,7 @@ def validate(self):
                 raise ConanInvalidConfiguration(
                     "Lower Open62541 versions than 1.1.0 are not cpp compatible due to -fpermisive flags")
 
-        # FIXME: correct clang versions condition
-        max_clang_version = "8" if Version(
-            self.version) < "1.1.0" else "9"
+        max_clang_version = "8" if Version(self.version) < "1.1.0" else "9"
         if self.settings.compiler == "clang" and Version(self.settings.compiler.version) > max_clang_version:
             raise ConanInvalidConfiguration(
                 "Open62541 supports Clang up to {} compiler version".format(max_clang_version))
@@ -244,19 +243,13 @@ def source(self):
         with open(submodule_filename, 'r') as submodule_stream:
             submodules_data = yaml.safe_load(submodule_stream)
             for path, submodule in submodules_data["submodules"][self.version].items():
-                filename = os.path.basename(submodule["url"])
-                archive_name = submodule["archive_pattern"].format(
-                    version=os.path.splitext(filename.replace('v', ''))[0])
-
-                submodule_data = {
-                    "url": submodule["url"],
-                    "sha256": submodule["sha256"]
-                }
-
-                get(self, **submodule_data)
-                submodule_source = os.path.join(self.source_folder, path)
-                rmdir(self, submodule_source)
-                rename(self, archive_name, submodule_source)
+                archive_name = os.path.splitext(
+                    os.path.basename(submodule["url"]))[0]
+                get(self, url=submodule["url"],
+                    sha256=submodule["sha256"],
+                    destination=path,
+                    filename=archive_name,
+                    strip_root=True)
 
     def _get_log_level(self):
         return {
@@ -356,11 +349,11 @@ def generate(self):
         tc.variables["UA_ENABLE_STATUSCODE_DESCRIPTIONS"] = self.options.readable_statuscodes
         tc.variables["UA_ENABLE_HARDENING"] = self.options.hardening
 
-        if self.settings.compiler == "Visual Studio" and self.options.shared == True:
+        if self.settings.compiler == "msvc" and self.options.shared == True:
             tc.variables["UA_MSVC_FORCE_STATIC_CRT"] = True
 
         tc.variables["UA_COMPILE_AS_CXX"] = self.options.cpp_compatible
-
+        
         # Honor BUILD_SHARED_LIBS from conan_toolchain (see https://github.com/conan-io/conan/issues/11840)
         tc.cache_variables["CMAKE_POLICY_DEFAULT_CMP0077"] = "NEW"
 
@@ -371,8 +364,7 @@ def generate(self):
     def _patch_sources(self):
         apply_conandata_patches(self)
         if Version(self.version) >= "1.3.1":
-            os.unlink(os.path.join(self.source_folder,
-                      "tools", "cmake", "FindPython3.cmake"))
+            os.unlink(os.path.join(self.source_folder, "tools", "cmake", "FindPython3.cmake"))
 
     def build(self):
         self._patch_sources()
@@ -393,8 +385,9 @@ def _module_file_rel_path(self):
         return os.path.join(self._module_subfolder, "open62541Macros.cmake")
 
     def package(self):
-        self.copy("LICENSE", dst="licenses", src=self.source_folder)
-        self.copy("LICENSE-CC0", dst="licenses", src=self.source_folder)
+        licenses_dir = os.path.join(self.package_folder, "licenses")
+        copy(self, "LICENSE", src=self.source_folder, dst=licenses_dir)
+        copy(self, "LICENSE-CC0", src=self.source_folder, dst=licenses_dir)
         cmake = CMake(self)
         cmake.install()
 
@@ -408,10 +401,9 @@ def package(self):
         rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig"))
         rmdir(self, os.path.join(self.package_folder, "share"))
 
-        self.copy("generate_*.py", src=self._tools_subfolder,
-                  dst=os.path.join("res", "tools"))
-        self.copy("nodeset_compiler/*", src=self._tools_subfolder,
-                  dst=os.path.join("res", "tools"))
+        tools_dir = os.path.join(self.package_folder, "res", "tools")
+        copy(self, "generate_*.py", src=self._tools_subfolder, dst=tools_dir)
+        copy(self, "nodeset_compiler/*", src=self._tools_subfolder, dst=tools_dir)
 
     @staticmethod
     def _chmod_plus_x(filename):
@@ -423,10 +415,7 @@ def package_info(self):
         self.cpp_info.names["cmake_find_package_multi"] = "open62541"
         self.cpp_info.names["pkg_config"] = "open62541"
         self.cpp_info.libs = collect_libs(self)
-        self.cpp_info.includedirs = [
-            "include",
-            os.path.join("include", "open62541", "plugin")
-        ]
+        self.cpp_info.includedirs = ["include"]
 
         # required for creating custom servers from ua-nodeset
         self.conf_info.define("user.open62541:tools_dir", os.path.join(
@@ -439,14 +428,19 @@ def package_info(self):
 
         if self.options.single_header:
             self.cpp_info.defines.append("UA_ENABLE_AMALGAMATION")
-        if self.settings.os == "Windows":
-            self.cpp_info.system_libs.append("ws2_32")
-            self.cpp_info.includedirs.append(
-                os.path.join("include", "open62541", "win32"))
         else:
             self.cpp_info.includedirs.append(
-                os.path.join("include", "open62541", "posix"))
-        if self.settings.os in ("Linux", "FreeBSD"):
+                os.path.join("include", "open62541", "plugin"))
+            if self.settings.os == "Windows":
+                self.cpp_info.includedirs.append(
+                    os.path.join("include", "open62541", "win32"))
+            else:
+                self.cpp_info.includedirs.append(
+                    os.path.join("include", "open62541", "posix"))
+
+        if self.settings.os == "Windows":
+            self.cpp_info.system_libs.append("ws2_32")
+        elif self.settings.os in ("Linux", "FreeBSD"):
             self.cpp_info.system_libs.extend(["pthread", "m", "rt"])
 
         self.cpp_info.builddirs.append(self._module_subfolder)


Test patch:
diff --git a/recipes/open62541/all/test_package/conanfile.py b/recipes/open62541/all/test_package/conanfile.py
--- a/recipes/open62541/all/test_package/conanfile.py
+++ b/recipes/open62541/all/test_package/conanfile.py
@@ -7,7 +7,7 @@
 # It will become the standard on Conan 2.x
 class TestPackageConan(ConanFile):
     settings = "os", "arch", "compiler", "build_type"
-    generators = "CMakeDeps", "CMakeToolchain", "VirtualRunEnv"
+    generators = "CMakeDeps", "VirtualRunEnv"
     test_type = "explicit"
 
     def requirements(self):
@@ -19,8 +19,8 @@ def layout(self):
 
     def generate(self):
         tc = CMakeToolchain(self)
-        tc.variables["open62541_NODESET_DIR"] = self.deps_user_info["ua-nodeset"].nodeset_dir.replace(
-            "\\", "/")  # ua-nodeset path needs to be sanitized for windows systems
+        tc.variables["open62541_NODESET_DIR"] = self.dependencies["ua-nodeset"].conf_info.get(
+            "user.ua-nodeset:nodeset_dir").replace("\\", "/")  # sanitize path for windows systems
         tc.variables["open62541_TOOLS_DIR"] = self.dependencies["open62541"].conf_info.get(
             "user.open62541:tools_dir")
         tc.generate()