]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
cmake: add support for brotli
authorDon <don.j.olmstead@gmail.com>
Fri, 16 Mar 2018 19:49:13 +0000 (12:49 -0700)
committerDaniel Stenberg <daniel@haxx.se>
Mon, 19 Mar 2018 07:28:32 +0000 (08:28 +0100)
Currently CMake cannot detect Brotli support. This adds detection of the
libraries and associated header files. It also adds this to the
generated config.

Closes #2392

CMake/FindBrotli.cmake [new file with mode: 0644]
CMakeLists.txt
lib/curl_config.h.cmake

diff --git a/CMake/FindBrotli.cmake b/CMake/FindBrotli.cmake
new file mode 100644 (file)
index 0000000..351b8f7
--- /dev/null
@@ -0,0 +1,20 @@
+include(FindPackageHandleStandardArgs)
+
+find_path(BROTLI_INCLUDE_DIR "brotli/decode.h")
+
+find_library(BROTLICOMMON_LIBRARY NAMES brotlicommon)
+find_library(BROTLIDEC_LIBRARY NAMES brotlidec)
+
+find_package_handle_standard_args(BROTLI
+    FOUND_VAR
+      BROTLI_FOUND
+    REQUIRED_VARS
+      BROTLIDEC_LIBRARY
+      BROTLICOMMON_LIBRARY
+      BROTLI_INCLUDE_DIR
+    FAIL_MESSAGE
+      "Could NOT find BROTLI"
+)
+
+set(BROTLI_INCLUDE_DIRS ${BROTLI_INCLUDE_DIR})
+set(BROTLI_LIBRARIES ${BROTLICOMMON_LIBRARY} ${BROTLIDEC_LIBRARY})
index 490cc19ef8373cd0c7ac171348b0c8bc51dcf53e..3232e9a49b6556995f46eb7a856d39fa2054b7c2 100644 (file)
@@ -521,6 +521,18 @@ if(CURL_ZLIB)
   endif()
 endif()
 
+option(CURL_BROTLI "Set to ON to enable building curl with brotli support." OFF)
+set(HAVE_BROTLI OFF)
+if(CURL_BROTLI)
+  find_package(BROTLI QUIET)
+  if(BROTLI_FOUND)
+    set(HAVE_BROTLI ON)
+    list(APPEND CURL_LIBS ${BROTLI_LIBRARIES})
+    include_directories(${BROTLI_INCLUDE_DIRS})
+    list(APPEND CMAKE_REQUIRED_INCLUDES ${BROTLI_INCLUDE_DIRS})
+  endif()
+endif()
+
 #libSSH2
 option(CMAKE_USE_LIBSSH2 "Use libSSH2" ON)
 mark_as_advanced(CMAKE_USE_LIBSSH2)
index e640cc65636f02b45fdee6fb65434b3ed87cbcac..4b12083f2961a82827ae14e5f7fa4466c2f63c72 100644 (file)
 /* if zlib is available */
 #cmakedefine HAVE_LIBZ 1
 
+/* if brotli is available */
+#cmakedefine HAVE_BROTLI 1
+
 /* if your compiler supports LL */
 #cmakedefine HAVE_LL 1