Repository: conan-io/conan-center-index

Issue:
[package] freeglut/*: mesa-glu and glu/system conflict
### Description

After the changes in https://github.com/conan-io/conan-center-index/pull/22428 there's a possible conflict between `freeglut` and other GL libraries depending on `glu/system` (`glew/2.2.0` and `pcl/1.13.1` with opengl for instance). When trying to use both packages in the same tree, Conan complains showing this error:
```bash
ERROR: At least two recipes provide the same functionality:
 - 'glu' provided by 'mesa-glu/9.0.3', 'glu/system'
```

PCL explicitly uses `freeglut` and `glu/system` together:
https://github.com/conan-io/conan-center-index/blob/master/recipes/pcl/all/conanfile.py#L378-L383

### Package and Environment Details

* Package Name/Version: 
   - **freeglut/3.4.0**
   - **pcl/1.13.1**
   - **glew/2.2.0**
* Operating System+version: **Linux Ubuntu 22.04**
* Conan version: **conan 1.61.0**
* Python version: **Python 3.10.12**


### Conan profile

```
[settings]
os=Linux
os_build=Linux
arch=x86_64
arch_build=x86_64
compiler=gcc
compiler.version=11
compiler.libcxx=libstdc++11
build_type=Release
[options]
[build_requires]
cmake/3.27.1
doxygen/1.9.4
[env]
```

### Steps to reproduce

`conan install -r conancenter pcl/1.13.1@ -o pcl:visualization=True`

### Logs

<details><summary>Click to expand log</summary>

```
$ conan install -r conancenter pcl/1.13.1@ -o pcl:visualization=True
Conan 1 is on a deprecation path, please consider migrating to Conan 2
Configuration:
[settings]
arch=x86_64
arch_build=x86_64
build_type=Release
compiler=gcc
compiler.libcxx=libstdc++
compiler.version=11
os=Linux
os_build=Linux
[options]
pcl:visualization=True
[build_requires]
[env]

pcl/1.13.1: Retrieving from server 'conancenter' 
pcl/1.13.1: Trying with 'conancenter'...
Downloading conanmanifest.txt completed [0.49k]                                          
Downloading conanfile.py completed [25.36k]                                              
Downloading conan_export.tgz completed [0.63k]                                           
Decompressing conan_export.tgz completed [0.00k]                                         
pcl/1.13.1: Downloaded recipe revision 0
boost/1.83.0: Retrieving from server 'conancenter' 
boost/1.83.0: Trying with 'conancenter'...
Downloading conanmanifest.txt completed [0.35k]                                          
Downloading conanfile.py completed [88.45k]                                              
Downloading conan_export.tgz completed [1.55k]                                           
Decompressing conan_export.tgz completed [0.00k]                                         
boost/1.83.0: Downloaded recipe revision 0
WARN: boost/1.83.0: requirement zlib/[>=1.2.11 <2] overridden by pcl/1.13.1 to zlib/1.3.1 
zlib/1.3.1: Retrieving from server 'conancenter' 
zlib/1.3.1: Trying with 'conancenter'...
Downloading conanmanifest.txt completed [0.18k]                                          
Downloading conanfile.py completed [4.09k]                                               
Downloading conan_export.tgz completed [0.43k]                                           
Decompressing conan_export.tgz completed [0.00k]                                         
zlib/1.3.1: Downloaded recipe revision 0
bzip2/1.0.8: Retrieving from server 'conancenter' 
bzip2/1.0.8: Trying with 'conancenter'...
Downloading conanmanifest.txt completed [0.17k]                                          
Downloading conanfile.py completed [4.00k]                                               
Downloading conan_export.tgz completed [0.31k]                                           
Decompressing conan_export.tgz completed [0.00k]                                         
bzip2/1.0.8: Downloaded recipe revision 0
libbacktrace/cci.20210118: Retrieving from server 'conancenter' 
libbacktrace/cci.20210118: Trying with 'conancenter'...
Downloading conanmanifest.txt completed [0.28k]                                          
Downloading conanfile.py completed [3.84k]                                               
Downloading conan_export.tgz completed [0.41k]                                           
Decompressing conan_export.tgz completed [0.00k]                                         
libbacktrace/cci.20210118: Downloaded recipe revision 0
eigen/3.4.0: Retrieving from server 'conancenter' 
eigen/3.4.0: Trying with 'conancenter'...
Downloading conanmanifest.txt completed [0.19k]                                          
Downloading conanfile.py completed [3.25k]                                               
Downloading conan_export.tgz completed [0.46k]                                           
Decompressing conan_export.tgz completed [0.00k]                                         
eigen/3.4.0: Downloaded recipe revision 0
flann/1.9.2: Retrieving from server 'conancenter' 
flann/1.9.2: Trying with 'conancenter'...
Downloading conanmanifest.txt completed [0.27k]                                          
Downloading conanfile.py completed [6.29k]                                               
Downloading conan_export.tgz completed [0.30k]                                           
Decompressing conan_export.tgz completed [0.00k]                                         
flann/1.9.2: Downloaded recipe revision 0
lz4/1.9.4: Retrieving from server 'conancenter' 
lz4/1.9.4: Trying with 'conancenter'...
Downloading conanmanifest.txt completed [0.22k]                                          
Downloading conanfile.py completed [4.65k]                                               
Downloading conan_export.tgz completed [0.45k]                                           
Decompressing conan_export.tgz completed [0.00k]                                         
lz4/1.9.4: Downloaded recipe revision 0
libpng/1.6.40: Retrieving from server 'conancenter' 
libpng/1.6.40: Trying with 'conancenter'...
Downloading conanmanifest.txt completed [0.19k]                                          
Downloading conanfile.py completed [6.58k]                                               
Downloading conan_export.tgz completed [0.32k]                                           
Decompressing conan_export.tgz completed [0.00k]                                         
libpng/1.6.40: Downloaded recipe revision 0
WARN: libpng/1.6.40: requirement zlib/[>=1.2.11 <2] overridden by pcl/1.13.1 to zlib/1.3.1 
qhull/8.0.1: Retrieving from server 'conancenter' 
qhull/8.0.1: Trying with 'conancenter'...
Downloading conanmanifest.txt completed [0.29k]                                          
Downloading conanfile.py completed [4.80k]                                               
Downloading conan_export.tgz completed [0.36k]                                           
Decompressing conan_export.tgz completed [0.00k]                                         
qhull/8.0.1: Downloaded recipe revision 0
libusb/1.0.26: Retrieving from server 'conancenter' 
libusb/1.0.26: Trying with 'conancenter'...
Downloading conanmanifest.txt completed [0.21k]                                          
Downloading conanfile.py completed [6.37k]                                               
Downloading conan_export.tgz completed [0.41k]                                           
Decompressing conan_export.tgz completed [0.00k]                                         
libusb/1.0.26: Downloaded recipe revision 0
libudev/system: Retrieving from server 'conancenter' 
libudev/system: Trying with 'conancenter'...
Downloading conanmanifest.txt completed [0.06k]                                          
Downloading conanfile.py completed [1.68k]                                               
libudev/system: Downloaded recipe revision 0
libpcap/1.10.4: Retrieving from server 'conancenter' 
libpcap/1.10.4: Trying with 'conancenter'...
Downloading conanmanifest.txt completed [0.10k]                                          
Downloading conanfile.py completed [6.71k]                                               
Downloading conan_export.tgz completed [0.32k]                                           
Decompressing conan_export.tgz completed [0.00k]                                         
libpcap/1.10.4: Downloaded recipe revision 0
opengl/system: Retrieving from server 'conancenter' 
opengl/system: Trying with 'conancenter'...
Downloading conanmanifest.txt completed [0.06k]                                          
Downloading conanfile.py completed [2.24k]                                               
opengl/system: Downloaded recipe revision 0
freeglut/3.4.0: Retrieving from server 'conancenter' 
freeglut/3.4.0: Trying with 'conancenter'...
Downloading conanmanifest.txt completed [0.47k]                                          
Downloading conanfile.py completed [10.43k]                                              
Downloading conan_export.tgz completed [0.57k]                                           
Decompressing conan_export.tgz completed [0.00k]                                         
freeglut/3.4.0: Downloaded recipe revision 0
mesa-glu/9.0.3: Retrieving from server 'conancenter' 
mesa-glu/9.0.3: Trying with 'conancenter'...
Downloading conanmanifest.txt completed [0.10k]                                          
Downloading conanfile.py completed [3.32k]                                               
Downloading conan_export.tgz completed [0.32k]                                           
Decompressing conan_export.tgz completed [0.00k]                                         
mesa-glu/9.0.3: Downloaded recipe revision 0
libglvnd/1.7.0: Retrieving from server 'conancenter' 
libglvnd/1.7.0: Trying with 'conancenter'...
Downloading conanmanifest.txt completed [0.10k]                                          
Downloading conanfile.py completed [7.06k]                                               
Downloading conan_export.tgz completed [0.33k]                                           
Decompressing conan_export.tgz completed [0.00k]                                         
libglvnd/1.7.0: Downloaded recipe revision 0
xorg/system: Retrieving from server 'conancenter' 
xorg/system: Trying with 'conancenter'...
Downloading conanmanifest.txt completed [0.06k]                                          
Downloading conanfile.py completed [7.00k]                                               
xorg/system: Downloaded recipe revision 0
xorg-proto/2022.2: Retrieving from server 'conancenter' 
xorg-proto/2022.2: Trying with 'conancenter'...
Downloading conanmanifest.txt completed [0.10k]                                          
Downloading conanfile.py completed [4.09k]                                               
Downloading conan_export.tgz completed [0.32k]                                           
Decompressing conan_export.tgz completed [0.00k]                                         
xorg-proto/2022.2: Downloaded recipe revision 0
wayland/1.22.0: Retrieving from server 'conancenter' 
wayland/1.22.0: Trying with 'conancenter'...
Downloading conanmanifest.txt completed [0.10k]                                          
Downloading conanfile.py completed [8.26k]                                               
Downloading conan_export.tgz completed [0.33k]                                           
Decompressing conan_export.tgz completed [0.00k]                                         
wayland/1.22.0: Downloaded recipe revision 0
libffi/3.4.4: Retrieving from server 'conancenter' 
libffi/3.4.4: Trying with 'conancenter'...
Downloading conanmanifest.txt completed [0.61k]                                          
Downloading conanfile.py completed [7.18k]                                               
Downloading conan_export.tgz completed [0.55k]                                           
Decompressing conan_export.tgz completed [0.00k]                                         
libffi/3.4.4: Downloaded recipe revision 0
libxml2/2.12.3: Retrieving from server 'conancenter' 
libxml2/2.12.3: Trying with 'conancenter'...
Downloading conanmanifest.txt completed [0.10k]                                          
Downloading conanfile.py completed [17.42k]                                              
Downloading conan_export.tgz completed [0.32k]                                           
Decompressing conan_export.tgz completed [0.00k]                                         
libxml2/2.12.3: Downloaded recipe revision 0
WARN: libxml2/2.12.3: requirement zlib/[>=1.2.11 <2] overridden by wayland/1.22.0 to zlib/1.3.1 
libiconv/1.17: Retrieving from server 'conancenter' 
libiconv/1.17: Trying with 'conancenter'...
Downloading conanmanifest.txt completed [0.10k]                                          
Downloading conanfile.py completed [6.73k]                                               
Downloading conan_export.tgz completed [0.31k]                                           
Decompressing conan_export.tgz completed [0.00k]                                         
libiconv/1.17: Downloaded recipe revision 0
expat/2.6.0: Retrieving from server 'conancenter' 
expat/2.6.0: Trying with 'conancenter'...
Downloading conanmanifest.txt completed [0.10k]                                          
Downloading conanfile.py completed [3.80k]                                               
Downloading conan_export.tgz completed [0.33k]                                           
Decompressing conan_export.tgz completed [0.00k]                                         
expat/2.6.0: Downloaded recipe revision 0
xkbcommon/1.6.0: Retrieving from server 'conancenter' 
xkbcommon/1.6.0: Trying with 'conancenter'...
Downloading conanmanifest.txt completed [0.10k]                                          
Downloading conanfile.py completed [7.75k]                                               
Downloading conan_export.tgz completed [0.31k]                                           
Decompressing conan_export.tgz completed [0.00k]                                         
xkbcommon/1.6.0: Downloaded recipe revision 0
xkeyboard-config/system: Retrieving from server 'conancenter' 
xkeyboard-config/system: Trying with 'conancenter'...
Downloading conanmanifest.txt completed [0.06k]                                          
Downloading conanfile.py completed [2.15k]                                               
xkeyboard-config/system: Downloaded recipe revision 0
glew/2.2.0: Retrieving from server 'conancenter' 
glew/2.2.0: Trying with 'conancenter'...
Downloading conanmanifest.txt completed [0.18k]                                          
Downloading conanfile.py completed [4.00k]                                               
Downloading conan_export.tgz completed [0.42k]                                           
Decompressing conan_export.tgz completed [0.00k]                                         
glew/2.2.0: Downloaded recipe revision 0
glu/system: Retrieving from server 'conancenter' 
glu/system: Trying with 'conancenter'...
Downloading conanmanifest.txt completed [0.06k]                                          
Downloading conanfile.py completed [2.02k]                                               
glu/system: Downloaded recipe revision 0
Version ranges solved
    zlib/* versions found in 'conancenter' remote
    Version range '>=1.2.11 <2' required by 'pcl/1.13.1' resolved to 'zlib/1.3.1' in remote 'conancenter'
    Version range '>=1.2.11 <2' required by 'boost/1.83.0' valid for downstream requirement 'zlib/1.3.1'
    Version range '>=1.2.11 <2' required by 'libpng/1.6.40' valid for downstream requirement 'zlib/1.3.1'
    Version range '>=1.2.11 <2' required by 'libxml2/2.12.3' valid for downstream requirement 'zlib/1.3.1'

ERROR: At least two recipes provides the same functionality:
 - 'glu' provided by 'mesa-glu/9.0.3', 'glu/system'

```

</details>



Discussion:
Yeah, we'll need to start updating the recipes to use `mesa-glu` everywhere except macOS and Windows.

Resolving patch:
diff --git a/recipes/glew/all/conanfile.py b/recipes/glew/all/conanfile.py
--- a/recipes/glew/all/conanfile.py
+++ b/recipes/glew/all/conanfile.py
@@ -1,4 +1,5 @@
 from conan import ConanFile
+from conan.tools.apple import is_apple_os
 from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout
 from conan.tools.files import apply_conandata_patches, copy, export_conandata_patches, get, rm, rmdir
 import os
@@ -45,7 +46,11 @@ def layout(self):
 
     def requirements(self):
         self.requires("opengl/system")
-        self.requires("glu/system")
+        # GL/glew.h includes glu.h.
+        if is_apple_os(self) or self.settings.os == "Windows":
+            self.requires("glu/system", transitive_headers=True)
+        else:
+            self.requires("mesa-glu/9.0.3", transitive_headers=True)
 
     def source(self):
         get(self, **self.conan_data["sources"][self.version], strip_root=True)
@@ -90,7 +95,11 @@ def package_info(self):
         self.cpp_info.components["glewlib"].libs = [lib_name]
         if self.settings.os == "Windows" and not self.options.shared:
             self.cpp_info.components["glewlib"].defines.append("GLEW_STATIC")
-        self.cpp_info.components["glewlib"].requires = ["opengl::opengl", "glu::glu"]
+        self.cpp_info.components["glewlib"].requires = ["opengl::opengl"]
+        if is_apple_os(self) or self.settings.os == "Windows":
+            self.cpp_info.components["glewlib"].requires.append("glu::glu")
+        else:
+            self.cpp_info.components["glewlib"].requires.append("mesa-glu::mesa-glu")
 
         # TODO: to remove in conan v2 once cmake_find_package_* generators removed
         self.cpp_info.filenames["cmake_find_package"] = "GLEW"


Test patch: