From 3b42f866347c10a430e9134aaaf5982e1655519b Mon Sep 17 00:00:00 2001 From: CGQAQ Date: Thu, 23 Mar 2023 09:47:01 +0800 Subject: [PATCH 1/3] fix: fix cmake builds --- .gitignore | 2 ++ CMakeLists.txt | 17 ++++------------- 2 files changed, 6 insertions(+), 13 deletions(-) diff --git a/.gitignore b/.gitignore index 6b35b1f..5b27050 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,5 @@ /woff2_compress /woff2_decompress /woff2_info + +build diff --git a/CMakeLists.txt b/CMakeLists.txt index ecfbb83..94f564a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -31,16 +31,7 @@ if ("${isSystemDir}" STREQUAL "-1") set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_LIBDIR}") endif() -# Find Brotli dependencies -set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake") -find_package(BrotliDec) -if (NOT BROTLIDEC_FOUND) - message(FATAL_ERROR "librotlidec is needed to build woff2.") -endif () -find_package(BrotliEnc) -if (NOT BROTLIENC_FOUND) - message(FATAL_ERROR "librotlienc is needed to build woff2.") -endif () +add_subdirectory(brotli) # Set compiler flags if (NOT CANONICAL_PREFIXES) @@ -65,7 +56,7 @@ set(CMAKE_CXX_STANDARD 11) # Set search path for our private/public headers as well as Brotli headers include_directories("src" "include" - "${BROTLIDEC_INCLUDE_DIRS}" "${BROTLIENC_INCLUDE_DIRS}") + "${BROTLI_INCLUDE_DIRS}") # Common part used by decoder and encoder add_library(woff2common @@ -77,7 +68,7 @@ add_library(woff2common add_library(woff2dec src/woff2_dec.cc src/woff2_out.cc) -target_link_libraries(woff2dec woff2common "${BROTLIDEC_LIBRARIES}") +target_link_libraries(woff2dec woff2common brotlidec) add_executable(woff2_decompress src/woff2_decompress.cc) target_link_libraries(woff2_decompress woff2dec) @@ -88,7 +79,7 @@ add_library(woff2enc src/normalize.cc src/transform.cc src/woff2_enc.cc) -target_link_libraries(woff2enc woff2common "${BROTLIENC_LIBRARIES}") +target_link_libraries(woff2enc woff2common brotlienc) add_executable(woff2_compress src/woff2_compress.cc) target_link_libraries(woff2_compress woff2enc) From 2d2895ca354cc0d9e8637f7a68a0e8beb4c9a3df Mon Sep 17 00:00:00 2001 From: CGQAQ Date: Thu, 23 Mar 2023 09:56:07 +0800 Subject: [PATCH 2/3] chore: remove unused cmake find scripts --- cmake/FindBrotliDec.cmake | 35 ----------------------------------- cmake/FindBrotliEnc.cmake | 35 ----------------------------------- 2 files changed, 70 deletions(-) delete mode 100644 cmake/FindBrotliDec.cmake delete mode 100644 cmake/FindBrotliEnc.cmake diff --git a/cmake/FindBrotliDec.cmake b/cmake/FindBrotliDec.cmake deleted file mode 100644 index abb06f4..0000000 --- a/cmake/FindBrotliDec.cmake +++ /dev/null @@ -1,35 +0,0 @@ -# Copyright 2017 Igalia S.L. All Rights Reserved. -# -# Distributed under MIT license. -# See file LICENSE for detail or copy at https://opensource.org/licenses/MIT - -# Try to find BrotliDec. Once done, this will define -# -# BROTLIDEC_FOUND - system has BrotliDec. -# BROTLIDEC_INCLUDE_DIRS - the BrotliDec include directories -# BROTLIDEC_LIBRARIES - link these to use BrotliDec. - -find_package(PkgConfig) - -pkg_check_modules(PC_BROTLIDEC libbrotlidec) - -find_path(BROTLIDEC_INCLUDE_DIRS - NAMES brotli/decode.h - HINTS ${PC_BROTLIDEC_INCLUDEDIR} -) - -find_library(BROTLIDEC_LIBRARIES - NAMES brotlidec - HINTS ${PC_BROTLIDEC_LIBDIR} -) - -include(FindPackageHandleStandardArgs) -find_package_handle_standard_args(BrotliDec - REQUIRED_VARS BROTLIDEC_INCLUDE_DIRS BROTLIDEC_LIBRARIES - FOUND_VAR BROTLIDEC_FOUND - VERSION_VAR PC_BROTLIDEC_VERSION) - -mark_as_advanced( - BROTLIDEC_INCLUDE_DIRS - BROTLIDEC_LIBRARIES -) diff --git a/cmake/FindBrotliEnc.cmake b/cmake/FindBrotliEnc.cmake deleted file mode 100644 index 4be347d..0000000 --- a/cmake/FindBrotliEnc.cmake +++ /dev/null @@ -1,35 +0,0 @@ -# Copyright 2017 Igalia S.L. All Rights Reserved. -# -# Distributed under MIT license. -# See file LICENSE for detail or copy at https://opensource.org/licenses/MIT - -# Try to find BrotliEnc. Once done, this will define -# -# BROTLIENC_FOUND - system has BrotliEnc. -# BROTLIENC_INCLUDE_DIRS - the BrotliEnc include directories -# BROTLIENC_LIBRARIES - link these to use BrotliEnc. - -find_package(PkgConfig) - -pkg_check_modules(PC_BROTLIENC libbrotlienc) - -find_path(BROTLIENC_INCLUDE_DIRS - NAMES brotli/encode.h - HINTS ${PC_BROTLIENC_INCLUDEDIR} -) - -find_library(BROTLIENC_LIBRARIES - NAMES brotlienc - HINTS ${PC_BROTLIENC_LIBDIR} -) - -include(FindPackageHandleStandardArgs) -find_package_handle_standard_args(BrotliEnc - REQUIRED_VARS BROTLIENC_INCLUDE_DIRS BROTLIENC_LIBRARIES - FOUND_VAR BROTLIENC_FOUND - VERSION_VAR PC_BROTLIENC_VERSION) - -mark_as_advanced( - BROTLIENC_INCLUDE_DIRS - BROTLIENC_LIBRARIES -) From 5cda4aad3b3a9869de4588b5db4411c43cbee042 Mon Sep 17 00:00:00 2001 From: CGQAQ Date: Fri, 1 Sep 2023 19:33:37 +0800 Subject: [PATCH 3/3] fix windows build cmake -B build -S . cmake --build build --- CMakeLists.txt | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 94f564a..785faa5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -60,26 +60,29 @@ include_directories("src" "include" # Common part used by decoder and encoder add_library(woff2common + STATIC src/table_tags.cc src/variable_length.cc src/woff2_common.cc) # WOFF2 Decoder add_library(woff2dec + STATIC src/woff2_dec.cc src/woff2_out.cc) -target_link_libraries(woff2dec woff2common brotlidec) +target_link_libraries(woff2dec woff2common brotlidec-static) add_executable(woff2_decompress src/woff2_decompress.cc) target_link_libraries(woff2_decompress woff2dec) # WOFF2 Encoder add_library(woff2enc + STATIC src/font.cc src/glyph.cc src/normalize.cc src/transform.cc src/woff2_enc.cc) -target_link_libraries(woff2enc woff2common brotlienc) +target_link_libraries(woff2enc woff2common brotlienc-static) add_executable(woff2_compress src/woff2_compress.cc) target_link_libraries(woff2_compress woff2enc)