summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDon <don.j.olmstead@gmail.com>2018-03-16 12:49:13 -0700
committerDaniel Stenberg <daniel@haxx.se>2018-03-19 08:28:32 +0100
commitd22e5e02a2d3670a79cf09bed81613ca90738163 (patch)
tree17d5fbeaaf63b16be4f483d2beda2dd440b4bef0
parentb7b2809a212a69f1ce59a25ba86b4f1d8a17ebc4 (diff)
downloadcurl-d22e5e02a2d3670a79cf09bed81613ca90738163.tar.gz
cmake: add support for brotli
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
-rw-r--r--CMake/FindBrotli.cmake20
-rw-r--r--CMakeLists.txt12
-rw-r--r--lib/curl_config.h.cmake3
3 files changed, 35 insertions, 0 deletions
diff --git a/CMake/FindBrotli.cmake b/CMake/FindBrotli.cmake
new file mode 100644
index 000000000..351b8f757
--- /dev/null
+++ b/CMake/FindBrotli.cmake
@@ -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})
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 490cc19ef..3232e9a49 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -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)
diff --git a/lib/curl_config.h.cmake b/lib/curl_config.h.cmake
index e640cc656..4b12083f2 100644
--- a/lib/curl_config.h.cmake
+++ b/lib/curl_config.h.cmake
@@ -398,6 +398,9 @@
/* 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