diff options
author | Stefan Hacker <mail@hacst.net> | 2018-01-14 13:38:20 +0100 |
---|---|---|
committer | Stefan Hacker <dd0t@users.sourceforge.net> | 2018-01-14 19:30:38 +0100 |
commit | 471a5dc18b4465b051cddf4e02dbdf44336f80ce (patch) | |
tree | fd534dba572be147b0c8bee6f7bc2d257d1ae45d /cmake | |
parent | e1e562eb171c81fad24176e898cc4e722bee227b (diff) |
Fix cmake export for grpc
This patch fixes two issues with the targets exported by the
grpc cmake build:
- Install directories are now given relative instead of absolute.
Previously the exported targets would contain absolute paths to
their created targets when they should be relative. The actual
installation location stays the same as cmake automatically
interprets the paths relative to CMAKE_INSTALL_PREFIX
- ZLIB and OpenSSL are now linked using targets instead of the
legacy library variables if possible. Using the legacy paths
produces absolute paths to those dependencies in the export.
With this change cmake inserts the target names instead.
With these changes no more absolute paths are inserted into the
export allowing the install location to be used as an artifact
that can be moved or transfered to another machine and used there.
Diffstat (limited to 'cmake')
-rw-r--r-- | cmake/ssl.cmake | 8 | ||||
-rw-r--r-- | cmake/zlib.cmake | 8 |
2 files changed, 14 insertions, 2 deletions
diff --git a/cmake/ssl.cmake b/cmake/ssl.cmake index 75ce069fe6..53d8a1597e 100644 --- a/cmake/ssl.cmake +++ b/cmake/ssl.cmake @@ -32,7 +32,13 @@ if("${gRPC_SSL_PROVIDER}" STREQUAL "module") endif() elseif("${gRPC_SSL_PROVIDER}" STREQUAL "package") find_package(OpenSSL REQUIRED) - set(_gRPC_SSL_LIBRARIES ${OPENSSL_LIBRARIES}) + + if(TARGET OpenSSL::SSL) + set(_gRPC_SSL_LIBRARIES OpenSSL::SSL OpenSSL::Crypto) + else() + set(_gRPC_SSL_LIBRARIES ${OPENSSL_LIBRARIES}) + endif() set(_gRPC_SSL_INCLUDE_DIR ${OPENSSL_INCLUDE_DIR}) + set(_gRPC_FIND_SSL "if(NOT OPENSSL_FOUND)\n find_package(OpenSSL)\nendif()") endif() diff --git a/cmake/zlib.cmake b/cmake/zlib.cmake index 16cd9e66d5..e324802f65 100644 --- a/cmake/zlib.cmake +++ b/cmake/zlib.cmake @@ -34,6 +34,12 @@ if("${gRPC_ZLIB_PROVIDER}" STREQUAL "module") endif() elseif("${gRPC_ZLIB_PROVIDER}" STREQUAL "package") find_package(ZLIB REQUIRED) - set(_gRPC_ZLIB_LIBRARIES ${ZLIB_LIBRARIES}) + + if(TARGET ZLIB::ZLIB) + set(_gRPC_ZLIB_LIBRARIES ZLIB::ZLIB) + else() + set(_gRPC_ZLIB_LIBRARIES ${ZLIB_LIBRARIES}) + endif() + set(_gRPC_FIND_ZLIB "if(NOT ZLIB_FOUND)\n find_package(ZLIB)\nendif()") endif() |