Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSybren A. Stüvel <sybren@blender.org>2022-01-25 13:34:13 +0300
committerSybren A. Stüvel <sybren@blender.org>2022-01-25 13:34:13 +0300
commita000de7c2a4da1fb57cb22658b29d1ac17c9cd51 (patch)
tree2bb203942837d544da3096e03533b7fc9ce579d5 /build_files
parenta54142f3f1de827bb2005998190c81c0c3cec8ca (diff)
CMake/Linux: find Brotli library the proper way
Use a `FindBrotli.cmake` module instead of manually appending library paths. This is just for Linux; Windows and macOS will be reviewed separately.
Diffstat (limited to 'build_files')
-rw-r--r--build_files/cmake/Modules/FindBrotli.cmake77
-rw-r--r--build_files/cmake/platform/platform_unix.cmake5
2 files changed, 78 insertions, 4 deletions
diff --git a/build_files/cmake/Modules/FindBrotli.cmake b/build_files/cmake/Modules/FindBrotli.cmake
new file mode 100644
index 00000000000..cdb45de31dd
--- /dev/null
+++ b/build_files/cmake/Modules/FindBrotli.cmake
@@ -0,0 +1,77 @@
+# - Find Brotli library (compression for freetype/woff2).
+# This module defines
+# BROTLI_INCLUDE_DIRS, where to find Brotli headers, Set when
+# BROTLI_INCLUDE_DIR is found.
+# BROTLI_LIBRARIES, libraries to link against to use Brotli.
+# BROTLI_ROOT_DIR, The base directory to search for Brotli.
+# This can also be an environment variable.
+# BROTLI_FOUND, If false, do not try to use Brotli.
+#
+
+#=============================================================================
+# Copyright 2022 Blender Foundation.
+#
+# Distributed under the OSI-approved BSD 3-Clause License,
+# see accompanying file BSD-3-Clause-license.txt for details.
+#=============================================================================
+
+# If BROTLI_ROOT_DIR was defined in the environment, use it.
+IF(NOT BROTLI_ROOT_DIR AND NOT $ENV{BROTLI_ROOT_DIR} STREQUAL "")
+ SET(BROTLI_ROOT_DIR $ENV{BROTLI_ROOT_DIR})
+ENDIF()
+
+SET(_BROTLI_SEARCH_DIRS
+ ${BROTLI_ROOT_DIR}
+)
+
+FIND_PATH(BROTLI_INCLUDE_DIR
+ NAMES
+ brotli/decode.h
+ HINTS
+ ${_BROTLI_SEARCH_DIRS}
+ PATH_SUFFIXES
+ include
+ DOC "Brotli header files"
+)
+
+FIND_LIBRARY(BROTLI_LIBRARY_COMMON
+ NAMES
+ brotlicommon-static
+ HINTS
+ ${_BROTLI_SEARCH_DIRS}
+ PATH_SUFFIXES
+ lib64 lib lib/static
+ DOC "Brotli static common library"
+)
+FIND_LIBRARY(BROTLI_LIBRARY_DEC
+ NAMES
+ brotlidec-static
+ HINTS
+ ${_BROTLI_SEARCH_DIRS}
+ PATH_SUFFIXES
+ lib64 lib lib/static
+ DOC "Brotli static decode library"
+)
+
+
+IF(${BROTLI_LIBRARY_COMMON_NOTFOUND} or ${BROTLI_LIBRARY_DEC_NOTFOUND})
+ set(BROTLI_FOUND FALSE)
+ELSE()
+ # handle the QUIETLY and REQUIRED arguments and set BROTLI_FOUND to TRUE if
+ # all listed variables are TRUE
+ INCLUDE(FindPackageHandleStandardArgs)
+ FIND_PACKAGE_HANDLE_STANDARD_ARGS(Brotli DEFAULT_MSG BROTLI_LIBRARY_COMMON BROTLI_LIBRARY_DEC BROTLI_INCLUDE_DIR)
+
+ IF(BROTLI_FOUND)
+ get_filename_component(BROTLI_LIBRARY_DIR ${BROTLI_LIBRARY_COMMON} DIRECTORY)
+ SET(BROTLI_INCLUDE_DIRS ${BROTLI_INCLUDE_DIR})
+ SET(BROTLI_LIBRARIES ${BROTLI_LIBRARY_DEC} ${BROTLI_LIBRARY_COMMON})
+ ENDIF()
+ENDIF()
+
+MARK_AS_ADVANCED(
+ BROTLI_INCLUDE_DIR
+ BROTLI_LIBRARY_DIR
+)
+
+UNSET(_BROTLI_SEARCH_DIRS)
diff --git a/build_files/cmake/platform/platform_unix.cmake b/build_files/cmake/platform/platform_unix.cmake
index 5aace62211c..593f3b7043c 100644
--- a/build_files/cmake/platform/platform_unix.cmake
+++ b/build_files/cmake/platform/platform_unix.cmake
@@ -103,10 +103,7 @@ find_package_wrapper(Zstd REQUIRED)
# FreeType compiled with Brotli compression for woff2.
find_package_wrapper(Freetype REQUIRED)
-list(APPEND FREETYPE_LIBRARIES
- ${LIBDIR}/brotli/lib/libbrotlidec-static.a
- ${LIBDIR}/brotli/lib/libbrotlicommon-static.a
-)
+find_package_wrapper(Brotli REQUIRED)
if(WITH_PYTHON)
# No way to set py35, remove for now.