Repository: conan-io/conan-center-index

Issue:
[package] gdal/3.5.2: fails to build with libjpeg-turbo
### Description

gdal 3.5.2 fails to build with `gdal:with_jpeg=libjpeg-turbo`. It seems like gdal is being given the wrong `JPEG::JPEG` target because several files can't find `jpeglib.h`, e.g.

```
C:\Users\Sean\.conan\data\gdal\3.5.2\_\_\build\02c58328d59df28f01cefee90151b370bbb4517b\source_subfolder\frmts\jpeg\vsidataio.h(40,12): fatal error C1083: Cannot open include file: 'jpeglib.h': No such file or directory [C:\Users\Sean\.conan\data\gdal\3.5.2\_\_\build\02c58328d59df28f01cefee90151b370bbb4517b\build\source_subfolder\frmts\gtiff\gdal_GTIFF.vcxproj]
```


The diff below fixes it for me. This isn't a complete fix because if libjpeg-turbo is built as a shared library the target will be called `libjpeg-turbo::jpeg` instead of `libjpeg-turbo::jpeg-static`. I'm not sure how to chose the right one in `conanfile.py`. Any advice here would be appreciated.

@jpilet maybe you will have some other ideas for fixing this?

```diff
diff --git a/recipes/gdal/post_3.5.0/conanfile.py b/recipes/gdal/post_3.5.0/conanfile.py
index 2c127ca42..dc189547b 100644
--- a/recipes/gdal/post_3.5.0/conanfile.py
+++ b/recipes/gdal/post_3.5.0/conanfile.py
@@ -513,7 +513,7 @@ class GdalConan(ConanFile):
             cmake.definitions["GDAL_USE_JPEG"] = True
             cmake.definitions["GDAL_CONAN_PACKAGE_FOR_JPEG"] = self.options.with_jpeg
             cmake.definitions["TARGET_FOR_JPEG"] = \
-                    "JPEG::JPEG" if self.options.with_jpeg == "libjpeg" else "libjpeg-turbo::libjpeg-turbo"
+                    "JPEG::JPEG" if self.options.with_jpeg == "libjpeg" else "libjpeg-turbo::jpeg-static"
         else:
             cmake.definitions["JPEG_FOUND"] = False
 
@@ -808,7 +808,7 @@ class GdalConan(ConanFile):
         if self.options.with_jpeg == "libjpeg":
             self.cpp_info.requires.extend(['libjpeg::libjpeg'])
         elif self.options.with_jpeg == "libjpeg-turbo":
-            self.cpp_info.requires.extend(['libjpeg-turbo::jpeg'])
+            self.cpp_info.requires.extend(['libjpeg-turbo::libjpeg-turbo'])
 
         if self.options.with_libkml:
             self.cpp_info.requires.extend(['libkml::kmldom', 'libkml::kmlengine'])
```

### Package and Environment Details

* Package Name/Version: **gdal/3.5.2**
* Operating System+version: **Windows 10**
* Compiler+version: **Visual Studio 17.3.4**
* Docker image: **N/A**
* Conan version: **conan 1.52.0**
* Python version: **Python 3.9.13**


### Conan profile

[settings]
arch=x86_64
arch_build=x86_64
build_type=Release
compiler=Visual Studio
compiler.runtime=MD
compiler.version=17
os=Windows
os_build=Windows
[options]
gdal:with_jpeg=libjpeg-turbo
libtiff:jpeg=libjpeg-turbo
[build_requires]
[env]


### Steps to reproduce

conan install -r conancenter gdal/3.5.2@ -o gdal:with_jpeg=libjpeg-turbo -o libtiff:jpeg=libjpeg-turbo --build=missing

### Logs

The log was too big as a github comment. Here's the log as a file: [output.txt](https://github.com/conan-io/conan-center-index/files/9693408/output.txt)



Discussion:

Resolving patch:
diff --git a/recipes/gdal/post_3.5.0/conanfile.py b/recipes/gdal/post_3.5.0/conanfile.py
--- a/recipes/gdal/post_3.5.0/conanfile.py
+++ b/recipes/gdal/post_3.5.0/conanfile.py
@@ -512,8 +512,10 @@ def _configure_cmake(self):
             print(f'self.options.with_jpeg: {self.options.with_jpeg}')
             cmake.definitions["GDAL_USE_JPEG"] = True
             cmake.definitions["GDAL_CONAN_PACKAGE_FOR_JPEG"] = self.options.with_jpeg
-            cmake.definitions["TARGET_FOR_JPEG"] = \
-                    "JPEG::JPEG" if self.options.with_jpeg == "libjpeg" else "libjpeg-turbo::libjpeg-turbo"
+            cmake.definitions["TARGET_FOR_JPEG"] = (
+                    "JPEG::JPEG" if self.options.with_jpeg == "libjpeg" else
+                    self.dependencies["libjpeg-turbo"].cpp_info.components["turbojpeg"] \
+                            .get_property("cmake_target_name"))
         else:
             cmake.definitions["JPEG_FOUND"] = False
 
@@ -808,7 +810,7 @@ def package_info(self):
         if self.options.with_jpeg == "libjpeg":
             self.cpp_info.requires.extend(['libjpeg::libjpeg'])
         elif self.options.with_jpeg == "libjpeg-turbo":
-            self.cpp_info.requires.extend(['libjpeg-turbo::jpeg'])
+            self.cpp_info.requires.extend(['libjpeg-turbo::turbojpeg'])
 
         if self.options.with_libkml:
             self.cpp_info.requires.extend(['libkml::kmldom', 'libkml::kmlengine'])


Test patch: