summaryrefslogtreecommitdiffstats
path: root/cmake
diff options
context:
space:
mode:
authorLi Xinwei <1326710505@qq.com>2021-04-19 16:04:03 +0800
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2021-04-20 16:57:59 +0000
commite5e6ca783682d269eb2bdeed489c37bbb651ff42 (patch)
tree7eb9d139209831f2257c6d1edc95dc88e82b514e /cmake
parenta68597872365c6ccc46352ab2acd7541cc4cb65a (diff)
make FindWrapBrotli.cmake not depend on vcpkg or PkgConfig
Currently, FindWrapBrotli.cmake depends on vcpkg or PkgConfig. But for users who build Brotli by themselves and don't have vcpkg or PkgConfig, the Brotli cannot be found. As a reference, I use following CMake commands to build Brotli: cmake path/to/Brotli/source -G"Ninja Multi-Config" -DCMAKE_CONFIGURATION_TYPES=Release;Debug -DCMAKE_CROSS_CONFIGS=all -DCMAKE_DEFAULT_CONFIGS=all -DCMAKE_DEBUG_POSTFIX=d -DCMAKE_INSTALL_PREFIX=path/to/install Change-Id: I2fa8d3293dd55ebc18937e13fac40d144ca4c1e2 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io> (cherry picked from commit 5d2da76c1ee70ffd1f027365c0f3af74b76fd382) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'cmake')
-rw-r--r--cmake/FindWrapBrotli.cmake47
1 files changed, 47 insertions, 0 deletions
diff --git a/cmake/FindWrapBrotli.cmake b/cmake/FindWrapBrotli.cmake
index e01deee6e3..524cb425e4 100644
--- a/cmake/FindWrapBrotli.cmake
+++ b/cmake/FindWrapBrotli.cmake
@@ -39,5 +39,52 @@ else()
target_link_libraries(WrapBrotli::WrapBrotliCommon INTERFACE PkgConfig::libbrotlicommon)
set(WrapBrotli_FOUND ON)
endif()
+ else()
+ find_path(BROTLI_INCLUDE_DIR NAMES "brotli/decode.h")
+
+ foreach(lib_name BrotliDec BrotliEnc BrotliCommon)
+ string(TOLOWER ${lib_name} lower_lib_name)
+
+ find_library(${lib_name}_LIBRARY_RELEASE
+ NAMES ${lower_lib_name} ${lower_lib_name}-static)
+
+ find_library(${lib_name}_LIBRARY_DEBUG
+ NAMES ${lower_lib_name}d ${lower_lib_name}-staticd
+ ${lower_lib_name} ${lower_lib_name}-static)
+
+ include(SelectLibraryConfigurations)
+ select_library_configurations(${lib_name})
+
+ if (BROTLI_INCLUDE_DIR AND ${lib_name}_LIBRARY)
+ set(${lib_name}_FOUND TRUE)
+ endif()
+
+ if (${lib_name}_FOUND AND NOT TARGET WrapBrotli::Wrap${lib_name})
+ add_library(WrapBrotli::Wrap${lib_name} UNKNOWN IMPORTED)
+ set_target_properties(WrapBrotli::Wrap${lib_name} PROPERTIES
+ INTERFACE_INCLUDE_DIRECTORIES "${BROTLI_INCLUDE_DIR}"
+ IMPORTED_LOCATION "${${lib_name}_LIBRARY}")
+
+ if(${lib_name}_LIBRARY_RELEASE)
+ foreach(config_name RELEASE RELWITHDEBINFO MINSIZEREL)
+ set_property(TARGET WrapBrotli::Wrap${lib_name} APPEND PROPERTY
+ IMPORTED_CONFIGURATIONS ${config_name})
+ set_target_properties(WrapBrotli::Wrap${lib_name} PROPERTIES
+ IMPORTED_LOCATION_${config_name} "${${lib_name}_LIBRARY_RELEASE}")
+ endforeach()
+ endif()
+
+ if(${lib_name}_LIBRARY_DEBUG)
+ set_property(TARGET WrapBrotli::Wrap${lib_name} APPEND PROPERTY
+ IMPORTED_CONFIGURATIONS DEBUG)
+ set_target_properties(WrapBrotli::Wrap${lib_name} PROPERTIES
+ IMPORTED_LOCATION_DEBUG "${${lib_name}_LIBRARY_DEBUG}")
+ endif()
+ endif()
+ endforeach()
+
+ include(FindPackageHandleStandardArgs)
+ find_package_handle_standard_args(WrapBrotli REQUIRED_VARS
+ BrotliDec_FOUND BrotliEnc_FOUND BrotliCommon_FOUND)
endif()
endif()