Skip to content

cmake: add code to detect system brotli library #952

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 12, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions Release/cmake/cpprest_find_brotli.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,17 @@ function(cpprest_find_brotli)
return()
endif()

find_package(unofficial-brotli REQUIRED)

add_library(cpprestsdk_brotli_internal INTERFACE)
target_link_libraries(cpprestsdk_brotli_internal INTERFACE unofficial::brotli::brotlienc unofficial::brotli::brotlidec unofficial::brotli::brotlicommon)
find_package(PkgConfig)
pkg_check_modules(BROTLIENC libbrotlienc)
pkg_check_modules(BROTLIDEC libbrotlidec)
if(BROTLIDEC_FOUND AND BROTLIENC_FOUND)
target_link_libraries(cpprest PRIVATE ${BROTLIDEC_LDFLAGS} ${BROTLIENC_LDFLAGS})
else(BROTLIDEC_FOUND AND BROTLIENC_FOUND)
find_package(unofficial-brotli REQUIRED)
add_library(cpprestsdk_brotli_internal INTERFACE)
target_link_libraries(cpprestsdk_brotli_internal INTERFACE unofficial::brotli::brotlienc unofficial::brotli::brotlidec unofficial::brotli::brotlicommon)
target_link_libraries(cpprest PRIVATE cpprestsdk_brotli_internal)
endif(BROTLIDEC_FOUND AND BROTLIENC_FOUND)

endfunction()
1 change: 0 additions & 1 deletion Release/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ else()
target_compile_definitions(cpprest PRIVATE -DCPPREST_EXCLUDE_BROTLI=1)
else()
cpprest_find_brotli()
target_link_libraries(cpprest PRIVATE cpprestsdk_brotli_internal)
endif()
endif()

Expand Down