Repository: conan-io/conan-center-index

Issue:
[package] libdwarf/0.5.0: dwarf.h missing from package
### Description

dwarf.h is not present in the v0.5.0 package. The headers defines all DWARF types and is needed to use the library. 

The update to v0.5.0[ change a test](https://github.com/conan-io/conan-center-index/blob/7581062d7195d756a82c9e1adb136709c777bff6/recipes/libdwarf/all/test_package/test_package.c#L6-L11) to only check for the libdwarf,h. There's is no mention in libdwarf about dropping dwarf.h from consumer applications, it even states the [opposite](https://github.com/davea42/libdwarf-code/blob/81e5968d506aa50562aa3df64783f030d9e316cc/src/lib/libdwarf/libdwarf.h#L35-L39).

The issue comes from using cmake install. libdwarf is not installing the header file (probably a bug in the CMakeLists, because it tries to copy [all header files](https://github.com/davea42/libdwarf-code/blob/81e5968d506aa50562aa3df64783f030d9e316cc/src/lib/libdwarf/CMakeLists.txt#L126-L127)). It only installs the libdwarf.h.

We can solve the issue by copying the file from conan or applying a patch to libdwarf´s CMakeLists to fix the directory install line and actually export all the headers.

### Package and Environment Details

* Package Name/Version: **libdwarf/0.5.0**
* Operating System+version: **Windows 10**
* Compiler+version: **Visual Studio 2022**
* Conan version: **conan 1.59.0**
* Python version: **Python 3.10.2**


### Conan profile

[settings]
os=Windows
os_build=Windows
arch=x86
arch_build=x86_64
compiler=Visual Studio
compiler.version=17
build_type=RelWithDebInfo
compiler.cppstd=20
[options]
[conf]
[build_requires]
[env]


### Steps to reproduce

conan install libdwarf/0.5.0@ 

Try using the dwarf.h

### Logs

<details><summary>Click to expand log</summary>

```

```

</details>



Discussion:
Good catch. Actually in the previous version handled in conancenter, dwarf.h is installed thanks to a patch which seems to have been improperly ported in https://github.com/conan-io/conan-center-index/pull/15332.

Resolving patch:
diff --git a/recipes/libdwarf/all/conanfile.py b/recipes/libdwarf/all/conanfile.py
--- a/recipes/libdwarf/all/conanfile.py
+++ b/recipes/libdwarf/all/conanfile.py
@@ -47,7 +47,8 @@ def layout(self):
         cmake_layout(self, src_folder="src")
 
     def requirements(self):
-        self.requires("libelf/0.8.13")
+        if self.options.with_dwarfgen or self.version == "20191104":
+            self.requires("libelf/0.8.13")
         self.requires("zlib/[>=1.2.11 <2]")
 
     def source(self):
@@ -104,4 +105,4 @@ def package_info(self):
             self.env_info.PATH.append(bindir)
 
             if self.version != "20191104":
-                self.cpp_info.libs.append = ["dwarfp"]
+                self.cpp_info.libs.append("dwarfp")


Test patch:
diff --git a/recipes/libdwarf/all/test_package/test_package.c b/recipes/libdwarf/all/test_package/test_package.c
--- a/recipes/libdwarf/all/test_package/test_package.c
+++ b/recipes/libdwarf/all/test_package/test_package.c
@@ -7,6 +7,7 @@
     #include "dwarf.h"
     #include "libdwarf.h"
 #else
+    #include "libdwarf/dwarf.h"
     #include "libdwarf/libdwarf.h"
 #endif
 
@@ -20,6 +21,8 @@ void example1(Dwarf_Die somedie) {
     errv = dwarf_attrlist(somedie, &atlist, &atcount, &error);
     if (errv == DW_DLV_OK) {
         for (i = 0; i < atcount; ++i) {
+            Dwarf_Bool is_string;
+            dwarf_hasform(atlist[i], DW_FORM_string, &is_string, &error);
             dwarf_dealloc(dbg, atlist[i], DW_DLA_ATTR);
         }
         dwarf_dealloc(dbg, atlist, DW_DLA_LIST);