Repository: conan-io/conan-center-index

Issue:
[doxygen] Model iconv dependency as a conan package
Specify library name and version:  **doxygen/1.9.2**

This resolves an issue where `iconv` wasn't being appropriately modelled as a conan dependency in the doxygen recipe. This lead to unresolved symbol errors on Macos builds with conan 2. This was previously part of https://github.com/conan-io/conan-center-index/pull/18415, but is being split to a separate PR to separate concerns and make review easier.

Closes #19903 

---

- [x] I've read the [contributing guidelines](https://github.com/conan-io/conan-center-index/blob/master/CONTRIBUTING.md).
- [x] I've used a [recent](https://github.com/conan-io/conan/releases/latest) Conan client version close to the [currently deployed](https://github.com/conan-io/conan-center-index/blob/master/.c3i/config_v1.yml#L6).
- [x] I've tried at least one configuration locally with the [conan-center hook](https://github.com/conan-io/hooks.git) activated.



Discussion:
### Conan v1 pipeline :x:

Failure in build 1 (`f869285b4112d98c0dc776704834e71fd5569676`):

 * **doxygen/1.9.4:**
   Didn't run or was cancelled before finishing

 * **doxygen/1.8.17:**
   Didn't run or was cancelled before finishing

 * **doxygen/1.8.20:**
   Didn't run or was cancelled before finishing

 * **doxygen/1.9.2:**
   CI failed to create some packages ([All logs](https://c3i.jfrog.io/c3i/misc/summary.html?json=https://c3i.jfrog.io/c3i/misc/logs/pr/19904/1-linux-clang/doxygen/1.9.2//summary.json))
   
   <details><summary>Logs for packageID <code>47ca2eab07c2b3e7e587f0a51621bda013cca2d1</code>:</summary>
   
   ```
   [settings]
   arch=x86_64
   build_type=Debug
   compiler=clang
   compiler.libcxx=libstdc++
   compiler.version=12
   os=Linux
   ```
   
   ```
   [...]
   > cd '/home/conan/w/prod-v1/bsr/cci-bc68f6d1/recipes/doxygen/all/test_v1_package/build/ad9c5bd7c0898fcdd41ffb5c8175d48308e737b4' && cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE="Debug" -DCONAN_IN_LOCAL_CACHE="OFF" -DCONAN_COMPILER="clang" -DCONAN_COMPILER_VERSION="12" -DCONAN_CXX_FLAGS="-m64" -DCONAN_SHARED_LINKER_FLAGS="-m64" -DCONAN_C_FLAGS="-m64" -DCONAN_LIBCXX="libstdc++" -DCMAKE_INSTALL_PREFIX="/home/conan/w/prod-v1/bsr/cci-bc68f6d1/recipes/doxygen/all/test_v1_package/build/ad9c5bd7c0898fcdd41ffb5c8175d48308e737b4/package" -DCMAKE_INSTALL_BINDIR="bin" -DCMAKE_INSTALL_SBINDIR="bin" -DCMAKE_INSTALL_LIBEXECDIR="bin" -DCMAKE_INSTALL_LIBDIR="lib" -DCMAKE_INSTALL_INCLUDEDIR="include" -DCMAKE_INSTALL_OLDINCLUDEDIR="include" -DCMAKE_INSTALL_DATAROOTDIR="share" -DCMAKE_EXPORT_NO_PACKAGE_REGISTRY="ON" -DCONAN_EXPORTED="1" -Wno-dev '/home/conan/w/prod-v1/bsr/cci-bc68f6d1/recipes/doxygen/all/test_v1_package'
   -----------------
   -- The C compiler identification is Clang 12.0.0
   -- The CXX compiler identification is Clang 12.0.0
   -- Check for working C compiler: /usr/local/bin/clang
   -- Check for working C compiler: /usr/local/bin/clang -- works
   -- Detecting C compiler ABI info
   -- Detecting C compiler ABI info - done
   -- Detecting C compile features
   -- Detecting C compile features - done
   -- Check for working CXX compiler: /usr/local/bin/clang++
   -- Check for working CXX compiler: /usr/local/bin/clang++ -- works
   -- Detecting CXX compiler ABI info
   -- Detecting CXX compiler ABI info - done
   -- Detecting CXX compile features
   -- Detecting CXX compile features - done
   -- Conan: called by CMake conan helper
   -- Conan: Adjusting output directories
   -- Conan: Using cmake targets configuration
   -- Library xapian found /home/conan/w/prod-v1/bsr/10744/dcace/.conan/data/xapian-core/1.4.19/_/_/package/82a3566c3c5d5b70ad1a48fd367f1cba0a987996/lib/libxapian.a
   -- Library iconv found /home/conan/w/prod-v1/bsr/10744/dcace/.conan/data/libiconv/1.17/_/_/package/9387155579217a8eec37b28e121e419c4350656c/lib/libiconv.a
   -- Library charset found /home/conan/w/prod-v1/bsr/10744/dcace/.conan/data/libiconv/1.17/_/_/package/9387155579217a8eec37b28e121e419c4350656c/lib/libcharset.a
   -- Library z found /home/conan/w/prod-v1/bsr/10744/dcace/.conan/data/zlib/1.2.13/_/_/package/9387155579217a8eec37b28e121e419c4350656c/lib/libz.a
   -- Library uuid found /home/conan/w/prod-v1/bsr/10744/dcace/.conan/data/util-linux-libuuid/2.39/_/_/package/9387155579217a8eec37b28e121e419c4350656c/lib/libuuid.a
   -- Conan: Adjusting default RPATHs Conan policies
   -- Conan: Adjusting language standard
   -- Conan: Compiler Clang>=8, checking major version 12
   -- Conan: Checking correct version: 12
   -- Conan: C++ stdlib: libstdc++
   -- Found Doxygen: /home/conan/w/prod-v1/bsr/10744/dcace/.conan/data/doxygen/1.9.2/_/_/package/47ca2eab07c2b3e7e587f0a51621bda013cca2d1/bin/doxygen (found version "") found components:  doxygen missing components:  dot
   -- Configuring incomplete, errors occurred!
   See also "/home/conan/w/prod-v1/bsr/cci-bc68f6d1/recipes/doxygen/all/test_v1_package/build/ad9c5bd7c0898fcdd41ffb5c8175d48308e737b4/CMakeFiles/CMakeOutput.log".
   /home/conan/w/prod-v1/bsr/10744/dcace/.conan/data/doxygen/1.9.2/_/_/package/47ca2eab07c2b3e7e587f0a51621bda013cca2d1/bin/doxygen: /lib/x86_64-linux-gnu/libm.so.6: version `GLIBC_2.29' not found (required by /home/conan/w/prod-v1/bsr/10744/dcace/.conan/data/doxygen/1.9.2/_/_/package/47ca2eab07c2b3e7e587f0a51621bda013cca2d1/bin/doxygen)
   CMake Warning at /usr/share/cmake-3.15/Modules/FindDoxygen.cmake:434 (message):
     Unable to determine doxygen version: 1
   Call Stack (most recent call first):
     /usr/share/cmake-3.15/Modules/FindDoxygen.cmake:597 (_Doxygen_find_doxygen)
     /home/conan/w/prod-v1/bsr/cci-bc68f6d1/recipes/doxygen/all/test_package/CMakeLists.txt:4 (find_package)
   
   
   /home/conan/w/prod-v1/bsr/10744/dcace/.conan/data/doxygen/1.9.2/_/_/package/47ca2eab07c2b3e7e587f0a51621bda013cca2d1/bin/doxygen: /lib/x86_64-linux-gnu/libm.so.6: version `GLIBC_2.29' not found (required by /home/conan/w/prod-v1/bsr/10744/dcace/.conan/data/doxygen/1.9.2/_/_/package/47ca2eab07c2b3e7e587f0a51621bda013cca2d1/bin/doxygen)
   CMake Error at /usr/share/cmake-3.15/Modules/FindDoxygen.cmake:676 (message):
     Unable to generate Doxyfile template: 1
   Call Stack (most recent call first):
     /home/conan/w/prod-v1/bsr/cci-bc68f6d1/recipes/doxygen/all/test_package/CMakeLists.txt:4 (find_package)
   
   
   ERROR: doxygen/1.9.2 (test package): Error in build() method, line 13
   	cmake.configure()
   	ConanException: Error 1 while executing cd '/home/conan/w/prod-v1/bsr/cci-bc68f6d1/recipes/doxygen/all/test_v1_package/build/ad9c5bd7c0898fcdd41ffb5c8175d48308e737b4' && cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE="Debug" -DCONAN_IN_LOCAL_CACHE="OFF" -DCONAN_COMPILER="clang" -DCONAN_COMPILER_VERSION="12" -DCONAN_CXX_FLAGS="-m64" -DCONAN_SHARED_LINKER_FLAGS="-m64" -DCONAN_C_FLAGS="-m64" -DCONAN_LIBCXX="libstdc++" -DCMAKE_INSTALL_PREFIX="/home/conan/w/prod-v1/bsr/cci-bc68f6d1/recipes/doxygen/all/test_v1_package/build/ad9c5bd7c0898fcdd41ffb5c8175d48308e737b4/package" -DCMAKE_INSTALL_BINDIR="bin" -DCMAKE_INSTALL_SBINDIR="bin" -DCMAKE_INSTALL_LIBEXECDIR="bin" -DCMAKE_INSTALL_LIBDIR="lib" -DCMAKE_INSTALL_INCLUDEDIR="include" -DCMAKE_INSTALL_OLDINCLUDEDIR="include" -DCMAKE_INSTALL_DATAROOTDIR="share" -DCMAKE_EXPORT_NO_PACKAGE_REGISTRY="ON" -DCONAN_EXPORTED="1" -Wno-dev '/home/conan/w/prod-v1/bsr/cci-bc68f6d1/recipes/doxygen/all/test_v1_package'
   ```
   
   </details>

 * **doxygen/1.9.1:**
   Didn't run or was cancelled before finishing

 * **doxygen/1.8.18:**
   Didn't run or was cancelled before finishing

---

<sup>**Note:** To save resources, CI tries to finish as soon as an error is found. For this reason you might find that not all the references have been launched or not all the configurations for a given reference. Also, take into account that we cannot guarantee the order of execution as it depends on CI workload and workers availability.</sup>
@jcar87 @uilianries @RubenRBS do any of you know why I'm getting GLIBC version errors here? Have the underlying docker images changed and it's still matching against a binary built on a different image?

Also, why would it be matching pre-existing binaries? Shouldn't this change have modified the recipe revision and triggered a build?

Resolving patch:
diff --git a/recipes/doxygen/all/conanfile.py b/recipes/doxygen/all/conanfile.py
--- a/recipes/doxygen/all/conanfile.py
+++ b/recipes/doxygen/all/conanfile.py
@@ -21,10 +21,12 @@ class DoxygenConan(ConanFile):
     options = {
         "enable_parse": [True, False],
         "enable_search": [True, False],
+        "enable_app": [True, False],
     }
     default_options = {
         "enable_parse": True,
         "enable_search": True,
+        "enable_app": False,
     }
 
     @property
@@ -52,10 +54,10 @@ def layout(self):
     def requirements(self):
         if self.options.enable_search:
             self.requires("xapian-core/1.4.19")
-            self.requires("zlib/1.2.13")
-
-    def package_id(self):
-        del self.info.settings.compiler
+            self.requires("zlib/[>=1.2.11 <2]")
+        if self.options.enable_app or self.options.enable_parse:
+            # INFO: Doxygen uses upper case CMake variables to link/include IConv, so we are using patches for targets.
+            self.requires("libiconv/1.17")
 
     def compatibility(self):
         return [{"settings": [("build_type", "Release")]}]
@@ -81,6 +83,7 @@ def generate(self):
         tc = CMakeToolchain(self)
         tc.variables["build_parse"] = self.options.enable_parse
         tc.variables["build_search"] = self.options.enable_search
+        tc.variables["build_app"] = self.options.enable_app
         tc.variables["use_libc++"] = self.settings.compiler.get_safe("libcxx") == "libc++"
         tc.variables["win_static"] = is_msvc_static_runtime(self)
         tc.generate()
@@ -103,6 +106,8 @@ def package_info(self):
         self.cpp_info.set_property("cmake_find_mode", "none")
         self.cpp_info.libdirs = []
         self.cpp_info.includedirs = []
+        if self.settings.os in ["Linux", "FreeBSD"]:
+            self.cpp_info.system_libs = ["pthread", "m"]
 
         # TODO: to remove in conan v2
         self.env_info.PATH.append(os.path.join(self.package_folder, "bin"))


Test patch:
diff --git a/recipes/doxygen/all/test_package/CMakeLists.txt b/recipes/doxygen/all/test_package/CMakeLists.txt
deleted file mode 100644
--- a/recipes/doxygen/all/test_package/CMakeLists.txt
+++ /dev/null
@@ -1,8 +0,0 @@
-cmake_minimum_required(VERSION 3.9)
-project(test_package LANGUAGES CXX)
-
-find_package(Doxygen REQUIRED)
-
-add_executable(${PROJECT_NAME} test_package.cpp)
-
-doxygen_add_docs(docs test_package.cpp ALL COMMENT "generate HTML")
diff --git a/recipes/doxygen/all/test_package/conanfile.py b/recipes/doxygen/all/test_package/conanfile.py
--- a/recipes/doxygen/all/test_package/conanfile.py
+++ b/recipes/doxygen/all/test_package/conanfile.py
@@ -1,28 +1,16 @@
 from conan import ConanFile
-from conan.tools.cmake import cmake_layout, CMake
-from conan.errors import ConanException
-import os
+from conan.tools.build import can_run
 
 
 class TestPackageConan(ConanFile):
     settings = "os", "arch", "compiler", "build_type"
-    generators = "CMakeDeps", "CMakeToolchain", "VirtualBuildEnv"
+    generators = "VirtualBuildEnv"
     test_type = "explicit"
 
-    def layout(self):
-        cmake_layout(self)
-
     def build_requirements(self):
         self.tool_requires(self.tested_reference_str)
 
-    def build(self):
-        cmake = CMake(self)
-        cmake.configure()
-        cmake.build()
-
     def test(self):
-        if not os.path.isdir(os.path.join(self.build_folder, "html")):
-            raise ConanException("doxygen did not create html documentation directory")
-
-        self.output.info("Version:")
-        self.run("doxygen --version")
+        if can_run(self):
+            self.output.info("Doxygen Version:")
+            self.run("doxygen --version")
diff --git a/recipes/doxygen/all/test_package/test_package.cpp b/recipes/doxygen/all/test_package/test_package.cpp
deleted file mode 100644
--- a/recipes/doxygen/all/test_package/test_package.cpp
+++ /dev/null
@@ -1,8 +0,0 @@
-#include <iostream>
-
-/// \brief just a simple main function for the hello world
-int main()
-{
-    std::cout << "bincrafters" << std::endl;
-    return 0;
-}
diff --git a/recipes/doxygen/all/test_v1_package/CMakeLists.txt b/recipes/doxygen/all/test_v1_package/CMakeLists.txt
deleted file mode 100644
--- a/recipes/doxygen/all/test_v1_package/CMakeLists.txt
+++ /dev/null
@@ -1,8 +0,0 @@
-cmake_minimum_required(VERSION 3.1)
-project(test_package)
-
-include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
-conan_basic_setup(TARGETS)
-
-add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../test_package
-                 ${CMAKE_CURRENT_BINARY_DIR}/test_package)
diff --git a/recipes/doxygen/all/test_v1_package/conanfile.py b/recipes/doxygen/all/test_v1_package/conanfile.py
deleted file mode 100644
--- a/recipes/doxygen/all/test_v1_package/conanfile.py
+++ /dev/null
@@ -1,22 +0,0 @@
-from conans import ConanFile, CMake, tools
-from conans.errors import ConanException
-import os
-
-
-class TestPackageConan(ConanFile):
-    settings = "os", "arch", "compiler", "build_type"
-    generators = "cmake"
-
-    def build(self):
-        if not tools.cross_building(self, skip_x64_x86=True):
-            cmake = CMake(self)
-            cmake.configure()
-            cmake.build()
-
-    def test(self):
-        if not tools.cross_building(self, skip_x64_x86=True):
-            if not os.path.isdir(os.path.join(self.build_folder, "test_package", "html")):
-                raise ConanException("doxygen did not create html documentation directory")
-
-            self.output.info("Version:")
-            self.run("doxygen --version", run_environment=True)