Przeglądaj źródła

FindOpenSSL: Lookup all pkg-config directories

When using a custom sysroot to build things using pkg-config, some of
the output variables feature the sysroot while others do not:

```console
$ export PKG_CONFIG_SYSROOT_DIR=/path/to/sysroot
$ export PKG_CONFIG_LIBDIR=/path/to/sysroot/usr/lib/pkgconfig
$ pkg-config --cflags-only-I openssl
-I/path/to/sysroot/usr/include/
$ pkg-config --variable=includedir openssl
/usr/include
$ pkg-config --libs-only-L openssl
-L/path/to/sysroot/usr/lib
$ pkg-config --variable=libdir openssl
/usr/lib
```

When using `pkg_check_modules`, it's pretty much the same:
```cmake
pkg_check_modules(_OPENSSL QUIET openssl)
_OPENSSL_INCLUDE_DIRS == /path/to/sysroot/usr/include/
_OPENSSL_INCLUDEDIR == /usr/include
_OPENSSL_LIBRARY_DIRS == -L/path/to/sysroot/usr/lib
_OPENSSL_LIBDIR == /usr/lib
```

However, FindOpenSSL only searches for headers in `INCLUDEDIR` and
libraries in `LIBDIR` instead of searching `INCLUDE_DIRS` and
`LIBRARY_DIRS` as well.

This fixes that behaviour.

Fixes: #16885

Signed-off-by: Denis Thulin <[email protected]>
Denis Thulin 6 lat temu
rodzic
commit
24d52daf49
1 zmienionych plików z 3 dodań i 0 usunięć
  1. 3 0
      Modules/FindOpenSSL.cmake

+ 3 - 0
Modules/FindOpenSSL.cmake

@@ -131,6 +131,7 @@ find_path(OPENSSL_INCLUDE_DIR
   ${_OPENSSL_ROOT_HINTS_AND_PATHS}
   HINTS
     ${_OPENSSL_INCLUDEDIR}
+    ${_OPENSSL_INCLUDE_DIRS}
   PATH_SUFFIXES
     include
 )
@@ -319,6 +320,7 @@ else()
     ${_OPENSSL_ROOT_HINTS_AND_PATHS}
     HINTS
       ${_OPENSSL_LIBDIR}
+      ${_OPENSSL_LIBRARY_DIRS}
     PATH_SUFFIXES
       lib
   )
@@ -330,6 +332,7 @@ else()
     ${_OPENSSL_ROOT_HINTS_AND_PATHS}
     HINTS
       ${_OPENSSL_LIBDIR}
+      ${_OPENSSL_LIBRARY_DIRS}
     PATH_SUFFIXES
       lib
   )