libcpprestsdk: fix building as a static library (#1344)

On Unix, try to use pkg-config to find OpenSSL. This will automatically
find any dependent libraries and put them in the correct order for
linking. If pkg-config is not available or system is not UNIX, fallback
on current mechanism

Signed-off-by: Adam Duskett <aduskett@gmail.com>
[Retrieved (and slightly updated) from:
https://git.buildroot.net/buildroot/tree/package/libcpprestsdk/0001-libcpprestsdk-fix-building-as-a-static-library.patch]
Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
This commit is contained in:
Fabrice Fontaine 2020-03-02 23:51:12 +01:00 коммит произвёл GitHub
Родитель b94bc32ff8
Коммит cb7ca74e5f
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
1 изменённых файлов: 10 добавлений и 2 удалений

Просмотреть файл

@ -41,7 +41,15 @@ function(cpprest_find_openssl)
# This should prevent linking against the system provided 0.9.8y
set(_OPENSSL_VERSION "")
endif()
find_package(OpenSSL 1.0.0 REQUIRED)
if(UNIX)
find_package(PkgConfig)
pkg_search_module(OPENSSL openssl)
endif()
if(OPENSSL_FOUND)
target_link_libraries(cpprest PRIVATE ${OPENSSL_LDFLAGS})
else()
find_package(OpenSSL 1.0.0 REQUIRED)
endif()
INCLUDE(CheckCXXSourceCompiles)
set(CMAKE_REQUIRED_INCLUDES "${OPENSSL_INCLUDE_DIR}")
@ -67,4 +75,4 @@ function(cpprest_find_openssl)
# libressl doesn't ship with the cleanup method being used in ws_client_wspp
target_compile_definitions(cpprestsdk_openssl_internal INTERFACE -DCPPREST_NO_SSL_LEAK_SUPPRESS)
endif()
endfunction()
endfunction()